@plentymarkets/shop-core 1.27.0 → 1.27.1
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.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/plugins/cache-control.server.js +3 -1
- package/dist/runtime/plugins/feature-flags.server.js +3 -2
- package/dist/runtime/types/module.d.ts +1 -0
- package/dist/runtime/utils/featureFlagsHelper.d.ts +1 -1
- package/dist/runtime/utils/featureFlagsHelper.js +1 -6
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -170,6 +170,7 @@ const module$1 = defineNuxtModule({
|
|
|
170
170
|
enableSSRMetrics: _options.experimental?.enableSSRMetrics ?? false,
|
|
171
171
|
enablePlentyLogs: _options.experimental?.enablePlentyLogs ?? true
|
|
172
172
|
},
|
|
173
|
+
featureFlags: _options.featureFlags ?? {},
|
|
173
174
|
middlewareSSRUrl: _options.middlewareSSRUrl,
|
|
174
175
|
logger: {
|
|
175
176
|
sdkPlugin: {
|
|
@@ -2,6 +2,7 @@ import { defineNuxtPlugin, useCookie, useRequestEvent, useRuntimeConfig } from "
|
|
|
2
2
|
import { setResponseHeader } from "h3";
|
|
3
3
|
import { getCacheControlMeta } from "../utils/cacheHelper.js";
|
|
4
4
|
import { isServer } from "../utils/runtime.js";
|
|
5
|
+
import { useFeatureFlag } from "../composables/useFeatureFlag.js";
|
|
5
6
|
export default defineNuxtPlugin({
|
|
6
7
|
name: "shop-core:cache-control",
|
|
7
8
|
enforce: "post",
|
|
@@ -13,7 +14,8 @@ export default defineNuxtPlugin({
|
|
|
13
14
|
const pwaCookie = useCookie("pwa");
|
|
14
15
|
const cacheControlValue = getCacheControlMeta(nuxtApp.$router);
|
|
15
16
|
const isPreview = !!pwaCookie.value || !!runtimeConfig.public.isPreview;
|
|
16
|
-
|
|
17
|
+
const isCloudfrontEnabled = useFeatureFlag("shopPwaEnableCloudfront", false);
|
|
18
|
+
if (cacheControlValue && !isPreview && isCloudfrontEnabled.value) {
|
|
17
19
|
setResponseHeader(event, "Cache-Control", cacheControlValue);
|
|
18
20
|
} else {
|
|
19
21
|
setResponseHeader(event, "Cache-Control", "no-cache, no-store, must-revalidate");
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { defineNuxtPlugin, useState } from "#imports";
|
|
2
|
+
import { defineNuxtPlugin, useState, useRuntimeConfig } from "#imports";
|
|
3
3
|
import { loadFeatureFlags } from "../utils/featureFlagsHelper.js";
|
|
4
4
|
export default defineNuxtPlugin({
|
|
5
5
|
name: "shop-core:feature-flags",
|
|
6
6
|
enforce: "pre",
|
|
7
7
|
async setup() {
|
|
8
|
+
const runtimeConfig = useRuntimeConfig();
|
|
8
9
|
const flags = useState("feature-flags", () => ({}));
|
|
9
10
|
flags.value = await loadFeatureFlags({
|
|
10
11
|
readFile,
|
|
11
12
|
filePath: process.env.JSON_FEATURE_FLAGS_FILE ?? "/etc/plenty/feature-flags/flags.json",
|
|
12
|
-
|
|
13
|
+
configFlags: runtimeConfig.public.shopCore.featureFlags
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type LoadFeatureFlagsDeps = {
|
|
2
2
|
readFile: (path: string, encoding: BufferEncoding) => Promise<string>;
|
|
3
3
|
filePath: string;
|
|
4
|
-
|
|
4
|
+
configFlags?: Record<string, unknown>;
|
|
5
5
|
};
|
|
6
6
|
export declare const loadFeatureFlags: (deps: LoadFeatureFlagsDeps) => Promise<Record<string, unknown>>;
|
|
@@ -5,10 +5,5 @@ export const loadFeatureFlags = async (deps) => {
|
|
|
5
5
|
if (isRecord(parsed)) return parsed;
|
|
6
6
|
} catch {
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
const parsed = JSON.parse(deps.flagsEnv ?? "");
|
|
10
|
-
if (isRecord(parsed)) return parsed;
|
|
11
|
-
} catch {
|
|
12
|
-
}
|
|
13
|
-
return {};
|
|
8
|
+
return deps.configFlags ?? {};
|
|
14
9
|
};
|