@scayle/storefront-nuxt 7.84.3 → 7.84.5

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.
@@ -1,14 +1,11 @@
1
- import type { Product, WishlistItem, RpcMethodParameters, WishlistResponseData } from '@scayle/storefront-core';
2
- import type { MaybeRefOrGetter } from '#imports';
1
+ import type { Product, WishlistItem, RpcMethodParameters } from '@scayle/storefront-core';
2
+ import { type UseRpcReturn } from '../core/useRpc';
3
+ import type { MaybeRefOrGetter, ComputedRef } from '#imports';
3
4
  type Options = Partial<{
4
5
  params: MaybeRefOrGetter<RpcMethodParameters<'getWishlist'>>;
5
6
  key: string;
6
7
  }>;
7
- export declare function useWishlist({ params, key, }?: Options): {
8
- data: import("vue").Ref<WishlistResponseData, WishlistResponseData>;
9
- count: import("vue").ComputedRef<number>;
10
- items: import("vue").ComputedRef<WishlistItem[]>;
11
- products: import("vue").ComputedRef<Product[]>;
8
+ type UseWishlistBaseReturn = Awaited<UseRpcReturn<'getWishlist'>> & {
12
9
  addItem: (item: {
13
10
  variantId?: number;
14
11
  productId?: number;
@@ -25,60 +22,23 @@ export declare function useWishlist({ params, key, }?: Options): {
25
22
  productId?: number;
26
23
  }) => Promise<void>;
27
24
  clear: () => Promise<void>;
28
- fetching: import("vue").Ref<boolean, boolean>;
29
- fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
30
- toggleItem: (item: {
31
- variantId?: number;
32
- productId?: number;
33
- }) => Promise<void>;
34
25
  findItem: (item: {
35
- variantId?: number;
36
- productId?: number;
26
+ variantId: number;
27
+ } | {
28
+ productId: number;
37
29
  }) => WishlistItem | undefined;
38
30
  contains: (item: {
39
31
  variantId: number;
40
32
  } | {
41
33
  productId: number;
42
34
  }) => boolean;
43
- error: import("vue").Ref<any, any>;
44
- status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus, import("nuxt/app").AsyncDataRequestStatus>;
45
- } & Promise<{
46
- data: import("vue").Ref<WishlistResponseData, WishlistResponseData>;
47
- count: import("vue").ComputedRef<number>;
48
- items: import("vue").ComputedRef<WishlistItem[]>;
49
- products: import("vue").ComputedRef<Product[]>;
50
- addItem: (item: {
51
- variantId?: number;
52
- productId?: number;
53
- }) => Promise<void>;
54
- removeItem: (item: {
55
- variantId?: number;
56
- productId?: number;
57
- }) => Promise<void>;
58
- replaceItem: (item: {
59
- variantId?: number;
60
- productId?: number;
61
- }, newItem: {
62
- variantId?: number;
63
- productId?: number;
64
- }) => Promise<void>;
65
- clear: () => Promise<void>;
66
- fetching: import("vue").Ref<boolean, boolean>;
67
- fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
68
35
  toggleItem: (item: {
69
36
  variantId?: number;
70
37
  productId?: number;
71
38
  }) => Promise<void>;
72
- findItem: (item: {
73
- variantId?: number;
74
- productId?: number;
75
- }) => WishlistItem | undefined;
76
- contains: (item: {
77
- variantId: number;
78
- } | {
79
- productId: number;
80
- }) => boolean;
81
- error: import("vue").Ref<any, any>;
82
- status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus, import("nuxt/app").AsyncDataRequestStatus>;
83
- }>;
39
+ count: ComputedRef<number>;
40
+ items: ComputedRef<WishlistItem[]>;
41
+ products: ComputedRef<Product[]>;
42
+ };
43
+ export declare function useWishlist({ params, key, }?: Options): UseWishlistBaseReturn & Promise<UseWishlistBaseReturn>;
84
44
  export {};
@@ -99,7 +99,7 @@ export function useWishlist({
99
99
  const products = computed(() => {
100
100
  return items.value?.map((item) => item.product) || [];
101
101
  });
102
- return extendPromise(asyncData.then(() => ({})), {
102
+ return extendPromise(asyncData, {
103
103
  data,
104
104
  count,
105
105
  items,
@@ -1,21 +1,4 @@
1
1
  import { Log } from "./log.mjs";
2
- function prepareData(data) {
3
- if (!data) {
4
- return data;
5
- }
6
- if (data.response) {
7
- const { response, message, name, code, ...other } = data;
8
- return {
9
- message,
10
- name,
11
- code,
12
- status: response?.status,
13
- statusText: response?.statusText,
14
- ...other
15
- };
16
- }
17
- return data;
18
- }
19
2
  const levelMap = {
20
3
  error: 0,
21
4
  warn: 1,
@@ -30,7 +13,7 @@ export default function createLog(createConsola, space = "default-storefront", l
30
13
  level: toConsolaLogLevel(level)
31
14
  });
32
15
  const handler = (entry) => {
33
- const data = prepareData(entry.data);
16
+ const data = entry.data;
34
17
  const log = logger[entry.level] || logger.info;
35
18
  const message = `[${entry.space}] ${entry.message}`;
36
19
  const args = data ? [message, data] : [message];
@@ -3,7 +3,7 @@ export interface LogEntry {
3
3
  level: LogLevel;
4
4
  space: string;
5
5
  message: string;
6
- data?: object;
6
+ data?: object | undefined;
7
7
  }
8
8
  export type LogHandler = (entry: LogEntry) => void;
9
9
  export interface LogOptions {
@@ -20,11 +20,11 @@ export declare class Log {
20
20
  _space: string;
21
21
  _type: string;
22
22
  constructor(options?: LogOptions);
23
- debug(message: string, data?: any): void;
24
- info(message: string, data?: any): void;
25
- warn(message: string, data?: any): void;
26
- error(message: string | Error, data?: any): void;
27
- write(level: LogLevel, message: string, data?: any): void;
23
+ debug(message: string, data?: unknown): void;
24
+ info(message: string, data?: unknown): void;
25
+ warn(message: string, data?: unknown): void;
26
+ error(message: string | Error, data?: unknown): void;
27
+ write(level: LogLevel, message: string, data?: unknown): void;
28
28
  /**
29
29
  * Create a new sub-space.
30
30
  * All spaces are being separated by a dot. E.g. `global.api` and `global.api.getUser`
@@ -1,3 +1,9 @@
1
+ function dataToObject(data) {
2
+ if (data === null || data === void 0) {
3
+ return void 0;
4
+ }
5
+ return typeof data !== "object" ? { data } : data;
6
+ }
1
7
  export class Log {
2
8
  static default = new this({
3
9
  space: "global",
@@ -24,18 +30,16 @@ export class Log {
24
30
  if (error) {
25
31
  data = {
26
32
  error: message,
27
- ...data
33
+ ...dataToObject(data)
28
34
  };
29
35
  }
30
36
  this.write("error", error?.message ?? message, data);
31
37
  }
32
38
  write(level, message, data) {
33
- if (typeof data !== "undefined") {
34
- data = typeof data !== "object" ? { data } : data;
35
- }
39
+ const d = dataToObject(data);
36
40
  if (this._handler) {
37
41
  try {
38
- this._handler({ level, message, data, space: this._space });
42
+ this._handler({ level, message, data: d, space: this._space });
39
43
  } catch (e) {
40
44
  console.error(`Error writing log message: "${message}" -- ${e}`);
41
45
  }
@@ -1124,9 +1124,9 @@ type SessionConfig = SessionType & {
1124
1124
  */
1125
1125
  type RedisConfig = RedisConfigType;
1126
1126
  type CustomDriverName = string & {
1127
- _custom?: any;
1127
+ _custom?: unknown;
1128
1128
  };
1129
- type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName = any, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : any> = {
1129
+ type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : unknown> = {
1130
1130
  driver: Driver;
1131
1131
  compression?: CompressionEncodings;
1132
1132
  } & DriverOptions;
@@ -1124,9 +1124,9 @@ type SessionConfig = SessionType & {
1124
1124
  */
1125
1125
  type RedisConfig = RedisConfigType;
1126
1126
  type CustomDriverName = string & {
1127
- _custom?: any;
1127
+ _custom?: unknown;
1128
1128
  };
1129
- type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName = any, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : any> = {
1129
+ type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : unknown> = {
1130
1130
  driver: Driver;
1131
1131
  compression?: CompressionEncodings;
1132
1132
  } & DriverOptions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.84.3",
4
+ "version": "7.84.5",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -60,7 +60,7 @@
60
60
  "@nuxt/kit": "^3.12.2",
61
61
  "@opentelemetry/api": "^1.9.0",
62
62
  "@scayle/h3-session": "^0.4.0",
63
- "@scayle/storefront-core": "^7.64.0",
63
+ "@scayle/storefront-core": "7.64.1",
64
64
  "@scayle/unstorage-compression-driver": "^0.1.3",
65
65
  "@vueuse/core": "^10.11.0",
66
66
  "consola": "^3.2.3",
@@ -86,9 +86,9 @@
86
86
  "@nuxt/test-utils": "3.14.0",
87
87
  "@scayle/eslint-config-storefront": "4.3.0",
88
88
  "@scayle/eslint-plugin-vue-composable": "0.2.0",
89
- "@types/node": "20.14.14",
89
+ "@types/node": "20.14.15",
90
90
  "dprint": "0.47.2",
91
- "eslint": "9.8.0",
91
+ "eslint": "9.9.0",
92
92
  "eslint-formatter-gitlab": "5.1.0",
93
93
  "fishery": "2.2.2",
94
94
  "h3": "1.12.0",
@@ -107,7 +107,7 @@
107
107
  },
108
108
  "resolutions": {
109
109
  "h3": "1.12.0",
110
- "vue": "3.4.36",
110
+ "vue": "3.4.37",
111
111
  "@nuxt/kit": "3.12.4",
112
112
  "@nuxt/schema": "3.12.4"
113
113
  },