@vue-storefront/nuxt 9.0.0-rc.3 → 9.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/module.d.mts +8 -8
- package/dist/module.d.ts +8 -8
- package/dist/module.json +3 -3
- package/dist/module.mjs +63 -38
- package/dist/runtime/defineGetConfigSwitcherHeader.template +1 -0
- package/dist/runtime/defineSdkConfig.template +107 -21
- package/dist/runtime/plugin.template +3 -10
- package/dist/runtime/serverMiddleware.d.ts +2 -0
- package/dist/runtime/serverMiddleware.js +5 -0
- package/dist/runtime/utils/defaults.d.ts +14 -14
- package/dist/runtime/utils/defaults.js +8 -8
- package/dist/types.d.mts +8 -8
- package/dist/types.d.ts +8 -8
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/module.d.mts
CHANGED
|
@@ -6,11 +6,6 @@ interface MiddlewareConfig {
|
|
|
6
6
|
* @example "http://localhost:4000"
|
|
7
7
|
*/
|
|
8
8
|
apiUrl: string;
|
|
9
|
-
/**
|
|
10
|
-
* The URL of the middleware for server-side rendering.
|
|
11
|
-
* @example "http://localhost:4000"
|
|
12
|
-
*/
|
|
13
|
-
ssrApiUrl: string;
|
|
14
9
|
/**
|
|
15
10
|
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
16
11
|
* Usually it's a commit hash.
|
|
@@ -18,6 +13,11 @@ interface MiddlewareConfig {
|
|
|
18
13
|
* @default "no-cache-busting-id-set"
|
|
19
14
|
*/
|
|
20
15
|
cdnCacheBustingId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL of the middleware for server-side rendering.
|
|
18
|
+
* @example "http://localhost:4000"
|
|
19
|
+
*/
|
|
20
|
+
ssrApiUrl: string;
|
|
21
21
|
}
|
|
22
22
|
interface MultistoreConfig {
|
|
23
23
|
/**
|
|
@@ -27,15 +27,15 @@ interface MultistoreConfig {
|
|
|
27
27
|
*/
|
|
28
28
|
enabled: boolean;
|
|
29
29
|
}
|
|
30
|
-
type LogVerbosity = "
|
|
30
|
+
type LogVerbosity = "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
|
|
31
31
|
type LoggerOptions = Partial<{
|
|
32
|
-
verbosity: LogVerbosity;
|
|
33
32
|
includeStackTrace: boolean;
|
|
33
|
+
verbosity: LogVerbosity;
|
|
34
34
|
}>;
|
|
35
35
|
interface AlokaiModuleOptions {
|
|
36
|
+
logger?: LoggerOptions;
|
|
36
37
|
middleware: MiddlewareConfig;
|
|
37
38
|
multistore?: MultistoreConfig;
|
|
38
|
-
logger?: LoggerOptions;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
declare const _default: _nuxt_schema.NuxtModule<AlokaiModuleOptions, AlokaiModuleOptions, false>;
|
package/dist/module.d.ts
CHANGED
|
@@ -6,11 +6,6 @@ interface MiddlewareConfig {
|
|
|
6
6
|
* @example "http://localhost:4000"
|
|
7
7
|
*/
|
|
8
8
|
apiUrl: string;
|
|
9
|
-
/**
|
|
10
|
-
* The URL of the middleware for server-side rendering.
|
|
11
|
-
* @example "http://localhost:4000"
|
|
12
|
-
*/
|
|
13
|
-
ssrApiUrl: string;
|
|
14
9
|
/**
|
|
15
10
|
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
16
11
|
* Usually it's a commit hash.
|
|
@@ -18,6 +13,11 @@ interface MiddlewareConfig {
|
|
|
18
13
|
* @default "no-cache-busting-id-set"
|
|
19
14
|
*/
|
|
20
15
|
cdnCacheBustingId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL of the middleware for server-side rendering.
|
|
18
|
+
* @example "http://localhost:4000"
|
|
19
|
+
*/
|
|
20
|
+
ssrApiUrl: string;
|
|
21
21
|
}
|
|
22
22
|
interface MultistoreConfig {
|
|
23
23
|
/**
|
|
@@ -27,15 +27,15 @@ interface MultistoreConfig {
|
|
|
27
27
|
*/
|
|
28
28
|
enabled: boolean;
|
|
29
29
|
}
|
|
30
|
-
type LogVerbosity = "
|
|
30
|
+
type LogVerbosity = "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
|
|
31
31
|
type LoggerOptions = Partial<{
|
|
32
|
-
verbosity: LogVerbosity;
|
|
33
32
|
includeStackTrace: boolean;
|
|
33
|
+
verbosity: LogVerbosity;
|
|
34
34
|
}>;
|
|
35
35
|
interface AlokaiModuleOptions {
|
|
36
|
+
logger?: LoggerOptions;
|
|
36
37
|
middleware: MiddlewareConfig;
|
|
37
38
|
multistore?: MultistoreConfig;
|
|
38
|
-
logger?: LoggerOptions;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
declare const _default: _nuxt_schema.NuxtModule<AlokaiModuleOptions, AlokaiModuleOptions, false>;
|
package/dist/module.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@vue-storefront/nuxt",
|
|
3
|
-
"configKey": "alokai",
|
|
4
2
|
"compatibility": {
|
|
5
3
|
"nuxt": "^3.0.0"
|
|
6
4
|
},
|
|
7
|
-
"
|
|
5
|
+
"configKey": "alokai",
|
|
6
|
+
"name": "@vue-storefront/nuxt",
|
|
7
|
+
"version": "9.0.0-rc.5",
|
|
8
8
|
"builder": {
|
|
9
9
|
"@nuxt/module-builder": "0.7.1",
|
|
10
10
|
"unbuild": "2.0.0"
|
package/dist/module.mjs
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, installModule, addTypeTemplate, addImports, addTemplate, addPluginTemplate, addImportsSources } from '@nuxt/kit';
|
|
2
|
-
import { genInlineTypeImport } from 'knitwork';
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule, addTypeTemplate, addImports, addTemplate, addPluginTemplate, addImportsSources, addServerHandler } from '@nuxt/kit';
|
|
3
2
|
import { defu } from 'defu';
|
|
3
|
+
import { genInlineTypeImport } from 'knitwork';
|
|
4
4
|
|
|
5
5
|
const module = defineNuxtModule({
|
|
6
|
-
meta: {
|
|
7
|
-
name: "@vue-storefront/nuxt",
|
|
8
|
-
configKey: "alokai",
|
|
9
|
-
compatibility: {
|
|
10
|
-
nuxt: "^3.0.0"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
6
|
defaults: {
|
|
7
|
+
logger: {
|
|
8
|
+
includeStackTrace: false,
|
|
9
|
+
verbosity: "debug"
|
|
10
|
+
},
|
|
14
11
|
/**
|
|
15
12
|
* In the `middleware` object, both `apiUrl` and `ssrApiUrl` keys have to be
|
|
16
13
|
* present to allow Nuxt replacing them with the actual values from the
|
|
17
14
|
* .env file at runtime.
|
|
18
|
-
*
|
|
15
|
+
*
|
|
19
16
|
* https://nuxt.com/docs/guide/going-further/runtime-config
|
|
20
17
|
*/
|
|
21
18
|
middleware: {
|
|
@@ -25,12 +22,15 @@ const module = defineNuxtModule({
|
|
|
25
22
|
},
|
|
26
23
|
multistore: {
|
|
27
24
|
enabled: false
|
|
28
|
-
},
|
|
29
|
-
logger: {
|
|
30
|
-
includeStackTrace: false,
|
|
31
|
-
verbosity: "debug"
|
|
32
25
|
}
|
|
33
26
|
},
|
|
27
|
+
meta: {
|
|
28
|
+
compatibility: {
|
|
29
|
+
nuxt: "^3.0.0"
|
|
30
|
+
},
|
|
31
|
+
configKey: "alokai",
|
|
32
|
+
name: "@vue-storefront/nuxt"
|
|
33
|
+
},
|
|
34
34
|
async setup(options, nuxt) {
|
|
35
35
|
const projectLayer = nuxt.options._layers[0];
|
|
36
36
|
const projectRootResolver = createResolver(projectLayer.config.rootDir);
|
|
@@ -44,10 +44,15 @@ const module = defineNuxtModule({
|
|
|
44
44
|
nuxt.options.app.head.meta = [
|
|
45
45
|
...nuxt.options.app.head.meta ?? [],
|
|
46
46
|
{
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
content: "Alokai Storefront",
|
|
48
|
+
name: "generator"
|
|
49
49
|
}
|
|
50
50
|
];
|
|
51
|
+
nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
|
|
52
|
+
nitroConfig.externals = nitroConfig.externals || {};
|
|
53
|
+
nitroConfig.externals.inline = nitroConfig.externals.inline || [];
|
|
54
|
+
nitroConfig.externals.inline.push(localResolver.resolve("./runtime"));
|
|
55
|
+
});
|
|
51
56
|
addTypeTemplate({
|
|
52
57
|
filename: "sdk.config.d.ts",
|
|
53
58
|
getContents: () => `
|
|
@@ -61,67 +66,87 @@ export type SdkConfig = ${genInlineTypeImport(
|
|
|
61
66
|
src: localResolver.resolve("./runtime/types.template")
|
|
62
67
|
});
|
|
63
68
|
addImports({
|
|
64
|
-
name: "getDefaultMethodsRequestConfig",
|
|
65
69
|
as: "getDefaultMethodsRequestConfig",
|
|
66
|
-
from: localResolver.resolve("./runtime/utils/defaults")
|
|
70
|
+
from: localResolver.resolve("./runtime/utils/defaults"),
|
|
71
|
+
name: "getDefaultMethodsRequestConfig"
|
|
67
72
|
});
|
|
68
73
|
addTemplate({
|
|
69
|
-
src: localResolver.resolve("./runtime/useSdk.template"),
|
|
70
74
|
filename: "useSdk.ts",
|
|
75
|
+
src: localResolver.resolve("./runtime/useSdk.template"),
|
|
71
76
|
write: true
|
|
72
77
|
});
|
|
73
78
|
addTemplate({
|
|
74
|
-
src: localResolver.resolve("./runtime/defineSdkConfig.template"),
|
|
75
79
|
filename: "defineSdkConfig.ts",
|
|
76
|
-
write: true,
|
|
77
80
|
options: {
|
|
78
81
|
moduleConfig: JSON.stringify(options)
|
|
79
|
-
}
|
|
82
|
+
},
|
|
83
|
+
src: localResolver.resolve("./runtime/defineSdkConfig.template"),
|
|
84
|
+
write: true
|
|
85
|
+
});
|
|
86
|
+
addTemplate({
|
|
87
|
+
filename: "defineGetConfigSwitcherHeader.ts",
|
|
88
|
+
options: {
|
|
89
|
+
moduleConfig: JSON.stringify(options)
|
|
90
|
+
},
|
|
91
|
+
src: localResolver.resolve(
|
|
92
|
+
"./runtime/defineGetConfigSwitcherHeader.template"
|
|
93
|
+
),
|
|
94
|
+
write: true
|
|
80
95
|
});
|
|
81
96
|
addTemplate({
|
|
82
|
-
src: localResolver.resolve("./runtime/useSfState.template"),
|
|
83
97
|
filename: "useSfState.ts",
|
|
98
|
+
src: localResolver.resolve("./runtime/useSfState.template"),
|
|
84
99
|
write: true
|
|
85
100
|
});
|
|
86
101
|
addTemplate({
|
|
87
|
-
src: localResolver.resolve("./runtime/logger.template"),
|
|
88
102
|
filename: "logger.ts",
|
|
89
|
-
write: true,
|
|
90
103
|
options: {
|
|
91
104
|
moduleConfig: JSON.stringify(options)
|
|
92
|
-
}
|
|
105
|
+
},
|
|
106
|
+
src: localResolver.resolve("./runtime/logger.template"),
|
|
107
|
+
write: true
|
|
93
108
|
});
|
|
94
109
|
addTemplate({
|
|
95
|
-
src: localResolver.resolve("./runtime/errorHandler.template"),
|
|
96
110
|
filename: "errorHandler.ts",
|
|
111
|
+
src: localResolver.resolve("./runtime/errorHandler.template"),
|
|
97
112
|
write: true
|
|
98
113
|
});
|
|
99
114
|
addPluginTemplate({
|
|
100
|
-
src: localResolver.resolve("./runtime/plugin.template"),
|
|
101
115
|
filename: "alokaiPlugin.ts",
|
|
102
|
-
write: true,
|
|
103
116
|
options: {
|
|
104
117
|
moduleConfig: JSON.stringify(options)
|
|
105
|
-
}
|
|
118
|
+
},
|
|
119
|
+
src: localResolver.resolve("./runtime/plugin.template"),
|
|
120
|
+
write: true
|
|
106
121
|
});
|
|
107
122
|
addImportsSources([
|
|
108
123
|
{
|
|
109
|
-
|
|
110
|
-
|
|
124
|
+
from: buildDirectoryResolver.resolve("useSdk.ts"),
|
|
125
|
+
imports: ["useSdk"]
|
|
111
126
|
},
|
|
112
127
|
{
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
from: buildDirectoryResolver.resolve("defineSdkConfig.ts"),
|
|
129
|
+
imports: ["defineSdkConfig", "defineSdkModule"]
|
|
115
130
|
},
|
|
116
131
|
{
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
from: buildDirectoryResolver.resolve(
|
|
133
|
+
"defineGetConfigSwitcherHeader.ts"
|
|
134
|
+
),
|
|
135
|
+
imports: ["defineGetConfigSwitcherHeader"]
|
|
119
136
|
},
|
|
120
137
|
{
|
|
121
|
-
|
|
122
|
-
|
|
138
|
+
from: buildDirectoryResolver.resolve("useSfState.ts"),
|
|
139
|
+
imports: ["useSfState"]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
from: buildDirectoryResolver.resolve("logger.ts"),
|
|
143
|
+
imports: ["logger"]
|
|
123
144
|
}
|
|
124
145
|
]);
|
|
146
|
+
addServerHandler({
|
|
147
|
+
handler: localResolver.resolve("./runtime/serverMiddleware"),
|
|
148
|
+
middleware: true
|
|
149
|
+
});
|
|
125
150
|
}
|
|
126
151
|
});
|
|
127
152
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineGetConfigSwitcherHeader } from '@alokai/connect/sdk';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Extension, Module } from "@alokai/connect/sdk";
|
|
1
2
|
import { buildModule, middlewareModule } from "@alokai/connect/sdk";
|
|
2
3
|
import { useNuxtApp, useRequestHeaders, getDefaultMethodsRequestConfig } from "#imports";
|
|
4
|
+
import type { Composer } from '#i18n';
|
|
3
5
|
import type { AlokaiModuleOptions } from "./alokaiModule";
|
|
4
6
|
|
|
5
7
|
type InjectedContext = {
|
|
@@ -31,34 +33,62 @@ const moduleConfig: AlokaiModuleOptions = <%= options.moduleConfig %>;
|
|
|
31
33
|
/**
|
|
32
34
|
* Define SDK config function
|
|
33
35
|
*
|
|
34
|
-
* @param config - Function that returns SDK config
|
|
36
|
+
* @param config - Function that returns SDK config or a record of SDK modules
|
|
35
37
|
*
|
|
36
|
-
* @example
|
|
38
|
+
* @example Using a function:
|
|
37
39
|
* ```ts
|
|
38
|
-
* import {
|
|
39
|
-
*
|
|
40
|
-
* ContentfulModuleType,
|
|
41
|
-
* } from "@vsf-enterprise/contentful-sdk";
|
|
42
|
-
* import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
|
|
40
|
+
* import type { UnifiedEndpoints } from 'storefront-middleware/types';
|
|
41
|
+
* import { getConfigSwitcherHeader } from './utils';
|
|
43
42
|
*
|
|
44
43
|
* export default defineSdkConfig(
|
|
45
|
-
* ({ buildModule, middlewareModule, config,
|
|
46
|
-
* unified: buildModule(middlewareModule<
|
|
47
|
-
* apiUrl: config.apiUrl + "/commerce",
|
|
48
|
-
* ssrApiUrl: config.ssrApiUrl + "/commerce",
|
|
49
|
-
* defaultRequestConfig: { headers: { ...getCookieHeader() } },
|
|
44
|
+
* ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
|
|
45
|
+
* unified: buildModule(middlewareModule<UnifiedEndpoints>, {
|
|
46
|
+
* apiUrl: config.apiUrl + "/commerce/unified",
|
|
47
|
+
* ssrApiUrl: config.ssrApiUrl + "/commerce/unified",
|
|
50
48
|
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
49
|
+
* defaultRequestConfig: {
|
|
50
|
+
* getConfigSwitcherHeader,
|
|
51
|
+
* headers: getRequestHeaders(),
|
|
52
|
+
* },
|
|
51
53
|
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
52
54
|
* }),
|
|
53
|
-
* contentful: buildModule(contentfulModule, {
|
|
54
|
-
* apiUrl: config.apiUrl + "/cntf",
|
|
55
|
-
* ssrApiUrl: config.ssrApiUrl + "/cntf",
|
|
56
|
-
* })
|
|
57
55
|
* }),
|
|
58
56
|
* );
|
|
59
57
|
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Using a record of modules:
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { defineSdkModule } from '@vue-storefront/nuxt';
|
|
62
|
+
* import type { UnifiedEndpoints } from 'storefront-middleware/types';
|
|
63
|
+
* import { getConfigSwitcherHeader } from './utils';
|
|
64
|
+
*
|
|
65
|
+
* const unified = defineSdkModule(({ buildModule, config, getRequestHeaders, middlewareModule }) =>
|
|
66
|
+
* buildModule(middlewareModule<UnifiedEndpoints>, {
|
|
67
|
+
* apiUrl: config.apiUrl + "/commerce/unified",
|
|
68
|
+
* ssrApiUrl: config.ssrApiUrl + "/commerce/unified",
|
|
69
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
70
|
+
* defaultRequestConfig: {
|
|
71
|
+
* getConfigSwitcherHeader,
|
|
72
|
+
* headers: getRequestHeaders(),
|
|
73
|
+
* },
|
|
74
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
75
|
+
* }),
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* export default defineSdkConfig({
|
|
79
|
+
* unified,
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
60
82
|
*/
|
|
61
|
-
export function defineSdkConfig<TConfig>(config: Config<TConfig>)
|
|
83
|
+
export function defineSdkConfig<TConfig>(config: Config<TConfig>): () => TConfig;
|
|
84
|
+
export function defineSdkConfig<TModules extends Record<string, DefineSdkModule>>(
|
|
85
|
+
modules: TModules,
|
|
86
|
+
): () => {
|
|
87
|
+
[K in keyof TModules]: ReturnType<TModules[K]>;
|
|
88
|
+
};
|
|
89
|
+
export function defineSdkConfig<TConfig>(
|
|
90
|
+
config: Config<TConfig> | Record<string, DefineSdkModule>,
|
|
91
|
+
) {
|
|
62
92
|
return () => {
|
|
63
93
|
const nuxtApp = useNuxtApp()
|
|
64
94
|
const runtimeConfig = useRuntimeConfig();
|
|
@@ -67,9 +97,12 @@ export function defineSdkConfig<TConfig>(config: Config<TConfig>) {
|
|
|
67
97
|
const resolvedOptions = resolveOptions(runtimeConfig.public.alokai);
|
|
68
98
|
|
|
69
99
|
const getCookieHeader = () => useRequestHeaders(["cookie"]);
|
|
70
|
-
const getRequestHeaders = () =>
|
|
100
|
+
const getRequestHeaders = () => ({
|
|
101
|
+
"x-alokai-locale": (nuxtApp as unknown as { $i18n: Composer }).$i18n?.locale?.value,
|
|
102
|
+
...useRequestHeaders()
|
|
103
|
+
});
|
|
71
104
|
|
|
72
|
-
|
|
105
|
+
const context = {
|
|
73
106
|
buildModule,
|
|
74
107
|
middlewareModule,
|
|
75
108
|
getCookieHeader,
|
|
@@ -81,10 +114,63 @@ export function defineSdkConfig<TConfig>(config: Config<TConfig>) {
|
|
|
81
114
|
defaultMethodsRequestConfig: getDefaultMethodsRequestConfig(),
|
|
82
115
|
cdnCacheBustingId: runtimeConfig.public.alokai.middleware.cdnCacheBustingId,
|
|
83
116
|
}
|
|
84
|
-
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (typeof config === 'function') {
|
|
120
|
+
return config(context);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return buildModules(config)(context);
|
|
85
124
|
}
|
|
86
125
|
}
|
|
87
126
|
|
|
127
|
+
type DefineSdkModule = (
|
|
128
|
+
context: InjectedContext,
|
|
129
|
+
) => ReturnType<typeof buildModule>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Defines an SDK module that can be used with defineSdkConfig.
|
|
133
|
+
* Each module is a function that takes the InjectedContext and returns a built module.
|
|
134
|
+
*
|
|
135
|
+
* @param moduleDefinition - A function that takes InjectedContext and returns a built module
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { defineSdkModule } from '@vue-storefront/nuxt';
|
|
140
|
+
* import type { UnifiedEndpoints } from 'storefront-middleware/types';
|
|
141
|
+
* import { getConfigSwitcherHeader } from './utils';
|
|
142
|
+
*
|
|
143
|
+
* export const unified = defineSdkModule(({ buildModule, config, getRequestHeaders, middlewareModule }) =>
|
|
144
|
+
* buildModule(middlewareModule<UnifiedEndpoints>, {
|
|
145
|
+
* apiUrl: config.apiUrl + "/commerce/unified",
|
|
146
|
+
* ssrApiUrl: config.ssrApiUrl + "/commerce/unified",
|
|
147
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
148
|
+
* defaultRequestConfig: {
|
|
149
|
+
* getConfigSwitcherHeader,
|
|
150
|
+
* headers: getRequestHeaders(),
|
|
151
|
+
* },
|
|
152
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
153
|
+
* }),
|
|
154
|
+
* );
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export function defineSdkModule<TModuleDefinition extends DefineSdkModule>(
|
|
158
|
+
moduleDefinition: TModuleDefinition,
|
|
159
|
+
) {
|
|
160
|
+
return moduleDefinition;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildModules<TModules extends Record<string, DefineSdkModule>>(
|
|
164
|
+
modules: TModules,
|
|
165
|
+
) {
|
|
166
|
+
return (context: InjectedContext) =>
|
|
167
|
+
Object.fromEntries(
|
|
168
|
+
Object.entries(modules).map(([key, module]) => [key, module(context)]),
|
|
169
|
+
) as {
|
|
170
|
+
[K in keyof TModules]: ReturnType<TModules[K]>;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
88
174
|
/**
|
|
89
175
|
* Helper function to resolve the SDK options based on the configuration.
|
|
90
176
|
*
|
|
@@ -106,4 +192,4 @@ function resolveOptions(
|
|
|
106
192
|
|
|
107
193
|
type ResolveSdkOptionsConfig = {
|
|
108
194
|
customSuffix: string;
|
|
109
|
-
}
|
|
195
|
+
}
|
|
@@ -3,16 +3,9 @@ import sdkConfig from "~/sdk.config";
|
|
|
3
3
|
import type { SdkConfig } from "./sdk.config";
|
|
4
4
|
import { defineNuxtPlugin } from '#app';
|
|
5
5
|
|
|
6
|
-
export default defineNuxtPlugin(() => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const getSdk = () => {
|
|
10
|
-
if (!sdk) {
|
|
11
|
-
const config = sdkConfig();
|
|
12
|
-
sdk = initSDK(config);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return sdk;
|
|
6
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
7
|
+
const getSdk: () => SDKApi<ReturnType<SdkConfig>> = () => {
|
|
8
|
+
return initSDK(sdkConfig());
|
|
16
9
|
};
|
|
17
10
|
|
|
18
11
|
return {
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
export declare function getDefaultMethodsRequestConfig(): {
|
|
2
|
-
readonly
|
|
2
|
+
readonly unifiedCms: {
|
|
3
3
|
readonly middlewareModule: {
|
|
4
|
-
readonly
|
|
4
|
+
readonly getEntries: {
|
|
5
5
|
readonly method: "GET";
|
|
6
6
|
};
|
|
7
|
-
readonly
|
|
7
|
+
readonly getPage: {
|
|
8
8
|
readonly method: "GET";
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
readonly unifiedCommerce: {
|
|
13
|
+
readonly middlewareModule: {
|
|
14
|
+
readonly getCategories: {
|
|
11
15
|
readonly method: "GET";
|
|
12
16
|
};
|
|
13
|
-
readonly
|
|
17
|
+
readonly getCategory: {
|
|
14
18
|
readonly method: "GET";
|
|
15
19
|
};
|
|
16
|
-
readonly
|
|
20
|
+
readonly getCurrencies: {
|
|
17
21
|
readonly method: "GET";
|
|
18
22
|
};
|
|
19
|
-
readonly
|
|
23
|
+
readonly getProductDetails: {
|
|
20
24
|
readonly method: "GET";
|
|
21
25
|
};
|
|
22
|
-
readonly
|
|
26
|
+
readonly getProductReviews: {
|
|
23
27
|
readonly method: "GET";
|
|
24
28
|
};
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
readonly unifiedCms: {
|
|
28
|
-
readonly middlewareModule: {
|
|
29
|
-
readonly getPage: {
|
|
29
|
+
readonly getProducts: {
|
|
30
30
|
readonly method: "GET";
|
|
31
31
|
};
|
|
32
|
-
readonly
|
|
32
|
+
readonly searchProducts: {
|
|
33
33
|
readonly method: "GET";
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export function getDefaultMethodsRequestConfig() {
|
|
2
2
|
return {
|
|
3
|
+
unifiedCms: {
|
|
4
|
+
middlewareModule: {
|
|
5
|
+
getEntries: { method: "GET" },
|
|
6
|
+
getPage: { method: "GET" }
|
|
7
|
+
}
|
|
8
|
+
},
|
|
3
9
|
unifiedCommerce: {
|
|
4
10
|
middlewareModule: {
|
|
5
|
-
getCategory: { method: "GET" },
|
|
6
11
|
getCategories: { method: "GET" },
|
|
12
|
+
getCategory: { method: "GET" },
|
|
13
|
+
getCurrencies: { method: "GET" },
|
|
7
14
|
getProductDetails: { method: "GET" },
|
|
8
15
|
getProductReviews: { method: "GET" },
|
|
9
16
|
getProducts: { method: "GET" },
|
|
10
|
-
getCurrencies: { method: "GET" },
|
|
11
17
|
searchProducts: { method: "GET" }
|
|
12
18
|
}
|
|
13
|
-
},
|
|
14
|
-
unifiedCms: {
|
|
15
|
-
middlewareModule: {
|
|
16
|
-
getPage: { method: "GET" },
|
|
17
|
-
getEntries: { method: "GET" }
|
|
18
|
-
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
package/dist/types.d.mts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import type { } from './module.js'
|
|
3
3
|
|
|
4
4
|
export interface ModuleOptions {
|
|
5
|
+
logger: {
|
|
6
|
+
/** @default false */
|
|
7
|
+
includeStackTrace: boolean,
|
|
8
|
+
|
|
9
|
+
/** @default "debug" */
|
|
10
|
+
verbosity: string,
|
|
11
|
+
},
|
|
12
|
+
|
|
5
13
|
middleware: {
|
|
6
14
|
/** @default "" */
|
|
7
15
|
apiUrl: string,
|
|
@@ -17,14 +25,6 @@ import type { } from './module.js'
|
|
|
17
25
|
/** @default false */
|
|
18
26
|
enabled: boolean,
|
|
19
27
|
},
|
|
20
|
-
|
|
21
|
-
logger: {
|
|
22
|
-
/** @default false */
|
|
23
|
-
includeStackTrace: boolean,
|
|
24
|
-
|
|
25
|
-
/** @default "debug" */
|
|
26
|
-
verbosity: string,
|
|
27
|
-
},
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare module '@nuxt/schema' {
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import type { } from './module'
|
|
3
3
|
|
|
4
4
|
export interface ModuleOptions {
|
|
5
|
+
logger: {
|
|
6
|
+
/** @default false */
|
|
7
|
+
includeStackTrace: boolean,
|
|
8
|
+
|
|
9
|
+
/** @default "debug" */
|
|
10
|
+
verbosity: string,
|
|
11
|
+
},
|
|
12
|
+
|
|
5
13
|
middleware: {
|
|
6
14
|
/** @default "" */
|
|
7
15
|
apiUrl: string,
|
|
@@ -17,14 +25,6 @@ import type { } from './module'
|
|
|
17
25
|
/** @default false */
|
|
18
26
|
enabled: boolean,
|
|
19
27
|
},
|
|
20
|
-
|
|
21
|
-
logger: {
|
|
22
|
-
/** @default false */
|
|
23
|
-
includeStackTrace: boolean,
|
|
24
|
-
|
|
25
|
-
/** @default "debug" */
|
|
26
|
-
verbosity: string,
|
|
27
|
-
},
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare module '@nuxt/schema' {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-storefront/nuxt",
|
|
3
|
-
"version": "9.0.0-rc.
|
|
3
|
+
"version": "9.0.0-rc.5",
|
|
4
4
|
"description": "Alokai dedicated features for Nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "nuxt-module-build build",
|
|
21
|
-
"lint": "
|
|
21
|
+
"lint": "eslint",
|
|
22
|
+
"lint:fix": "eslint --fix",
|
|
22
23
|
"format": "prettier --write .",
|
|
23
24
|
"prepare": "nuxi prepare",
|
|
24
25
|
"version": "cp CHANGELOG.md ../../docs/enterprise/content/storefront/6.change-log/nuxt.md"
|
|
@@ -32,15 +33,14 @@
|
|
|
32
33
|
"pinia": "^2.1.7"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@alokai/connect": "^1.0.0-rc.
|
|
36
|
+
"@alokai/connect": "^1.0.0-rc.4",
|
|
36
37
|
"@types/node": "^18.11.17",
|
|
37
38
|
"@nuxt/devtools": "1.3.8",
|
|
38
39
|
"@nuxt/module-builder": "0.7.1",
|
|
39
|
-
"@biomejs/biome": "1.9.2",
|
|
40
40
|
"nuxt": "3.12.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@alokai/connect": "^1.0.0-rc.
|
|
43
|
+
"@alokai/connect": "^1.0.0-rc.4"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|