Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
middlewareModule
to createSdk
params.- import { UnifiedApiExtension } from "storefront-middleware/types"
+ import { UnifiedEndpoints } from "storefront-middleware/types"
export const { getSdk } = createSdk(
options,
- ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
- commerce: buildModule(unifiedModule<UnifiedApiExtension>, {
- apiUrl: `${middlewareUrl}/commerce`,
- requestOptions: {
- headers: getRequestHeaders,
+ ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
+ commerce: buildModule(middlewareModule<UnifiedEndpoints>, {
+ apiUrl: `${middlewareUrl}/commerce`,
+ defaultRequestConfig: {
+ headers: getRequestHeaders(),
},
}),
})
);
middlewareModule
to defineSdkConfig
params.- import { UnifiedApiExtension } from "storefront-middleware/types"
+ import { UnifiedEndpoints } from "storefront-middleware/types"
export default defineSdkConfig(
- ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
- commerce: buildModule(unifiedModule<UnifiedApiExtension>, {
- apiUrl: `${middlewareUrl}/commerce`,
- requestOptions: { headers: getRequestHeaders },
+ ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
+ commerce: buildModule(middlewareModule<UnifiedEndpoints>, {
+ apiUrl: `${middlewareUrl}/commerce`,
+ defaultRequestConfig: { headers: getRequestHeaders() },
}),
})
);
getCookieHeader
, use getRequestHeaders
insteadexport default defineSdkConfig(
- ({ buildModule, middlewareModule, middlewareUrl, getCookieHeader }) => ({
+ ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
commerce: buildModule(middlewareModule<UnifiedEndpoints>, {
apiUrl: `${middlewareUrl}/commerce`,
- defaultRequestConfig: { headers: getCookieHeader() }, // Only cookie header is included.
+ defaultRequestConfig: { headers: getRequestHeaders() }, // All headers are included.
}),
})
);
[CHANGED] Updated buildModule
function to work well with modules, whether they have optional or mandatory options.
Simplified how buildModule
is set up,
Added a new type, ModuleInitializerWithMandatoryOptions
.
712ba85a6: [ADDED] Adds WithoutContext type helper.
type ApiClientMethods = {
getProduct: (context: any, id: string) => Promise<Product>;
};
type Endpoints = WithoutContext<ApiClientMethods>;
set
method returns any
type and get
returns StoreConfig | undefined
. Also, MiddlewareConfiguration
type has been removed as it is no longer necessary.8ea533e05: [CHANGED] We standardized the way of creating and configuring multistore extension.
Previously, the extension was created by importing multistoreExtension
from @vue-storefront/multistore
and passing it to the extensions
function.
Configuration was passed to the extension by adding multistore
property to the configuration
object.
Now, the extension is created by calling createMultistoreExtension
from @vue-storefront/multistore
and passing the multistore configuration to it.
- import { multistoreExtension } from "@vue-storefront/multistore";
+ import { createMultistoreExtension } from "@vue-storefront/multistore";
import { multistoreConfig } from "./multistore.config";
export default {
integrations: {
sapcc: {
location: "@vue-storefront/sapcc-api/server",
configuration: {
// ...
- multistore: multistoreConfig,
},
extensions: (predefinedExtensions) => [
...predefinedExtensions,
- multistoreExtension,
+ createMultistoreExtension(multistoreConfig),
],
},
},
};
8ea533e05: [FIXED] singleton cache issue, previously the cache was a singleton which could lead to unexpected behaviour when extension was used in different integrations in parallel. Now, the cache is being created during extension creation, what ensures proper cache behaviour.
buildModule
function optional. It's not required for the buildModule
function to have the second argument. In some cases, when the first generic argument was provided, the second one was required.option
parameter type resolution in the buildModule
function was not working correctly. The options
parameter is now required or optional, depending on the module implementation.