Skip to content

Instantly share code, notes, and snippets.

@MarlonPassos-git
Created October 7, 2022 01:19
Show Gist options
  • Save MarlonPassos-git/1f5873d2994185c24a807e493c8a6607 to your computer and use it in GitHub Desktop.
Save MarlonPassos-git/1f5873d2994185c24a807e493c8a6607 to your computer and use it in GitHub Desktop.
types checkout m3
import { OrderForm } from "./orderForm"
import { ShippingSimutation } from "./shipping-simulation"
import { Store } from "./store"
declare global {
const vtexjs: {
checkout: {
orderForm: OrderForm,
orderFormId: string,
sendAttachment: (attachmentId: string, attachment: any, expectedOrderFormSections?: string[]) => Promise<OrderForm>
simulateShipping: (shippingData: unknown, orderFormId: string, country: string) => Promise<ShippingSimutation>
getOrderForm: () => Promise<OrderForm>
}
}
const checkout: any
const vtex: any
const checkout: any
const cart: {
loading: (isLoading?: boolean) => boolean
}
const store: Store
}
export { };
export interface OrderForm {
orderFormId: string;
salesChannel: string;
loggedIn: boolean;
isCheckedIn: boolean;
storeId: null;
checkedInPickupPointId: null;
allowManualPrice: boolean;
canEditData: boolean;
userProfileId: string;
userType: null;
ignoreProfileData: boolean;
value: number;
messages: any[];
items: OrderFormItem[];
selectableGifts: any[];
totalizers: Totalizer[];
shippingData: ShippingData;
clientProfileData: ClientProfileData;
paymentData: PaymentData;
marketingData: MarketingData;
sellers: Seller[];
clientPreferencesData: ClientPreferencesData;
commercialConditionData: null;
storePreferencesData: StorePreferencesData;
giftRegistryData: null;
openTextField: OpenTextField;
invoiceData: null;
customData: CustomData;
itemMetadata: ItemMetadata;
hooksData: null;
ratesAndBenefitsData: RatesAndBenefitsData;
subscriptionData: null;
merchantContextData: null;
itemsOrdination: null;
}
export interface ClientPreferencesData {
locale: string;
optinNewsLetter: boolean;
}
export interface ClientProfileData {
email: string;
firstName: string;
lastName: string;
document: string;
documentType: string;
phone: string;
corporateName: null;
tradeName: null;
corporateDocument: null;
stateInscription: null;
corporatePhone: null;
isCorporate: boolean;
profileCompleteOnLoading: boolean;
profileErrorOnLoading: boolean;
customerClass: null;
}
export interface CustomData {
customApps: CustomApp[];
}
export interface CustomApp {
fields: Fields;
id: string;
major: number;
}
export interface Fields {
fiscaldata?: string;
recogeEnAuto?: string;
department?: string;
document?: string;
documentType?: string;
address?: string;
town?: string;
}
export interface ItemMetadata {
items: ItemMetadataItem[];
}
export interface ItemMetadataItem {
id: string;
seller: string;
name: string;
skuName: string;
productId: string;
refId: string;
ean: null;
imageUrl: string;
detailUrl: string;
assemblyOptions: any[];
}
export interface OrderFormItem {
uniqueId: string;
id: string;
productId: string;
productRefId: string;
refId: string;
ean: null;
name: string;
skuName: string;
modalType: null;
parentItemIndex: null;
parentAssemblyBinding: null;
assemblies: any[];
priceValidUntil: Date;
tax: number;
price: number;
listPrice: number;
manualPrice: null;
manualPriceAppliedBy: null;
sellingPrice: number;
rewardValue: number;
isGift: boolean;
additionalInfo: AdditionalInfo;
preSaleDate: null;
productCategoryIds: string;
productCategories: { [key: string]: string };
quantity: number;
seller: string;
sellerChain: string[];
imageUrl: string;
detailUrl: string;
components: any[];
bundleItems: any[];
attachments: any[];
attachmentOfferings: any[];
offerings: any[];
priceTags: any[];
availability: string;
measurementUnit: string;
unitMultiplier: number;
manufacturerCode: null;
priceDefinition: PriceDefinition;
}
export interface AdditionalInfo {
dimension: null;
brandName: string;
brandId: string;
offeringInfo: null;
offeringType: null;
offeringTypeId: null;
}
export interface PriceDefinition {
calculatedSellingPrice: number;
total: number;
sellingPrices: SellingPrice[];
}
export interface SellingPrice {
value: number;
quantity: number;
}
export interface MarketingData {
utmSource: null;
utmMedium: null;
utmCampaign: null;
utmipage: null;
utmiPart: null;
utmiCampaign: null;
coupon: null;
marketingTags: string[];
}
export interface OpenTextField {
value: string;
}
export interface PaymentData {
updateStatus: string;
installmentOptions: InstallmentOption[];
paymentSystems: PaymentSystem[];
payments: Payment[];
giftCards: any[];
giftCardMessages: any[];
availableAccounts: any[];
availableTokens: any[];
availableAssociations: AvailableAssociations;
}
export interface AvailableAssociations {
}
export interface InstallmentOption {
paymentSystem: string;
bin: null;
paymentName: null;
paymentGroupName: null;
value: number;
installments: Installment[];
}
export interface Installment {
count: number;
hasInterestRate: boolean;
interestRate: number;
value: number;
total: number;
sellerMerchantInstallments?: Installment[];
id?: string;
}
export interface PaymentSystem {
id: number;
name: string;
groupName: string;
validator: Validator;
stringId: string;
template: string;
requiresDocument: boolean;
displayDocument: boolean;
isCustom: boolean;
description: null | string;
requiresAuthentication: boolean;
dueDate: Date;
availablePayments: null;
}
export interface Validator {
regex: null | string;
mask: null | string;
cardCodeRegex: null | string;
cardCodeMask: null | string;
weights: number[] | null;
useCvv: boolean;
useExpirationDate: boolean;
useCardHolderName: boolean;
useBillingAddress: boolean;
}
export interface Payment {
paymentSystem: string;
bin: null;
accountId: null;
tokenId: null;
installments: number;
referenceValue: number;
value: number;
merchantSellerPayments: MerchantSellerPayment[];
}
export interface MerchantSellerPayment {
id: string;
installments: number;
referenceValue: number;
value: number;
interestRate: number;
installmentValue: number;
}
export interface RatesAndBenefitsData {
rateAndBenefitsIdentifiers: any[];
teaser: any[];
}
export interface Seller {
id: string;
name: string;
logo: string;
}
export interface ShippingData {
address: Address;
logisticsInfo: LogisticsInfo[];
selectedAddresses: Address[];
availableAddresses: Address[];
pickupPoints: PickupPoint[];
}
export interface Address {
addressType: AddressType;
receiverName: null | string;
addressId: string;
isDisposable: boolean;
postalCode: null | string;
city: null | string;
state: string | null;
country: string;
street: null | string;
number: null | string;
neighborhood: null | string;
complement: null | string;
reference: string | null;
geoCoordinates: number[];
addressQuery?: string
}
export enum AddressType {
Pickup = "pickup",
Residential = "residential",
Search = "search",
}
export interface LogisticsInfo {
itemIndex: number;
selectedSla: string;
selectedDeliveryChannel: string;
addressId: string;
slas: Sla[];
shipsTo: string[];
itemId: string;
deliveryChannels: DeliveryChannel[];
}
export interface DeliveryChannel {
id: string;
}
export interface Sla {
id: string;
deliveryChannel: string;
name: string;
deliveryIds: DeliveryID[];
shippingEstimate: string;
shippingEstimateDate: null;
lockTTL: null;
availableDeliveryWindows: AvailableDeliveryWindow[];
deliveryWindow: null;
price: number;
listPrice: number;
tax: number;
pickupStoreInfo: PickupStoreInfo;
pickupPointId: null | string;
pickupDistance: number;
polygonName: string;
transitTime: string;
}
export interface AvailableDeliveryWindow {
startDateUtc: Date;
endDateUtc: Date;
price: number;
lisPrice: number;
tax: number;
}
export interface DeliveryID {
courierId: string;
warehouseId: string;
dockId: string;
courierName: string;
quantity: number;
kitItemDetails: any[];
}
export interface PickupStoreInfo {
isPickupStore: boolean;
friendlyName: null | string;
address: Address | null;
additionalInfo: null | string;
dockId: null | string;
}
export interface PickupPoint {
friendlyName: string;
address: Address;
additionalInfo: string;
id: string;
businessHours: BusinessHour[];
}
export interface BusinessHour {
dayOfWeek: number;
openingTime: string;
closingTime: string;
}
export interface StorePreferencesData {
countryCode: string;
saveUserData: boolean;
timeZone: string;
currencyCode: string;
currencyLocale: number;
currencySymbol: string;
currencyFormatInfo: CurrencyFormatInfo;
}
export interface CurrencyFormatInfo {
currencyDecimalDigits: number;
currencyDecimalSeparator: string;
currencyGroupSeparator: string;
currencyGroupSize: number;
startsWithCurrencySymbol: boolean;
}
export interface Totalizer {
id: string;
name: string;
value: number;
}
export interface ShippingSimutation {
items: Item[];
ratesAndBenefitsData: RatesAndBenefitsData;
paymentData: string;
selectableGifts: any[];
marketingData: MarketingData;
postalCode: null;
country: string;
logisticsInfo: LogisticsInfo[];
messages: any[];
purchaseConditions: PurchaseConditions;
pickupPoints: PickupPoint[];
subscriptionData: null;
totals: Total[];
itemMetadata: null;
}
export enum Country {
Slv = "SLV",
}
export interface Item {
id: string;
requestIndex: number;
quantity: number;
seller: string;
sellerChain: string[];
tax: number;
priceValidUntil: Date;
price: number;
listPrice: number;
rewardValue: number;
sellingPrice: number;
offerings: any[];
priceTags: any[];
measurementUnit: string;
unitMultiplier: number;
parentItemIndex: null;
parentAssemblyBinding: null;
availability: string;
catalogProvider: string;
priceDefinition: PriceDefinition;
}
export interface PriceDefinition {
calculatedSellingPrice: number;
total: number;
sellingPrices: SellingPrice[];
}
export interface SellingPrice {
value: number;
quantity: number;
}
export interface LogisticsInfo {
itemIndex: number;
addressId: string;
selectedSla: null;
selectedDeliveryChannel: null;
quantity: number;
shipsTo: string[];
slas: Sla[];
deliveryChannels: DeliveryChannel[];
}
export interface DeliveryChannel {
id: DeliveryChannelEnum;
}
export enum DeliveryChannelEnum {
Delivery = "delivery",
PickupInPoint = "pickup-in-point",
}
export interface Sla {
id: string;
deliveryChannel: DeliveryChannelEnum;
name: string;
deliveryIds: DeliveryID[];
shippingEstimate: string;
shippingEstimateDate: null;
lockTTL: null;
availableDeliveryWindows: any[];
deliveryWindow: null;
price: number;
listPrice: number;
tax: number;
pickupStoreInfo: PickupStoreInfo;
pickupPointId: null | string;
pickupDistance: number;
polygonName: string;
transitTime: string;
}
export interface DeliveryID {
courierId: string;
warehouseId: string;
dockId: string;
courierName: string;
quantity: number;
kitItemDetails: any[];
}
export interface PickupStoreInfo {
isPickupStore: boolean;
friendlyName: null | string;
address: Address | null;
additionalInfo: null | string;
dockId: null | string;
}
export interface Address {
addressType: string;
receiverName: null;
addressId: string;
isDisposable: boolean;
postalCode: string;
city: string
state: string
country: string;
street: string;
number: string;
neighborhood: string;
complement: string;
reference: null;
geoCoordinates: number[];
}
export enum AddressType {
Pickup = "pickup",
}
export interface MarketingData {
utmSource: null;
utmMedium: null;
utmCampaign: null;
utmipage: null;
utmiPart: null;
utmiCampaign: null;
coupon: null;
marketingTags: string[];
}
export interface PaymentData {
installmentOptions: InstallmentOption[];
paymentSystems: PaymentSystem[];
payments: Payment[];
giftCards: any[];
giftCardMessages: any[];
availableAccounts: any[];
availableTokens: any[];
availableAssociations: AvailableAssociations;
}
export interface AvailableAssociations {
}
export interface InstallmentOption {
paymentSystem: string;
bin: null;
paymentName: string;
paymentGroupName: string;
value: number;
installments: Installment[];
}
export interface Installment {
count: number;
hasInterestRate: boolean;
interestRate: number;
value: number;
total: number;
sellerMerchantInstallments?: Installment[];
id?: string;
}
export interface PaymentSystem {
id: number;
name: string;
groupName: string;
validator: null;
stringId: string;
template: string;
requiresDocument: boolean;
displayDocument: boolean;
isCustom: boolean;
description: null | string;
requiresAuthentication: boolean;
dueDate: Date;
availablePayments: null;
}
export interface Payment {
paymentSystem: string;
bin: null;
accountId: null;
tokenId: null;
installments: number;
referenceValue: number;
value: number;
merchantSellerPayments: MerchantSellerPayment[];
}
export interface MerchantSellerPayment {
id: string;
installments: number;
referenceValue: number;
value: number;
interestRate: number;
installmentValue: number;
}
export interface PickupPoint {
friendlyName: string;
address: Address;
additionalInfo: string;
id: string;
businessHours: BusinessHour[];
}
export interface BusinessHour {
DayOfWeek: number;
OpeningTime: string;
ClosingTime: string;
}
export interface PurchaseConditions {
itemPurchaseConditions: ItemPurchaseCondition[];
}
export interface ItemPurchaseCondition {
id: string;
seller: string;
sellerChain: string[];
slas: Sla[];
price: number;
listPrice: number;
}
export interface RatesAndBenefitsData {
rateAndBenefitsIdentifiers: any[];
teaser: any[];
}
export interface Total {
id: string;
name: string;
value: number;
}
export interface Store {
getState: () => StoreState
subscribe: (cb: (state: StoreState) => void) => void
dispatch: (event: any) => unknown
}
export interface StoreState {
orderForm: OrderForm;
pickup: Pickup;
addressForm: AddressForm;
accountInfo: AccountInfo;
componentActivity: ComponentActivity;
delivery: Delivery;
invoiceAddressForm: InvoiceAddressForm;
shippingPreview: ShippingPreview;
}
export interface AccountInfo {
loadingAccountInfo: boolean;
acceptSearchKeys: string[];
googleMapsKey: string;
geolocation: boolean;
accountName: string;
}
export interface AddressForm {
addresses: { [key: string]: AddressValue };
valid: boolean;
receiverName: string;
alreadyCompletedReceiverName: boolean;
queuedValidations: string[];
shouldSubmit: boolean;
localCanEditData: boolean;
residentialId: string;
searchId: string;
}
export interface AddressValue {
addressId: InvoiceAddress;
addressType: InvoiceAddress;
city: InvoiceAddress;
complement: InvoiceAddress;
country: Country;
geoCoordinates: InvoiceAddress;
neighborhood: InvoiceAddress;
number: InvoiceAddress;
postalCode: PostalCode;
receiverName: InvoiceAddress;
reference: InvoiceAddress;
state: InvoiceAddress;
street: InvoiceAddress;
addressQuery: InvoiceAddress;
isDisposable: IsDisposable;
}
export interface InvoiceAddress {
value: number[] | boolean | null | string;
}
export interface Country {
value: number[] | boolean | null | string;
postalCodeAutoCompleted?: boolean;
}
export interface IsDisposable {
value?: number[] | boolean | null | string;
}
export interface PostalCode {
value: number[] | boolean | null | string;
loading?: boolean;
valid?: boolean;
reason?: string;
focus?: boolean;
}
export interface ComponentActivity {
isUnavailableGeolocation: boolean;
isGeolocationInitialState: boolean;
isCalculateBttnEnabled: boolean;
isAddressListActive: boolean;
isAddressActive: boolean;
isOmniShippingCompleted: boolean;
isOmniShippingOpen: boolean;
activeDeliveryChannel: ActiveDeliveryChannel;
editAddressActive: boolean;
newAddressActive: boolean;
isEditingOmnishipping: boolean;
hasPickup: boolean;
isSplitActive: boolean;
isInitialInputState: boolean;
triedCompleteOmnishipping: boolean;
}
export enum ActiveDeliveryChannel {
Delivery = "delivery",
PickupInPoint = "pickup-in-point",
}
export interface Delivery {
CHEAPEST: LogisticInfo[];
COMBINED: LogisticInfo[];
FASTEST: LogisticInfo[];
logisticsInfo: LogisticInfo[];
activeDeliveryOption: 'CHEAPEST' | 'COMBINED' | 'FASTEST';
showSlasList: boolean;
simulateRequested: boolean;
selectedDeliveryPackageSlider: number;
shouldUpdateUi: boolean;
shouldDisableToggle: boolean;
optionsDetails: OptionsDetail[];
shouldUpdateLeanOptionsState: boolean;
isScheduledDeliveryActive?: boolean;
}
export interface LogisticInfo {
itemIndex: number;
selectedSla: ID;
selectedDeliveryChannel: ActiveDeliveryChannel;
addressId: string;
slas: ActivePickupPoint[];
shipsTo: CountryCode[];
itemId: string;
deliveryChannels: DeliveryChannel[];
}
export interface DeliveryChannel {
id: ActiveDeliveryChannel;
}
export enum ID {
RecogerEnTiendaGalerias10103 = "Recoger en tienda - Galerias (10103)",
RecogerEnTiendaLaGranVia10106 = "Recoger en tienda - La Gran Via (10106)",
RecogerEnTiendaMetrocentro10102 = "Recoger en tienda - Metrocentro (10102)",
RecogerEnTiendaPlazaMundo10110 = "Recoger en tienda - Plaza Mundo (10110)",
RecogerEnTiendaPlazaMundoSv10110 = "Recoger en tienda - Plaza Mundo sv (10110)",
}
export enum CountryCode {
Cri = "CRI",
Slv = "SLV",
}
export interface ActivePickupPoint {
id: ID;
deliveryChannel: ActiveDeliveryChannel;
name: ID;
deliveryIds: DeliveryID[];
shippingEstimate: string;
shippingEstimateDate: null;
lockTTL: null;
availableDeliveryWindows: DeliveryWindow[];
deliveryWindow: DeliveryWindow | null;
price: number;
listPrice: number;
tax: number;
pickupStoreInfo: PickupStoreInfo;
pickupPointId: string;
pickupDistance: number;
polygonName: string;
transitTime: string;
}
export interface DeliveryWindow {
startDateUtc: string;
endDateUtc: string;
price: number;
lisPrice: number;
tax: number;
}
export interface DeliveryID {
courierId: CourierID;
warehouseId: string;
dockId: string;
courierName: string;
quantity: number;
kitItemDetails: any[];
}
export enum CourierID {
Recogetiendagalerias = "RECOGETIENDAGALERIAS",
Recogetiendametrocentro = "RECOGETIENDAMETROCENTRO",
Svrecogetiendalagranviamc = "SVRECOGETIENDALAGRANVIAMC",
Svrecogetiendaplazamundo = "SVRECOGETIENDAPLAZAMUNDO",
Svrecogetiendaplazamundomc = "SVRECOGETIENDAPLAZAMUNDOMC",
}
export interface PickupStoreInfo {
isPickupStore: boolean;
friendlyName: string;
address: AvailableAddressClass;
additionalInfo: string;
dockId: string;
}
export interface AvailableAddressClass {
addressType: AddressType;
receiverName: null | string;
addressId: string;
isDisposable: boolean;
postalCode: null | string;
city: string | null;
state: string | null;
country: CountryCode;
street: null | string;
number: null | string;
neighborhood: null | string;
complement: null | string;
reference: null;
geoCoordinates: number[];
}
export enum AddressType {
Pickup = "pickup",
Search = "search",
}
export interface OptionsDetail {
price: number;
shippingEstimate: string | null;
shippingEstimateInSeconds: null;
averageEstimatePerItem: number;
packagesLength: number;
id: string;
}
export interface InvoiceAddressForm {
invoiceAddress: { [key: string]: InvoiceAddress };
geolocation: boolean;
isInvoiceButtonActive: boolean;
isInvoiceAddressCompleted: boolean;
isInvoiceAddressActive: boolean;
isCreatingInvoiceAddress: boolean;
}
export interface OrderForm {
giftRegistryData: null;
orderFormId: string;
salesChannel: string;
clientProfileData: ClientProfileData;
clientPreferencesData: ClientPreferencesData;
storePreferencesData: StorePreferencesData;
marketingData: MarketingData;
sellers: Seller[];
loggedIn: boolean;
canEditData: boolean;
selectableGifts: any[];
userProfileId: null;
items: Item[];
shippingData: ShippingData;
}
export interface ClientPreferencesData {
locale: string;
optinNewsLetter: boolean;
}
export interface ClientProfileData {
email: string;
firstName: string;
lastName: string;
document: string;
documentType: string;
phone: string;
corporateName: null;
tradeName: null;
corporateDocument: null;
stateInscription: null;
corporatePhone: null;
isCorporate: boolean;
profileCompleteOnLoading: boolean;
profileErrorOnLoading: boolean;
customerClass: null;
}
export interface Item {
uniqueId: string;
id: string;
productId: string;
productRefId: string;
refId: string;
ean: string;
name: string;
skuName: string;
modalType: null;
parentItemIndex: null;
parentAssemblyBinding: null;
assemblies: any[];
priceValidUntil: Date;
tax: number;
price: number;
listPrice: number;
manualPrice: null;
manualPriceAppliedBy: null;
sellingPrice: number;
rewardValue: number;
isGift: boolean;
additionalInfo: AdditionalInfo;
preSaleDate: null;
productCategoryIds: string;
productCategories: { [key: string]: string };
quantity: number;
seller: string;
sellerChain: string[];
imageUrl: string;
detailUrl: string;
components: any[];
bundleItems: any[];
attachments: any[];
attachmentOfferings: any[];
offerings: any[];
priceTags: PriceTag[];
availability: string;
measurementUnit: string;
unitMultiplier: number;
manufacturerCode: null;
priceDefinition: PriceDefinition;
}
export interface AdditionalInfo {
dimension: null;
brandName: string;
brandId: string;
offeringInfo: null;
offeringType: null;
offeringTypeId: null;
}
export interface PriceDefinition {
calculatedSellingPrice: number;
total: number;
sellingPrices: SellingPrice[];
}
export interface SellingPrice {
value: number;
quantity: number;
}
export interface PriceTag {
name: string;
value: number;
rawValue: number;
isPercentual: boolean;
identifier: string;
ratesAndBenefitsIdentifier: RatesAndBenefitsIdentifier;
}
export interface RatesAndBenefitsIdentifier {
id: string;
name: string;
featured: boolean;
description: null;
matchedParameters: MatchedParameters;
additionalInfo: null;
}
export interface MatchedParameters {
"productCluster@CatalogSystem"?: string;
"product@CatalogSystem"?: string;
}
export interface MarketingData {
utmSource: string;
utmMedium: string;
utmCampaign: string;
utmipage: string;
utmiPart: string;
utmiCampaign: null;
coupon: null;
marketingTags: string[];
}
export interface Seller {
id: string;
name: string;
logo: string;
}
export interface ShippingData {
address: AvailableAddressClass;
logisticsInfo: LogisticInfo[];
selectedAddresses: AvailableAddressClass[];
availableAddresses: AvailableAddressClass[];
pickupPoints: PickupPoint[];
}
export interface PickupPoint {
friendlyName: string;
address: AvailableAddressClass;
additionalInfo: string;
id: string;
businessHours: BusinessHour[];
}
export interface BusinessHour {
dayOfWeek: number;
openingTime: string;
closingTime: string;
}
export interface StorePreferencesData {
countryCode: CountryCode;
saveUserData: boolean;
timeZone: string;
currencyCode: string;
currencyLocale: number;
currencySymbol: string;
currencyFormatInfo: CurrencyFormatInfo;
}
export interface CurrencyFormatInfo {
currencyDecimalDigits: number;
currencyDecimalSeparator: string;
currencyGroupSeparator: string;
currencyGroupSize: number;
startsWithCurrencySymbol: boolean;
}
export interface Pickup {
isModalActive: boolean;
isPickupDetailsActive: boolean;
pickupOptions: ActivePickupPoint[];
pickupPoint: null;
activePickupPoint: ActivePickupPoint;
activeSellerId: string;
askForGeolocation: null;
isSearching: boolean;
hasGeolocation: boolean;
}
export interface ShippingPreview {
isInitialInputState: boolean;
isLoadingResult: boolean;
isLoadingUpdate: boolean;
isLoadingTabChange: boolean;
isModalActive: boolean;
showShippingPreview: boolean;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment