@scayle/storefront-nuxt 7.42.2 → 7.43.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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.43.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Extend `StorageEntity` with optional `compression: 'none' | 'deflate' | 'gzip' | 'brotli'` option.
8
+ Modify [unstorage](https://unstorage.unjs.io/) driver creation during server startup to configure`@scayle/unstorage-compression-driver` if value of `compression` is set to a supported compression algorithm.
9
+
10
+ ### Patch Changes
11
+
12
+ - Ensure correct unstorage drivers are bundled
13
+ - Updated dependencies
14
+ - @scayle/unstorage-compression-driver@0.1.1
15
+ - @scayle/storefront-core@7.29.0
16
+
17
+ ## 7.42.3
18
+
19
+ ### Patch Changes
20
+
21
+ - Fix incorrect parsing of legacy config
22
+ - Include missing unstorage drivers in final build
23
+ - Updated dependencies
24
+ - @scayle/storefront-core@7.28.2
25
+
3
26
  ## 7.42.2
4
27
 
5
28
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.180408c8.mjs';
1
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.mjs';
2
2
  export { rpcCall } from './rpc.mjs';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
+ import '@scayle/unstorage-compression-driver';
5
6
  import 'unstorage';
6
7
  import 'nuxt/app';
7
8
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.180408c8.js';
1
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.js';
2
2
  export { rpcCall } from './rpc.js';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
+ import '@scayle/unstorage-compression-driver';
5
6
  import 'unstorage';
6
7
  import 'nuxt/app';
7
8
 
package/dist/module.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.180408c8.mjs';
3
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.180408c8.mjs';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.5af220a0.mjs';
3
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.mjs';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
+ import '@scayle/unstorage-compression-driver';
5
6
  import 'unstorage';
6
7
 
7
8
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
package/dist/module.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.180408c8.js';
3
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.180408c8.js';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.5af220a0.js';
3
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.js';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
+ import '@scayle/unstorage-compression-driver';
5
6
  import 'unstorage';
6
7
 
7
8
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.7.0"
6
6
  },
7
- "version": "7.42.1"
7
+ "version": "7.42.3"
8
8
  }
package/dist/module.mjs CHANGED
@@ -2,7 +2,43 @@ import { defineNuxtModule, createResolver, extendViteConfig, addServerHandler, a
2
2
  import yn from 'yn';
3
3
  import { rpcMethods } from '@scayle/storefront-core';
4
4
  import { defu } from 'defu';
5
+ import { genImport, genSafeVariableName } from 'knitwork';
6
+ import { builtinDrivers } from 'unstorage';
5
7
 
8
+ function getUsedDrivers(options) {
9
+ const drivers = /* @__PURE__ */ new Set();
10
+ drivers.add("memory");
11
+ if (options.redis || Object.values(options.stores).some((store) => store.redis)) {
12
+ drivers.add("redis");
13
+ }
14
+ const addDriver = (config) => {
15
+ if (config?.cache?.driver) {
16
+ drivers.add(config.cache.driver);
17
+ }
18
+ if (config?.session?.driver) {
19
+ drivers.add(config.session.driver);
20
+ }
21
+ };
22
+ addDriver(options.storage);
23
+ Object.values(options.stores).forEach((store) => {
24
+ addDriver(store.storage);
25
+ });
26
+ return Array.from(drivers);
27
+ }
28
+ function createVirtualDriverImport(options) {
29
+ const usedDrivers = getUsedDrivers(options);
30
+ const usesCompression = !yn(process.env.SFC_OMIT_COMPRESSION);
31
+ return `${usedDrivers.map(
32
+ (driver) => genImport(builtinDrivers[driver], genSafeVariableName(driver))
33
+ ).join("\n")}
34
+
35
+ ${usesCompression ? genImport("@scayle/unstorage-compression-driver", "compression") : ""}
36
+
37
+ export default {
38
+ ${usedDrivers.map((driver) => '"' + driver + '":' + genSafeVariableName(driver) + ",").join("\n")}
39
+ ${usesCompression ? "compression" : ""}
40
+ }`;
41
+ }
6
42
  const module = defineNuxtModule({
7
43
  meta: {
8
44
  name: "@scayle/storefront-nuxt",
@@ -173,6 +209,12 @@ const module = defineNuxtModule({
173
209
  nitroConfig.replace["process.env.SFC_OMIT_MD5"] = yn(
174
210
  process.env.SFC_OMIT_MD5
175
211
  );
212
+ nitroConfig.virtual = {
213
+ ...nitroConfig.virtual,
214
+ "#virtual/storage-drivers": createVirtualDriverImport(
215
+ nuxt.options.runtimeConfig.storefront
216
+ )
217
+ };
176
218
  });
177
219
  nuxt.options.alias["#rpcMethods"] = appResolve(
178
220
  options.rpcDir ?? "./rpcMethods"
package/dist/rpc.d.mts CHANGED
@@ -1,6 +1,7 @@
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.180408c8.mjs';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.5af220a0.mjs';
4
+ import '@scayle/unstorage-compression-driver';
4
5
  import 'unstorage';
5
6
 
6
7
  /**
package/dist/rpc.d.ts CHANGED
@@ -1,6 +1,7 @@
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.180408c8.js';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.5af220a0.js';
4
+ import '@scayle/unstorage-compression-driver';
4
5
  import 'unstorage';
5
6
 
6
7
  /**
@@ -1,34 +1,37 @@
1
- import memoryDriver from "unstorage/drivers/memory";
2
- import { builtinDrivers } from "unstorage";
3
1
  import { createConsola } from "consola";
4
2
  import {
5
3
  STORAGE_MOUNT_CACHE,
6
4
  STORAGE_MOUNT_SESSION
7
5
  } from "../../server/utils/cacheStorage.mjs";
8
6
  import createLog from "../../createLog.mjs";
7
+ import drivers from "#virtual/storage-drivers";
9
8
  import { defineNitroPlugin, useRuntimeConfig, useStorage } from "#imports";
10
- async function createMountDriver(options) {
9
+ function createMountDriver(options) {
11
10
  if (options?.driver) {
12
- const driver = await import(
13
- // @ts-ignore
14
- builtinDrivers[options.driver] || options.driver
15
- ).then((r) => r.default || r);
16
- return driver(options ?? {});
11
+ const compression = options?.compression;
12
+ const isCompressionEnabled = !!compression && compression !== "none";
13
+ const driver = drivers[options.driver ?? "memory"];
14
+ const createdDriver = driver(options);
15
+ return isCompressionEnabled ? drivers.compression({
16
+ ...options,
17
+ encoding: compression,
18
+ passthroughDriver: createdDriver
19
+ }) : createdDriver;
17
20
  }
18
- return memoryDriver();
21
+ return drivers.memory();
19
22
  }
20
- async function mountStorage(storage, options) {
23
+ function mountStorage(storage, options) {
21
24
  const { config, base } = options;
22
25
  const mounts = storage.getMounts().map((existingMount) => existingMount.base.replace(":", ""));
23
26
  if (!mounts.includes(base)) {
24
27
  if (config) {
25
- storage.mount(base, await createMountDriver(config));
28
+ storage.mount(base, createMountDriver(config));
26
29
  } else {
27
- storage.mount(base, await createMountDriver());
30
+ storage.mount(base, createMountDriver());
28
31
  }
29
32
  }
30
33
  }
31
- function transformLegacyConfig(provider = "memory", mode, log, redis, shopId = void 0) {
34
+ function transformLegacyConfig(provider = "redis", mode, log, redis, shopId = void 0) {
32
35
  log.warn(
33
36
  `${shopId ? "Shop " + shopId + " Storage" : "Global Storage"}: Using legacy storage config for ${mode}. The \`provider\` and \`redis\` options are deprecated.`
34
37
  );
@@ -115,7 +118,7 @@ function getShopSessionConfig(config, shop, log) {
115
118
  shop.shopId
116
119
  );
117
120
  }
118
- export default defineNitroPlugin(async () => {
121
+ export default defineNitroPlugin(() => {
119
122
  const storage = useStorage();
120
123
  const config = useRuntimeConfig();
121
124
  const log = createLog(
@@ -126,12 +129,12 @@ export default defineNitroPlugin(async () => {
126
129
  const shops = config.storefront.stores;
127
130
  try {
128
131
  const globalCacheConfig = getCacheConfig(config, log);
129
- await mountStorage(storage, {
132
+ mountStorage(storage, {
130
133
  base: STORAGE_MOUNT_CACHE,
131
134
  config: globalCacheConfig
132
135
  });
133
136
  const globalSessionConfig = getSessionConfig(config, log);
134
- await mountStorage(storage, {
137
+ mountStorage(storage, {
135
138
  base: STORAGE_MOUNT_SESSION,
136
139
  config: globalSessionConfig
137
140
  });
@@ -140,14 +143,14 @@ export default defineNitroPlugin(async () => {
140
143
  const shopSessionMount = `${STORAGE_MOUNT_SESSION}:${shop.shopId}`;
141
144
  const cacheConfig = getShopCacheConfig(config, shop, log);
142
145
  if (cacheConfig) {
143
- await mountStorage(storage, {
146
+ mountStorage(storage, {
144
147
  base: shopCacheMount,
145
148
  config: cacheConfig
146
149
  });
147
150
  }
148
151
  const sessionConfig = getShopSessionConfig(config, shop, log);
149
152
  if (sessionConfig) {
150
- await mountStorage(storage, {
153
+ mountStorage(storage, {
151
154
  base: shopSessionMount,
152
155
  config: sessionConfig
153
156
  });
@@ -44,7 +44,7 @@ async function handleOauth(event, storefrontConfig, log) {
44
44
  }
45
45
  async function bootstrap(event, log, url, $shopConfig, $storefrontConfig, apiBasePath, config) {
46
46
  const bootstrapLog = log.space("bootstrap");
47
- bootstrapLog.debug("Bootstrapping request: ", url.toString());
47
+ bootstrapLog.debug("Bootstrapping request: " + url.toString());
48
48
  const $cache = useCacheStorage(
49
49
  String($shopConfig.shopId),
50
50
  $shopConfig.shopId,
@@ -7,14 +7,9 @@ async function updateSession(event, data) {
7
7
  }
8
8
  const updateUser = async (event) => {
9
9
  const session = event.context.session;
10
- const checkoutUrl = event.context.$rpcContext.checkout.url;
11
- const shopId = event.context.$currentShop.shopId;
12
10
  const user = await rpcMethods.fetchUser(
13
11
  { accessToken: session.data.accessToken, callback: "" },
14
- {
15
- checkoutUrl,
16
- shopId
17
- }
12
+ event.context.$rpcContext
18
13
  );
19
14
  await updateSession(event, {
20
15
  user
@@ -64,14 +59,9 @@ const revokeTokensAndDestroySession = async (event, log) => {
64
59
  };
65
60
  const updateSessionWithUser = async (event, sessionData, log) => {
66
61
  try {
67
- const checkoutUrl = event.context.$rpcContext.checkout.url;
68
- const shopId = event.context.$currentShop.shopId;
69
62
  const user = await rpcMethods.fetchUser(
70
63
  { accessToken: sessionData.accessToken, callback: "" },
71
- {
72
- checkoutUrl,
73
- shopId
74
- }
64
+ event.context.$rpcContext
75
65
  );
76
66
  await updateSession(event, {
77
67
  user
@@ -1,4 +1,5 @@
1
1
  import { LogLevel, HashAlgorithm, WithParams, ShopUser } from '@scayle/storefront-core';
2
+ import { CompressionEncodings } from '@scayle/unstorage-compression-driver';
2
3
  import { BuiltinDriverName, BuiltinDriverOptions } from 'unstorage';
3
4
 
4
5
  type StorageProvider = 'memory' | 'redis';
@@ -73,6 +74,7 @@ type CustomDriverName = string & {
73
74
  };
74
75
  type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName = any, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : any> = {
75
76
  driver: Driver;
77
+ compression?: CompressionEncodings;
76
78
  } & DriverOptions;
77
79
  interface StorageConfig {
78
80
  cache?: StorageEntity;
@@ -1,4 +1,5 @@
1
1
  import { LogLevel, HashAlgorithm, WithParams, ShopUser } from '@scayle/storefront-core';
2
+ import { CompressionEncodings } from '@scayle/unstorage-compression-driver';
2
3
  import { BuiltinDriverName, BuiltinDriverOptions } from 'unstorage';
3
4
 
4
5
  type StorageProvider = 'memory' | 'redis';
@@ -73,6 +74,7 @@ type CustomDriverName = string & {
73
74
  };
74
75
  type StorageEntity<Driver extends BuiltinDriverName | CustomDriverName = any, DriverOptions = Driver extends keyof BuiltinDriverOptions ? BuiltinDriverOptions[Driver] : any> = {
75
76
  driver: Driver;
77
+ compression?: CompressionEncodings;
76
78
  } & DriverOptions;
77
79
  interface StorageConfig {
78
80
  cache?: StorageEntity;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.42.2",
4
+ "version": "7.43.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -62,13 +62,15 @@
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.8.2",
64
64
  "@scayle/h3-session": "0.3.4",
65
- "@scayle/storefront-core": "7.28.1",
66
- "@vueuse/core": "10.6.1",
65
+ "@scayle/storefront-core": "7.29.0",
66
+ "@scayle/unstorage-compression-driver": "0.1.1",
67
+ "@vueuse/core": "10.7.0",
67
68
  "consola": "3.2.3",
68
- "core-js": "3.33.3",
69
+ "core-js": "3.34.0",
69
70
  "defu": "6.1.3",
70
71
  "h3": "1.9.0",
71
72
  "jose": "4.15.4",
73
+ "knitwork": "1.0.0",
72
74
  "nitropack": "2.8.1",
73
75
  "ofetch": "1.3.3",
74
76
  "radash": "11.0.0",
@@ -83,15 +85,15 @@
83
85
  "@nuxt/test-utils": "3.8.1",
84
86
  "@scayle/eslint-config-storefront": "3.2.5",
85
87
  "@scayle/prettier-config-storefront": "2.0.2",
86
- "@types/node": "20.10.1",
87
- "eslint": "8.54.0",
88
+ "@types/node": "20.10.4",
89
+ "eslint": "8.55.0",
88
90
  "eslint-formatter-gitlab": "5.1.0",
89
91
  "node-mocks-http": "1.13.0",
90
92
  "nuxt": "3.8.2",
91
93
  "prettier": "3.0.0",
92
- "publint": "0.2.5",
93
- "vitest": "0.34.6",
94
- "vue-tsc": "1.8.24"
94
+ "publint": "0.2.6",
95
+ "vitest": "1.0.2",
96
+ "vue-tsc": "1.8.25"
95
97
  },
96
98
  "peerDependencies": {
97
99
  "nuxt": ">=3.8.1",