@vsf-enterprise/unified-api-sapcc
4.0.0ri:link
Major Changesri:link
Update the middleware to 5.1.0
3.2.3ri:link
Patch Changesri:link
- CHANGED the version of
@vsf-enterprise/sapcc-api
to^8.1.0
. It allows to use the new feature - customizable header names.
3.2.2ri:link
Patch Changesri:link
- CHANGED Minor improvements in type declarations.
3.2.1ri:link
Patch Changesri:link
- FIXED: Added the missing utils: slugify, maybe, graphqlTypeGuardFactory
3.2.0ri:link
Minor Changesri:link
- FIXED Algolia and B2B methods recursively references itself error.
3.1.2ri:link
Patch Changesri:link
- CHANGED: Upgraded
@vsf-enterprise/sapcc-api
to v8.0.6 that fixes the token renew issue.
3.1.1ri:link
Patch Changesri:link
- FIXED Re-export unified-data-model methods after accidental removal.
3.1.0ri:link
Minor Changesri:link
- ADDED: Refactored
NormalizerContext
to be an interface. Now you can use declaration merging to extend theNormalizerContext
typings when you're usingassignToNormalizerContext
function.
import {
assignToNormalizerContext,
getNormalizers,
} from "@vue-storefront/unified-api-<integration>";
declare module "@vue-storefront/unified-api-<integration>" {
interface NormalizerContext {
sku?: string;
}
}
async function getProduct(context, args) {
const product = await context.api.getProduct({ id: productId.id });
const { normalizeProduct } = getNormalizers(context);
assignToNormalizerContext(context, {
sku: product.sku,
});
return normalizeProduct(product);
}
- ADDED: Exported helpers need by
SearchProducts
API Method. Exported alsogetCategorySlug
helper, typeCategoryWithParentCode
andassignToNormalizerContext
function from UDL.
Patch Changesri:link
- ADDED re-export SfContract from unified-data-model
3.0.1ri:link
Patch Changesri:link
- FIXED order normalizer will no longer throw error if there are no products in the order
3.0.0ri:link
Major Changesri:link
- CHANGED Update
sapcc-api
dependencies to8.0.0
andvue-storefront/middleware
to^4.0.0
2.0.0ri:link
Major Changesri:link
- BREAKING Updated peerDependencies:
@vue-storefront/middleware
version to^4.0.0
.@vsf-enterprise/sapcc-api
version to^7.0.0
.@vsf-enterprise/sapcc-types
version to^3.0.0
.
Make sure this versions are used in your project.
{
...
"dependencies": {
- "@vsf-enterprise/sapcc-api": "4.x.x",
+ "@vsf-enterprise/sapcc-api": "7.0.0"
- "@vsf-enterprise/sapcc-types": "2.x.x",
+ "@vsf-enterprise/sapcc-types": "3.0.0"
- "@vue-storefront/middleware": "3.x.x",
+ "@vue-storefront/middleware": "4.2.0"
}
}
1.0.3ri:link
Patch Changesri:link
- FIXED
registerCustomer
api method for ASM, now properly sets user id after registration
1.0.2ri:link
Patch Changesri:link
- CHANGED the
logoutCustomer
method to work with ASM
1.0.1ri:link
Patch Changesri:link
- FIXED SAPCC Integration Context type
- CHANGED
registerCustomer
api method now don't create new token if one already exists
1.0.0ri:link
Major Changesri:link
The version v1.0.0
of @vsf-enterprise/unified-api-[commerce]
packages brings the following changes:
- ✨ Simplified the extension initialization
- 🛠️ A new
addCustomFields
API which simplifies adding custom fields to the normalizers - ⚠️ Deprecation of the
unifiedSdk
- 🔄 Redefined a way to add custom methods
- 🔍 New utilities such as
defineNormalizer
which allow you to override the normalizer with the inferred typed of the raw data
Migrationri:link
If you are interested in migrating to the new version, check the Migration guide page.
Simplified the extension initializationri:link
There is no need to pass the generics to the createUnifiedExtension
, nor to pass the default normalizers and methods. Now all of them are built into the extension.
In examples, we are using sapcc package. Remember to replace it with the name of the commerce you are using.
- import {
- Config,
- Context,
- createUnifiedExtension,
- methods,
- normalizers,
- } from "@vsf-enterprise/unified-api-sapcc";
+ import { createUnifiedExtension } from "@vsf-enterprise/unified-api-sapcc";
- export const unifiedApiExtension = createUnifiedExtension<Context, Config>()({
- normalizers,
- apiMethods: {
- ...apiMethods,
- },
+ export const unifiedApiExtension = createUnifiedExtension({
+ normalizers: {
+ addCustomFields: [{}],
+ },
config: {
...
},
});
addCustomFields
APIri:link
The addCustomFields
API allows you to add custom fields to the normalizers. The defineNormalizers
utility have been removed and replaced with this API.
Before:
import { normalizers as normalizersSAP, defineNormalizers } from "@vsf-enterprise/unified-api-sapcc";
const normalizersSAP = defineNormalizers<typeof normalizersSAP>()({
...normalizersSAP,
normalizeProductCatalogItem: (rawProduct) => ({
...normalizersSAP.normalizeProductCatalogItem(product, context),
description: rawProduct.description,
}),
});
export const unifiedApiExtension = createUnifiedExtension<Context, Config>()({
normalizers,
apiMethods: {
...apiMethods,
},
config: {
...
}
});
Now:
export const unifiedApiExtension = createUnifiedExtension({
normalizers: {
addCustomFields: [
{
normalizeProductCatalogItem: (context, rawProduct) => ({
description: rawProduct.description,
}),
},
],
},
config: {
...
},
});
addCustomFields
is an array, so you can easily split the custom fields into separate files or import the custom fields from other packages.
import { customFields } from "@example/module";
import { productCustomFields, cartCustomFields } from "./customFields";
export const unifiedApiExtension = createUnifiedExtension({
normalizers: {
addCustomFields: [
productCustomFields,
cartCustomFields,
customFields,
],
},
config: {
...
},
});
If you want to override the default normalizers, you can use the override
key:
import { normalizers } from "@vsf-enterprise/unified-api-sapcc";
export const unifiedApiExtension = createUnifiedExtension({
normalizers: {
override: {
normalizeProductCatalogItem: (context, rawProduct) => ({
// to call the default normalizer
...normalizers.normalizeProductCatalogItem(context, rawProduct),
name: `${rawProduct.name} - ${rawProduct.sku}`,
}),
},
},
config: {
...
},
});
Deprecation of the unifiedSdk
ri:link
The @vsf-enterprise/unified-sdk
package has been deprecated. Now the same functionality can be achieved by using the @vue-storefront/sdk
.
- import { unifiedModule } from '@vsf-enterprise/unified-sdk';
import { CreateSdkOptions, createSdk } from '@vue-storefront/next';
- import { UnifiedApiExtension } from 'storefront-middleware/middleware.config';
+ import { UnifiedEndpoints } from 'storefront-middleware/middleware.config';
-export const { getSdk } = createSdk(options, ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
+export const { getSdk } = createSdk(options, ({ buildModule, middlewareUrl, getRequestHeaders, middlewareModule }) => ({
- unified: buildModule(unifiedModule<UnifiedApiExtension>, {
+ unified: buildModule(middlewareModule<UnifiedEndpoints>, {
apiUrl: `${middlewareUrl}/commerce`,
- requestOptions: {
- headers: () => getRequestHeaders() as Record<string, string>,
+ defaultRequestConfig: {
+ headers: getRequestHeaders(),
},
}),
The middlewareModule
can be used with any other extension, not only the Unified. It requires an endpoints type to be passed as a generic. An endpoint is just a record containing names of the methods and its contract:
export type MyEndpoints = {
getProduct: (params: { id: string }) => Promise<Product>;
};
Redefined a way to add custom methodsri:link
Thanks to the middlewareModule
you can now add custom methods to the SDK, by just implementing a new extension to the middleware.
import type { ContextualizedEndpoints, SAPIntegrationContext } from "@vsf-enterprise/sapcc-api"
export const customMethodsExtension = {
name: "customMethods",
extendApiMethods: {
getProduct: async (context, params: { id: string }) => {
// your implementation
},
},
} satisfies ApiClientExtension<ContextualizedEndpoints, SAPIntegrationContext>;
// the Endpoints type can be written manually, or inferred from the extension
export type CustomMethodsEndpoints = WithoutContext<CustomMethodsExtension["extendApiMethods"]>;
export const config = {
location: "@vsf-enterprise/sapcc-api/server",
configuration: {
...
},
extensions: (extensions: ApiClientExtension[]) => [
...extensions,
unifiedApiExtension,
// register your extension in extensions array
customMethodsExtension,
],
} satisfies Integration<MiddlewareConfig>;
Then you can use it on the Storefront side, in the sdk.config.ts
file add the new module:
unified: buildModule(middlewareModule<UnifiedEndpoints>, {
apiUrl: `${middlewareUrl}/commerce`,
defaultRequestConfig: {
headers: getRequestHeaders(),
},
}),
+ customExtension: buildModule(middlewareModule<CustomMethodsEndpoints>, {
+ apiUrl: `${middlewareUrl}/commerce`,
+ defaultRequestConfig: {
+ headers: getRequestHeaders(),
+ },
+ }),
cms: buildModule(contentfulModule, {
apiUrl: `${middlewareUrl}/cntf`,
}),
You can now call the new method in the application:
sdk.customMethods.getProduct({ id: "123" });
This change is important in terms of the createUnifiedExtension
API. Our goal is to make a clear separation between the Unified Methods, which are shared across all supported eCommerce backends, and your custom methods. This approach should help you in the future if you will decide to migrate to another eCommerce.
Now you you should implement every non-Unified Method in a separate extension.
export const unifiedApiExtension = createUnifiedExtension<Context, Config>()({
apiMethods: {
...apiMethods,
- customMethod: async (context, params) => {...}
},
})
export const customMethodsExtension = {
name: "customMethods",
extendApiMethods: {
getProduct: async (context, params: { id: string }) => {
// your implementation
},
+ customMethod: async (context, params) => {...}
},
} satisfies ApiClientExtension<ContextualizedEndpoints, SAPIntegrationContext>;
If you want to override the Unified Method, you can use the override
key:
export const unifiedApiExtension = createUnifiedExtension({
apiMethods: {
override: {
getProduct: async (context, params) => {
// your implementation
},
},
},
});
Please remember that in this case, the parameters and return type of the method should be the same as in the Unified Method.
New utilitiesri:link
defineNormalizer
ri:link
You can split the override normalizer entries into separate variables. To get proper typings, you can use the defineNormalizer
utility.
import { normalizers, defineNormalizer } from "@vsf-enterprise/unified-api-sapcc";
const normalizeProductCatalogItem = defineNormalizer.normalizeProductCatalogItem((context, rawProduct) => ({
// to call the default normalizer
...normalizers.normalizeProductCatalogItem(context, rawProduct),
name: `${rawProduct.name} - ${rawProduct.sku}`,
}));
export const unifiedApiExtension = createUnifiedExtension({
normalizers: {
override: {
normalizeProductCatalogItem,
},
},
config: {
...
},
});
defineAddCustomFields
ri:link
Similarly, you can use the defineAddCustomFields
utility to split the custom fields into separate variables.
import { defineAddCustomFields } from "@vsf-enterprise/unified-api-sapcc";
const productCustomFields = defineAddCustomFields({
normalizeProductCatalogItem: (context, rawProduct) => ({
description: rawProduct.description,
}),
});
export const unifiedApiExtension = createUnifiedExtension({
normalizers: {
addCustomFields: [productCustomFields],
},
config: {
...
},
});
Patch Changesri:link
- ADDED
beforeCall
hook to Unified Extension, which set thedefaultCurrency
forvsf-locale
, whenvsf-locale
is empty. - ADDED export
getNormalizers
from package
1.0.0-rc.2ri:link
Patch Changesri:link
- ADDED export
getNormalizers
from package
1.0.0-rc.1ri:link
Major Changesri:link
First draft of v1.0.0
Patch Changesri:link
- ADDED
beforeCall
hook to Unified Extension, which set thedefaultCurrency
forvsf-locale
, whenvsf-locale
is empty.
1.0.0-rc.0ri:link
Major Changesri:link
Internal draft of v1.0.0
0.22.4ri:link
Patch Changesri:link
- CHANGED
loginCustomer
returns 403, when customer is already logged in. - FIXED clear customer token on login error.
- FIXED After
loginCustomer
orregisterCustomer
, if the guest cart is not empty, it will be set as the customer cart. Previously a new, empty, cart was created for the customer every time they logged in or registered.
0.22.3ri:link
Patch Changesri:link
- CHANGED Removed check for
state
field inunnormalizeAddress
. Now it's optional.
0.22.2ri:link
Patch Changesri:link
- ADDED
beforeCall
hook to Unified Extension, which set thedefaultCurrency
forvsf-locale
, whenvsf-locale
is empty.
0.22.1ri:link
Patch Changesri:link
- FIXED Product Gallery returns large images.
0.22.0ri:link
Minor Changesri:link
- ADDED
defineNormalizer
utility which helps in overriding the normalizers. It should be used only when you want to override the default normalizers. If you want to add custom fields, you should still declare the normalizer within thedefineNormalizers
.
import {
defineNormalizer,
normalizers as normalizersSAP,
defineNormalizers,
} from "@vsf-enterprise/unified-api-sapcc";
const customNormalizeProduct = defineNormalizer.normalizeProduct((rawProduct, ctx) => {
// your implementation goes here, no custom fields
});
const normalizers = defineNormalizers<typeof normalizersSAP>()({
...normalizersSAP,
normalizeProduct: customNormalizeProduct,
normalizeCart: (cart, context) => ({
...normalizersSAP.normalizeCart(cart, context),
// still use inline normalizer to add custom fields
version: cart.version,
}),
});
- ADDED
normalizers
toNormalizerContext
. You can now access the other normalizers from the context. This is useful when you want to reuse the existing normalizers in your custom normalizer.
const customNormalizeProduct = defineNormalizer.normalizeProduct((rawProduct, ctx) => {
// ctx.normalizers.normalizeMoney is now available
});
- REMOVED
normalizeAttributes
fromnormalizersSAP
. Now anormalizeAttribute
should be used instead. ThenormalizeAttribute
accepts as an inputVariantOptionQualifier
.
Patch Changesri:link
- FIXED Normalizers such as
normalizeMoney
can be now overridden globally. This is useful when you want to change the way the money is represented accross the whole Unified extension.
0.21.3ri:link
Patch Changesri:link
- FIXED clear customer token on login error
0.21.2ri:link
Patch Changesri:link
- FIXED Allow empty string as a valid last name in
normalizeCustomer
- CHANGED B2B method
getCustomer
is checking if user is authenticated before sending request to api and B2BloginCustomer
is returning 403 if user is already logged in
0.21.1ri:link
Patch Changesri:link
- CHANGED
isAuthenticated
andassertAuthorized
, added check of theAUTH_USER_ID_COOKIE_NAME
cookie value
0.21.0ri:link
Minor Changesri:link
- ADDED
@vsf-enterprise/unified-api-sapcc/b2b
subpath export with Unified Methods implementation for SAP Commerce Cloud B2B
import { apiMethods as b2bApiMethods } from '@vsf-enterprise/unified-api-sapcc/b2b';
const unifiedApiExtension = createUnifiedExtension<Context>()({
normalizers,
apiMethods: {
...methods<typeof normalizers>(),
...b2bApiMethods<typeof normalizers>();
}
});
As some of the SAP Commerce Cloud API endpoints are the same for B2C and B2B, the b2bApiMethods
will override only the implementation for:
getCustomer
loginCustomer
updateCustomer
addCartLineItem
updateCartLineItem
As the B2B methods implement the same contract of the Unified Methods as B2C methods, there is no need to change the Storefront code.
0.20.0ri:link
Minor Changesri:link
- 724a3a2: Exported NormalizerContext type
Patch Changesri:link
- ce51cd4: Fixed issue with infinite loop of getting new cart. Now active cart is found by lack of
saveTime
andsavedBy
attribute.
0.19.1ri:link
Patch Changesri:link
- adc5bf9: Updated @vsf-enterprise/sapcc-api peerDependency to 4.2.1 as minimal version
0.19.0ri:link
Minor Changesri:link
- 2ac49bc: For
@vsf-enterprise/unified-api-sapcc/algolia
:- Fixed the Algolia record schema, by making
images
andprices
optional - Added a request context as a second argument of
getFacetLabel
andindexName
- Fixed the Algolia record schema, by making
0.18.0ri:link
Minor Changesri:link
- 82a761c: -
Unified Data Model
model and methods integration.- UDM extension import:
import { createUnifiedExtension } from "@vsf-enterprise/unified-api-sapcc"
- UDM model types import:
import { SfCategory, GetCategory } from "@vsf-enterprise/unified-api-sapcc"
- UDM extension import:
0.17.1ri:link
Patch Changesri:link
- 645259e: Changed the return value from
paymentMethod
in theorder
normalizer. Return"ACCOUNT"
ifcostCenter
is true, otherwise returns"CARD"
. - Updated dependencies 645259e
- @vue-storefront/unified-data-model@0.17.0
0.17.0ri:link
Minor Changesri:link
- 713734b: Added support for Algolia. A separate sub-package available as
@vsf-enterprise/unified-api-sapcc/algolia
. Using this API methods you can easily replace the searchProduct endpoint to the one based on the Algolia API. For further information check the Algolia Integration chapter in the docs.
0.16.0ri:link
Minor Changesri:link
- 98c8e77: Add new field
categoryParentId
to theSfCategory
model.
0.15.2ri:link
Patch Changesri:link
- a856688: Updated unnormalizeAddres function to match new type reqiurements
0.15.1ri:link
Patch Changesri:link
- 459d20a: Update dependencies
0.15.0ri:link
Minor Changesri:link
- 8401301: Integrated normalization methods from the
@vsf-enterprise/normalizer-sapcc
library. Update imports for normalizer methods as follows:import { normalizers } from "@vsf-enterprise/unified-api-sapcc"
0.14.0ri:link
Minor Changesri:link
- a912cf6: - Update
searchProducts()
API method:- remove
categoryHierarchy
,currentCategory
&subCategories
fields - Remove
productCount
field fromSfCategory
- remove
Patch Changesri:link
- Updated dependencies a912cf6
- @vsf-enterprise/normalizer-sapcc@0.9.0
0.13.0ri:link
Minor Changesri:link
- d514fe7: Implement a new
GetCategory
method which allows to get the category and its ancestors by category id.
0.12.0ri:link
Minor Changesri:link
- d3b0594: The searchProducts endpoint is updated to match the updated behavior of the
unified-data-model
. Removed the "latest" from the translated sort options, but it's still available using the value required by SAPCC API (topRated
). All non-standard sorting options are passing by directly to the API request now.
0.11.2ri:link
Patch Changesri:link
- 1f52ffa: Update dependencies
0.11.1ri:link
Patch Changesri:link
- 0e4f4cc: - Fixed arguments encoding in
getProductDetails
.
0.11.0ri:link
Minor Changesri:link
- bc2cdc7: Support
cartId
argument in cart methods.
0.10.2ri:link
Patch Changesri:link
- 81dd649: Fixes:
SfCart#id
normalization for authenthicated user. Previously a correct value was stored in the cookie, but the normalized object used incorrectlyguid
as a cart id. Now it usescode
for authenthicated user andguid
for guest user.Cannot read properties of undefined (reading 'flatMap')
error thrown fromgetProductDetails
method, when the product has undefinedbaseOptions
.
Added a newisAuthenticated
boolean flag to thenormalizerContext
.
0.10.1ri:link
Patch Changesri:link
- a2c442b: Fixed calculation of cartId in
addCartLineItem
, andupdateCartLineItem
methods for logged in customer
0.10.0ri:link
Minor Changesri:link
- 6a3e0e8: Customize
SfFacet
type withgetFacetType
config method. Filter outfacets
data fromsearchProducts
API method withfilterFacets
config method.
Patch Changesri:link
- Updated dependencies 6a3e0e8
- @vsf-enterprise/normalizer-sapcc@0.8.0
0.9.1ri:link
Patch Changesri:link
- f5d72f14: Update
unified-data-model
version
0.9.0ri:link
Minor Changesri:link
- 1df82d2c: Enhanced
getCurrencies
method to return current currency value - f5a32640: Unified error response for
changeCustomerPassword
. Now whencurrentPassword
is invalid, a 403 error response will be returned.
Patch Changesri:link
- Updated dependencies 1df82d2c
- @vue-storefront/unified-data-model@0.10.0
0.8.0ri:link
Minor Changesri:link
- Add more flexibility to customizing the image urls. Previous
mediaHost
config option has been replaced with atransformImageUrl
option.
0.7.3ri:link
Patch Changesri:link
- Fix for handling lowercase coupon codes
0.7.2ri:link
Patch Changesri:link
- Fixed searchproduct method in
unified-api-sapcc
- Fix the issue with being not authenticated after account registration
0.7.1ri:link
Patch Changesri:link
- Update setCartAddress in unified-api-sapcc & unified-api-commercetools
0.7.0ri:link
Minor Changesri:link
- Export all commons functions, utilities and types
- PlaceOrder implementation in unified-api-commercetools & unified-api-sapcc
0.6.0ri:link
Minor Changesri:link
- Added GetOrders & GetOrderDetails endpoints and normalizers for Order, OrderLineItem & OrderListItem
Patch Changesri:link
- Updated dependencies:
- @vue-storefront/unified-data-model@0.7.0
- @vsf-enterprise/normalizer-sapcc@0.4.0
0.5.1ri:link
Patch Changesri:link
- Publish
src
directory - Updated dependencies:
- @vue-storefront/unified-data-model@0.6.0
0.5.0ri:link
Minor Changesri:link
- Introduce the possibility of overwrite the normalizers in unified extension. Also provide functions for creating unified extension & define normalizers in Middleware configuration.
Patch Changesri:link
- Fix unified-api-sap user session cart cookie
- Updated dependencies:
- @vue-storefront/unified-data-model@0.5.0
0.4.0ri:link
Minor Changesri:link
- Added implementation for customer address methods of
@vue-storefront/unified-data-model
:CreateCustomerAddress
UpdateCustomerAddress
GetCustomerAddresses
DeleteCustomerAddress
Patch Changesri:link
- Updated dependencies:
- @vsf-enterprise/normalizer-sapcc@0.3.0
- @vue-storefront/unified-data-model@0.4.0
0.3.0ri:link
Minor Changesri:link
- Implemented
updateCustomer
method for unified-api-sapcc
Patch Changesri:link
- Updated dependencies:
- @vue-storefront/unified-data-model@0.3.0
0.2.0ri:link
Minor Changesri:link
- Created normalizer for SfCustomer & 4 API methods for handling customer related actions
- Split
GetProducts
method into two methods:GetProducts
which allows to get specific products byids
orskus
- and
SearchProducts
which allows to search for products byfacets
,category
, andsearch
phrase with an option to paginate and sort results
Patch Changesri:link
- Fixed sortBy filter & pagination index
- Updated dependencies:
- @vsf-enterprise/normalizer-sapcc@0.2.0
- @vue-storefront/unified-data-model@0.2.0
0.1.0ri:link
Minor Changesri:link
- Stable version implementing
@vue-storefront/unified-data-model@0.1.0
0.0.4ri:link
Patch Changesri:link
- Updated dependencies:
- @vue-storefront/unified-data-model@0.1.0
- @vsf-enterprise/normalizer-sapcc@0.1.1
0.0.3ri:link
Patch Changesri:link
- Updated dependencies:
- @vsf-enterprise/unified-data-model@0.5.0
- @vsf-enterprise/normalizer-sapcc@0.1.0
0.0.2ri:link
Patch Changesri:link
- Updated dependencies:
- @vsf-enterprise/unified-actions@0.5.0
- @vsf-enterprise/unified-data-model@0.4.0
- @vsf-enterprise/normalizer-sapcc@0.0.2