@scayle/storefront-nuxt 7.83.0 → 7.84.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.d.mts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/module.d.mts +2 -2
  5. package/dist/module.d.ts +2 -2
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +10 -10
  8. package/dist/rpc.d.mts +1 -1
  9. package/dist/rpc.d.ts +1 -1
  10. package/dist/runtime/api/cacheAuth.mjs +1 -0
  11. package/dist/runtime/composables/core/useIDP.mjs +2 -11
  12. package/dist/runtime/composables/core/useRpc.mjs +3 -1
  13. package/dist/runtime/composables/core/useSession.mjs +10 -17
  14. package/dist/runtime/composables/core/useUser.mjs +7 -14
  15. package/dist/runtime/composables/storefront/useBasket.mjs +11 -24
  16. package/dist/runtime/composables/storefront/useCategories.mjs +2 -10
  17. package/dist/runtime/composables/storefront/useCurrentPromotions.mjs +7 -1
  18. package/dist/runtime/composables/storefront/useSearch.mjs +3 -10
  19. package/dist/runtime/composables/storefront/useStorefrontSearch.mjs +5 -15
  20. package/dist/runtime/composables/storefront/useWishlist.mjs +9 -24
  21. package/dist/runtime/nitro/plugins/configValidation.d.ts +4 -0
  22. package/dist/runtime/nitro/plugins/configValidation.mjs +2 -2
  23. package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.mjs +2 -1
  24. package/dist/runtime/server/middleware/bootstrap.d.ts +11 -1
  25. package/dist/runtime/server/middleware/bootstrap.mjs +3 -1
  26. package/dist/runtime/server/middleware/bootstrap.utils.d.ts +2 -2
  27. package/dist/runtime/server/middleware/bootstrap.utils.mjs +9 -7
  28. package/dist/runtime/utils/zodSchema.d.ts +987 -148
  29. package/dist/runtime/utils/zodSchema.mjs +34 -10
  30. package/dist/shared/{storefront-nuxt.87331293.d.mts → storefront-nuxt.d852fe87.d.mts} +21 -7
  31. package/dist/shared/{storefront-nuxt.87331293.d.ts → storefront-nuxt.d852fe87.d.ts} +21 -7
  32. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -1,11 +1,32 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.84.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve typing of `H3EventContext` and `Session.data`
8
+
9
+ ## 7.84.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Migrate from `ModuleBaseOptions.stores` to `ModuleBaseOptions.shops`
14
+
3
15
  ## 7.83.0
4
16
 
5
17
  ### Minor Changes
6
18
 
19
+ - Introduce `disableDefaultGetCachedDataOverride` flag in the public runtime configuration. Setting this to true prevents `useRpc` from sharing data across multiple instances.
20
+ Important: The `disableDefaultGetCachedDataOverride` flag currently does not affect the `useUser`, `useBasket`, and `useWishlist` composables. These composables will continue to share a common cache even when `disableDefaultGetCachedDataOverride` is set to true.
7
21
  - Deprecate `useQueryFilterState` in the `@scayle/storefront-nuxt` package
8
22
 
23
+ ### Patch Changes
24
+
25
+ - Remove `shopCampaignKeyword` from ShopConfigSchema
26
+ - Migrate from using `RpcContext.bapiClient` to using `RpcContext.sapiClient`
27
+ - Updated dependencies
28
+ - @scayle/storefront-core@7.63.0
29
+
9
30
  ## 7.82.2
10
31
 
11
32
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.87331293.mjs';
1
+ export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.d852fe87.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 { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.87331293.js';
1
+ export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.d852fe87.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 ModuleBaseOptions } from './shared/storefront-nuxt.87331293.mjs';
3
- export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.87331293.mjs';
2
+ import { M as ModuleBaseOptions } from './shared/storefront-nuxt.d852fe87.mjs';
3
+ export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.d852fe87.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 ModuleBaseOptions } from './shared/storefront-nuxt.87331293.js';
3
- export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.87331293.js';
2
+ import { M as ModuleBaseOptions } from './shared/storefront-nuxt.d852fe87.js';
3
+ export { e as AdditionalShopConfig, A as AppKeys, B as BapiConfig, i as CheckoutEvent, C as CheckoutShopConfig, j as ModulePublicRuntimeConfig, P as PublicShopConfig, R as RedisConfig, d as SapiConfig, a as SessionConfig, f as ShopConfig, g as ShopConfigIndexed, c as StorageConfig, b as StorageEntity, S as StorageProvider, h as StorefrontConfig } from './shared/storefront-nuxt.d852fe87.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.83.0",
3
+ "version": "7.84.1",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -8,11 +8,11 @@ import { createConsola } from 'consola';
8
8
  import 'h3';
9
9
  import { joinURL } from 'ufo';
10
10
 
11
- const convertShopsToList = (stores) => {
12
- if (Array.isArray(stores)) {
13
- return stores;
11
+ const convertShopsToList = (shops) => {
12
+ if (Array.isArray(shops)) {
13
+ return shops;
14
14
  }
15
- return Object.values(stores);
15
+ return Object.values(shops);
16
16
  };
17
17
  function getApiBasePath(storefrontConfig, shop, baseUrl) {
18
18
  const path = Array.isArray(shop.path) ? shop.path[0] : shop.path;
@@ -33,7 +33,8 @@ function getApiBasePath(storefrontConfig, shop, baseUrl) {
33
33
  function getUsedDrivers(options) {
34
34
  const drivers = /* @__PURE__ */ new Set();
35
35
  drivers.add("memory");
36
- if (options.redis || Object.values(options.stores).some((store) => store.redis)) {
36
+ const shops = ("shops" in options ? options.shops : options.stores) ?? {};
37
+ if (options.redis || Object.values(shops).some((shop) => shop.redis)) {
37
38
  drivers.add("redis");
38
39
  }
39
40
  const addDriver = (config) => {
@@ -45,8 +46,8 @@ function getUsedDrivers(options) {
45
46
  }
46
47
  };
47
48
  addDriver(options.storage);
48
- Object.values(options.stores).forEach((store) => {
49
- addDriver(store.storage);
49
+ Object.values(shops).forEach((shop) => {
50
+ addDriver(shop.storage);
50
51
  });
51
52
  return Array.from(drivers);
52
53
  }
@@ -65,7 +66,7 @@ export default {
65
66
  }`;
66
67
  }
67
68
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
68
- const PACKAGE_VERSION = "7.83.0";
69
+ const PACKAGE_VERSION = "7.84.1";
69
70
  const logger = createConsola({
70
71
  fancy: true,
71
72
  formatOptions: {
@@ -99,7 +100,6 @@ const module = defineNuxtModule({
99
100
  // maxAge: undefined,
100
101
  },
101
102
  shopSelector: "domain",
102
- stores: {},
103
103
  oauth: {
104
104
  apiHost: "",
105
105
  clientId: "",
@@ -190,7 +190,7 @@ Missing RPC Overrides: ${Array.from(overridenRPCMethodNames).map((name) => `'${n
190
190
  });
191
191
  }
192
192
  const shops = convertShopsToList(
193
- nuxt.options.runtimeConfig.storefront.stores
193
+ ("shops" in nuxt.options.runtimeConfig.storefront ? nuxt.options.runtimeConfig.storefront.shops : nuxt.options.runtimeConfig.storefront.stores) ?? {}
194
194
  );
195
195
  const shopSelector = nuxt.options.runtimeConfig.storefront.shopSelector;
196
196
  if (shopSelector === "path" || shopSelector === "path_or_default") {
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.87331293.mjs';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.d852fe87.mjs';
4
4
  import '@scayle/unstorage-compression-driver';
5
5
  import 'unstorage';
6
6
  import 'zod';
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.87331293.js';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.d852fe87.js';
4
4
  import '@scayle/unstorage-compression-driver';
5
5
  import 'unstorage';
6
6
  import 'zod';
@@ -1,3 +1,4 @@
1
+ import { Buffer } from "node:buffer";
1
2
  import {
2
3
  getRequestHeaders,
3
4
  defineEventHandler,
@@ -1,12 +1,7 @@
1
- import { useNuxtApp } from "nuxt/app";
2
1
  import { useRpc } from "../core/useRpc.mjs";
3
2
  import { extendPromise } from "../../utils/promise.mjs";
4
- import { rpcCall } from "./../../rpc/rpcCall.mjs";
5
- import { useCurrentShop } from "./useCurrentShop.mjs";
6
- import { toValue } from "#imports";
3
+ import { useRpcCall } from "../core/useRpcCall.mjs";
7
4
  export function useIDP(params = {}, key) {
8
- const nuxtApp = useNuxtApp();
9
- const shop = useCurrentShop();
10
5
  const useRpcPromise = useRpc(
11
6
  "getExternalIdpRedirect",
12
7
  key ?? "useIDP",
@@ -20,11 +15,7 @@ export function useIDP(params = {}, key) {
20
15
  refresh,
21
16
  status
22
17
  } = useRpcPromise;
23
- const handleIDPLoginCallback = rpcCall(
24
- nuxtApp,
25
- "handleIDPLoginCallback",
26
- toValue(shop)
27
- );
18
+ const handleIDPLoginCallback = useRpcCall("handleIDPLoginCallback");
28
19
  return extendPromise(useRpcPromise.then(() => ({})), {
29
20
  data,
30
21
  fetch,
@@ -4,6 +4,7 @@ import { useCoreLog } from "../useCoreLog.mjs";
4
4
  import { useCurrentShop } from "./useCurrentShop.mjs";
5
5
  import { extendPromise } from "../../utils/promise.mjs";
6
6
  import { toValue, computed, isRef } from "#imports";
7
+ import { useRuntimeConfig } from "#app/nuxt";
7
8
  function getFetch(nuxtApp, log) {
8
9
  const fetch = nuxtApp.ssrContext?.event.$fetch ?? $fetch;
9
10
  if (nuxtApp.ssrContext?.event && !nuxtApp.ssrContext?.event.$fetch) {
@@ -15,6 +16,7 @@ export function useRpc(method, key, params, options) {
15
16
  const currentShop = useCurrentShop();
16
17
  const log = useCoreLog("rpc");
17
18
  const nuxtApp = useNuxtApp();
19
+ const { public: { storefront: { disableDefaultGetCachedDataOverride } } } = useRuntimeConfig();
18
20
  if (options && options.autoFetch !== void 0) {
19
21
  log.warn("autoFetch is disabled; use immediate instead");
20
22
  if (options.immediate === void 0) {
@@ -45,7 +47,7 @@ export function useRpc(method, key, params, options) {
45
47
  {
46
48
  // Both refs and getter functions are valid watch sources
47
49
  ...isRef(params) || typeof params === "function" ? { watch: [params] } : {},
48
- getCachedData(key2, nuxtApp2) {
50
+ getCachedData: disableDefaultGetCachedDataOverride ? void 0 : (key2, nuxtApp2) => {
49
51
  const hydrationData = nuxtApp2.isHydrating ? nuxtApp2.payload.data[key2] : nuxtApp2.static.data[key2];
50
52
  return hydrationData ?? nuxtApp2._asyncData[key2]?.data.value;
51
53
  },
@@ -1,22 +1,15 @@
1
- import { useNuxtApp } from "nuxt/app";
2
- import { rpcCall } from "../../rpc/rpcCall.mjs";
3
- import { useCurrentShop } from "./useCurrentShop.mjs";
4
- import { toValue } from "#imports";
1
+ import { useRpcCall } from "../core/useRpcCall.mjs";
5
2
  export function useSession() {
6
- const nuxtApp = useNuxtApp();
7
- const shop = useCurrentShop();
8
3
  return {
9
- login: rpcCall(nuxtApp, "oauthLogin", toValue(shop)),
10
- register: rpcCall(nuxtApp, "oauthRegister", toValue(shop)),
11
- guestLogin: rpcCall(nuxtApp, "oauthGuestLogin", toValue(shop)),
12
- refreshToken: rpcCall(nuxtApp, "refreshAccessToken", toValue(shop)),
13
- revokeToken: rpcCall(nuxtApp, "oauthRevokeToken", toValue(shop)),
14
- forgetPassword: rpcCall(nuxtApp, "oauthForgetPassword", toValue(shop)),
15
- resetPasswordByHash: rpcCall(
16
- nuxtApp,
17
- "updatePasswordByHash",
18
- toValue(shop)
4
+ login: useRpcCall("oauthLogin"),
5
+ register: useRpcCall("oauthRegister"),
6
+ guestLogin: useRpcCall("oauthGuestLogin"),
7
+ refreshToken: useRpcCall("refreshAccessToken"),
8
+ revokeToken: useRpcCall("oauthRevokeToken"),
9
+ forgetPassword: useRpcCall("oauthForgetPassword"),
10
+ resetPasswordByHash: useRpcCall(
11
+ "updatePasswordByHash"
19
12
  ),
20
- loginWithIDP: rpcCall(nuxtApp, "handleIDPLoginCallback", toValue(shop))
13
+ loginWithIDP: useRpcCall("handleIDPLoginCallback")
21
14
  };
22
15
  }
@@ -1,15 +1,16 @@
1
1
  import { useNuxtApp } from "nuxt/app";
2
2
  import { computed } from "vue";
3
- import { rpcCall } from "../../rpc/rpcCall.mjs";
4
3
  import { useCoreLog } from "../useCoreLog.mjs";
5
4
  import { extendPromise } from "../../utils/promise.mjs";
6
5
  import { useRpc } from "./useRpc.mjs";
7
- import { useCurrentShop } from "./useCurrentShop.mjs";
8
6
  import { toValue } from "#imports";
7
+ import { useRpcCall } from "../core/useRpcCall.mjs";
9
8
  export function useUser(options = {}) {
10
9
  const nuxtApp = useNuxtApp();
11
- const shop = useCurrentShop();
12
10
  const log = useCoreLog("useUser");
11
+ const updateUserRpc = useRpcCall("updateShopUser");
12
+ const updatePasswordRpc = useRpcCall("updatePassword");
13
+ const refreshUserRpc = useRpcCall("refreshUser");
13
14
  if (options && options.autoFetch !== void 0) {
14
15
  log.warn("autoFetch is disabled; use immediate instead");
15
16
  if (options.immediate === void 0) {
@@ -40,19 +41,11 @@ export function useUser(options = {}) {
40
41
  const { data, fetching, fetch, error, status } = asyncDataPromise;
41
42
  const updateUser = async (payload) => {
42
43
  log.debug("Update user");
43
- data.value = await rpcCall(
44
- nuxtApp,
45
- "updateShopUser",
46
- toValue(shop)
47
- )(payload);
44
+ data.value = await updateUserRpc(payload);
48
45
  };
49
46
  const updatePassword = async (payload) => {
50
47
  log.debug("Update password");
51
- const response = await rpcCall(
52
- nuxtApp,
53
- "updatePassword",
54
- toValue(shop)
55
- )(payload);
48
+ const response = await updatePasswordRpc(payload);
56
49
  if (response) {
57
50
  data.value = response;
58
51
  }
@@ -67,7 +60,7 @@ export function useUser(options = {}) {
67
60
  });
68
61
  const forceRefresh = async () => {
69
62
  log.debug("Refresh user");
70
- data.value = await rpcCall(nuxtApp, "refreshUser", toValue(shop))();
63
+ data.value = await refreshUserRpc();
71
64
  };
72
65
  return extendPromise(asyncDataPromise.then(() => ({})), {
73
66
  user,
@@ -8,17 +8,20 @@ import {
8
8
  } from "@scayle/storefront-core";
9
9
  import { useNuxtApp } from "nuxt/app";
10
10
  import { computed } from "vue";
11
- import { rpcCall } from "../../rpc/rpcCall.mjs";
12
11
  import { extendPromise } from "../../utils/promise.mjs";
13
12
  import { useRpc } from "../core/useRpc.mjs";
14
- import { useCurrentShop } from "../core/useCurrentShop.mjs";
13
+ import { useRpcCall } from "../core/useRpcCall.mjs";
15
14
  import { toValue, toRef } from "#imports";
16
15
  export function useBasket({
17
16
  params,
18
17
  key = "useBasket"
19
18
  } = {}) {
20
19
  const nuxtApp = useNuxtApp();
21
- const shop = useCurrentShop();
20
+ const addItemToBasketRpc = useRpcCall("addItemToBasket");
21
+ const addItemsToBasketRpc = useRpcCall("addItemsToBasket");
22
+ const mergeBasketsRpc = useRpcCall("mergeBaskets");
23
+ const clearBasketRpc = useRpcCall("clearBasket");
24
+ const removeItemFromBasketRpc = useRpcCall("removeItemFromBasket");
22
25
  const asyncData = useRpc("getBasket", key, params, {
23
26
  server: false,
24
27
  // TODO: In some cases it might be ok to fetch on server
@@ -44,11 +47,7 @@ export function useBasket({
44
47
  customData,
45
48
  itemGroup
46
49
  }) => {
47
- data.value = await rpcCall(
48
- nuxtApp,
49
- "addItemToBasket",
50
- toValue(shop)
51
- )({
50
+ data.value = await addItemToBasketRpc({
52
51
  promotionId,
53
52
  variantId,
54
53
  quantity,
@@ -60,22 +59,14 @@ export function useBasket({
60
59
  });
61
60
  };
62
61
  const addItems = async (items2, existingItemHandling = ExistingItemHandling.AddQuantityToExisting) => {
63
- data.value = await rpcCall(
64
- nuxtApp,
65
- "addItemsToBasket",
66
- toValue(shop)
67
- )({
62
+ data.value = await addItemsToBasketRpc({
68
63
  items: items2,
69
64
  existingItemHandling,
70
65
  with: toValue(params)
71
66
  });
72
67
  };
73
68
  const mergeBaskets = async (args) => {
74
- return await rpcCall(
75
- nuxtApp,
76
- "mergeBaskets",
77
- toValue(shop)
78
- )({
69
+ return await mergeBasketsRpc({
79
70
  ...args,
80
71
  with: toValue(params)
81
72
  });
@@ -100,17 +91,13 @@ export function useBasket({
100
91
  `Could not find basket item by variant-id: ${item.variantId}`
101
92
  );
102
93
  }
103
- data.value = await rpcCall(
104
- nuxtApp,
105
- "removeItemFromBasket",
106
- toValue(shop)
107
- )({
94
+ data.value = await removeItemFromBasketRpc({
108
95
  itemKey: element.key,
109
96
  with: toValue(params)
110
97
  });
111
98
  };
112
99
  const clear = async () => {
113
- await rpcCall(nuxtApp, "clearBasket", toValue(shop))();
100
+ await clearBasketRpc();
114
101
  };
115
102
  const products = computed(
116
103
  () => data.value?.items.map((item) => item.product) || []
@@ -1,26 +1,18 @@
1
- import { useNuxtApp } from "nuxt/app";
2
1
  import { useRpc } from "../core/useRpc.mjs";
3
- import { useCurrentShop } from "../core/useCurrentShop.mjs";
4
- import { rpcCall } from "../../rpc/rpcCall.mjs";
5
2
  import { extendPromise } from "../../utils/promise.mjs";
3
+ import { useRpcCall } from "../core/useRpcCall.mjs";
6
4
  export function useCategories({
7
5
  params,
8
6
  options,
9
7
  key: _key
10
8
  } = {}, key) {
11
- const currentShop = useCurrentShop();
12
- const nuxtApp = useNuxtApp();
13
9
  const useRpcPromise = useRpc(
14
10
  "getCategoriesByPath",
15
11
  _key ?? key ?? "useCategories",
16
12
  params,
17
13
  options
18
14
  );
19
- const getCategoryById = rpcCall(
20
- nuxtApp,
21
- "getCategoryById",
22
- currentShop.value ?? void 0
23
- );
15
+ const getCategoryById = useRpcCall("getCategoryById");
24
16
  const {
25
17
  data,
26
18
  error,
@@ -8,6 +8,12 @@ export function useCurrentPromotions({
8
8
  "getCurrentPromotions",
9
9
  _key ?? key ?? "useCurrentPromotions",
10
10
  params,
11
- options
11
+ {
12
+ getCachedData(key2, nuxtApp) {
13
+ const hydrationData = nuxtApp.isHydrating ? nuxtApp.payload.data[key2] : nuxtApp.static.data[key2];
14
+ return hydrationData ?? nuxtApp._asyncData[key2]?.data.value;
15
+ },
16
+ ...options
17
+ }
12
18
  );
13
19
  }
@@ -1,18 +1,15 @@
1
1
  import { useState } from "nuxt/app";
2
- import { rpcCall } from "../../rpc/rpcCall.mjs";
3
- import { useCurrentShop } from "../core/useCurrentShop.mjs";
4
- import { useNuxtApp, toValue } from "#imports";
2
+ import { useRpcCall } from "../core/useRpcCall.mjs";
5
3
  export function useSearch({ params, key = "search" } = {}) {
6
4
  const data = useState(
7
5
  `${key}-data`,
8
6
  () => void 0
9
7
  );
10
- const nuxtApp = useNuxtApp();
11
8
  const searchQuery = useState(`${key}-searchQuery`, () => "");
12
9
  const pending = useState(`${key}-pending`, () => false);
13
10
  const error = useState(`${key}-error`, () => void 0);
14
11
  const status = useState(`${key}-error`, () => "idle");
15
- const shop = useCurrentShop();
12
+ const searchProductsRpc = useRpcCall("searchProducts");
16
13
  const search = async ({ term, slug, productLimit }) => {
17
14
  pending.value = true;
18
15
  status.value = "pending";
@@ -20,11 +17,7 @@ export function useSearch({ params, key = "search" } = {}) {
20
17
  return;
21
18
  }
22
19
  try {
23
- data.value = await rpcCall(
24
- nuxtApp,
25
- "searchProducts",
26
- toValue(shop)
27
- )({
20
+ data.value = await searchProductsRpc({
28
21
  term: String(term),
29
22
  slug,
30
23
  with: params?.with,
@@ -1,20 +1,18 @@
1
1
  import { useState } from "nuxt/app";
2
- import { rpcCall } from "../../rpc/rpcCall.mjs";
3
- import { useCurrentShop } from "../core/useCurrentShop.mjs";
4
- import { useNuxtApp, toValue } from "#imports";
2
+ import { useRpcCall } from "../core/useRpcCall.mjs";
5
3
  export function useStorefrontSearch(searchQuery, { params, key = "search" } = {}) {
6
4
  const data = useState(
7
5
  `${key}-data`,
8
6
  () => void 0
9
7
  );
10
- const nuxtApp = useNuxtApp();
8
+ const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
9
+ const resolveSearchRpc = useRpcCall("resolveSearch");
11
10
  const pending = useState(`${key}-pending`, () => false);
12
11
  const error = useState(
13
12
  `${key}-error`,
14
13
  () => void 0
15
14
  );
16
15
  const status = useState(`${key}-error`, () => "idle");
17
- const shop = useCurrentShop();
18
16
  const getSearchSuggestions = async () => {
19
17
  pending.value = true;
20
18
  status.value = "pending";
@@ -22,11 +20,7 @@ export function useStorefrontSearch(searchQuery, { params, key = "search" } = {}
22
20
  return;
23
21
  }
24
22
  try {
25
- data.value = await rpcCall(
26
- nuxtApp,
27
- "getSearchSuggestions",
28
- toValue(shop)
29
- )({
23
+ data.value = await getSearchSuggestionsRpc({
30
24
  term: String(searchQuery.value),
31
25
  ...params
32
26
  });
@@ -41,11 +35,7 @@ export function useStorefrontSearch(searchQuery, { params, key = "search" } = {}
41
35
  if (!searchQuery.value) {
42
36
  return;
43
37
  }
44
- return await rpcCall(
45
- nuxtApp,
46
- "resolveSearch",
47
- toValue(shop)
48
- )({
38
+ return await resolveSearchRpc({
49
39
  term: searchQuery.value,
50
40
  ...params
51
41
  });
@@ -5,17 +5,18 @@ import {
5
5
  } from "@scayle/storefront-core";
6
6
  import { useNuxtApp } from "nuxt/app";
7
7
  import { computed } from "vue";
8
- import { rpcCall } from "../../rpc/rpcCall.mjs";
9
8
  import { useRpc } from "../core/useRpc.mjs";
10
9
  import { extendPromise } from "../../utils/promise.mjs";
11
- import { useCurrentShop } from "../core/useCurrentShop.mjs";
12
10
  import { toValue, toRef } from "#imports";
11
+ import { useRpcCall } from "../core/useRpcCall.mjs";
13
12
  export function useWishlist({
14
13
  params,
15
14
  key = "useWishlist"
16
15
  } = {}) {
17
16
  const nuxtApp = useNuxtApp();
18
- const shop = useCurrentShop();
17
+ const addItemToWishlistRpc = useRpcCall("addItemToWishlist");
18
+ const removeItemFromWishlistRpc = useRpcCall("removeItemFromWishlist");
19
+ const clearWishlistRpc = useRpcCall("clearWishlist");
19
20
  const asyncData = useRpc(
20
21
  "getWishlist",
21
22
  key,
@@ -38,11 +39,7 @@ export function useWishlist({
38
39
  status
39
40
  } = asyncData;
40
41
  const addItem = async (item) => {
41
- data.value = await rpcCall(
42
- nuxtApp,
43
- "addItemToWishlist",
44
- toValue(shop)
45
- )({
42
+ data.value = await addItemToWishlistRpc({
46
43
  ...item,
47
44
  with: toValue(params)
48
45
  });
@@ -56,11 +53,7 @@ export function useWishlist({
56
53
  "Could not find wishlist item."
57
54
  );
58
55
  }
59
- data.value = await rpcCall(
60
- nuxtApp,
61
- "removeItemFromWishlist",
62
- toValue(shop)
63
- )({
56
+ data.value = await removeItemFromWishlistRpc({
64
57
  itemKey: element.key,
65
58
  with: toValue(params)
66
59
  });
@@ -74,25 +67,17 @@ export function useWishlist({
74
67
  `Could not find wishlist item by: ${JSON.stringify(item)}`
75
68
  );
76
69
  }
77
- await rpcCall(
78
- nuxtApp,
79
- "removeItemFromWishlist",
80
- toValue(shop)
81
- )({
70
+ await removeItemFromWishlistRpc({
82
71
  with: toValue(params),
83
72
  itemKey: element.key
84
73
  });
85
- data.value = await rpcCall(
86
- nuxtApp,
87
- "addItemToWishlist",
88
- toValue(shop)
89
- )({
74
+ data.value = await addItemToWishlistRpc({
90
75
  ...newItem,
91
76
  with: toValue(params)
92
77
  });
93
78
  };
94
79
  const clear = async () => {
95
- data.value = await rpcCall(nuxtApp, "clearWishlist", toValue(shop))();
80
+ data.value = await clearWishlistRpc();
96
81
  };
97
82
  const findItem = (item) => {
98
83
  return data.value?.items?.find((entry) => {
@@ -1,3 +1,7 @@
1
+ import type { RuntimeConfig } from '@nuxt/schema';
2
+ import type { ZodIssue } from 'zod';
1
3
  export declare const sensitiveKeys: string[];
4
+ export declare const getValue: (object: any, pathArray: any) => string;
5
+ export declare const formatZodError: (issues: Array<ZodIssue>, runtimeConfig: RuntimeConfig) => never[];
2
6
  declare const _default: any;
3
7
  export default _default;
@@ -8,12 +8,12 @@ export const sensitiveKeys = [
8
8
  "apiToken",
9
9
  "secret"
10
10
  ];
11
- const getValue = (object, pathArray) => {
11
+ export const getValue = (object, pathArray) => {
12
12
  return String(pathArray.reduce((acc, key) => {
13
13
  return acc ? acc[key] : void 0;
14
14
  }, object));
15
15
  };
16
- const formatZodError = (issues, runtimeConfig) => {
16
+ export const formatZodError = (issues, runtimeConfig) => {
17
17
  const errorMessages = [];
18
18
  issues.forEach((issue) => {
19
19
  if (issue.code === "invalid_union") {
@@ -121,9 +121,10 @@ function getShopSessionConfig(config, shop, log) {
121
121
  export default defineNitroPlugin(() => {
122
122
  const storage = useStorage();
123
123
  const config = useRuntimeConfig();
124
+ const storefront = config.storefront;
124
125
  const logConfig = config.public.storefront.log;
125
126
  const log = createLog(createConsola, logConfig.name, logConfig.level);
126
- const shops = config.storefront.stores;
127
+ const shops = "shops" in storefront ? storefront.shops : storefront.stores;
127
128
  try {
128
129
  const globalCacheConfig = getCacheConfig(config, log);
129
130
  mountStorage(storage, {
@@ -1,4 +1,4 @@
1
- import type { RpcContext, Cache } from '@scayle/storefront-core';
1
+ import type { RpcContext, Cache, ShopUser } from '@scayle/storefront-core';
2
2
  import type { PublicShopConfig } from '../../../module';
3
3
  declare module 'h3' {
4
4
  interface H3EventContext {
@@ -8,5 +8,15 @@ declare module 'h3' {
8
8
  $availableShops: PublicShopConfig[];
9
9
  }
10
10
  }
11
+ export interface ShopSessionData {
12
+ user?: ShopUser;
13
+ accessToken?: string;
14
+ refreshToken?: string;
15
+ shopId?: number;
16
+ }
17
+ declare module '@scayle/h3-session' {
18
+ interface SessionDataT extends ShopSessionData {
19
+ }
20
+ }
11
21
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
12
22
  export default _default;