@scayle/storefront-nuxt 7.82.0 → 7.82.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +45 -27
  2. package/dist/index.d.mts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/module.d.mts +3 -3
  5. package/dist/module.d.ts +3 -3
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +1 -5
  8. package/dist/rpc.d.mts +1 -1
  9. package/dist/rpc.d.ts +1 -1
  10. package/dist/runtime/campaignKey.d.ts +1 -1
  11. package/dist/runtime/campaignKey.mjs +2 -2
  12. package/dist/runtime/composables/core/useIDP.d.ts +16 -10
  13. package/dist/runtime/composables/core/useIDP.mjs +15 -1
  14. package/dist/runtime/composables/storefront/useBasket.d.ts +6 -8
  15. package/dist/runtime/composables/storefront/useBasket.mjs +7 -5
  16. package/dist/runtime/composables/storefront/useCategories.d.ts +24 -18
  17. package/dist/runtime/composables/storefront/useCategories.mjs +15 -1
  18. package/dist/runtime/composables/storefront/useOrder.d.ts +12 -8
  19. package/dist/runtime/composables/storefront/useOrder.mjs +16 -3
  20. package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +11 -7
  21. package/dist/runtime/composables/storefront/useOrderConfirmation.mjs +15 -2
  22. package/dist/runtime/context.d.ts +6 -0
  23. package/dist/runtime/context.mjs +7 -6
  24. package/dist/runtime/server/middleware/redirects.mjs +11 -11
  25. package/dist/runtime/utils/zodSchema.d.ts +863 -731
  26. package/dist/runtime/utils/zodSchema.mjs +25 -19
  27. package/dist/shared/{storefront-nuxt.ed010583.d.mts → storefront-nuxt.87331293.d.mts} +78 -26
  28. package/dist/shared/{storefront-nuxt.ed010583.d.ts → storefront-nuxt.87331293.d.ts} +78 -26
  29. package/dist/types.d.mts +1 -1
  30. package/dist/types.d.ts +1 -1
  31. package/package.json +12 -12
@@ -80,22 +80,23 @@ async function sessionProperties(context) {
80
80
  }
81
81
  export const buildContext = async (context) => {
82
82
  const { $cache, $shopConfig, $storefront, $log, config, event } = context;
83
- const bapiConfig = $shopConfig.bapi ?? $storefront.bapi;
83
+ const sapiConfig = $shopConfig.sapi ?? $shopConfig.bapi ?? $storefront.sapi ?? $storefront.bapi;
84
84
  const appKeys = $shopConfig.appKeys ?? $storefront.appKeys;
85
85
  const idpConfig = $shopConfig.idp ?? $storefront.idp;
86
- const bapiClient = new StorefrontAPIClient({
87
- host: bapiConfig.host,
86
+ const sapiClient = new StorefrontAPIClient({
87
+ host: sapiConfig.host,
88
88
  shopId: $shopConfig.shopId,
89
89
  auth: {
90
90
  type: "token",
91
- token: bapiConfig.token
91
+ token: sapiConfig.token
92
92
  }
93
93
  });
94
94
  const cached = new Cached($cache, $log, "", $storefront.cache?.enabled ?? true).execute;
95
95
  const { hooks } = useNitroApp();
96
96
  const baseContext = {
97
97
  cached,
98
- bapiClient,
98
+ bapiClient: sapiClient,
99
+ sapiClient,
99
100
  auth: {
100
101
  resetPasswordUrl: $shopConfig.auth?.resetPasswordUrl
101
102
  },
@@ -136,7 +137,7 @@ export const buildContext = async (context) => {
136
137
  withParams: $storefront.withParams,
137
138
  storeCampaignKeyword: $shopConfig.storeCampaignKeyword,
138
139
  campaignKey: await fetchCampaignKey(
139
- bapiClient,
140
+ sapiClient,
140
141
  cached,
141
142
  $shopConfig.storeCampaignKeyword,
142
143
  $log
@@ -13,10 +13,10 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
13
13
  }
14
14
  return cachedResult;
15
15
  }
16
- log.debug("No cached result for redirect; querying BAPI");
17
- let bapiResult;
16
+ log.debug("No cached result for redirect; querying SAPI");
17
+ let sapiResult;
18
18
  try {
19
- bapiResult = await storefrontAPIClient.redirects.post(sourceUrl);
19
+ sapiResult = await storefrontAPIClient.redirects.post(sourceUrl);
20
20
  } catch (error) {
21
21
  log.error(
22
22
  `Error: Failed to fetch redirects ... ${error} for sourceURL: ${sourceUrl}`
@@ -26,19 +26,19 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
26
26
  const isValidRedirect = (redirect) => {
27
27
  return redirect && redirect?.source && redirect?.target && redirect.source !== redirect.target;
28
28
  };
29
- if (!bapiResult || !isValidRedirect(bapiResult)) {
29
+ if (!sapiResult || !isValidRedirect(sapiResult)) {
30
30
  await redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL);
31
31
  return null;
32
32
  }
33
33
  await redirectCache.set(
34
- bapiResult.source,
34
+ sapiResult.source,
35
35
  {
36
- target: bapiResult.target,
37
- statusCode: bapiResult.statusCode
36
+ target: sapiResult.target,
37
+ statusCode: sapiResult.statusCode
38
38
  },
39
39
  REDIRECT_CACHE_TTL
40
40
  );
41
- return bapiResult;
41
+ return sapiResult;
42
42
  }
43
43
  export async function useRedirects(event) {
44
44
  const config = useRuntimeConfig();
@@ -54,7 +54,7 @@ export async function useRedirects(event) {
54
54
  shopCache.storage,
55
55
  shopCache.prefix + REDIS_REDIRECT_PREFIX
56
56
  );
57
- const bapiClient = event.context.$rpcContext.bapiClient;
57
+ const sapiClient = event.context.$rpcContext.sapiClient;
58
58
  const queryParamWhitelist = new Set(options?.queryParamWhitelist ?? []);
59
59
  log.debug(`Querying redirect for ${url.toString()}`);
60
60
  const { relativeSourceUrl, absoluteSourceUrl } = getRedirectLookupUrls(
@@ -62,8 +62,8 @@ export async function useRedirects(event) {
62
62
  queryParamWhitelist
63
63
  );
64
64
  const [relativeRedirect, absoluteRedirect] = await Promise.all([
65
- fetchRedirectWithCache(relativeSourceUrl, bapiClient, redirectCache, log),
66
- fetchRedirectWithCache(absoluteSourceUrl, bapiClient, redirectCache, log)
65
+ fetchRedirectWithCache(relativeSourceUrl, sapiClient, redirectCache, log),
66
+ fetchRedirectWithCache(absoluteSourceUrl, sapiClient, redirectCache, log)
67
67
  ]);
68
68
  if (relativeRedirect && absoluteRedirect) {
69
69
  log.info(`There are multiple valid redirects for: ${url.toString()}`);