The Vue Storefront Essentials Course is now available! Learn More
Customer normalizer

Customer normalizer

The normalizeCustomer function is used to map a SFCC Customer into the unified SfCustomer data model.

Parameters

NameTypeDefault valueDescription
userCustomerSFCC Customer

Extending

The SfCustomer model is returned from Unified Methods such as RegisterCustomer, LoginCustomer and GetCustomer. If the SfCustomer structure doesn't contain the information you need for your Storefront, you can extend its logic using the defineNormalizers function. The following example demonstrates how to extend SfCustomer with a job_title field.

import { normalizers as normalizersSFCC, defineNormalizers } from "@vsf-enterprise/unified-api-sfcc";

const normalizers = defineNormalizers<typeof normalizersSFCC>()({
  ...normalizersSFCC,
  normalizeCustomer: (user) => ({
    ...normalizersSFCC.normalizeCustomer(user),
    job_title: user.jobTitle,
  }),
});

Source

SFCC Customer have some fields optional on the interface, but in the reality a valid Customer should contain a customerId, email, firstName, and lastName, so if any of these information is missing, normalizer returns an error.

🔴 ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/auth/customer.ts | Snippet does not exist 🔴