@scayle/storefront-nuxt 7.81.0 → 7.82.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.
- package/CHANGELOG.md +55 -27
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/core/useRpcCall.d.ts +2 -0
- package/dist/runtime/composables/core/useRpcCall.mjs +8 -0
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.mjs +1 -0
- package/dist/runtime/composables/storefront/useBasket.d.ts +6 -8
- package/dist/runtime/composables/storefront/useBasket.mjs +7 -5
- package/package.json +33 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.82.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix types of `useBasket` composable
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @scayle/storefront-core@7.61.0
|
|
10
|
+
|
|
11
|
+
## 7.82.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- Add new `useRpcCall` composable to make imperative RPC calls more ergonomic
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
const getConfig = useRpcCall('getShopConfiguration)
|
|
20
|
+
const getProduct = useRpcCall('getProductById')
|
|
21
|
+
const config = await getConfig()
|
|
22
|
+
const product = await getProduct({ id: 1 })
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @scayle/storefront-core@7.59.1
|
|
30
|
+
|
|
3
31
|
## 7.81.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -49,27 +77,27 @@
|
|
|
49
77
|
Hooks can be registered by adding a nitro plugin inside ´server/plugins/´:
|
|
50
78
|
|
|
51
79
|
```ts
|
|
52
|
-
import { defineNitroPlugin } from
|
|
80
|
+
import { defineNitroPlugin } from '#imports'
|
|
53
81
|
|
|
54
82
|
export default defineNitroPlugin((nitroApp) => {
|
|
55
|
-
nitroApp.hooks.hook(
|
|
56
|
-
rpcContext.log.debug(`Before: ${rpcName}`)
|
|
57
|
-
})
|
|
83
|
+
nitroApp.hooks.hook('storefront:rpc:before', (rpcName, rpcContext) => {
|
|
84
|
+
rpcContext.log.debug(`Before: ${rpcName}`)
|
|
85
|
+
})
|
|
58
86
|
|
|
59
87
|
nitroApp.hooks.hook(
|
|
60
|
-
|
|
88
|
+
'storefront:rpc:after',
|
|
61
89
|
(rpcName, rpcContext, result) => {
|
|
62
|
-
rpcContext.log.debug(`After: ${rpcName} returned ${result}`)
|
|
63
|
-
}
|
|
64
|
-
)
|
|
90
|
+
rpcContext.log.debug(`After: ${rpcName} returned ${result}`)
|
|
91
|
+
},
|
|
92
|
+
)
|
|
65
93
|
|
|
66
94
|
nitroApp.hooks.hook(
|
|
67
|
-
|
|
95
|
+
'storefront:rpc:error',
|
|
68
96
|
(rpcName, rpcContext, error) => {
|
|
69
|
-
rpcContext.log.error(`ERROR: ${rpcName} did throw ${error}`)
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
})
|
|
97
|
+
rpcContext.log.error(`ERROR: ${rpcName} did throw ${error}`)
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
})
|
|
73
101
|
```
|
|
74
102
|
|
|
75
103
|
Added [`callHook`](https://github.com/unjs/hookable?tab=readme-ov-file#async-callhook-name-args), `callHookParallel` and [`callHookWith`](https://github.com/unjs/hookable?tab=readme-ov-file#callhookwith-name-callerfn) to `RpcContext` to allow triggering hooks within RPCs
|
|
@@ -337,20 +365,20 @@
|
|
|
337
365
|
- It is now also possible to extend the RPCContext using the `storefront:context:created` nitro runtime hook.
|
|
338
366
|
|
|
339
367
|
```ts
|
|
340
|
-
import { defineNitroPlugin } from
|
|
368
|
+
import { defineNitroPlugin } from 'nitropack/runtime/plugin'
|
|
341
369
|
// Augment RpxContext type
|
|
342
|
-
declare module
|
|
370
|
+
declare module '@scayle/storefront-nuxt' {
|
|
343
371
|
interface AdditionalRpcContext {
|
|
344
|
-
myNewProp: string
|
|
372
|
+
myNewProp: string
|
|
345
373
|
}
|
|
346
374
|
}
|
|
347
375
|
|
|
348
376
|
// Set new value on rpcContext
|
|
349
377
|
export default defineNitroPlugin((nitroApp) => {
|
|
350
|
-
nitroApp.hooks.hook(
|
|
351
|
-
rpcContext.myNewProp =
|
|
352
|
-
})
|
|
353
|
-
})
|
|
378
|
+
nitroApp.hooks.hook('storefront:context:created', (rpcContext) => {
|
|
379
|
+
rpcContext.myNewProp = 'My campaign key'
|
|
380
|
+
})
|
|
381
|
+
})
|
|
354
382
|
```
|
|
355
383
|
|
|
356
384
|
### Patch Changes
|
|
@@ -553,8 +581,8 @@
|
|
|
553
581
|
|
|
554
582
|
```ts
|
|
555
583
|
const { data: externalIDPRedirects } = await useIDP({
|
|
556
|
-
queryParams: { redirectTo:
|
|
557
|
-
})
|
|
584
|
+
queryParams: { redirectTo: '/account' },
|
|
585
|
+
})
|
|
558
586
|
```
|
|
559
587
|
|
|
560
588
|
Please note that `code` and `state` are not supported as these are used by the SCAYLE Authentication API.
|
|
@@ -973,16 +1001,16 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
|
|
|
973
1001
|
Before:
|
|
974
1002
|
|
|
975
1003
|
```typescript
|
|
976
|
-
toCurrency(100, { currency:
|
|
977
|
-
formatPrice(100, { currencyFractionDigits: 2 })
|
|
1004
|
+
toCurrency(100, { currency: 'EUR' })
|
|
1005
|
+
formatPrice(100, { currencyFractionDigits: 2 })
|
|
978
1006
|
```
|
|
979
1007
|
|
|
980
1008
|
After:
|
|
981
1009
|
|
|
982
1010
|
```typescript
|
|
983
|
-
const { formatCurrency } = useFormatHelpers()
|
|
984
|
-
formatCurrency(100, { currency:
|
|
985
|
-
formatCurrency(100, { style:
|
|
1011
|
+
const { formatCurrency } = useFormatHelpers()
|
|
1012
|
+
formatCurrency(100, { currency: 'EUR' })
|
|
1013
|
+
formatCurrency(100, { style: 'decimal', currencyFractionDigits: 2 })
|
|
986
1014
|
```
|
|
987
1015
|
|
|
988
1016
|
## 7.44.1
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { RpcContext, RpcMethodName, RpcMethodParameters, RpcMethodReturnType } from '@scayle/storefront-core';
|
|
2
|
+
export declare function useRpcCall<N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>, TakesParameters = P extends RpcContext ? undefined : boolean>(method: N): TakesParameters extends undefined ? () => Promise<TResult> : (params: P) => Promise<TResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
2
|
+
import { useNuxtApp } from "nuxt/app";
|
|
3
|
+
import { useCurrentShop } from "./useCurrentShop.mjs";
|
|
4
|
+
export function useRpcCall(method) {
|
|
5
|
+
const nuxtApp = useNuxtApp();
|
|
6
|
+
const currentShop = useCurrentShop();
|
|
7
|
+
return rpcCall(nuxtApp, method, currentShop.value);
|
|
8
|
+
}
|
|
@@ -4,6 +4,7 @@ export * from './core/useFormatHelpers';
|
|
|
4
4
|
export * from './core/useIDP';
|
|
5
5
|
export * from './core/useLog';
|
|
6
6
|
export * from './core/useRpc';
|
|
7
|
+
export * from './core/useRpcCall';
|
|
7
8
|
export * from './core/useSession';
|
|
8
9
|
export * from './core/useUser';
|
|
9
10
|
export * from './storefront/useBasket';
|
|
@@ -4,6 +4,7 @@ export * from "./core/useFormatHelpers.mjs";
|
|
|
4
4
|
export * from "./core/useIDP.mjs";
|
|
5
5
|
export * from "./core/useLog.mjs";
|
|
6
6
|
export * from "./core/useRpc.mjs";
|
|
7
|
+
export * from "./core/useRpcCall.mjs";
|
|
7
8
|
export * from "./core/useSession.mjs";
|
|
8
9
|
export * from "./core/useUser.mjs";
|
|
9
10
|
export * from "./storefront/useBasket.mjs";
|
|
@@ -5,10 +5,7 @@ type UseBasketOptions = Partial<{
|
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getBasket'>>;
|
|
6
6
|
key: string;
|
|
7
7
|
}>;
|
|
8
|
-
export declare function useBasket({ params, key, }?: UseBasketOptions):
|
|
9
|
-
fetching: import("vue").Ref<boolean>;
|
|
10
|
-
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
11
|
-
} & {
|
|
8
|
+
export declare function useBasket({ params, key, }?: UseBasketOptions): {
|
|
12
9
|
data: import("vue").Ref<BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>>;
|
|
13
10
|
items: import("vue").ComputedRef<import("@scayle/storefront-api").BasketItem<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>[]>;
|
|
14
11
|
cost: import("vue").ComputedRef<import("@scayle/storefront-api").BasketTotalPrice>;
|
|
@@ -17,7 +14,9 @@ export declare function useBasket({ params, key, }?: UseBasketOptions): import("
|
|
|
17
14
|
shippingDates: import("vue").ComputedRef<(string | null)[] | undefined>;
|
|
18
15
|
isEmpty: import("vue").ComputedRef<boolean>;
|
|
19
16
|
fetching: import("vue").Ref<boolean>;
|
|
17
|
+
pending: import("vue").Ref<boolean>;
|
|
20
18
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
19
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
21
20
|
count: import("vue").ComputedRef<number>;
|
|
22
21
|
countWithoutSoldOutItems: import("vue").ComputedRef<number>;
|
|
23
22
|
addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
|
|
@@ -63,10 +62,7 @@ export declare function useBasket({ params, key, }?: UseBasketOptions): import("
|
|
|
63
62
|
} | undefined>;
|
|
64
63
|
error: import("vue").Ref<any>;
|
|
65
64
|
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
66
|
-
} & Promise<
|
|
67
|
-
fetching: import("vue").Ref<boolean>;
|
|
68
|
-
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
69
|
-
} & {
|
|
65
|
+
} & Promise<{
|
|
70
66
|
data: import("vue").Ref<BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>>;
|
|
71
67
|
items: import("vue").ComputedRef<import("@scayle/storefront-api").BasketItem<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>[]>;
|
|
72
68
|
cost: import("vue").ComputedRef<import("@scayle/storefront-api").BasketTotalPrice>;
|
|
@@ -75,7 +71,9 @@ export declare function useBasket({ params, key, }?: UseBasketOptions): import("
|
|
|
75
71
|
shippingDates: import("vue").ComputedRef<(string | null)[] | undefined>;
|
|
76
72
|
isEmpty: import("vue").ComputedRef<boolean>;
|
|
77
73
|
fetching: import("vue").Ref<boolean>;
|
|
74
|
+
pending: import("vue").Ref<boolean>;
|
|
78
75
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
76
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
79
77
|
count: import("vue").ComputedRef<number>;
|
|
80
78
|
countWithoutSoldOutItems: import("vue").ComputedRef<number>;
|
|
81
79
|
addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
|
|
@@ -30,9 +30,9 @@ export function useBasket({
|
|
|
30
30
|
});
|
|
31
31
|
const {
|
|
32
32
|
data,
|
|
33
|
-
pending
|
|
33
|
+
pending,
|
|
34
34
|
error,
|
|
35
|
-
refresh
|
|
35
|
+
refresh,
|
|
36
36
|
status
|
|
37
37
|
} = asyncData;
|
|
38
38
|
const addItem = async ({
|
|
@@ -159,7 +159,7 @@ export function useBasket({
|
|
|
159
159
|
const shippingDates = computed(
|
|
160
160
|
() => packages.value ? getShippingDates(packages.value) : void 0
|
|
161
161
|
);
|
|
162
|
-
return extendPromise(asyncData, {
|
|
162
|
+
return extendPromise(asyncData.then(() => ({})), {
|
|
163
163
|
data,
|
|
164
164
|
items,
|
|
165
165
|
cost,
|
|
@@ -167,8 +167,10 @@ export function useBasket({
|
|
|
167
167
|
packages,
|
|
168
168
|
shippingDates,
|
|
169
169
|
isEmpty,
|
|
170
|
-
fetching,
|
|
171
|
-
|
|
170
|
+
fetching: pending,
|
|
171
|
+
pending,
|
|
172
|
+
fetch: refresh,
|
|
173
|
+
refresh,
|
|
172
174
|
count,
|
|
173
175
|
countWithoutSoldOutItems,
|
|
174
176
|
addItem,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.82.1",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -57,47 +57,47 @@
|
|
|
57
57
|
"test:watch": "vitest watch"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@nuxt/kit": "3.12.2",
|
|
61
|
-
"@opentelemetry/api": "1.9.0",
|
|
62
|
-
"@scayle/h3-session": "0.4.0",
|
|
63
|
-
"@scayle/storefront-core": "7.
|
|
64
|
-
"@scayle/unstorage-compression-driver": "0.1.3",
|
|
65
|
-
"@vueuse/core": "10.11.0",
|
|
66
|
-
"consola": "3.2.3",
|
|
67
|
-
"core-js": "3.37.1",
|
|
68
|
-
"defu": "6.1.4",
|
|
69
|
-
"hookable": "5.5.3",
|
|
60
|
+
"@nuxt/kit": "^3.12.2",
|
|
61
|
+
"@opentelemetry/api": "^1.9.0",
|
|
62
|
+
"@scayle/h3-session": "^0.4.0",
|
|
63
|
+
"@scayle/storefront-core": "^7.61.0",
|
|
64
|
+
"@scayle/unstorage-compression-driver": "^0.1.3",
|
|
65
|
+
"@vueuse/core": "^10.11.0",
|
|
66
|
+
"consola": "^3.2.3",
|
|
67
|
+
"core-js": "^3.37.1",
|
|
68
|
+
"defu": "^6.1.4",
|
|
69
|
+
"hookable": "^5.5.3",
|
|
70
70
|
"jose": "^5.2.0",
|
|
71
|
-
"knitwork": "1.1.0",
|
|
72
|
-
"nitropack": "2.9.7",
|
|
73
|
-
"ofetch": "1.3.4",
|
|
74
|
-
"radash": "12.1.0",
|
|
75
|
-
"ufo": "1.5.3",
|
|
76
|
-
"uncrypto": "0.1.3",
|
|
77
|
-
"unstorage": "1.10.2",
|
|
78
|
-
"vue-router": "4.4.0",
|
|
79
|
-
"yn": "5.0.0",
|
|
80
|
-
"zod": "3.23.8"
|
|
71
|
+
"knitwork": "^1.1.0",
|
|
72
|
+
"nitropack": "^2.9.7",
|
|
73
|
+
"ofetch": "^1.3.4",
|
|
74
|
+
"radash": "^12.1.0",
|
|
75
|
+
"ufo": "^1.5.3",
|
|
76
|
+
"uncrypto": "^0.1.3",
|
|
77
|
+
"unstorage": "^1.10.2",
|
|
78
|
+
"vue-router": "^4.4.0",
|
|
79
|
+
"yn": "^5.0.0",
|
|
80
|
+
"zod": "^3.23.8"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@nuxt/eslint": "0.3.13",
|
|
84
84
|
"@nuxt/module-builder": "0.5.5",
|
|
85
|
-
"@nuxt/schema": "3.12.
|
|
85
|
+
"@nuxt/schema": "3.12.4",
|
|
86
86
|
"@nuxt/test-utils": "3.13.1",
|
|
87
87
|
"@scayle/eslint-config-storefront": "4.2.0",
|
|
88
88
|
"@scayle/eslint-plugin-vue-composable": "0.2.0",
|
|
89
|
-
"@types/node": "20.14.
|
|
90
|
-
"dprint": "0.47.
|
|
91
|
-
"eslint": "9.
|
|
89
|
+
"@types/node": "20.14.11",
|
|
90
|
+
"dprint": "0.47.2",
|
|
91
|
+
"eslint": "9.7.0",
|
|
92
92
|
"eslint-formatter-gitlab": "5.1.0",
|
|
93
93
|
"fishery": "2.2.2",
|
|
94
94
|
"h3": "1.12.0",
|
|
95
95
|
"node-mocks-http": "1.15.0",
|
|
96
96
|
"nuxi": "3.12.0",
|
|
97
|
-
"nuxt": "3.12.
|
|
98
|
-
"publint": "0.2.
|
|
99
|
-
"vitest": "2.0.
|
|
100
|
-
"vue-tsc": "2.0.
|
|
97
|
+
"nuxt": "3.12.4",
|
|
98
|
+
"publint": "0.2.9",
|
|
99
|
+
"vitest": "2.0.4",
|
|
100
|
+
"vue-tsc": "2.0.28"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"h3": "^1.10.0",
|
|
@@ -107,11 +107,11 @@
|
|
|
107
107
|
},
|
|
108
108
|
"resolutions": {
|
|
109
109
|
"h3": "1.12.0",
|
|
110
|
-
"vue": "3.4.
|
|
111
|
-
"@nuxt/kit": "3.12.
|
|
112
|
-
"@nuxt/schema": "3.12.
|
|
110
|
+
"vue": "3.4.32",
|
|
111
|
+
"@nuxt/kit": "3.12.4",
|
|
112
|
+
"@nuxt/schema": "3.12.4"
|
|
113
113
|
},
|
|
114
114
|
"volta": {
|
|
115
|
-
"node": "20.15.
|
|
115
|
+
"node": "20.15.1"
|
|
116
116
|
}
|
|
117
117
|
}
|