@plentymarkets/shop-core 1.27.0 → 1.27.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 +1 -0
- package/dist/runtime/composables/useDynamicPaymentButtons.d.ts +2 -0
- package/dist/runtime/composables/useDynamicPaymentButtons.js +11 -1
- 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/types/render.d.ts +6 -0
- package/dist/runtime/utils/featureFlagsHelper.d.ts +1 -1
- package/dist/runtime/utils/featureFlagsHelper.js +1 -6
- package/dist/types.d.mts +1 -1
- package/package.json +2 -2
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 { CacheControlMeta, Cookie, CookieGroup, CookieGroupFromNuxtConfig, Events, ExtensionEntry, JsonCookie, LocalizationMessage, Notification, PaymentButtonComponent, PaymentButtonComponentProps, SSRMetrics, ShopCoreConfigInput } from '../dist/runtime/types/index.js';
|
|
3
|
+
export { CacheControlMeta, Cookie, CookieGroup, CookieGroupFromNuxtConfig, Events, ExtensionEntry, JsonCookie, LocalizationMessage, Notification, PaymentButtonComponent, PaymentButtonComponentProps, ReInitializePaymentButtonComponentProps, 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
|
@@ -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: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PaymentButtonComponent } from '../types/index.js';
|
|
2
2
|
export declare const useDynamicPaymentButtons: () => {
|
|
3
3
|
components: import("vue").Ref<PaymentButtonComponent[], PaymentButtonComponent[]>;
|
|
4
|
+
reInitializeComponents: import("vue").Ref<PaymentButtonComponent[], PaymentButtonComponent[]>;
|
|
4
5
|
addComponent: (component: PaymentButtonComponent) => void;
|
|
6
|
+
addReInitializeComponent: (component: PaymentButtonComponent) => void;
|
|
5
7
|
};
|
|
@@ -2,7 +2,8 @@ import { useState } from "nuxt/app";
|
|
|
2
2
|
import { toRefs } from "vue";
|
|
3
3
|
export const useDynamicPaymentButtons = () => {
|
|
4
4
|
const state = useState("useDynamicPaymentButtons", () => ({
|
|
5
|
-
components: []
|
|
5
|
+
components: [],
|
|
6
|
+
reInitializeComponents: []
|
|
6
7
|
}));
|
|
7
8
|
const addComponent = (component) => {
|
|
8
9
|
if (state.value.components.some(
|
|
@@ -12,8 +13,17 @@ export const useDynamicPaymentButtons = () => {
|
|
|
12
13
|
}
|
|
13
14
|
state.value.components.push(component);
|
|
14
15
|
};
|
|
16
|
+
const addReInitializeComponent = (component) => {
|
|
17
|
+
if (state.value.reInitializeComponents.some(
|
|
18
|
+
(stateComponent) => stateComponent.componentName === component.componentName
|
|
19
|
+
)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
state.value.reInitializeComponents.push(component);
|
|
23
|
+
};
|
|
15
24
|
return {
|
|
16
25
|
addComponent,
|
|
26
|
+
addReInitializeComponent,
|
|
17
27
|
...toRefs(state.value)
|
|
18
28
|
};
|
|
19
29
|
};
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import type { Order } from '@plentymarkets/shop-api';
|
|
1
2
|
export type CacheControlMeta = {
|
|
2
3
|
type: 'public' | 'private';
|
|
3
4
|
maxAge: number;
|
|
@@ -15,3 +16,8 @@ export type PaymentButtonComponentProps = {
|
|
|
15
16
|
disabled: boolean;
|
|
16
17
|
paymentKey?: string;
|
|
17
18
|
};
|
|
19
|
+
export type ReInitializePaymentButtonComponentProps = {
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
order: Order;
|
|
22
|
+
paymentKey?: string;
|
|
23
|
+
};
|
|
@@ -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
|
};
|
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 CacheControlMeta, type Cookie, type CookieGroup, type CookieGroupFromNuxtConfig, type Events, type ExtensionEntry, 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 ExtensionEntry, type JsonCookie, type LocalizationMessage, type Notification, type PaymentButtonComponent, type PaymentButtonComponentProps, type ReInitializePaymentButtonComponentProps, 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.27.
|
|
3
|
+
"version": "1.27.2",
|
|
4
4
|
"description": "Core module for PlentyONE Shop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@noble/hashes": "^2.0.1",
|
|
54
|
-
"@plentymarkets/shop-api": "^0.173.
|
|
54
|
+
"@plentymarkets/shop-api": "^0.173.1",
|
|
55
55
|
"@vue-storefront/sdk": "^3.4.1",
|
|
56
56
|
"cookie-es": "^2.0.0",
|
|
57
57
|
"knitwork": "^1.3.0",
|