@vue-storefront/next 6.0.0-rc.3 → 6.0.0-rc.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.
- package/README.md +1 -1
- package/dist/client.d.mts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +7 -7
- package/dist/client.mjs +7 -7
- package/dist/index.d.mts +101 -21
- package/dist/index.d.ts +101 -21
- package/dist/index.js +95 -61
- package/dist/index.mjs +92 -61
- package/dist/{types-C90MV4A8.d.mts → types-glZZCnsn.d.mts} +92 -85
- package/dist/{types-C90MV4A8.d.ts → types-glZZCnsn.d.ts} +92 -85
- package/package.json +6 -5
|
@@ -1,51 +1,13 @@
|
|
|
1
|
-
import { buildModule, middlewareModule
|
|
2
|
-
import React, { PropsWithChildren, ReactNode } from 'react';
|
|
1
|
+
import { SDKApi, buildModule, middlewareModule } from '@alokai/connect/sdk';
|
|
3
2
|
import { cookies } from 'next/headers';
|
|
3
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
readonly unifiedCommerce: {
|
|
7
|
-
readonly middlewareModule: {
|
|
8
|
-
readonly getCategory: {
|
|
9
|
-
readonly method: "GET";
|
|
10
|
-
};
|
|
11
|
-
readonly getCategories: {
|
|
12
|
-
readonly method: "GET";
|
|
13
|
-
};
|
|
14
|
-
readonly getProductDetails: {
|
|
15
|
-
readonly method: "GET";
|
|
16
|
-
};
|
|
17
|
-
readonly getProductReviews: {
|
|
18
|
-
readonly method: "GET";
|
|
19
|
-
};
|
|
20
|
-
readonly getProducts: {
|
|
21
|
-
readonly method: "GET";
|
|
22
|
-
};
|
|
23
|
-
readonly getCurrencies: {
|
|
24
|
-
readonly method: "GET";
|
|
25
|
-
};
|
|
26
|
-
readonly searchProducts: {
|
|
27
|
-
readonly method: "GET";
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
readonly unifiedCms: {
|
|
32
|
-
readonly middlewareModule: {
|
|
33
|
-
readonly getPage: {
|
|
34
|
-
readonly method: "GET";
|
|
35
|
-
};
|
|
36
|
-
readonly getEntries: {
|
|
37
|
-
readonly method: "GET";
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type Maybe<TType> = TType | null;
|
|
5
|
+
type Maybe<TType> = null | TType;
|
|
44
6
|
|
|
45
7
|
type SfContract = {
|
|
46
8
|
SfCart: unknown;
|
|
47
|
-
SfCustomer: unknown;
|
|
48
9
|
SfCurrency: unknown;
|
|
10
|
+
SfCustomer: unknown;
|
|
49
11
|
SfLocale: unknown;
|
|
50
12
|
};
|
|
51
13
|
interface SfStateProps<TSfContract extends SfContract> {
|
|
@@ -55,12 +17,12 @@ interface SfStateProps<TSfContract extends SfContract> {
|
|
|
55
17
|
locales: TSfContract["SfLocale"][];
|
|
56
18
|
}
|
|
57
19
|
interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContract> {
|
|
58
|
-
cart: TSfContract["SfCart"] |
|
|
59
|
-
customer: TSfContract["SfCustomer"] |
|
|
60
|
-
setCart: (cart?: TSfContract["SfCart"]
|
|
20
|
+
cart: null | TSfContract["SfCart"] | undefined;
|
|
21
|
+
customer: null | TSfContract["SfCustomer"] | undefined;
|
|
22
|
+
setCart: (cart?: null | TSfContract["SfCart"]) => void;
|
|
61
23
|
setCurrencies: (currencies: TSfContract["SfCurrency"][]) => void;
|
|
62
24
|
setCurrency: (currency: TSfContract["SfCurrency"]) => void;
|
|
63
|
-
setCustomer: (customer?: TSfContract["SfCustomer"]
|
|
25
|
+
setCustomer: (customer?: null | TSfContract["SfCustomer"]) => void;
|
|
64
26
|
setLocale: (locale: TSfContract["SfLocale"]) => void;
|
|
65
27
|
setLocales: (locales: TSfContract["SfLocale"][]) => void;
|
|
66
28
|
}
|
|
@@ -68,43 +30,76 @@ declare function createSfStateProvider<TSfContract extends SfContract>(): {
|
|
|
68
30
|
SfStateProvider: ({ children, initialData, }: {
|
|
69
31
|
initialData: SfStateProps<TSfContract>;
|
|
70
32
|
} & PropsWithChildren) => React.JSX.Element;
|
|
71
|
-
|
|
72
|
-
TSfContract["
|
|
73
|
-
(
|
|
33
|
+
useSfCartState: () => [
|
|
34
|
+
null | TSfContract["SfCart"] | undefined,
|
|
35
|
+
(cart?: null | TSfContract["SfCart"]) => void
|
|
74
36
|
];
|
|
75
37
|
useSfCurrenciesState: () => [
|
|
76
38
|
TSfContract["SfCurrency"][],
|
|
77
39
|
(currencies: TSfContract["SfCurrency"][]) => void
|
|
78
40
|
];
|
|
79
|
-
|
|
80
|
-
TSfContract["
|
|
81
|
-
(
|
|
41
|
+
useSfCurrencyState: () => [
|
|
42
|
+
TSfContract["SfCurrency"],
|
|
43
|
+
(currency: TSfContract["SfCurrency"]) => void
|
|
44
|
+
];
|
|
45
|
+
useSfCustomerState: () => [
|
|
46
|
+
null | TSfContract["SfCustomer"] | undefined,
|
|
47
|
+
(customer?: null | TSfContract["SfCustomer"]) => void
|
|
82
48
|
];
|
|
83
49
|
useSfLocalesState: () => [
|
|
84
50
|
TSfContract["SfLocale"][],
|
|
85
51
|
(locales: TSfContract["SfLocale"][]) => void
|
|
86
52
|
];
|
|
87
|
-
|
|
88
|
-
TSfContract["
|
|
89
|
-
(
|
|
90
|
-
];
|
|
91
|
-
useSfCustomerState: () => [
|
|
92
|
-
TSfContract["SfCustomer"] | null | undefined,
|
|
93
|
-
(customer?: TSfContract["SfCustomer"] | null) => void
|
|
53
|
+
useSfLocaleState: () => [
|
|
54
|
+
TSfContract["SfLocale"],
|
|
55
|
+
(locale: TSfContract["SfLocale"]) => void
|
|
94
56
|
];
|
|
95
57
|
};
|
|
96
58
|
|
|
59
|
+
declare const defaultMethodsRequestConfig: {
|
|
60
|
+
readonly unifiedCms: {
|
|
61
|
+
readonly middlewareModule: {
|
|
62
|
+
readonly getEntries: {
|
|
63
|
+
readonly method: "GET";
|
|
64
|
+
};
|
|
65
|
+
readonly getPage: {
|
|
66
|
+
readonly method: "GET";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly unifiedCommerce: {
|
|
71
|
+
readonly middlewareModule: {
|
|
72
|
+
readonly getCategories: {
|
|
73
|
+
readonly method: "GET";
|
|
74
|
+
};
|
|
75
|
+
readonly getCategory: {
|
|
76
|
+
readonly method: "GET";
|
|
77
|
+
};
|
|
78
|
+
readonly getCurrencies: {
|
|
79
|
+
readonly method: "GET";
|
|
80
|
+
};
|
|
81
|
+
readonly getProductDetails: {
|
|
82
|
+
readonly method: "GET";
|
|
83
|
+
};
|
|
84
|
+
readonly getProductReviews: {
|
|
85
|
+
readonly method: "GET";
|
|
86
|
+
};
|
|
87
|
+
readonly getProducts: {
|
|
88
|
+
readonly method: "GET";
|
|
89
|
+
};
|
|
90
|
+
readonly searchProducts: {
|
|
91
|
+
readonly method: "GET";
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
97
|
interface MiddlewareConfig {
|
|
98
98
|
/**
|
|
99
99
|
* The URL of the middleware.
|
|
100
100
|
* @example "http://localhost:4000"
|
|
101
101
|
*/
|
|
102
102
|
apiUrl: string;
|
|
103
|
-
/**
|
|
104
|
-
* The URL of the middleware for server-side rendering.
|
|
105
|
-
* @example "http://localhost:4000"
|
|
106
|
-
*/
|
|
107
|
-
ssrApiUrl: string;
|
|
108
103
|
/**
|
|
109
104
|
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
110
105
|
* Usually it's a commit hash.
|
|
@@ -112,6 +107,11 @@ interface MiddlewareConfig {
|
|
|
112
107
|
* @default "no-cache-busting-id-set"
|
|
113
108
|
*/
|
|
114
109
|
cdnCacheBustingId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The URL of the middleware for server-side rendering.
|
|
112
|
+
* @example "http://localhost:4000"
|
|
113
|
+
*/
|
|
114
|
+
ssrApiUrl: string;
|
|
115
115
|
}
|
|
116
116
|
interface MultistoreConfig {
|
|
117
117
|
/**
|
|
@@ -122,43 +122,47 @@ interface MultistoreConfig {
|
|
|
122
122
|
enabled: boolean;
|
|
123
123
|
}
|
|
124
124
|
interface CreateSdkOptions {
|
|
125
|
-
multistore?: MultistoreConfig;
|
|
126
125
|
middleware: MiddlewareConfig;
|
|
126
|
+
multistore?: MultistoreConfig;
|
|
127
127
|
}
|
|
128
128
|
type Cookies = ReturnType<typeof cookies>;
|
|
129
|
-
type NextHeaders = Record<string, string | string[] | undefined
|
|
129
|
+
type NextHeaders = Headers | Record<string, string | string[] | undefined>;
|
|
130
130
|
type GetSdkContext = {
|
|
131
|
+
/**
|
|
132
|
+
* A function that returns the current locale string;
|
|
133
|
+
*/
|
|
134
|
+
getLocale?: () => string;
|
|
131
135
|
/**
|
|
132
136
|
* A function that returns the request headers.
|
|
133
137
|
*/
|
|
134
|
-
getRequestHeaders?: () =>
|
|
135
|
-
headers: NextHeaders;
|
|
138
|
+
getRequestHeaders?: () => {
|
|
136
139
|
cookies: Cookies;
|
|
137
|
-
|
|
140
|
+
headers: NextHeaders;
|
|
141
|
+
} | NextHeaders;
|
|
138
142
|
};
|
|
139
143
|
type DynamicContext = {
|
|
140
144
|
getRequestHeaders: () => Record<string, string | string[]>;
|
|
141
145
|
};
|
|
142
146
|
type StaticContext = {
|
|
143
147
|
buildModule: typeof buildModule;
|
|
144
|
-
middlewareModule: typeof middlewareModule;
|
|
145
|
-
/**
|
|
146
|
-
* @deprecated Use `config.defaultMethodsRequestConfig` instead.
|
|
147
|
-
*/
|
|
148
|
-
defaults: typeof defaultMethodsRequestConfig;
|
|
149
148
|
config: {
|
|
150
149
|
apiUrl: string;
|
|
151
|
-
ssrApiUrl: string;
|
|
152
|
-
defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
|
|
153
150
|
cdnCacheBustingId: string;
|
|
151
|
+
defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
|
|
152
|
+
ssrApiUrl: string;
|
|
154
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use `config.defaultMethodsRequestConfig` instead.
|
|
156
|
+
*/
|
|
157
|
+
defaults: typeof defaultMethodsRequestConfig;
|
|
158
|
+
middlewareModule: typeof middlewareModule;
|
|
155
159
|
};
|
|
156
160
|
type InjectedContext = DynamicContext & StaticContext;
|
|
157
161
|
type Config<TConfig> = (context: InjectedContext) => TConfig;
|
|
158
162
|
type AlokaiProviderProps<TSdk, TSfContract extends SfContract> = {
|
|
159
163
|
children: ReactNode;
|
|
160
|
-
sdk: TSdk;
|
|
161
164
|
initialData: SfStateProps<TSfContract>;
|
|
165
|
+
sdk: TSdk;
|
|
162
166
|
};
|
|
163
167
|
interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
164
168
|
/**
|
|
@@ -176,9 +180,10 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
|
176
180
|
* import type { GetServerSideProps } from "next";
|
|
177
181
|
* import { getSdk } from "../../sdk.config";
|
|
178
182
|
*
|
|
179
|
-
* export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
|
180
|
-
* const sdk = getSdk({
|
|
183
|
+
* export const getServerSideProps: GetServerSideProps = async ({ req, locale }) => {
|
|
184
|
+
* const sdk = await getSdk({
|
|
181
185
|
* getRequestHeaders: () => req.headers,
|
|
186
|
+
* getLocale: () => locale,
|
|
182
187
|
* });
|
|
183
188
|
* const { products } = await sdk.unified.getProducts();
|
|
184
189
|
*
|
|
@@ -195,8 +200,10 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
|
195
200
|
* import { getSdk } from "../../sdk.config";
|
|
196
201
|
*
|
|
197
202
|
* export default async function SsrPage() {
|
|
198
|
-
* const
|
|
203
|
+
* const locale = await getLocale();
|
|
204
|
+
* const sdk = await getSdk({
|
|
199
205
|
* getRequestHeaders: () => headers(),
|
|
206
|
+
* getLocale: () => locale,
|
|
200
207
|
* });
|
|
201
208
|
* const { products } = await sdk.unified.getProducts();
|
|
202
209
|
*
|
|
@@ -209,12 +216,12 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
|
209
216
|
type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfContract> = Readonly<{
|
|
210
217
|
AlokaiProvider: ({ children, }: AlokaiProviderProps<TSdk, TSfContract>) => JSX.Element;
|
|
211
218
|
useSdk: () => TSdk;
|
|
212
|
-
useSfCurrencyState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrencyState"];
|
|
213
|
-
useSfCurrenciesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrenciesState"];
|
|
214
|
-
useSfLocaleState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocaleState"];
|
|
215
|
-
useSfLocalesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocalesState"];
|
|
216
219
|
useSfCartState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCartState"];
|
|
220
|
+
useSfCurrenciesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrenciesState"];
|
|
221
|
+
useSfCurrencyState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrencyState"];
|
|
217
222
|
useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
|
|
223
|
+
useSfLocalesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocalesState"];
|
|
224
|
+
useSfLocaleState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocaleState"];
|
|
218
225
|
}>;
|
|
219
226
|
|
|
220
|
-
export { type
|
|
227
|
+
export { type CreateSdkContextReturn as C, type InjectedContext as I, type Maybe as M, type SfContract as S, type SfStateProps as a, type SfState as b, createSfStateProvider as c, type CreateSdkOptions as d, type Config as e, type CreateSdkReturn as f };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@vue-storefront/next",
|
|
3
3
|
"description": "Alokai dedicated features for Next.js",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "6.0.0-rc.
|
|
5
|
+
"version": "6.0.0-rc.5",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsup",
|
|
23
|
-
"lint": "
|
|
23
|
+
"lint": "eslint",
|
|
24
|
+
"lint:fix": "eslint --fix",
|
|
24
25
|
"format": "prettier --write .",
|
|
25
26
|
"test:unit": "vitest run",
|
|
26
27
|
"version": "cp CHANGELOG.md ../../docs/enterprise/content/storefront/6.change-log/next.md"
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"zustand": "^4.5.4"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@alokai/connect": "^1.0.0-rc.
|
|
33
|
+
"@alokai/connect": "^1.0.0-rc.4",
|
|
33
34
|
"@types/react": "18.3.2",
|
|
34
35
|
"@types/react-dom": "18.3.0",
|
|
35
36
|
"react-dom": "18.3.1",
|
|
@@ -37,10 +38,10 @@
|
|
|
37
38
|
"tsup": "8.3.0",
|
|
38
39
|
"vitest": "2.1.5",
|
|
39
40
|
"react": "18.3.1",
|
|
40
|
-
"next": "14.2.
|
|
41
|
+
"next": "14.2.25"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"@alokai/connect": "^1.0.0-rc.
|
|
44
|
+
"@alokai/connect": "^1.0.0-rc.4",
|
|
44
45
|
"react": "^18.2.0",
|
|
45
46
|
"next": "^13.4.7 || ^14.0.0"
|
|
46
47
|
},
|