@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.27.0",
4
+ "version": "1.27.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
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
- if (cacheControlValue && !isPreview) {
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
- flagsEnv: process.env.JSON_FEATURE_FLAGS
13
+ configFlags: runtimeConfig.public.shopCore.featureFlags
13
14
  });
14
15
  }
15
16
  });
@@ -2,6 +2,7 @@ export interface ModuleOptions {
2
2
  apiUrl: string;
3
3
  apiEndpoint: string;
4
4
  configId: number;
5
+ featureFlags?: Record<string, unknown>;
5
6
  experimental?: {
6
7
  enableSSRMetrics?: boolean;
7
8
  enablePlentyLogs?: boolean;
@@ -1,6 +1,6 @@
1
1
  export type LoadFeatureFlagsDeps = {
2
2
  readFile: (path: string, encoding: BufferEncoding) => Promise<string>;
3
3
  filePath: string;
4
- flagsEnv: string | undefined;
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
- try {
9
- const parsed = JSON.parse(deps.flagsEnv ?? "");
10
- if (isRecord(parsed)) return parsed;
11
- } catch {
12
- }
13
- return {};
8
+ return deps.configFlags ?? {};
14
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",