@scayle/storefront-nuxt 7.75.0 → 7.76.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.76.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `useOrder` `useOrderConfirmation` and `useIDP` are now optionally awaitable
8
+
9
+ ## 7.75.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Add `immediate` option to `useUser` and deprecate `autoFetch`
14
+ - Log warning when deprecated `autoFetch` option is used
15
+
3
16
  ## 7.75.0
4
17
 
5
18
  ### Minor Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "7.74.0",
3
+ "version": "7.75.1",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -64,7 +64,7 @@ export default {
64
64
  }`;
65
65
  }
66
66
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
67
- const PACKAGE_VERSION = "7.74.0";
67
+ const PACKAGE_VERSION = "7.75.1";
68
68
  const logger = createConsola({
69
69
  fancy: true,
70
70
  formatOptions: {
@@ -1,13 +1,22 @@
1
1
  import { type MaybeRefOrGetter } from 'vue';
2
2
  import type { RpcMethodParameters } from '@scayle/storefront-core';
3
- export declare function useIDP(params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>, key?: string): Promise<{
4
- data: import("vue").Ref<{
5
- [k: string]: string;
3
+ export declare function useIDP(params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>, key?: string): import("nuxt/dist/app/composables/asyncData")._AsyncData<{
4
+ [k: string]: string;
5
+ }, import("nuxt/app").NuxtError<unknown> | null> & {
6
+ fetching: import("vue").Ref<boolean>;
7
+ fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
8
+ } & {
9
+ handleIDPLoginCallback: (params: string | {
10
+ code: string;
11
+ }) => Promise<{
12
+ message: string;
6
13
  }>;
14
+ } & Promise<import("nuxt/dist/app/composables/asyncData")._AsyncData<{
15
+ [k: string]: string;
16
+ }, import("nuxt/app").NuxtError<unknown> | null> & {
7
17
  fetching: import("vue").Ref<boolean>;
8
18
  fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
9
- error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | null>;
10
- status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
19
+ } & {
11
20
  handleIDPLoginCallback: (params: string | {
12
21
  code: string;
13
22
  }) => Promise<{
@@ -1,12 +1,13 @@
1
1
  import { useNuxtApp } from "nuxt/app";
2
2
  import { useRpc } from "../core/useRpc.mjs";
3
+ import { extendPromise } from "../../utils/promise.mjs";
3
4
  import { rpcCall } from "./../../rpc/rpcCall.mjs";
4
5
  import { useCurrentShop } from "./useCurrentShop.mjs";
5
6
  import { toValue } from "#imports";
6
- export async function useIDP(params = {}, key) {
7
+ export function useIDP(params = {}, key) {
7
8
  const nuxtApp = useNuxtApp();
8
9
  const shop = useCurrentShop();
9
- const { data, fetching, fetch, error, status } = await useRpc(
10
+ const useRpcPromise = useRpc(
10
11
  "getExternalIdpRedirect",
11
12
  key ?? "useIDP",
12
13
  params
@@ -16,13 +17,8 @@ export async function useIDP(params = {}, key) {
16
17
  "handleIDPLoginCallback",
17
18
  toValue(shop)
18
19
  );
19
- return {
20
- data,
21
- fetching,
22
- fetch,
23
- error,
24
- status,
20
+ return extendPromise(useRpcPromise, {
25
21
  // TODO: Deprecate the property here and remove it with the next major release
26
22
  handleIDPLoginCallback
27
- };
23
+ });
28
24
  }
@@ -15,8 +15,13 @@ export function useRpc(method, key, params, options) {
15
15
  const currentShop = useCurrentShop();
16
16
  const log = useCoreLog("rpc");
17
17
  const nuxtApp = useNuxtApp();
18
- if (options && options.autoFetch !== void 0 && options.immediate === void 0) {
19
- options.immediate = options.autoFetch;
18
+ if (options && options.autoFetch !== void 0) {
19
+ log.warn("autoFetch is disabled; use immediate instead");
20
+ if (options.immediate === void 0) {
21
+ options.immediate = options.autoFetch;
22
+ } else {
23
+ log.warn("autoFetch will be ignored because immediate was specified");
24
+ }
20
25
  }
21
26
  const asyncData = useAsyncData(
22
27
  key,
@@ -1,8 +1,12 @@
1
- import type { ShopUser, UpdatePasswordParams, UseUserParams } from '@scayle/storefront-core';
2
- export type ExtendedUseUserParams = UseUserParams & {
1
+ import type { ShopUser, UpdatePasswordParams } from '@scayle/storefront-core';
2
+ export type ExtendedUseUserParams = {
3
+ key?: string;
4
+ /** @deprecated use immediate instead */
5
+ autoFetch?: boolean;
6
+ immediate?: boolean;
3
7
  lazy?: boolean;
4
8
  };
5
- export declare function useUser({ autoFetch, lazy, key, }?: ExtendedUseUserParams): {
9
+ export declare function useUser(options?: ExtendedUseUserParams): {
6
10
  user: import("vue").ComputedRef<ShopUser | undefined>;
7
11
  isLoggedIn: import("vue").ComputedRef<boolean>;
8
12
  customerType: import("vue").ComputedRef<"guest" | "new" | "existing">;
@@ -6,20 +6,29 @@ import { extendPromise } from "../../utils/promise.mjs";
6
6
  import { useRpc } from "./useRpc.mjs";
7
7
  import { useCurrentShop } from "./useCurrentShop.mjs";
8
8
  import { toValue } from "#imports";
9
- export function useUser({
10
- autoFetch = true,
11
- lazy = false,
12
- key = "useUser"
13
- } = {}) {
9
+ export function useUser(options = {}) {
14
10
  const nuxtApp = useNuxtApp();
15
11
  const shop = useCurrentShop();
16
12
  const log = useCoreLog("useUser");
13
+ if (options && options.autoFetch !== void 0) {
14
+ log.warn("autoFetch is disabled; use immediate instead");
15
+ if (options.immediate === void 0) {
16
+ options.immediate = options.autoFetch;
17
+ } else {
18
+ log.warn("autoFetch will be ignored because immediate was specified");
19
+ }
20
+ }
21
+ const {
22
+ immediate = true,
23
+ lazy = false,
24
+ key = "useUser"
25
+ } = options;
17
26
  const asyncDataPromise = useRpc(
18
27
  "getUser",
19
28
  key,
20
29
  void 0,
21
30
  {
22
- autoFetch,
31
+ immediate,
23
32
  lazy,
24
33
  server: false,
25
34
  dedupe: "defer",
@@ -38,7 +38,7 @@ export function useFacet({
38
38
  path: currentPath.value,
39
39
  includeHidden: params.with?.product?.categories?.includeHidden || void 0
40
40
  }),
41
- options: { autoFetch: false },
41
+ options: { immediate: false },
42
42
  key: `${key}-categories`
43
43
  });
44
44
  const productsPromise = useProducts({
@@ -55,7 +55,7 @@ export function useFacet({
55
55
  cache: currentCacheParams.value,
56
56
  orFiltersOperator: currentOrFiltersOperator.value
57
57
  }),
58
- options: { autoFetch: false },
58
+ options: { immediate: false },
59
59
  key: `${key}-products`
60
60
  });
61
61
  const productsCountPromise = useProductsCount({
@@ -67,7 +67,7 @@ export function useFacet({
67
67
  where: productCountWhere.value,
68
68
  orFiltersOperator: currentOrFiltersOperator.value
69
69
  }),
70
- options: { autoFetch: false },
70
+ options: { immediate: false },
71
71
  key: `${key}-productCount`
72
72
  });
73
73
  const filtersPromise = useFilters({
@@ -79,7 +79,7 @@ export function useFacet({
79
79
  where: currentWhereCondition.value,
80
80
  orFiltersOperator: currentOrFiltersOperator.value
81
81
  }),
82
- options: { autoFetch: false },
82
+ options: { immediate: false },
83
83
  key: `${key}-filters`
84
84
  });
85
85
  const {
@@ -11,7 +11,10 @@ export declare function useOrder<P = {
11
11
  [k: string]: unknown;
12
12
  }, V = {
13
13
  [k: string]: unknown;
14
- }>({ params, options, key: _key }?: Options, key?: string): Promise<{
14
+ }>({ params, options, key: _key }?: Options, key?: string): import("nuxt/dist/app/composables/asyncData")._AsyncData<Order, import("nuxt/app").NuxtError<unknown> | null> & {
15
+ fetching: import("vue").Ref<boolean>;
16
+ fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
17
+ } & {
15
18
  data: Ref<Order & {
16
19
  items?: ({
17
20
  id?: number | undefined;
@@ -82,9 +85,79 @@ export declare function useOrder<P = {
82
85
  variant: V;
83
86
  })[] | undefined;
84
87
  }>;
88
+ } & Promise<import("nuxt/dist/app/composables/asyncData")._AsyncData<Order, import("nuxt/app").NuxtError<unknown> | null> & {
85
89
  fetching: import("vue").Ref<boolean>;
86
90
  fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
87
- error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | null>;
88
- status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
91
+ } & {
92
+ data: Ref<Order & {
93
+ items?: ({
94
+ id?: number | undefined;
95
+ availableQuantity?: number | undefined;
96
+ currency?: string | undefined;
97
+ customData?: {
98
+ [k: string]: unknown;
99
+ } | undefined;
100
+ deliveryForecast?: import("@scayle/storefront-core").DeliveryForecastFromWarehouse | undefined;
101
+ isManuallyReturnedByCci?: boolean | undefined;
102
+ itemGroup?: {
103
+ id: string;
104
+ isMainItem: boolean;
105
+ isRequired: boolean;
106
+ } | null | undefined;
107
+ key: string;
108
+ lowestPriorPrice?: {
109
+ relativeDifferenceToPrice: number;
110
+ withTax: number;
111
+ } | null | undefined;
112
+ merchant?: {
113
+ [k: string]: unknown;
114
+ id: number;
115
+ } | undefined;
116
+ packageId: number;
117
+ price: {
118
+ appliedReductions?: {
119
+ amount: {
120
+ absoluteWithTax: number;
121
+ relative: number;
122
+ };
123
+ category: "voucher" | "sale" | "campaign";
124
+ code?: string | undefined;
125
+ type: "relative" | "absolute";
126
+ }[] | undefined;
127
+ overrideWithoutTax?: number | undefined;
128
+ overrideWithTax?: number | undefined;
129
+ reference?: {
130
+ size?: string | undefined;
131
+ unit?: string | undefined;
132
+ withTax?: number | undefined;
133
+ } | undefined;
134
+ tax: {
135
+ [k: string]: {
136
+ amount: number;
137
+ rate: number;
138
+ };
139
+ };
140
+ undiscountedWithOutTax?: number | undefined;
141
+ undiscountedWithTax?: number | undefined;
142
+ withoutTax: number;
143
+ withTax: number;
144
+ };
145
+ product: {
146
+ [k: string]: unknown;
147
+ };
148
+ reservationKey?: string | undefined;
149
+ status: "available" | "unavailable" | "cancelled" | "delivered" | "returned";
150
+ variant: {
151
+ [k: string]: unknown;
152
+ };
153
+ warehouseId?: import("@scayle/storefront-core").PickingWarehouseId | undefined;
154
+ warehousePackageGroupId?: import("@scayle/storefront-core").WarehousePackageReference | undefined;
155
+ createdAt: string;
156
+ updatedAt: string;
157
+ } & {
158
+ product: P;
159
+ variant: V;
160
+ })[] | undefined;
161
+ }>;
89
162
  }>;
90
163
  export {};
@@ -1,17 +1,14 @@
1
1
  import { useRpc } from "../core/useRpc.mjs";
2
- export async function useOrder({ params, options, key: _key } = {}, key) {
3
- const { data, fetching, fetch, error, status } = await useRpc(
2
+ import { extendPromise } from "../../utils/promise.mjs";
3
+ export function useOrder({ params, options, key: _key } = {}, key) {
4
+ const promise = useRpc(
4
5
  "getOrderById",
5
6
  _key ?? key ?? "useOrder",
6
7
  params,
7
8
  options
8
9
  );
9
- const _data = data;
10
- return {
11
- data: _data,
12
- fetching,
13
- fetch,
14
- error,
15
- status
16
- };
10
+ const _data = promise.data;
11
+ return extendPromise(promise, {
12
+ data: _data
13
+ });
17
14
  }
@@ -11,7 +11,10 @@ export declare function useOrderConfirmation<P = {
11
11
  [k: string]: unknown;
12
12
  }, V = {
13
13
  [k: string]: unknown;
14
- }>({ params, options, key: _key }?: Options, key?: string): Promise<{
14
+ }>({ params, options, key: _key }?: Options, key?: string): import("nuxt/dist/app/composables/asyncData")._AsyncData<Order | undefined, import("nuxt/app").NuxtError<unknown> | null> & {
15
+ fetching: import("vue").Ref<boolean>;
16
+ fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
17
+ } & {
15
18
  data: Ref<Order & {
16
19
  items?: ({
17
20
  id?: number | undefined;
@@ -82,9 +85,79 @@ export declare function useOrderConfirmation<P = {
82
85
  variant: V;
83
86
  })[] | undefined;
84
87
  }>;
88
+ } & Promise<import("nuxt/dist/app/composables/asyncData")._AsyncData<Order | undefined, import("nuxt/app").NuxtError<unknown> | null> & {
85
89
  fetching: import("vue").Ref<boolean>;
86
90
  fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
87
- error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | null>;
88
- status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
91
+ } & {
92
+ data: Ref<Order & {
93
+ items?: ({
94
+ id?: number | undefined;
95
+ availableQuantity?: number | undefined;
96
+ currency?: string | undefined;
97
+ customData?: {
98
+ [k: string]: unknown;
99
+ } | undefined;
100
+ deliveryForecast?: import("@scayle/storefront-core").DeliveryForecastFromWarehouse | undefined;
101
+ isManuallyReturnedByCci?: boolean | undefined;
102
+ itemGroup?: {
103
+ id: string;
104
+ isMainItem: boolean;
105
+ isRequired: boolean;
106
+ } | null | undefined;
107
+ key: string;
108
+ lowestPriorPrice?: {
109
+ relativeDifferenceToPrice: number;
110
+ withTax: number;
111
+ } | null | undefined;
112
+ merchant?: {
113
+ [k: string]: unknown;
114
+ id: number;
115
+ } | undefined;
116
+ packageId: number;
117
+ price: {
118
+ appliedReductions?: {
119
+ amount: {
120
+ absoluteWithTax: number;
121
+ relative: number;
122
+ };
123
+ category: "voucher" | "sale" | "campaign";
124
+ code?: string | undefined;
125
+ type: "relative" | "absolute";
126
+ }[] | undefined;
127
+ overrideWithoutTax?: number | undefined;
128
+ overrideWithTax?: number | undefined;
129
+ reference?: {
130
+ size?: string | undefined;
131
+ unit?: string | undefined;
132
+ withTax?: number | undefined;
133
+ } | undefined;
134
+ tax: {
135
+ [k: string]: {
136
+ amount: number;
137
+ rate: number;
138
+ };
139
+ };
140
+ undiscountedWithOutTax?: number | undefined;
141
+ undiscountedWithTax?: number | undefined;
142
+ withoutTax: number;
143
+ withTax: number;
144
+ };
145
+ product: {
146
+ [k: string]: unknown;
147
+ };
148
+ reservationKey?: string | undefined;
149
+ status: "available" | "unavailable" | "cancelled" | "delivered" | "returned";
150
+ variant: {
151
+ [k: string]: unknown;
152
+ };
153
+ warehouseId?: import("@scayle/storefront-core").PickingWarehouseId | undefined;
154
+ warehousePackageGroupId?: import("@scayle/storefront-core").WarehousePackageReference | undefined;
155
+ createdAt: string;
156
+ updatedAt: string;
157
+ } & {
158
+ product: P;
159
+ variant: V;
160
+ })[] | undefined;
161
+ }>;
89
162
  }>;
90
163
  export {};
@@ -1,17 +1,14 @@
1
1
  import { useRpc } from "../core/useRpc.mjs";
2
- export async function useOrderConfirmation({ params, options, key: _key } = {}, key) {
3
- const { data, fetching, fetch, error, status } = await useRpc(
2
+ import { extendPromise } from "../../utils/promise.mjs";
3
+ export function useOrderConfirmation({ params, options, key: _key } = {}, key) {
4
+ const promise = useRpc(
4
5
  "getOrderDataByCbd",
5
6
  _key ?? key ?? "useOrderConfirmation",
6
7
  params,
7
8
  options
8
9
  );
9
- const _data = data;
10
- return {
11
- data: _data,
12
- fetching,
13
- fetch,
14
- error,
15
- status
16
- };
10
+ const _data = promise.data;
11
+ return extendPromise(promise, {
12
+ data: _data
13
+ });
17
14
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.75.0",
4
+ "version": "7.76.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@nuxt/kit": "3.11.1",
61
- "@opentelemetry/api": "1.8.0",
61
+ "@opentelemetry/api": "1.9.0",
62
62
  "@scayle/h3-session": "0.4.0",
63
63
  "@scayle/storefront-core": "7.55.0",
64
64
  "@scayle/unstorage-compression-driver": "0.1.3",
@@ -74,7 +74,7 @@
74
74
  "ufo": "1.5.3",
75
75
  "uncrypto": "0.1.3",
76
76
  "unstorage": "1.10.2",
77
- "vue-router": "4.3.2",
77
+ "vue-router": "4.3.3",
78
78
  "yn": "5.0.0",
79
79
  "zod": "3.23.8"
80
80
  },
@@ -86,7 +86,7 @@
86
86
  "@scayle/eslint-config-storefront": "4.2.0",
87
87
  "@scayle/eslint-plugin-vue-composable": "0.2.0",
88
88
  "@types/node": "20.14.2",
89
- "dprint": "0.46.1",
89
+ "dprint": "0.46.2",
90
90
  "eslint": "9.4.0",
91
91
  "eslint-formatter-gitlab": "5.1.0",
92
92
  "fishery": "2.2.2",
@@ -96,7 +96,7 @@
96
96
  "nuxt": "3.11.1",
97
97
  "publint": "0.2.8",
98
98
  "vitest": "1.6.0",
99
- "vue-tsc": "2.0.19"
99
+ "vue-tsc": "2.0.21"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "h3": "^1.10.0",