@plentymarkets/shop-core 1.16.0 → 1.16.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.json
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
import type { Endpoints } from '@plentymarkets/shop-api';
|
|
1
2
|
/**
|
|
2
3
|
* Plugin to provide the SDK instance globally via $sdk singleton
|
|
3
4
|
* The SDK is initialized once and reused across requests using the NuxtApp instance
|
|
4
5
|
*/
|
|
5
6
|
declare const _default: import("#app").Plugin<{
|
|
6
|
-
sdk:
|
|
7
|
-
plentysystems:
|
|
8
|
-
|
|
9
|
-
context: {
|
|
10
|
-
requestSender: import("@vue-storefront/sdk").RequestSender;
|
|
11
|
-
};
|
|
12
|
-
} & object;
|
|
13
|
-
}>;
|
|
7
|
+
sdk: {
|
|
8
|
+
plentysystems: Endpoints;
|
|
9
|
+
};
|
|
14
10
|
}> & import("#app").ObjectPlugin<{
|
|
15
|
-
sdk:
|
|
16
|
-
plentysystems:
|
|
17
|
-
|
|
18
|
-
context: {
|
|
19
|
-
requestSender: import("@vue-storefront/sdk").RequestSender;
|
|
20
|
-
};
|
|
21
|
-
} & object;
|
|
22
|
-
}>;
|
|
11
|
+
sdk: {
|
|
12
|
+
plentysystems: Endpoints;
|
|
13
|
+
};
|
|
23
14
|
}>;
|
|
24
15
|
export default _default;
|
|
@@ -40,6 +40,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
40
40
|
httpClient: async (url, params, config) => {
|
|
41
41
|
return nuxtApp.runWithContext(async () => {
|
|
42
42
|
logger.log(`\u{1F4E1} making SDK request to ${url}`);
|
|
43
|
+
logger.verbose("\u{1F50D} request params: ", JSON.stringify(params));
|
|
44
|
+
logger.verbose("\u{1F9ED} from route: ", nuxtApp?._route?.path);
|
|
43
45
|
const freshHeaders = getHeaders();
|
|
44
46
|
const response = await OriginalHttpClient(url, params, {
|
|
45
47
|
...config,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isServer } from "../runtime.js";
|
|
2
2
|
import { updateSsrCookie } from "./sdk.helper.js";
|
|
3
|
+
import { isEvent, setHeader } from "h3";
|
|
3
4
|
export const buildSdkHeaders = (context) => {
|
|
4
5
|
const headers = {
|
|
5
6
|
...context.configId && { "x-config-id": context.configId },
|
|
@@ -19,11 +20,13 @@ export const handleSdkResponse = (context) => {
|
|
|
19
20
|
context.csrfToken.value = context.response.csrfToken;
|
|
20
21
|
}
|
|
21
22
|
if (isServer() && context.response?.setCookie) {
|
|
22
|
-
|
|
23
|
-
if (context.ssrContext?.event?.node?.res) {
|
|
23
|
+
if (isEvent(context.ssrContext?.event)) {
|
|
24
24
|
updateSsrCookie(context.ssrCookie, context.response.setCookie);
|
|
25
|
-
context.ssrContext.event.node.res.
|
|
26
|
-
|
|
25
|
+
if (!context.ssrContext.event.node.res.headersSent) {
|
|
26
|
+
context.logger.verbose("\u{1F36A} setting cookie header from response", JSON.stringify(context.response?.setCookie));
|
|
27
|
+
setHeader(context.ssrContext.event, "Access-Control-Expose-Headers", "Set-Cookie");
|
|
28
|
+
context.ssrContext.event.node.res.setHeader("Set-Cookie", context.response.setCookie);
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NuxtSSRContext } from '#app';
|
|
1
2
|
import type { Ref } from '#imports';
|
|
2
3
|
import type { createSdkLogger } from './sdk.logger.js';
|
|
3
4
|
export interface SdkHeaderContext {
|
|
@@ -14,6 +15,6 @@ export interface HandleSdkResponseContext {
|
|
|
14
15
|
response: any;
|
|
15
16
|
csrfToken: Ref<string>;
|
|
16
17
|
ssrCookie: Ref<string>;
|
|
17
|
-
ssrContext:
|
|
18
|
+
ssrContext: NuxtSSRContext | undefined;
|
|
18
19
|
logger: ReturnType<typeof createSdkLogger>;
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plentymarkets/shop-core",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
4
4
|
"description": "Core module for PlentyONE Shop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"test:types": "vue-tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@plentymarkets/shop-api": "^0.
|
|
48
|
+
"@plentymarkets/shop-api": "^0.151.0",
|
|
49
49
|
"@vue-storefront/sdk": "^3.4.1",
|
|
50
50
|
"cookie": "^1.0.2",
|
|
51
51
|
"js-sha256": "^0.11.0",
|