@commercetools/frontend-sdk
Advanced tools
Comparing version 1.11.2 to 1.12.0
## Version 1.12.0 (2024-05-14) | ||
* Added support to add coFE-Custom-Configuration header value globally via configure, and modually on callAction and PageAPI methods | ||
## Version 1.11.2 (2024-05-02) | ||
@@ -3,0 +8,0 @@ |
@@ -715,2 +715,3 @@ "use strict"; | ||
#sessionLifetime; | ||
#customHeaderValue; | ||
set endpoint(url) { | ||
@@ -772,2 +773,5 @@ url = this.#normaliseUrl(url); | ||
} | ||
get customHeaderValue() { | ||
return this.#customHeaderValue; | ||
} | ||
constructor() { | ||
@@ -798,2 +802,4 @@ super(); | ||
* @param {string} [config.sessionLifetime=7776000000] - An optional number of milliseconds in which to persist the session lifeTime, to override the {@link DEFAULT_SESSION_LIFETIME} of 3 months. | ||
* | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods. | ||
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods. | ||
@@ -812,2 +818,3 @@ * | ||
this.#sessionLifetime = config.sessionLifetime ?? DEFAULT_SESSION_LIFETIME; | ||
this.#customHeaderValue = config.customHeaderValue; | ||
this.#hasBeenConfigured = true; | ||
@@ -864,3 +871,5 @@ } | ||
} | ||
#getDefaultAPIHeaders() { | ||
#getDefaultAPIHeaders(customHeaderValue) { | ||
const customValue = customHeaderValue ?? this.#customHeaderValue; | ||
const customHeader = customValue ? { "coFE-Custom-Configuration": customValue } : {}; | ||
return { | ||
@@ -871,3 +880,4 @@ "Frontastic-Locale": this.apiHubLocale, | ||
"Commercetools-Frontend-Extension-Version": this.#extensionVersion | ||
} : {} | ||
} : {}, | ||
...customHeader | ||
}; | ||
@@ -882,2 +892,3 @@ } | ||
* @param {boolean} [options.skipQueue] - An optional boolean, default false indicating whether or not to skip the action queue and execute fully asyncronously. May cause race conditions if used incorrectly. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -894,3 +905,3 @@ * | ||
body: JSON.stringify(options.payload), | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -949,3 +960,3 @@ let response; | ||
"Frontastic-Path": options.path, | ||
...this.#getDefaultAPIHeaders() | ||
...this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
} | ||
@@ -991,3 +1002,3 @@ }; | ||
method: "POST", | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -1036,3 +1047,3 @@ let response; | ||
method: "POST", | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -1039,0 +1050,0 @@ let response; |
@@ -32,2 +32,3 @@ import { EventManager } from './EventManager.js'; | ||
cookieHandlingOverride?: CookieManager; | ||
customHeaderValue?: string; | ||
}; | ||
@@ -59,2 +60,3 @@ declare class SDK<ExtensionEvents extends Events> extends EventManager<StandardEvents & ExtensionEvents> { | ||
get currency(): Currency; | ||
get customHeaderValue(): string | undefined; | ||
constructor(); | ||
@@ -70,2 +72,4 @@ /** | ||
* @param {string} [config.sessionLifetime=7776000000] - An optional number of milliseconds in which to persist the session lifeTime, to override the {@link DEFAULT_SESSION_LIFETIME} of 3 months. | ||
* | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods. | ||
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods. | ||
@@ -92,2 +96,3 @@ * | ||
* @param {boolean} [options.skipQueue] - An optional boolean, default false indicating whether or not to skip the action queue and execute fully asyncronously. May cause race conditions if used incorrectly. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -102,2 +107,3 @@ * | ||
skipQueue?: boolean; | ||
customHeaderValue?: string; | ||
serverOptions?: ServerOptions; | ||
@@ -104,0 +110,0 @@ }): Promise<SDKResponse<ReturnData>>; |
@@ -495,2 +495,3 @@ "use strict"; | ||
#sessionLifetime; | ||
#customHeaderValue; | ||
set endpoint(url) { | ||
@@ -552,2 +553,5 @@ url = this.#normaliseUrl(url); | ||
} | ||
get customHeaderValue() { | ||
return this.#customHeaderValue; | ||
} | ||
constructor() { | ||
@@ -578,2 +582,4 @@ super(); | ||
* @param {string} [config.sessionLifetime=7776000000] - An optional number of milliseconds in which to persist the session lifeTime, to override the {@link DEFAULT_SESSION_LIFETIME} of 3 months. | ||
* | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods. | ||
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods. | ||
@@ -592,2 +598,3 @@ * | ||
this.#sessionLifetime = config.sessionLifetime ?? DEFAULT_SESSION_LIFETIME; | ||
this.#customHeaderValue = config.customHeaderValue; | ||
this.#hasBeenConfigured = true; | ||
@@ -644,3 +651,5 @@ } | ||
} | ||
#getDefaultAPIHeaders() { | ||
#getDefaultAPIHeaders(customHeaderValue) { | ||
const customValue = customHeaderValue ?? this.#customHeaderValue; | ||
const customHeader = customValue ? { "coFE-Custom-Configuration": customValue } : {}; | ||
return { | ||
@@ -651,3 +660,4 @@ "Frontastic-Locale": this.apiHubLocale, | ||
"Commercetools-Frontend-Extension-Version": this.#extensionVersion | ||
} : {} | ||
} : {}, | ||
...customHeader | ||
}; | ||
@@ -662,2 +672,3 @@ } | ||
* @param {boolean} [options.skipQueue] - An optional boolean, default false indicating whether or not to skip the action queue and execute fully asyncronously. May cause race conditions if used incorrectly. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -674,3 +685,3 @@ * | ||
body: JSON.stringify(options.payload), | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -729,3 +740,3 @@ let response; | ||
"Frontastic-Path": options.path, | ||
...this.#getDefaultAPIHeaders() | ||
...this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
} | ||
@@ -771,3 +782,3 @@ }; | ||
method: "POST", | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -816,3 +827,3 @@ let response; | ||
method: "POST", | ||
headers: this.#getDefaultAPIHeaders() | ||
headers: this.#getDefaultAPIHeaders(options.customHeaderValue) | ||
}; | ||
@@ -819,0 +830,0 @@ let response; |
@@ -19,2 +19,3 @@ import { ServerOptions } from '../../cookieHandling/ServerOptions.js'; | ||
* @param {Object.<string, number, boolean, string[], number[], boolean[]>} [options.query] - An optional key, value pair object to be serialised into the url query. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link SDK.configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -27,2 +28,3 @@ * | ||
query?: AcceptedQueryTypes; | ||
customHeaderValue?: string; | ||
serverOptions?: ServerOptions; | ||
@@ -34,2 +36,3 @@ }) => Promise<SDKResponse<PageResponse>>; | ||
* @param {string} options.previewId - A string representing the ID of the preview to be fetched, likely to be acquired from a query in the visited URL. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link SDK.configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -41,2 +44,3 @@ * | ||
previewId: string; | ||
customHeaderValue?: string; | ||
serverOptions?: ServerOptions; | ||
@@ -50,2 +54,3 @@ }) => Promise<SDKResponse<PagePreviewResponse>>; | ||
* @param {string} [options.types="static"] - An optional string with a default value of "static". The types of pages to fetch. | ||
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value. Overrides customHeaderValue passed in {@link SDK.configure}. | ||
* @param {Object} [options.serverOptions] - An optional object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management. | ||
@@ -59,2 +64,3 @@ * | ||
types?: "static"; | ||
customHeaderValue?: string; | ||
serverOptions?: ServerOptions; | ||
@@ -61,0 +67,0 @@ }) => Promise<SDKResponse<PageFolderListResponse>>; |
{ | ||
"name": "@commercetools/frontend-sdk", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475438
5975