@vue-storefront/nuxt 6.1.0 → 6.2.0

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 CHANGED
@@ -32,8 +32,8 @@ export default defineNuxtConfig({
32
32
  modules: ["@vue-storefront/nuxt"],
33
33
  vsf: {
34
34
  middleware: {
35
- apiUrl: "http://localhost:4000"
36
- }
35
+ apiUrl: "http://localhost:4000",
36
+ },
37
37
  },
38
38
  });
39
39
  ```
package/dist/module.d.mts CHANGED
@@ -27,11 +27,17 @@ interface MultistoreConfig {
27
27
  */
28
28
  enabled: boolean;
29
29
  }
30
- interface SdkModuleOptions {
30
+ type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
31
+ type LoggerOptions = Partial<{
32
+ verbosity: LogVerbosity;
33
+ includeStackTrace: boolean;
34
+ }>;
35
+ interface AlokaiModuleOptions {
31
36
  middleware: MiddlewareConfig;
32
37
  multistore?: MultistoreConfig;
38
+ logger?: LoggerOptions;
33
39
  }
34
40
 
35
- declare const _default: _nuxt_schema.NuxtModule<SdkModuleOptions>;
41
+ declare const _default: _nuxt_schema.NuxtModule<AlokaiModuleOptions>;
36
42
 
37
43
  export { _default as default };
package/dist/module.d.ts CHANGED
@@ -27,11 +27,17 @@ interface MultistoreConfig {
27
27
  */
28
28
  enabled: boolean;
29
29
  }
30
- interface SdkModuleOptions {
30
+ type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
31
+ type LoggerOptions = Partial<{
32
+ verbosity: LogVerbosity;
33
+ includeStackTrace: boolean;
34
+ }>;
35
+ interface AlokaiModuleOptions {
31
36
  middleware: MiddlewareConfig;
32
37
  multistore?: MultistoreConfig;
38
+ logger?: LoggerOptions;
33
39
  }
34
40
 
35
- declare const _default: _nuxt_schema.NuxtModule<SdkModuleOptions>;
41
+ declare const _default: _nuxt_schema.NuxtModule<AlokaiModuleOptions>;
36
42
 
37
43
  export { _default as default };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "6.1.0",
7
+ "version": "6.2.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.7.1",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -17,6 +17,10 @@ const module = defineNuxtModule({
17
17
  },
18
18
  multistore: {
19
19
  enabled: false
20
+ },
21
+ logger: {
22
+ includeStackTrace: false,
23
+ verbosity: "debug"
20
24
  }
21
25
  },
22
26
  async setup(options, nuxt) {
@@ -76,10 +80,26 @@ export type SdkConfig = ${genInlineTypeImport(
76
80
  filename: "useSfState.ts",
77
81
  write: true
78
82
  });
83
+ addTemplate({
84
+ src: localResolver.resolve("./runtime/logger.template"),
85
+ filename: "logger.ts",
86
+ write: true,
87
+ options: {
88
+ moduleConfig: JSON.stringify(options)
89
+ }
90
+ });
91
+ addTemplate({
92
+ src: localResolver.resolve("./runtime/errorHandler.template"),
93
+ filename: "errorHandler.ts",
94
+ write: true
95
+ });
79
96
  addPluginTemplate({
80
97
  src: localResolver.resolve("./runtime/plugin.template"),
81
- filename: "alokaiSdkPlugin.ts",
82
- write: true
98
+ filename: "alokaiPlugin.ts",
99
+ write: true,
100
+ options: {
101
+ moduleConfig: JSON.stringify(options)
102
+ }
83
103
  });
84
104
  addImportsSources([
85
105
  {
@@ -93,6 +113,10 @@ export type SdkConfig = ${genInlineTypeImport(
93
113
  {
94
114
  imports: ["useSfState"],
95
115
  from: buildDirectoryResolver.resolve("useSfState.ts")
116
+ },
117
+ {
118
+ imports: ["logger"],
119
+ from: buildDirectoryResolver.resolve("logger.ts")
96
120
  }
97
121
  ]);
98
122
  }
@@ -1,6 +1,6 @@
1
1
  import { buildModule, middlewareModule } from "@vue-storefront/sdk";
2
2
  import { composeMiddlewareUrl, useNuxtApp, useRequestHeaders, getDefaultMethodsRequestConfig } from "#imports";
3
- import { SdkModuleOptions } from "./alokaiModule";
3
+ import type { AlokaiModuleOptions } from "./alokaiModule";
4
4
 
5
5
  type InjectedContext = {
6
6
  buildModule: typeof buildModule;
@@ -30,7 +30,7 @@ type InjectedContext = {
30
30
 
31
31
  type Config<TConfig> = (context: InjectedContext) => TConfig;
32
32
 
33
- const moduleConfig: SdkModuleOptions = <%= options.moduleConfig %>;
33
+ const moduleConfig: AlokaiModuleOptions = <%= options.moduleConfig %>;
34
34
 
35
35
  /**
36
36
  * Define SDK config function
@@ -55,7 +55,7 @@ const moduleConfig: SdkModuleOptions = <%= options.moduleConfig %>;
55
55
  * }),
56
56
  * contentful: buildModule(contentfulModule, {
57
57
  * apiUrl: config.middlewareUrl + "/cntf",
58
- * }),
58
+ * })
59
59
  * }),
60
60
  * );
61
61
  * ```
@@ -93,9 +93,9 @@ export function defineSdkConfig<TConfig>(config: Config<TConfig>) {
93
93
  }
94
94
 
95
95
  function resolveOptions(
96
- input: SdkModuleOptions,
96
+ input: Omit<AlokaiModuleOptions, 'logger'>,
97
97
  options: Partial<ResolveSdkOptionsConfig> = {}
98
- ): SdkModuleOptions {
98
+ ): AlokaiModuleOptions {
99
99
  if (input?.multistore?.enabled) {
100
100
  return {
101
101
  middleware: {
@@ -0,0 +1,5 @@
1
+ export default defineNuxtPlugin((nuxtApp) => {
2
+ nuxtApp.hook('vue:error', (error) => {
3
+ logger.error(error);
4
+ });
5
+ });
@@ -0,0 +1,37 @@
1
+ import { LoggerFactory, LoggerType, type LoggerInterface } from "@vue-storefront/logger";
2
+ import type { AlokaiModuleOptions, LoggerOptions } from "./alokaiModule";
3
+
4
+ function injectMetadata(
5
+ logger: LoggerInterface,
6
+ externalData: Record<string, any>,
7
+ ): LoggerInterface {
8
+ return new Proxy(logger, {
9
+ get(target, prop) {
10
+ const targetProp = target[prop as keyof LoggerInterface];
11
+ if (typeof targetProp === "function") {
12
+ return (...args: Parameters<typeof targetProp>[]) => {
13
+ const [logData, metadata] = args;
14
+ targetProp(logData, {
15
+ ...metadata,
16
+ ...externalData,
17
+ });
18
+ };
19
+ }
20
+ return targetProp;
21
+ },
22
+ });
23
+ }
24
+
25
+ const moduleConfig: AlokaiModuleOptions = <%= options.moduleConfig %>;
26
+
27
+ const createLogger = (options?: LoggerOptions) => {
28
+ const logger = LoggerFactory.create(LoggerType.ConsolaGcp, options);
29
+
30
+ return injectMetadata(logger, {
31
+ alokai: {
32
+ context: "storefront",
33
+ },
34
+ });
35
+ };
36
+
37
+ export const logger = createLogger(moduleConfig.logger);
@@ -27,7 +27,23 @@ export interface MultistoreConfig {
27
27
  enabled: boolean;
28
28
  }
29
29
 
30
- export interface SdkModuleOptions {
30
+ type LogVerbosity =
31
+ | "emergency"
32
+ | "alert"
33
+ | "critical"
34
+ | "error"
35
+ | "warning"
36
+ | "notice"
37
+ | "info"
38
+ | "debug";
39
+
40
+ export type LoggerOptions = Partial<{
41
+ verbosity: LogVerbosity;
42
+ includeStackTrace: boolean;
43
+ }>;
44
+
45
+ export interface AlokaiModuleOptions {
31
46
  middleware: MiddlewareConfig;
32
47
  multistore?: MultistoreConfig;
48
+ logger?: LoggerOptions;
33
49
  }
@@ -1,6 +1,6 @@
1
- import { SdkModuleOptions } from "~/src/types";
1
+ import type { AlokaiModuleOptions } from "~/src/types";
2
2
  interface ComposeMiddlewareUrlParams {
3
- options: SdkModuleOptions;
3
+ options: AlokaiModuleOptions;
4
4
  headers: Record<string, string | string[]>;
5
5
  }
6
6
  /**
package/dist/types.d.mts CHANGED
@@ -14,6 +14,14 @@ import type { } from './module.js'
14
14
  /** @default false */
15
15
  enabled: boolean,
16
16
  },
17
+
18
+ logger: {
19
+ /** @default false */
20
+ includeStackTrace: boolean,
21
+
22
+ /** @default "debug" */
23
+ verbosity: string,
24
+ },
17
25
  }
18
26
 
19
27
  declare module '@nuxt/schema' {
package/dist/types.d.ts CHANGED
@@ -14,6 +14,14 @@ import type { } from './module'
14
14
  /** @default false */
15
15
  enabled: boolean,
16
16
  },
17
+
18
+ logger: {
19
+ /** @default false */
20
+ includeStackTrace: boolean,
21
+
22
+ /** @default "debug" */
23
+ verbosity: string,
24
+ },
17
25
  }
18
26
 
19
27
  declare module '@nuxt/schema' {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vue-storefront/nuxt",
3
- "version": "6.1.0",
4
- "description": "Vue Storefront dedicated features for Nuxt",
3
+ "version": "6.2.0",
4
+ "description": "Alokai dedicated features for Nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
@@ -18,13 +18,8 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "nuxt-module-build build",
21
- "build:app": "cd __tests__/app && yarn build",
22
- "dev": "cd __tests__/app && yarn dev",
23
- "dev:middleware": "cd ../shared/src/__tests__/middleware && yarn dev",
24
- "lint": "eslint --ext .vue,.js,.ts .",
25
- "test:e2e:run": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev localhost:3000/ssr \"yarn test:e2e\"",
26
- "test:e2e": "cd ../shared/ && yarn test:e2e",
27
- "test:watch": "vitest watch",
21
+ "lint": "biome ci .",
22
+ "format": "prettier --write .",
28
23
  "prepare": "nuxi prepare"
29
24
  },
30
25
  "dependencies": {
@@ -33,20 +28,22 @@
33
28
  "@pinia/nuxt": "^0.5.1",
34
29
  "defu": "^6.0.0",
35
30
  "knitwork": "^1.0.0",
36
- "pinia": "^2.1.7"
31
+ "pinia": "^2.1.7",
32
+ "@vue-storefront/logger": "1.0.0"
37
33
  },
38
34
  "devDependencies": {
39
35
  "@types/node": "^18.11.17",
40
- "@nuxt/devtools": "1.3.3",
36
+ "@nuxt/devtools": "1.3.8",
41
37
  "@nuxt/module-builder": "0.7.1",
42
- "@nuxt/test-utils": "3.13.1",
43
- "@vue-storefront/sdk": "^3.1.0",
44
- "@vue-storefront/unified-data-model": "^2.0.0",
45
- "nuxt": "3.12.2",
46
- "start-server-and-test": "^2.0.3",
47
- "vitest": "1.6.0"
38
+ "@vue-storefront/sdk": "3.3.0",
39
+ "@vue-storefront/unified-data-model": "*",
40
+ "@biomejs/biome": "1.9.2",
41
+ "nuxt": "3.12.2"
48
42
  },
49
43
  "peerDependencies": {
50
- "@vue-storefront/sdk": "^3.1.0"
44
+ "@vue-storefront/sdk": "3.3.0"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
51
48
  }
52
49
  }