@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 +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -1
- package/dist/runtime/templates/types.template +3 -6
- package/dist/runtime/types/render.d.ts +5 -0
- package/dist/runtime/utils/cacheHelper.d.ts +14 -0
- package/dist/runtime/utils/cacheHelper.js +7 -0
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
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
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
|
|
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
|
|
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 +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'
|