@plentymarkets/shop-core 1.22.0 → 1.22.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/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { ModuleOptions } from '../dist/runtime/types/module.js';
3
- export { Cookie, CookieGroup, CookieGroupFromNuxtConfig, Events, JsonCookie, LocalizationMessage, Notification, PaymentButtonComponent, PaymentButtonComponentProps, SSRMetrics, ShopCoreConfigInput } from '../dist/runtime/types/index.js';
3
+ export { CacheControlMeta, Cookie, CookieGroup, CookieGroupFromNuxtConfig, Events, JsonCookie, LocalizationMessage, Notification, PaymentButtonComponent, PaymentButtonComponentProps, SSRMetrics, ShopCoreConfigInput } from '../dist/runtime/types/index.js';
4
4
 
5
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
6
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.22.0",
4
+ "version": "1.22.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -113,7 +113,7 @@ export type ShopCoreConfig = ${genInlineTypeImport(projectRootResolver.resolve("
113
113
  filePath: buildDirectoryResolver.resolve("ModuleComponentRendering.vue")
114
114
  });
115
115
  addPlugin(resolver.resolve("./runtime/plugins/sdk"));
116
- addPlugin(resolver.resolve("./runtime/plugins/cache-control.server.ts"));
116
+ addPlugin(resolver.resolve("./runtime/plugins/cache-control.server"));
117
117
  addImports({
118
118
  name: "useSdk",
119
119
  as: "useSdk",
@@ -189,6 +189,11 @@ export type ShopCoreConfig = ${genInlineTypeImport(projectRootResolver.resolve("
189
189
  as: "defineShopCoreConfig",
190
190
  from: resolver.resolve("./runtime/utils/defineShopCoreConfig")
191
191
  });
192
+ addImports({
193
+ name: "getCacheControl",
194
+ as: "getCacheControl",
195
+ from: resolver.resolve("./runtime/utils/cacheHelper")
196
+ });
192
197
  }
193
198
  });
194
199
 
@@ -1,4 +1,5 @@
1
1
  import type { ShopCoreConfig } from '#build/shop-core.config';
2
+ import type { CacheControlMeta } from '@plentymarkets/shop-core';
2
3
 
3
4
  declare module '#app' {
4
5
  interface NuxtApp {
@@ -7,12 +8,8 @@ declare module '#app' {
7
8
  };
8
9
  }
9
10
  interface PageMeta {
10
- /** Cache-Control header value to set for this page, e.g. { type: 'public', maxAge: 30, staleWhileRevalidate: 900 } */
11
- cacheControl?: {
12
- maxAge: number;
13
- staleWhileRevalidate: number;
14
- type: 'public' | 'private'
15
- };
11
+ /** Cache-Control header value to set for this page. Prefer using getCacheControl() helper function to construct this value instead of setting it directly. */
12
+ cacheControl?: CacheControlMeta;
16
13
  }
17
14
  }
18
15
 
@@ -1,3 +1,8 @@
1
+ export type CacheControlMeta = {
2
+ type: 'public' | 'private';
3
+ maxAge: number;
4
+ staleWhileRevalidate: number;
5
+ };
1
6
  export type PaymentButtonComponent = {
2
7
  componentName: string;
3
8
  key?: string;
@@ -1 +1,15 @@
1
+ import type { CacheControlMeta } from '../types/index.js';
1
2
  export declare const getCacheControlMeta: (route: any) => string | false;
3
+ /**
4
+ * Resolves the cache control configuration by merging explicit config values,
5
+ * environment variables, and hardcoded defaults — in that order of priority.
6
+ *
7
+ * Priority (highest to lowest):
8
+ * 1. Explicit `config` argument
9
+ * 2. Environment variables (`CACHE_TYPE`, `CACHE_MAX_AGE`, `CACHE_STALE_WHILE_REVALIDATE`)
10
+ * 3. Hardcoded defaults: `type: 'public'`, `maxAge: 30`, `staleWhileRevalidate: 900`
11
+ *
12
+ * @param config - Optional partial cache control configuration to override defaults.
13
+ * @returns A fully resolved `CacheControlMeta` object.
14
+ */
15
+ export declare const getCacheControl: (config?: CacheControlMeta) => CacheControlMeta;
@@ -5,3 +5,10 @@ export const getCacheControlMeta = (route) => {
5
5
  if (typeof type !== "string" || typeof maxAge !== "number" || typeof staleWhileRevalidate !== "number") return false;
6
6
  return `${type}, max-age=${maxAge}, stale-while-revalidate=${staleWhileRevalidate}`;
7
7
  };
8
+ export const getCacheControl = (config) => {
9
+ return {
10
+ type: config?.type || process.env.CACHE_TYPE || "public",
11
+ maxAge: config?.maxAge || Number(process.env.CACHE_MAX_AGE) || 30,
12
+ staleWhileRevalidate: config?.staleWhileRevalidate || Number(process.env.CACHE_STALE_WHILE_REVALIDATE) || 900
13
+ };
14
+ };
package/dist/types.d.mts CHANGED
@@ -4,6 +4,6 @@ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { type Cookie, type CookieGroup, type CookieGroupFromNuxtConfig, type Events, type JsonCookie, type LocalizationMessage, type Notification, type PaymentButtonComponent, type PaymentButtonComponentProps, type SSRMetrics, type ShopCoreConfigInput } from '../dist/runtime/types/index.js'
7
+ export { type CacheControlMeta, type Cookie, type CookieGroup, type CookieGroupFromNuxtConfig, type Events, type JsonCookie, type LocalizationMessage, type Notification, type PaymentButtonComponent, type PaymentButtonComponentProps, type SSRMetrics, type ShopCoreConfigInput } from '../dist/runtime/types/index.js'
8
8
 
9
9
  export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.22.0",
3
+ "version": "1.22.2",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",