-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
314 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
type ErrorType = 'BadRequestError' | 'NotFoundError' | 'RedirectError' | ||
|
||
interface Extension { | ||
type: ErrorType | ||
status: number | ||
} | ||
|
||
class FastStoreError<T extends Extension = Extension> extends Error { | ||
constructor(public extensions: T, message?: string) { | ||
super(message) | ||
this.name = 'FastStoreError' | ||
} | ||
} | ||
|
||
export class BadRequestError extends FastStoreError { | ||
constructor(message?: string) { | ||
super({ status: 400, type: 'BadRequestError' }, message) | ||
} | ||
} | ||
|
||
export class NotFoundError extends FastStoreError { | ||
constructor(message?: string) { | ||
super({ status: 404, type: 'NotFoundError' }, message) | ||
} | ||
} | ||
|
||
export class RedirectError extends FastStoreError< | ||
Extension & { location: string; status: 301 | 302 } | ||
> { | ||
constructor(status: 301 | 302, location: string, message?: string) { | ||
super({ status, location, type: 'RedirectError' }, message) | ||
} | ||
} | ||
|
||
export const isFastStoreError = (error: any): error is FastStoreError => | ||
error?.name === 'FastStoreError' | ||
|
||
export const isRedirectError = (error: any): error is RedirectError => | ||
error?.extensions?.type === 'RedirectError' | ||
|
||
export const isNotFoundError = (error: any): error is NotFoundError => | ||
error?.extensions?.type === 'NotFoundError' | ||
|
||
export const isBadRequestError = (error: any): error is BadRequestError => | ||
error?.extensions?.type === 'BadRequestError' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
packages/api/src/platforms/vtex/clients/commerce/types/SearchResult.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
export interface SearchResult { | ||
productId: string | ||
productName: string | ||
brand: string | ||
brandId: number | ||
brandImageUrl: null | ||
linkText: string | ||
productReference: string | ||
productReferenceCode: null | ||
categoryId: string | ||
productTitle: string | ||
metaTagDescription: string | ||
releaseDate: Date | ||
clusterHighlights: any | ||
productClusters: ProductClusters | ||
searchableClusters: any | ||
categories: string[] | ||
categoriesIds: string[] | ||
link: string | ||
specification01: string[] | ||
specifications: string[] | ||
allSpecifications: string[] | ||
allSpecificationsGroups: string[] | ||
description: string | ||
items: Item[] | ||
} | ||
|
||
export interface Item { | ||
itemId: string | ||
name: string | ||
nameComplete: string | ||
complementName: string | ||
ean: string | ||
referenceId: ReferenceId[] | ||
measurementUnit: string | ||
unitMultiplier: number | ||
modalType: null | ||
isKit: boolean | ||
images: Image[] | ||
sellers: Seller[] | ||
videos: any[] | ||
estimatedDateArrival: null | ||
} | ||
|
||
export interface Image { | ||
imageId: string | ||
imageLabel: string | ||
imageTag: string | ||
imageUrl: string | ||
imageText: string | ||
imageLastModified: Date | ||
} | ||
|
||
export interface ReferenceId { | ||
key: string | ||
value: string | ||
} | ||
|
||
export interface Seller { | ||
sellerId: string | ||
sellerName: string | ||
addToCartLink: string | ||
sellerDefault: boolean | ||
commertialOffer: CommertialOffer | ||
} | ||
|
||
export interface CommertialOffer { | ||
deliverySlaSamplesPerRegion: DeliverySlaSamplesPerRegion | ||
installments: Installment[] | ||
discountHighLight: any[] | ||
giftSkuIds: any[] | ||
teasers: any[] | ||
buyTogether: any[] | ||
itemMetadataAttachment: any[] | ||
price: number | ||
listPrice: number | ||
priceWithoutDiscount: number | ||
rewardValue: number | ||
priceValidUntil: Date | ||
availableQuantity: number | ||
isAvailable: boolean | ||
tax: number | ||
deliverySlaSamples: DeliverySlaSample[] | ||
getInfoErrorMessage: null | ||
cacheVersionUsedToCallCheckout: string | ||
paymentOptions: PaymentOptions | ||
} | ||
|
||
export interface DeliverySlaSample { | ||
deliverySlaPerTypes: any[] | ||
region: null | ||
} | ||
|
||
export interface DeliverySlaSamplesPerRegion { | ||
the0: DeliverySlaSample | ||
} | ||
|
||
export interface Installment { | ||
value: number | ||
interestRate: number | ||
totalValuePlusInterestRate: number | ||
numberOfInstallments: number | ||
paymentSystemName: string | ||
paymentSystemGroupName: string | ||
name: string | ||
} | ||
|
||
export interface PaymentOptions { | ||
installmentOptions: InstallmentOption[] | ||
paymentSystems: PaymentSystem[] | ||
payments: any[] | ||
giftCards: any[] | ||
giftCardMessages: any[] | ||
availableAccounts: any[] | ||
availableTokens: any[] | ||
} | ||
|
||
export interface InstallmentOption { | ||
paymentSystem: string | ||
bin: null | ||
paymentName: string | ||
paymentGroupName: string | ||
value: number | ||
installments: InstallmentElement[] | ||
} | ||
|
||
export interface InstallmentElement { | ||
count: number | ||
hasInterestRate: boolean | ||
interestRate: number | ||
value: number | ||
total: number | ||
sellerMerchantInstallments?: InstallmentElement[] | ||
id?: string | ||
} | ||
|
||
export interface PaymentSystem { | ||
id: number | ||
name: string | ||
groupName: string | ||
validator: null | ||
stringId: string | ||
template: string | ||
requiresDocument: boolean | ||
isCustom: boolean | ||
description: null | string | ||
requiresAuthentication: boolean | ||
dueDate: Date | ||
availablePayments: null | ||
} | ||
|
||
export interface ProductClusters { | ||
the140: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import type { Resolver } from '..' | ||
|
||
type Root = { title?: string; description?: string } | ||
type Root = { title?: string; description?: string; canonical?: string } | ||
|
||
export const StoreSeo: Record<string, Resolver<Root>> = { | ||
title: ({ title }) => title ?? '', | ||
description: ({ description }) => description ?? '', | ||
canonical: ({ canonical }) => canonical ?? '', | ||
titleTemplate: () => '', | ||
canonical: () => '', | ||
} |
Oops, something went wrong.