@scayle/storefront-nuxt 7.82.1 → 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.
- package/CHANGELOG.md +10 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/module.d.mts +3 -3
- package/dist/module.d.ts +3 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -5
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/runtime/campaignKey.d.ts +1 -1
- package/dist/runtime/campaignKey.mjs +2 -2
- package/dist/runtime/composables/core/useIDP.d.ts +16 -10
- package/dist/runtime/composables/core/useIDP.mjs +15 -1
- package/dist/runtime/composables/storefront/useCategories.d.ts +24 -18
- package/dist/runtime/composables/storefront/useCategories.mjs +15 -1
- package/dist/runtime/composables/storefront/useOrder.d.ts +12 -8
- package/dist/runtime/composables/storefront/useOrder.mjs +16 -3
- package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +11 -7
- package/dist/runtime/composables/storefront/useOrderConfirmation.mjs +15 -2
- package/dist/runtime/context.d.ts +6 -0
- package/dist/runtime/context.mjs +7 -6
- package/dist/runtime/server/middleware/redirects.mjs +11 -11
- package/dist/runtime/utils/zodSchema.d.ts +863 -731
- package/dist/runtime/utils/zodSchema.mjs +25 -19
- package/dist/shared/{storefront-nuxt.ed010583.d.mts → storefront-nuxt.87331293.d.mts} +78 -26
- package/dist/shared/{storefront-nuxt.ed010583.d.ts → storefront-nuxt.87331293.d.ts} +78 -26
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.82.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix types of `useBasket` composable
|
|
8
|
+
- Fix types for more composables
|
|
9
|
+
- Migrate from using `RpcContext.bapiClient` to using `RpcContext.sapiClient`
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
- @scayle/storefront-core@7.62.0
|
|
12
|
+
|
|
3
13
|
## 7.82.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
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';
|
|
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 {
|
|
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';
|
|
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,11 +1,11 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.
|
|
3
|
-
export {
|
|
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';
|
|
4
4
|
export { LogLevel } from '@scayle/storefront-core';
|
|
5
5
|
import '@scayle/unstorage-compression-driver';
|
|
6
6
|
import 'unstorage';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleBaseOptions
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<Omit<ModuleBaseOptions, "sapi" | "bapi">>;
|
|
10
10
|
|
|
11
11
|
export { ModuleBaseOptions, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.
|
|
3
|
-
export {
|
|
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';
|
|
4
4
|
export { LogLevel } from '@scayle/storefront-core';
|
|
5
5
|
import '@scayle/unstorage-compression-driver';
|
|
6
6
|
import 'unstorage';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleBaseOptions
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<Omit<ModuleBaseOptions, "sapi" | "bapi">>;
|
|
10
10
|
|
|
11
11
|
export { ModuleBaseOptions, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -65,7 +65,7 @@ export default {
|
|
|
65
65
|
}`;
|
|
66
66
|
}
|
|
67
67
|
const PACKAGE_NAME = "@scayle/storefront-nuxt";
|
|
68
|
-
const PACKAGE_VERSION = "7.82.
|
|
68
|
+
const PACKAGE_VERSION = "7.82.2";
|
|
69
69
|
const logger = createConsola({
|
|
70
70
|
fancy: true,
|
|
71
71
|
formatOptions: {
|
|
@@ -98,10 +98,6 @@ const module = defineNuxtModule({
|
|
|
98
98
|
// if we set maxAge explicitly to undefined `useRuntimeConfig` will set it default to '' which leads to no sessions not being saved
|
|
99
99
|
// maxAge: undefined,
|
|
100
100
|
},
|
|
101
|
-
bapi: {
|
|
102
|
-
host: "",
|
|
103
|
-
token: ""
|
|
104
|
-
},
|
|
105
101
|
shopSelector: "domain",
|
|
106
102
|
stores: {},
|
|
107
103
|
oauth: {
|
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.
|
|
3
|
+
import { P as PublicShopConfig } from './shared/storefront-nuxt.87331293.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.
|
|
3
|
+
import { P as PublicShopConfig } from './shared/storefront-nuxt.87331293.js';
|
|
4
4
|
import '@scayle/unstorage-compression-driver';
|
|
5
5
|
import 'unstorage';
|
|
6
6
|
import 'zod';
|
|
@@ -3,4 +3,4 @@ export declare const isCampaignActive: (campaign?: Campaign) => boolean;
|
|
|
3
3
|
export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
|
|
4
4
|
export declare const campaignKeyMatchesKeyword: (campaign: Campaign, keyword?: string) => boolean;
|
|
5
5
|
export declare const sortCampaignsByDateAscending: (a: Campaign, b: Campaign) => number;
|
|
6
|
-
export declare const fetchCampaignKey: (
|
|
6
|
+
export declare const fetchCampaignKey: (sapiClient: StorefrontAPIClient, cached: CachedType, storeCampaignKeyword: string | undefined, log: Log) => Promise<string | undefined>;
|
|
@@ -21,10 +21,10 @@ export const campaignKeyMatchesKeyword = (campaign, keyword) => {
|
|
|
21
21
|
export const sortCampaignsByDateAscending = (a, b) => {
|
|
22
22
|
return new Date(a.start_at).getTime() - new Date(b.start_at).getTime();
|
|
23
23
|
};
|
|
24
|
-
export const fetchCampaignKey = async (
|
|
24
|
+
export const fetchCampaignKey = async (sapiClient, cached, storeCampaignKeyword, log) => {
|
|
25
25
|
try {
|
|
26
26
|
const { campaigns } = await cached(async () => {
|
|
27
|
-
const { entities } = await
|
|
27
|
+
const { entities } = await sapiClient.campaigns.get();
|
|
28
28
|
return {
|
|
29
29
|
campaigns: entities.filter((campaign) => {
|
|
30
30
|
return campaignHasNotEnded(campaign) && campaignKeyMatchesKeyword(campaign, storeCampaignKeyword);
|
|
@@ -1,22 +1,28 @@
|
|
|
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):
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export declare function useIDP(params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>, key?: string): {
|
|
4
|
+
data: import("vue").Ref<{
|
|
5
|
+
[k: string]: string;
|
|
6
|
+
}>;
|
|
7
7
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
8
|
-
|
|
8
|
+
fetching: import("vue").Ref<boolean>;
|
|
9
|
+
error: import("vue").Ref<any>;
|
|
10
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
11
|
+
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
9
12
|
handleIDPLoginCallback: (params: string | {
|
|
10
13
|
code: string;
|
|
11
14
|
}) => Promise<{
|
|
12
15
|
message: string;
|
|
13
16
|
}>;
|
|
14
|
-
} & Promise<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
} & Promise<{
|
|
18
|
+
data: import("vue").Ref<{
|
|
19
|
+
[k: string]: string;
|
|
20
|
+
}>;
|
|
18
21
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
19
|
-
|
|
22
|
+
fetching: import("vue").Ref<boolean>;
|
|
23
|
+
error: import("vue").Ref<any>;
|
|
24
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
25
|
+
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
20
26
|
handleIDPLoginCallback: (params: string | {
|
|
21
27
|
code: string;
|
|
22
28
|
}) => Promise<{
|
|
@@ -12,12 +12,26 @@ export function useIDP(params = {}, key) {
|
|
|
12
12
|
key ?? "useIDP",
|
|
13
13
|
params
|
|
14
14
|
);
|
|
15
|
+
const {
|
|
16
|
+
data,
|
|
17
|
+
fetch,
|
|
18
|
+
fetching,
|
|
19
|
+
error,
|
|
20
|
+
refresh,
|
|
21
|
+
status
|
|
22
|
+
} = useRpcPromise;
|
|
15
23
|
const handleIDPLoginCallback = rpcCall(
|
|
16
24
|
nuxtApp,
|
|
17
25
|
"handleIDPLoginCallback",
|
|
18
26
|
toValue(shop)
|
|
19
27
|
);
|
|
20
|
-
return extendPromise(useRpcPromise, {
|
|
28
|
+
return extendPromise(useRpcPromise.then(() => ({})), {
|
|
29
|
+
data,
|
|
30
|
+
fetch,
|
|
31
|
+
fetching,
|
|
32
|
+
error,
|
|
33
|
+
refresh,
|
|
34
|
+
status,
|
|
21
35
|
// TODO: Deprecate the property here and remove it with the next major release
|
|
22
36
|
handleIDPLoginCallback
|
|
23
37
|
});
|
|
@@ -7,27 +7,33 @@ type Options = Partial<{
|
|
|
7
7
|
/** @deprecated use the second argument of the composable to define the key */
|
|
8
8
|
key: string;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function useCategories({ params, options, key: _key, }?: Options, key?: string):
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
export declare function useCategories({ params, options, key: _key, }?: Options, key?: string): {
|
|
11
|
+
data: import("vue").Ref<{
|
|
12
|
+
categories: import("@scayle/storefront-api").Category[];
|
|
13
|
+
activeNode: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
categories: import("@scayle/storefront-api").Category;
|
|
16
|
+
activeNode: import("@scayle/storefront-api").Category;
|
|
17
|
+
}>;
|
|
18
|
+
error: import("vue").Ref<any>;
|
|
19
|
+
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
18
20
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
19
|
-
} & {
|
|
20
|
-
getCategoryById: (id: number, includeHidden?: true) => Promise<import("@scayle/storefront-api").Category>;
|
|
21
|
-
} & Promise<import("nuxt/dist/app/composables/asyncData")._AsyncData<{
|
|
22
|
-
categories: import("@scayle/storefront-api").Category[];
|
|
23
|
-
activeNode: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
categories: import("@scayle/storefront-api").Category;
|
|
26
|
-
activeNode: import("@scayle/storefront-api").Category;
|
|
27
|
-
}, any> & {
|
|
28
21
|
fetching: import("vue").Ref<boolean>;
|
|
22
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
23
|
+
getCategoryById: (id: number, includeHidden?: true) => Promise<import("@scayle/storefront-api").Category>;
|
|
24
|
+
} & Promise<{
|
|
25
|
+
data: import("vue").Ref<{
|
|
26
|
+
categories: import("@scayle/storefront-api").Category[];
|
|
27
|
+
activeNode: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
categories: import("@scayle/storefront-api").Category;
|
|
30
|
+
activeNode: import("@scayle/storefront-api").Category;
|
|
31
|
+
}>;
|
|
32
|
+
error: import("vue").Ref<any>;
|
|
33
|
+
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
29
34
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
30
|
-
|
|
35
|
+
fetching: import("vue").Ref<boolean>;
|
|
36
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
31
37
|
getCategoryById: (id: number, includeHidden?: true) => Promise<import("@scayle/storefront-api").Category>;
|
|
32
38
|
}>;
|
|
33
39
|
export {};
|
|
@@ -21,7 +21,21 @@ export function useCategories({
|
|
|
21
21
|
"getCategoryById",
|
|
22
22
|
currentShop.value ?? void 0
|
|
23
23
|
);
|
|
24
|
-
|
|
24
|
+
const {
|
|
25
|
+
data,
|
|
26
|
+
error,
|
|
27
|
+
status,
|
|
28
|
+
fetch,
|
|
29
|
+
fetching,
|
|
30
|
+
refresh
|
|
31
|
+
} = useRpcPromise;
|
|
32
|
+
return extendPromise(useRpcPromise.then(() => ({})), {
|
|
33
|
+
data,
|
|
34
|
+
error,
|
|
35
|
+
status,
|
|
36
|
+
fetch,
|
|
37
|
+
fetching,
|
|
38
|
+
refresh,
|
|
25
39
|
getCategoryById: (id, includeHidden) => getCategoryById({ id, includeHidden })
|
|
26
40
|
});
|
|
27
41
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RpcMethodParameters, Order } from '@scayle/storefront-core';
|
|
2
2
|
import type { RpcOptions } from '../core/useRpc';
|
|
3
|
-
import type { MaybeRefOrGetter } from '
|
|
3
|
+
import type { Ref, MaybeRefOrGetter } from 'vue';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getOrderById'>>;
|
|
6
6
|
options: RpcOptions;
|
|
@@ -11,10 +11,7 @@ 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):
|
|
15
|
-
fetching: import("vue").Ref<boolean>;
|
|
16
|
-
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
17
|
-
} & {
|
|
14
|
+
}>({ params, options, key: _key }?: Options, key?: string): {
|
|
18
15
|
data: Ref<Order & {
|
|
19
16
|
items?: ({
|
|
20
17
|
id?: import("@scayle/storefront-core").UniqueNumericIdentifierOfTheItem;
|
|
@@ -85,10 +82,12 @@ export declare function useOrder<P = {
|
|
|
85
82
|
variant: V;
|
|
86
83
|
})[];
|
|
87
84
|
}>;
|
|
88
|
-
} & Promise<import("nuxt/dist/app/composables/asyncData")._AsyncData<Order, any> & {
|
|
89
|
-
fetching: import("vue").Ref<boolean>;
|
|
90
85
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
91
|
-
|
|
86
|
+
fetching: Ref<boolean>;
|
|
87
|
+
error: Ref<any>;
|
|
88
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
89
|
+
status: Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
90
|
+
} & Promise<{
|
|
92
91
|
data: Ref<Order & {
|
|
93
92
|
items?: ({
|
|
94
93
|
id?: import("@scayle/storefront-core").UniqueNumericIdentifierOfTheItem;
|
|
@@ -159,5 +158,10 @@ export declare function useOrder<P = {
|
|
|
159
158
|
variant: V;
|
|
160
159
|
})[];
|
|
161
160
|
}>;
|
|
161
|
+
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
162
|
+
fetching: Ref<boolean>;
|
|
163
|
+
error: Ref<any>;
|
|
164
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
165
|
+
status: Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
162
166
|
}>;
|
|
163
167
|
export {};
|
|
@@ -7,8 +7,21 @@ export function useOrder({ params, options, key: _key } = {}, key) {
|
|
|
7
7
|
params,
|
|
8
8
|
options
|
|
9
9
|
);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const {
|
|
11
|
+
data,
|
|
12
|
+
fetch,
|
|
13
|
+
fetching,
|
|
14
|
+
error,
|
|
15
|
+
refresh,
|
|
16
|
+
status
|
|
17
|
+
} = promise;
|
|
18
|
+
const _data = data;
|
|
19
|
+
return extendPromise(promise.then(() => ({})), {
|
|
20
|
+
data: _data,
|
|
21
|
+
fetch,
|
|
22
|
+
fetching,
|
|
23
|
+
error,
|
|
24
|
+
refresh,
|
|
25
|
+
status
|
|
13
26
|
});
|
|
14
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RpcMethodParameters, Order } from '@scayle/storefront-core';
|
|
2
2
|
import type { RpcOptions } from '../core/useRpc';
|
|
3
|
-
import type { MaybeRefOrGetter } from '
|
|
3
|
+
import type { Ref, MaybeRefOrGetter } from 'vue';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getOrderDataByCbd'>>;
|
|
6
6
|
options: RpcOptions;
|
|
@@ -11,10 +11,12 @@ 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):
|
|
15
|
-
fetching: import("vue").Ref<boolean>;
|
|
14
|
+
}>({ params, options, key: _key }?: Options, key?: string): {
|
|
16
15
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
17
|
-
|
|
16
|
+
fetching: Ref<boolean>;
|
|
17
|
+
error: Ref<any>;
|
|
18
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
19
|
+
status: Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
18
20
|
data: Ref<Order & {
|
|
19
21
|
items?: ({
|
|
20
22
|
id?: import("@scayle/storefront-core").UniqueNumericIdentifierOfTheItem;
|
|
@@ -85,10 +87,12 @@ export declare function useOrderConfirmation<P = {
|
|
|
85
87
|
variant: V;
|
|
86
88
|
})[];
|
|
87
89
|
}>;
|
|
88
|
-
} & Promise<
|
|
89
|
-
fetching: import("vue").Ref<boolean>;
|
|
90
|
+
} & Promise<{
|
|
90
91
|
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
91
|
-
|
|
92
|
+
fetching: Ref<boolean>;
|
|
93
|
+
error: Ref<any>;
|
|
94
|
+
refresh: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions) => Promise<void>;
|
|
95
|
+
status: Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
92
96
|
data: Ref<Order & {
|
|
93
97
|
items?: ({
|
|
94
98
|
id?: import("@scayle/storefront-core").UniqueNumericIdentifierOfTheItem;
|
|
@@ -7,8 +7,21 @@ export function useOrderConfirmation({ params, options, key: _key } = {}, key) {
|
|
|
7
7
|
params,
|
|
8
8
|
options
|
|
9
9
|
);
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const {
|
|
11
|
+
data,
|
|
12
|
+
fetch,
|
|
13
|
+
fetching,
|
|
14
|
+
error,
|
|
15
|
+
refresh,
|
|
16
|
+
status
|
|
17
|
+
} = promise;
|
|
18
|
+
const _data = data;
|
|
19
|
+
return extendPromise(promise.then(() => ({})), {
|
|
20
|
+
fetch,
|
|
21
|
+
fetching,
|
|
22
|
+
error,
|
|
23
|
+
refresh,
|
|
24
|
+
status,
|
|
12
25
|
data: _data
|
|
13
26
|
});
|
|
14
27
|
}
|
|
@@ -2,6 +2,7 @@ import type { Session } from '@scayle/h3-session';
|
|
|
2
2
|
import type { RuntimeConfig } from '@nuxt/schema';
|
|
3
3
|
import { type H3Event } from 'h3';
|
|
4
4
|
import type { Log, RpcContext, Cache as CacheInterface } from '@scayle/storefront-core';
|
|
5
|
+
import { StorefrontAPIClient } from '@scayle/storefront-core';
|
|
5
6
|
import type { ShopConfig, StorefrontConfig } from '../module';
|
|
6
7
|
export interface ContextBuilderOptions {
|
|
7
8
|
$cache: CacheInterface;
|
|
@@ -14,3 +15,8 @@ export interface ContextBuilderOptions {
|
|
|
14
15
|
event: H3Event;
|
|
15
16
|
}
|
|
16
17
|
export declare const buildContext: (context: ContextBuilderOptions) => Promise<RpcContext>;
|
|
18
|
+
declare module '@scayle/storefront-core' {
|
|
19
|
+
interface AdditionalRpcContext {
|
|
20
|
+
sapiClient: StorefrontAPIClient;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/runtime/context.mjs
CHANGED
|
@@ -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
|
|
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
|
|
87
|
-
host:
|
|
86
|
+
const sapiClient = new StorefrontAPIClient({
|
|
87
|
+
host: sapiConfig.host,
|
|
88
88
|
shopId: $shopConfig.shopId,
|
|
89
89
|
auth: {
|
|
90
90
|
type: "token",
|
|
91
|
-
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
|
-
|
|
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
|
|
17
|
-
let
|
|
16
|
+
log.debug("No cached result for redirect; querying SAPI");
|
|
17
|
+
let sapiResult;
|
|
18
18
|
try {
|
|
19
|
-
|
|
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 (!
|
|
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
|
-
|
|
34
|
+
sapiResult.source,
|
|
35
35
|
{
|
|
36
|
-
target:
|
|
37
|
-
statusCode:
|
|
36
|
+
target: sapiResult.target,
|
|
37
|
+
statusCode: sapiResult.statusCode
|
|
38
38
|
},
|
|
39
39
|
REDIRECT_CACHE_TTL
|
|
40
40
|
);
|
|
41
|
-
return
|
|
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
|
|
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,
|
|
66
|
-
fetchRedirectWithCache(absoluteSourceUrl,
|
|
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()}`);
|