@scayle/storefront-nuxt 8.61.1 → 8.61.2
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-V7.md +3 -11
- package/CHANGELOG.md +227 -255
- package/dist/module.json +1 -1
- package/dist/module.mjs +95 -39
- package/dist/runtime/api/rpcHandler.js +1 -4
- package/dist/runtime/cached.js +1 -6
- package/dist/runtime/campaignKey.js +15 -15
- package/dist/runtime/composables/core/useIDP.js +11 -13
- package/dist/runtime/composables/core/useSession.js +1 -3
- package/dist/runtime/composables/core/useUser.js +24 -30
- package/dist/runtime/composables/storefront/useBasket.d.ts +1 -1
- package/dist/runtime/composables/storefront/useBasket.js +32 -45
- package/dist/runtime/composables/storefront/useBrand.js +1 -6
- package/dist/runtime/composables/storefront/useBrands.js +1 -6
- package/dist/runtime/composables/storefront/useCampaign.js +1 -6
- package/dist/runtime/composables/storefront/useCategories.js +12 -19
- package/dist/runtime/composables/storefront/useCategoryById.js +1 -6
- package/dist/runtime/composables/storefront/useCategoryByPath.js +1 -6
- package/dist/runtime/composables/storefront/useCurrentPromotions.js +7 -12
- package/dist/runtime/composables/storefront/useFilters.js +1 -6
- package/dist/runtime/composables/storefront/useNavigationTree.js +2 -12
- package/dist/runtime/composables/storefront/useNavigationTrees.js +1 -6
- package/dist/runtime/composables/storefront/useProduct.js +1 -6
- package/dist/runtime/composables/storefront/useProducts.js +1 -6
- package/dist/runtime/composables/storefront/useProductsByIds.js +1 -6
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.js +1 -6
- package/dist/runtime/composables/storefront/useProductsCount.js +1 -6
- package/dist/runtime/composables/storefront/usePromotions.js +1 -6
- package/dist/runtime/composables/storefront/usePromotionsByIds.js +1 -6
- package/dist/runtime/composables/storefront/useShopConfiguration.js +1 -6
- package/dist/runtime/composables/storefront/useUserAddresses.js +1 -6
- package/dist/runtime/composables/storefront/useVariant.js +1 -6
- package/dist/runtime/composables/storefront/useWishlist.d.ts +1 -1
- package/dist/runtime/composables/storefront/useWishlist.js +11 -25
- package/dist/runtime/context.js +2 -10
- package/dist/runtime/nitro/plugins/configValidation.js +6 -4
- package/dist/runtime/nitro/plugins/nitroStorageConfig.js +1 -4
- package/dist/runtime/server/middleware/bootstrap.js +3 -14
- package/dist/runtime/server/middleware/redirects.js +1 -3
- package/dist/runtime/utils/storage.js +1 -4
- package/dist/runtime/utils/zodSchema.js +33 -25
- package/package.json +4 -3
|
@@ -3,16 +3,11 @@ export function useCurrentPromotions({
|
|
|
3
3
|
params,
|
|
4
4
|
options
|
|
5
5
|
} = {}, key = "useCurrentPromotions") {
|
|
6
|
-
return useRpc(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return hydrationData ?? nuxtApp._asyncData[cacheKey]?.data.value;
|
|
14
|
-
},
|
|
15
|
-
...options
|
|
16
|
-
}
|
|
17
|
-
);
|
|
6
|
+
return useRpc("getCurrentPromotions", key, params, {
|
|
7
|
+
getCachedData(cacheKey, nuxtApp) {
|
|
8
|
+
const hydrationData = nuxtApp.isHydrating ? nuxtApp.payload.data[cacheKey] : nuxtApp.static.data[cacheKey];
|
|
9
|
+
return hydrationData ?? nuxtApp._asyncData[cacheKey]?.data.value;
|
|
10
|
+
},
|
|
11
|
+
...options
|
|
12
|
+
});
|
|
18
13
|
}
|
|
@@ -3,21 +3,11 @@ export function useNavigationTreeById({
|
|
|
3
3
|
params,
|
|
4
4
|
options
|
|
5
5
|
} = {}, key = "useNavigationTreeById") {
|
|
6
|
-
return useRpc(
|
|
7
|
-
"fetchNavigationTreeById",
|
|
8
|
-
key,
|
|
9
|
-
params,
|
|
10
|
-
options
|
|
11
|
-
);
|
|
6
|
+
return useRpc("fetchNavigationTreeById", key, params, options);
|
|
12
7
|
}
|
|
13
8
|
export function useNavigationTreeByName({
|
|
14
9
|
params,
|
|
15
10
|
options
|
|
16
11
|
} = {}, key = "useNavigationTreeByName") {
|
|
17
|
-
return useRpc(
|
|
18
|
-
"fetchNavigationTreeByName",
|
|
19
|
-
key,
|
|
20
|
-
params,
|
|
21
|
-
options
|
|
22
|
-
);
|
|
12
|
+
return useRpc("fetchNavigationTreeByName", key, params, options);
|
|
23
13
|
}
|
|
@@ -3,10 +3,5 @@ export function useProductsByReferenceKeys({
|
|
|
3
3
|
params,
|
|
4
4
|
options
|
|
5
5
|
} = {}, key = "useProductsByReferenceKeys") {
|
|
6
|
-
return useRpc(
|
|
7
|
-
"getProductsByReferenceKeys",
|
|
8
|
-
key,
|
|
9
|
-
params,
|
|
10
|
-
options
|
|
11
|
-
);
|
|
6
|
+
return useRpc("getProductsByReferenceKeys", key, params, options);
|
|
12
7
|
}
|
|
@@ -2,10 +2,5 @@ import { useRpc } from "../core/useRpc.js";
|
|
|
2
2
|
export function useShopConfiguration({
|
|
3
3
|
options
|
|
4
4
|
} = {}, key = "useShopConfiguration") {
|
|
5
|
-
return useRpc(
|
|
6
|
-
"getShopConfiguration",
|
|
7
|
-
key,
|
|
8
|
-
void 0,
|
|
9
|
-
options
|
|
10
|
-
);
|
|
5
|
+
return useRpc("getShopConfiguration", key, void 0, options);
|
|
11
6
|
}
|
|
@@ -2,10 +2,5 @@ import { useRpc } from "../core/useRpc.js";
|
|
|
2
2
|
export function useUserAddresses({
|
|
3
3
|
options
|
|
4
4
|
} = {}, key = "useUserAddresses") {
|
|
5
|
-
return useRpc(
|
|
6
|
-
"getShopUserAddresses",
|
|
7
|
-
key,
|
|
8
|
-
void 0,
|
|
9
|
-
options
|
|
10
|
-
);
|
|
5
|
+
return useRpc("getShopUserAddresses", key, void 0, options);
|
|
11
6
|
}
|
|
@@ -67,5 +67,5 @@ type UseWishlistBaseReturn = Awaited<UseRpcReturn<'getWishlist'>> & {
|
|
|
67
67
|
*
|
|
68
68
|
* @throws {Error} If an item cannot be found during removal or replacement.
|
|
69
69
|
*/
|
|
70
|
-
export declare function useWishlist({ params
|
|
70
|
+
export declare function useWishlist({ params }?: Options, key?: UseRpcCacheKey): UseWishlistBaseReturn & Promise<UseWishlistBaseReturn>;
|
|
71
71
|
export {};
|
|
@@ -3,33 +3,21 @@ import { useRpc } from "../core/useRpc.js";
|
|
|
3
3
|
import { extendPromise } from "../../utils/promise.js";
|
|
4
4
|
import { computed, toValue, toRef } from "vue";
|
|
5
5
|
import { useRpcCall } from "../core/useRpcCall.js";
|
|
6
|
-
export function useWishlist({
|
|
7
|
-
params
|
|
8
|
-
} = {}, key = "useWishlist") {
|
|
6
|
+
export function useWishlist({ params } = {}, key = "useWishlist") {
|
|
9
7
|
const nuxtApp = useNuxtApp();
|
|
10
8
|
const addItemToWishlistRpc = useRpcCall("addItemToWishlist");
|
|
11
9
|
const removeItemFromWishlistRpc = useRpcCall("removeItemFromWishlist");
|
|
12
10
|
const clearWishlistRpc = useRpcCall("clearWishlist");
|
|
13
|
-
const asyncData = useRpc(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
params,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
watch: [toRef(params)],
|
|
21
|
-
dedupe: "defer",
|
|
22
|
-
getCachedData: (key2) => {
|
|
23
|
-
return toValue(nuxtApp._asyncData[key2]?.data) ?? void 0;
|
|
24
|
-
}
|
|
11
|
+
const asyncData = useRpc("getWishlist", key, params, {
|
|
12
|
+
server: false,
|
|
13
|
+
// NOTE: In some cases it might be ok to fetch on server
|
|
14
|
+
watch: [toRef(params)],
|
|
15
|
+
dedupe: "defer",
|
|
16
|
+
getCachedData: (key2) => {
|
|
17
|
+
return toValue(nuxtApp._asyncData[key2]?.data) ?? void 0;
|
|
25
18
|
}
|
|
26
|
-
);
|
|
27
|
-
const {
|
|
28
|
-
data,
|
|
29
|
-
error,
|
|
30
|
-
status,
|
|
31
|
-
refresh
|
|
32
|
-
} = asyncData;
|
|
19
|
+
});
|
|
20
|
+
const { data, error, status, refresh } = asyncData;
|
|
33
21
|
const addItem = async (item) => {
|
|
34
22
|
data.value = await addItemToWishlistRpc({
|
|
35
23
|
...item,
|
|
@@ -47,9 +35,7 @@ export function useWishlist({
|
|
|
47
35
|
const removeItem = async (item) => {
|
|
48
36
|
const element = findItem(item);
|
|
49
37
|
if (!element) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
"Could not find wishlist item."
|
|
52
|
-
);
|
|
38
|
+
throw new Error("Could not find wishlist item.");
|
|
53
39
|
}
|
|
54
40
|
data.value = await removeItemFromWishlistRpc({
|
|
55
41
|
itemKey: element.key,
|
package/dist/runtime/context.js
CHANGED
|
@@ -69,11 +69,7 @@ export const buildContext = async (context) => {
|
|
|
69
69
|
"x-internal-access": $storefront.internalAccessHeader
|
|
70
70
|
} : {}
|
|
71
71
|
});
|
|
72
|
-
const cached = getCachedFunction(
|
|
73
|
-
$cache,
|
|
74
|
-
$log,
|
|
75
|
-
$storefront.cache?.enabled
|
|
76
|
-
);
|
|
72
|
+
const cached = getCachedFunction($cache, $log, $storefront.cache?.enabled);
|
|
77
73
|
const { hooks } = useNitroApp();
|
|
78
74
|
const callRpc = buildRpcCall(
|
|
79
75
|
context.event,
|
|
@@ -120,11 +116,7 @@ export const buildContext = async (context) => {
|
|
|
120
116
|
shopId: $shopConfig.shopId,
|
|
121
117
|
domain: $shopConfig.domain,
|
|
122
118
|
withParams: $storefront.withParams,
|
|
123
|
-
campaignKey: await fetchCampaignKey(
|
|
124
|
-
sapiClient,
|
|
125
|
-
cached,
|
|
126
|
-
$log
|
|
127
|
-
),
|
|
119
|
+
campaignKey: await fetchCampaignKey(sapiClient, cached, $log),
|
|
128
120
|
runtimeConfiguration: config,
|
|
129
121
|
get ip() {
|
|
130
122
|
return getRequestIP(event, { xForwardedFor: true });
|
|
@@ -11,10 +11,12 @@ export const sensitiveKeys = [
|
|
|
11
11
|
"secret"
|
|
12
12
|
];
|
|
13
13
|
export const getValue = (object, pathArray) => {
|
|
14
|
-
return JSON.stringify(
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
return JSON.stringify(
|
|
15
|
+
pathArray.reduce(
|
|
16
|
+
(acc, key) => typeof acc === "object" ? acc[key] : void 0,
|
|
17
|
+
object
|
|
18
|
+
)
|
|
19
|
+
);
|
|
18
20
|
};
|
|
19
21
|
export const formatZodError = (issues, runtimeConfig) => {
|
|
20
22
|
const errorMessages = [];
|
|
@@ -48,10 +48,7 @@ export default defineNitroPlugin(async () => {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
for (const shop of Object.values(shops)) {
|
|
51
|
-
await mountShopStorage(
|
|
52
|
-
shop.shopId,
|
|
53
|
-
`${STORAGE_MOUNT_CACHE}:${shop.shopId}`
|
|
54
|
-
);
|
|
51
|
+
await mountShopStorage(shop.shopId, `${STORAGE_MOUNT_CACHE}:${shop.shopId}`);
|
|
55
52
|
await mountShopStorage(
|
|
56
53
|
shop.shopId,
|
|
57
54
|
`${STORAGE_MOUNT_SESSION}:${shop.shopId}`
|
|
@@ -70,12 +70,7 @@ async function bootstrap(event, $shopConfig, $storefrontConfig, apiBasePath, con
|
|
|
70
70
|
try {
|
|
71
71
|
const cookieName = sessionConfig?.cookieName ?? "$session";
|
|
72
72
|
const secret = sessionConfig?.secret ?? "current-secret";
|
|
73
|
-
const oldSessionData = $storefrontConfig.legacy?.enableSessionMigration ? await getOldSessionData(
|
|
74
|
-
event,
|
|
75
|
-
cookieName,
|
|
76
|
-
sessionStorage,
|
|
77
|
-
secret
|
|
78
|
-
) : void 0;
|
|
73
|
+
const oldSessionData = $storefrontConfig.legacy?.enableSessionMigration ? await getOldSessionData(event, cookieName, sessionStorage, secret) : void 0;
|
|
79
74
|
await useSession(event, {
|
|
80
75
|
...sessionConfig,
|
|
81
76
|
store: sessionStorage,
|
|
@@ -137,10 +132,7 @@ export default defineEventHandler(async (event) => {
|
|
|
137
132
|
const config = useRuntimeConfig(event);
|
|
138
133
|
const url = getRequestURL(event);
|
|
139
134
|
const { path, originalPath } = getBootstrapPath(url, config.app.baseURL);
|
|
140
|
-
const tracer = trace.getTracer(
|
|
141
|
-
"storefront-nuxt",
|
|
142
|
-
"__sfc_version"
|
|
143
|
-
);
|
|
135
|
+
const tracer = trace.getTracer("storefront-nuxt", "__sfc_version");
|
|
144
136
|
if (path.startsWith(joinURL(config.app.baseURL, "/__nuxt"))) {
|
|
145
137
|
return;
|
|
146
138
|
}
|
|
@@ -163,10 +155,7 @@ export default defineEventHandler(async (event) => {
|
|
|
163
155
|
);
|
|
164
156
|
return;
|
|
165
157
|
}
|
|
166
|
-
const apiBasePath = getApiBasePath(
|
|
167
|
-
moduleOptions,
|
|
168
|
-
config.app.baseURL
|
|
169
|
-
);
|
|
158
|
+
const apiBasePath = getApiBasePath(moduleOptions, config.app.baseURL);
|
|
170
159
|
if (!event.context.$rpcContext) {
|
|
171
160
|
event.context.$log.debug(`Bootstrapping request: ${path}`);
|
|
172
161
|
await tracer.startActiveSpan(
|
|
@@ -32,9 +32,7 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
|
|
|
32
32
|
};
|
|
33
33
|
if (!sapiResult || !isValidRedirect(sapiResult)) {
|
|
34
34
|
waitUntil(
|
|
35
|
-
redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch(
|
|
36
|
-
(e) => log.error("Error saving redirect to cache", e)
|
|
37
|
-
)
|
|
35
|
+
redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch((e) => log.error("Error saving redirect to cache", e))
|
|
38
36
|
);
|
|
39
37
|
return null;
|
|
40
38
|
}
|
|
@@ -5,9 +5,6 @@ export const mountStorage = async (storage, mount) => {
|
|
|
5
5
|
const mounts = getAvailableMounts(storage);
|
|
6
6
|
if (!mounts.includes(mount)) {
|
|
7
7
|
const { driver: baseDriver } = storage.getMount(mount);
|
|
8
|
-
storage.mount(
|
|
9
|
-
mount,
|
|
10
|
-
baseDriver
|
|
11
|
-
);
|
|
8
|
+
storage.mount(mount, baseDriver);
|
|
12
9
|
}
|
|
13
10
|
};
|
|
@@ -71,13 +71,11 @@ const StorageSchema = z.discriminatedUnion("driver", [
|
|
|
71
71
|
}),
|
|
72
72
|
scayleKvConfigSchema
|
|
73
73
|
]);
|
|
74
|
-
const AppKeysSchema = z.object(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
);
|
|
74
|
+
const AppKeysSchema = z.object({
|
|
75
|
+
wishlistKey: z.string(),
|
|
76
|
+
basketKey: z.string(),
|
|
77
|
+
hashAlgorithm: z.enum(["md5", "sha256", "none"])
|
|
78
|
+
});
|
|
81
79
|
const CheckoutShopConfigSchema = z.object({
|
|
82
80
|
token: z.string().check(z.minLength(1)),
|
|
83
81
|
secret: z.string().check(z.minLength(1)),
|
|
@@ -86,9 +84,11 @@ const CheckoutShopConfigSchema = z.object({
|
|
|
86
84
|
cbdExpiration: z.optional(z.number()),
|
|
87
85
|
shopId: z.optional(z.number())
|
|
88
86
|
});
|
|
89
|
-
const emptyString = z.string().check(
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
const emptyString = z.string().check(
|
|
88
|
+
z.refine((val) => val === "", {
|
|
89
|
+
error: "Expected boolean, received string"
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
92
|
const ShopConfigSchema = z.object({
|
|
93
93
|
idp: z.optional(IdpSchema),
|
|
94
94
|
shopId: z.number(),
|
|
@@ -108,17 +108,21 @@ const ShopConfigSchema = z.object({
|
|
|
108
108
|
/**
|
|
109
109
|
* @deprecated The `storage` option within `shopConfig` is deprecated. Consider using nuxt storage configuration instead.
|
|
110
110
|
*/
|
|
111
|
-
storage: z.optional(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
storage: z.optional(
|
|
112
|
+
z.object({
|
|
113
|
+
session: z.optional(StorageSchema),
|
|
114
|
+
cache: z.optional(StorageSchema)
|
|
115
|
+
})
|
|
116
|
+
),
|
|
115
117
|
isDefault: z.optional(z.union([z.boolean(), emptyString]))
|
|
116
118
|
});
|
|
117
119
|
const CacheSchema = z.object({
|
|
118
|
-
auth: z.optional(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
auth: z.optional(
|
|
121
|
+
z.object({
|
|
122
|
+
username: z.string(),
|
|
123
|
+
password: z.string()
|
|
124
|
+
})
|
|
125
|
+
),
|
|
122
126
|
enabled: z.optional(z.boolean())
|
|
123
127
|
});
|
|
124
128
|
const ShopSelectorSchema = z.enum(["path", "domain", "path_or_default"]);
|
|
@@ -152,10 +156,12 @@ const StorefrontRuntimeConfigSchema = z.object({
|
|
|
152
156
|
/**
|
|
153
157
|
* @deprecated The `storage` option within `storefront` is deprecated. Consider using nuxt storage configuration instead.
|
|
154
158
|
*/
|
|
155
|
-
storage: z.optional(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
storage: z.optional(
|
|
160
|
+
z.object({
|
|
161
|
+
session: z.optional(StorageSchema),
|
|
162
|
+
cache: z.optional(StorageSchema)
|
|
163
|
+
})
|
|
164
|
+
),
|
|
159
165
|
oauth: OAuthSchema,
|
|
160
166
|
appKeys: AppKeysSchema,
|
|
161
167
|
cache: z.optional(CacheSchema),
|
|
@@ -186,9 +192,11 @@ const StorefrontPublicRuntimeConfigSchema = z.object({
|
|
|
186
192
|
output: z._default(z.enum(["stdout", "stderr", "auto"]), "auto")
|
|
187
193
|
}),
|
|
188
194
|
/** Collection of feature flags regarding legacy features and functionalities */
|
|
189
|
-
legacy: z.optional(
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
legacy: z.optional(
|
|
196
|
+
z.object({
|
|
197
|
+
enableDefaultGetCachedDataOverride: z.optional(z.boolean())
|
|
198
|
+
})
|
|
199
|
+
),
|
|
192
200
|
/**
|
|
193
201
|
* Controls the default lazy loading behavior for useRpc.
|
|
194
202
|
* If set to true,the useRpc composable will not block during data fetching.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.61.
|
|
4
|
+
"version": "8.61.2",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"core-js": "^3.37.1",
|
|
86
86
|
"defu": "^6.1.7",
|
|
87
87
|
"hookable": "^5.5.3",
|
|
88
|
+
"jiti": "^2.6.1",
|
|
88
89
|
"jose": "^6.0.8",
|
|
89
90
|
"knitwork": "^1.3.0",
|
|
90
91
|
"ofetch": "^1.3.4",
|
|
@@ -95,8 +96,8 @@
|
|
|
95
96
|
"utility-types": "^3.11.0",
|
|
96
97
|
"vue-router": "^4.4.0",
|
|
97
98
|
"zod": "^4.0.0",
|
|
98
|
-
"@scayle/
|
|
99
|
-
"@scayle/
|
|
99
|
+
"@scayle/h3-session": "0.7.0",
|
|
100
|
+
"@scayle/storefront-core": "8.61.2"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@arethetypeswrong/cli": "0.18.2",
|