Update types (#831)

* Update product types

* Cart types progress, add zod & initial schema validator

* Update normalize.ts

* Update with-schema-parser.ts

* Updated types, schemas & providers

* Fix providers after schema parse errors

* Fix paths

* More provider fixes

* Fix kibocommerce & commercejs

* Add customer updated types & fixes

* Add checkout & customer types

* Import core types only from commerce

* Update tsconfig.json

* Convert hooks interfaces to types

* Requested changes

* Change to relative paths

* Move Zod dependency
This commit is contained in:
Catalin Pinte
2022-10-05 09:02:29 +03:00
committed by GitHub
parent 8398a96215
commit 6c2610584d
291 changed files with 1992 additions and 1808 deletions

View File

@@ -1,7 +1,6 @@
import { Product as SFCCProduct, Search } from 'commerce-sdk'
import type {
Product,
ProductImage,
ProductOption,
ProductVariant,
} from '@vercel/commerce/types/product'
@@ -58,15 +57,16 @@ export function normalizeProduct(
// TODO: use `name-ID` as a virtual slug (for search 1:1)
slug: product.id, // use product ID as a slug
name: product.name!,
path: `/${product.id}`,
description: product.longDescription!,
price: {
value: product.price!,
currencyCode: product.currency,
},
images: product.imageGroups![0].images.map((image) => ({
url: image.disBaseLink,
altText: image.title,
})) as ProductImage[],
url: image.disBaseLink || image.link,
alt: image.title || '',
})),
variants: normaliseVariants(product.variants),
options: normaliseOptions(product.variationAttributes),
}
@@ -78,6 +78,7 @@ export function normalizeSearchProducts(
return products.map((product) => ({
id: product.productId,
slug: product.productId, // use product ID as a slug
path: `/${product.productId}`,
name: product.productName!,
description: '',
price: {
@@ -87,8 +88,8 @@ export function normalizeSearchProducts(
images: [
{
url: product.image!.link,
altText: product.productName,
} as ProductImage,
alt: product.productName,
},
],
variants: normaliseVariants(product.variants),
options: normaliseOptions(product.variationAttributes),