@mailbiz/onsite-vtex-vendor 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @mailbiz/onsite-wapstore-vendor
2
+
3
+ Vendor Doc:
4
+ https://developers.wapstore.com.br/wapstore/api/v2
5
+
6
+ Copyright (c) 2023 Mailbiz.
7
+
8
+ ### Vtex store implementations
9
+ There are two implementations:
10
+
11
+ Vtex IO
12
+ Communicates do the back-end using GraphQL
13
+
14
+ Vtex Legacy
15
+ Has a vtexjs local context
16
+
17
+ ### Navigation
18
+ Navigation from and to checkout always triggers a reload
@@ -0,0 +1,466 @@
1
+ import { OnsiteCoreWindow } from "@mailbiz/onsite-core";
2
+ //#region [Window]
3
+ interface VtexLocalStorage {
4
+ orderform?: string; // VtexIOOrderFrom JSON string
5
+ }
6
+ interface VtexLegacyContext {
7
+ catalog: any;
8
+ checkout: {
9
+ orderForm: VtexLegacyOrderForm;
10
+ };
11
+ }
12
+ interface VtexWindow extends OnsiteCoreWindow {
13
+ vtexjs?: VtexLegacyContext;
14
+ localStorage?: VtexLocalStorage;
15
+ CATALOG_SDK?: VtexLegacyCatalog;
16
+ dataLayer?: DataLayerEvent[];
17
+ }
18
+ //#endregion
19
+ //#region [Data Layer]
20
+ interface DataLayerProduct {
21
+ brand: string;
22
+ category: string;
23
+ dimension1: string;
24
+ dimension2: string;
25
+ dimension3: string;
26
+ dimension4: string;
27
+ id: string;
28
+ name: string;
29
+ price: number;
30
+ variant: string;
31
+ }
32
+ interface DataLayerEvent {
33
+ event?: string;
34
+ ecommerce?: {
35
+ detail?: {
36
+ products?: DataLayerProduct[];
37
+ };
38
+ };
39
+ }
40
+ //#endregion
41
+ //#region [Vtex Order Form]
42
+ interface ProductCategories {
43
+ [categoryId: string]: string;
44
+ }
45
+ interface PriceTag {
46
+ name: string;
47
+ value: number;
48
+ rawValue: number;
49
+ isPercentual: boolean;
50
+ identifier: string;
51
+ owner?: string;
52
+ __typename?: string;
53
+ ratesAndBenefitsIdentifier?: any;
54
+ }
55
+ interface PriceDefinition {
56
+ calculatedSellingPrice: number;
57
+ total: number;
58
+ sellingPrices: SellingPrice[];
59
+ __typename?: string;
60
+ }
61
+ interface SellingPrice {
62
+ value: number;
63
+ quantity: number;
64
+ __typename?: string;
65
+ }
66
+ interface VtexTotalizer {
67
+ id: string;
68
+ name: string;
69
+ value: number;
70
+ __typename?: string;
71
+ }
72
+ interface VtexLegacyShippingData {
73
+ address: any;
74
+ logisticsInfo: LogisticsInfo[];
75
+ selectedAddresses: VtexAddress[];
76
+ availableAddresses: VtexAddress[];
77
+ pickupPoints: any[];
78
+ trackingHints?: any[];
79
+ isFOB?: boolean | null;
80
+ }
81
+ interface LogisticsInfo {
82
+ itemIndex: number;
83
+ selectedSla: string | null;
84
+ selectedDeliveryChannel: string;
85
+ addressId: string | null;
86
+ slas: any[];
87
+ shipsTo: string[];
88
+ itemId: string;
89
+ deliveryChannels: DeliveryChannel[];
90
+ price?: number;
91
+ sellingPrice?: number;
92
+ listPrice?: number;
93
+ shippingEstimate?: string;
94
+ dockEstimate?: string;
95
+ shippingEstimateDate?: string;
96
+ lockTTL?: string;
97
+ deliveryCompany?: string | null;
98
+ polygonName?: string;
99
+ transitTime?: string;
100
+ deliveryIds?: any[];
101
+ deliveryWindow?: string | null;
102
+ pickupPointId?: string | null;
103
+ pickupStoreInfo?: {
104
+ isPickupStore: boolean;
105
+ friendlyName: string | null;
106
+ address: string | null;
107
+ additionalInfo: string | null;
108
+ dockId: string | null;
109
+ };
110
+ pickupDistance?: string | null;
111
+ }
112
+ interface DeliveryChannel {
113
+ id: string;
114
+ }
115
+ interface PaymentData {
116
+ updateStatus?: string;
117
+ installmentOptions: InstallmentOption[];
118
+ paymentSystems: PaymentSystem[];
119
+ payments: Payment[];
120
+ giftCards?: any[];
121
+ giftCardMessages?: any[];
122
+ availableAccounts: any[];
123
+ availableTokens?: any[];
124
+ availableAssociations?: any;
125
+ isValid?: boolean;
126
+ __typename?: string;
127
+ }
128
+ interface InstallmentOption {
129
+ paymentSystem: string;
130
+ bin?: any;
131
+ paymentName?: any;
132
+ paymentGroupName?: any;
133
+ value?: number;
134
+ installments: Installment[];
135
+ __typename?: string;
136
+ }
137
+ interface Installment {
138
+ count: number;
139
+ hasInterestRate: boolean;
140
+ interestRate: number;
141
+ value: number;
142
+ total: number;
143
+ sellerMerchantInstallments?: SellerMerchantInstallment[];
144
+ __typename?: string;
145
+ }
146
+ interface SellerMerchantInstallment {
147
+ id: string;
148
+ count: number;
149
+ hasInterestRate: boolean;
150
+ interestRate: number;
151
+ value: number;
152
+ total: number;
153
+ }
154
+ interface PaymentSystem {
155
+ id: number | string;
156
+ name: string;
157
+ groupName: string;
158
+ validator: Validator;
159
+ stringId: string;
160
+ template?: string;
161
+ requiresDocument: boolean;
162
+ displayDocument?: boolean;
163
+ isCustom: boolean;
164
+ description: any;
165
+ requiresAuthentication: boolean;
166
+ dueDate: string;
167
+ availablePayments?: any[] | null;
168
+ __typename?: string;
169
+ }
170
+ interface Validator {
171
+ regex: any;
172
+ mask: any;
173
+ cardCodeRegex: any;
174
+ cardCodeMask: any;
175
+ weights: any;
176
+ useCvv: boolean;
177
+ useExpirationDate: boolean;
178
+ useCardHolderName: boolean;
179
+ useBillingAddress: boolean;
180
+ __typename?: string;
181
+ }
182
+ interface Seller {
183
+ id: string;
184
+ name: string;
185
+ logo: string;
186
+ }
187
+ interface ClientPreferencesData {
188
+ locale: string;
189
+ optinNewsLetter?: any | null;
190
+ optInNewsLetter?: any | null;
191
+ savePersonalData?: boolean;
192
+ savePaymentData?: boolean;
193
+ __typename?: string;
194
+ }
195
+ interface VtexLegacyStorePreferencesData {
196
+ countryCode: string;
197
+ saveUserData: boolean;
198
+ timeZone: string;
199
+ currencyCode: string;
200
+ currencyLocale: number;
201
+ currencySymbol: string;
202
+ currencyFormatInfo: CurrencyFormatInfo;
203
+ }
204
+ interface CurrencyFormatInfo {
205
+ currencyDecimalDigits: number;
206
+ currencyDecimalSeparator: string;
207
+ currencyGroupSeparator: string;
208
+ currencyGroupSize: number;
209
+ startsWithCurrencySymbol: boolean;
210
+ }
211
+ interface ItemMetadata {
212
+ items: ItemMetadataItem[];
213
+ }
214
+ interface ItemMetadataItem {
215
+ id: string;
216
+ seller: string;
217
+ name: string;
218
+ skuName: string;
219
+ productId: string;
220
+ refId: string;
221
+ ean: string | null;
222
+ imageUrl: string;
223
+ detailUrl: string;
224
+ assemblyOptions: any[];
225
+ }
226
+ interface RatesAndBenefitsData {
227
+ rateAndBenefitsIdentifiers: RateAndBenefitsIdentifier[];
228
+ teaser: any[];
229
+ }
230
+ interface RateAndBenefitsIdentifier {
231
+ id: string;
232
+ name: string;
233
+ featured: boolean;
234
+ description: string;
235
+ matchedParameters: any;
236
+ additionalInfo: any;
237
+ }
238
+ interface MarketingData {
239
+ coupon: string | null;
240
+ utmCampaign: string | null;
241
+ utmMedium: string | null;
242
+ utmSource: string | null;
243
+ utmiCampaign: string | null;
244
+ utmiPart: string | null;
245
+ utmPartner?: string | null;
246
+ utmipage?: string | null;
247
+ marketingTags?: string[];
248
+ __typename?: string;
249
+ }
250
+ interface Payment {
251
+ paymentSystem: string;
252
+ bin: any;
253
+ accountId: any;
254
+ tokenId: any;
255
+ installments: number | null;
256
+ referenceValue: number;
257
+ value: number;
258
+ merchantSellerPayments?: any;
259
+ __typename?: string;
260
+ }
261
+ interface OrderFormMessages {
262
+ couponMessages?: any[];
263
+ generalMessages?: any[];
264
+ code?: string;
265
+ fields?: any;
266
+ status?: string;
267
+ text?: string;
268
+ __typename?: string;
269
+ }
270
+ interface VtexAddress {
271
+ addressId: string;
272
+ addressType: string;
273
+ city: string;
274
+ complement: string;
275
+ country: string;
276
+ neighborhood: string;
277
+ number: string;
278
+ postalCode: string;
279
+ receiverName: string;
280
+ reference: any;
281
+ state: string;
282
+ street: string;
283
+ isDisposable: boolean;
284
+ geoCoordinates?: number[];
285
+ __typename?: string;
286
+ }
287
+ interface BaseClientData {
288
+ email: string;
289
+ firstName: string;
290
+ lastName: string;
291
+ document: string;
292
+ documentType: string;
293
+ phone: string;
294
+ }
295
+ interface VtexLegacyClientData extends BaseClientData {
296
+ corporateDocument: string | null;
297
+ corporateName: string | null;
298
+ corporatePhone: string | null;
299
+ customerClass: string | null;
300
+ isCorporate: boolean;
301
+ isProspect?: boolean;
302
+ profileCompleteOnLoading: boolean;
303
+ profileErrorOnLoading: boolean;
304
+ stateInscription: string | null;
305
+ tradeName: string | null;
306
+ }
307
+ interface ExtendedItemAdditionalInfo extends ItemAdditionalInfo {
308
+ dimension: any;
309
+ brandId: string;
310
+ offeringInfo: any;
311
+ offeringType: any;
312
+ offeringTypeId: any;
313
+ categoriesIds?: string;
314
+ productClusterId?: string;
315
+ commercialConditionId?: string;
316
+ }
317
+ interface ItemAdditionalInfo {
318
+ brandName: string;
319
+ __typename?: string;
320
+ }
321
+ interface BaseItem {
322
+ uniqueId: string;
323
+ id: string;
324
+ productId: string;
325
+ productRefId: string;
326
+ refId: string;
327
+ name: string;
328
+ skuName: string;
329
+ modalType: any;
330
+ parentItemIndex: any;
331
+ parentAssemblyBinding: any;
332
+ assemblies?: any[];
333
+ price: number;
334
+ listPrice: number;
335
+ manualPrice: any;
336
+ sellingPrice: number;
337
+ isGift: boolean;
338
+ productCategoryIds: string;
339
+ productCategories: ProductCategories;
340
+ quantity: number;
341
+ seller: string;
342
+ detailUrl: string;
343
+ priceTags: PriceTag[];
344
+ availability: string;
345
+ measurementUnit: string;
346
+ unitMultiplier: number;
347
+ priceDefinition: PriceDefinition;
348
+ attachmentOfferings: any[];
349
+ offerings: any[];
350
+ attachments: any[];
351
+ bundleItems: any[];
352
+ }
353
+ interface VtexLegacyItem extends BaseItem {
354
+ additionalInfo: ExtendedItemAdditionalInfo;
355
+ ean: string | null;
356
+ priceValidUntil: string;
357
+ tax: number;
358
+ rewardValue: number;
359
+ preSaleDate: any;
360
+ sellerChain: string[];
361
+ imageUrl: string;
362
+ components: any[];
363
+ availabilityMessage?: string;
364
+ formattedPrice?: string;
365
+ manufacturerCode: any;
366
+ manualPriceAppliedBy?: string | null;
367
+ }
368
+ interface BaseOrderForm {
369
+ loggedIn: boolean;
370
+ canEditData: boolean;
371
+ allowManualPrice: boolean;
372
+ totalizers: VtexTotalizer[];
373
+ clientPreferencesData: ClientPreferencesData;
374
+ marketingData: MarketingData | null;
375
+ userProfileId: string | null;
376
+ messages: OrderFormMessages;
377
+ paymentData: PaymentData;
378
+ value: number;
379
+ customData: any | null;
380
+ userType: string | null;
381
+ }
382
+ interface VtexLegacyOrderForm extends BaseOrderForm {
383
+ items: VtexLegacyItem[];
384
+ clientProfileData: VtexLegacyClientData | null;
385
+ orderFormId: string;
386
+ salesChannel: string;
387
+ isCheckedIn: boolean;
388
+ storeId: string | null;
389
+ checkedInPickupPointId: string | null;
390
+ ignoreProfileData: boolean;
391
+ selectableGifts: any[];
392
+ shippingData: VtexLegacyShippingData;
393
+ sellers: Seller[];
394
+ commercialConditionData: any;
395
+ storePreferencesData: VtexLegacyStorePreferencesData;
396
+ giftRegistryData: any;
397
+ openTextField: any;
398
+ invoiceData: any;
399
+ itemMetadata: ItemMetadata;
400
+ hooksData: any;
401
+ ratesAndBenefitsData: RatesAndBenefitsData;
402
+ subscriptionData: any;
403
+ merchantContextData: any;
404
+ itemsOrdination: any;
405
+ }
406
+ //#endregion
407
+ //#region [Vtex Catalog / Product]
408
+ interface VtexLegacyCatalogProductCacheSku {
409
+ available: boolean;
410
+ availablequantity: number;
411
+ bestPrice: number;
412
+ bestPriceFormated: string;
413
+ cacheVersionUsedToCallCheckout: string;
414
+ dimensions: Record<string, string>;
415
+ discount?: number;
416
+ fullSellingPrice: string;
417
+ hasDiscount?: boolean;
418
+ image: string;
419
+ installments: number;
420
+ installmentsInsterestRate: number;
421
+ installmentsValue: number;
422
+ listPrice: number;
423
+ listPriceFormated: string;
424
+ measures: {
425
+ cubicweight: number;
426
+ height: number;
427
+ length: number;
428
+ weight: number;
429
+ width: number;
430
+ };
431
+ rewardValue: number;
432
+ seller: string;
433
+ sellerId: string;
434
+ sku: number;
435
+ skuname: string;
436
+ spotPrice: number;
437
+ taxAsInt: number;
438
+ taxFormated: string;
439
+ unitMultiplier: number;
440
+ validBestPrice?: boolean;
441
+ validListPrice?: boolean;
442
+ values: any[];
443
+ }
444
+ interface VtexLegacyCatalogProductCache {
445
+ available: boolean;
446
+ dimensions: string[];
447
+ dimensionsInputType: Record<string, string>;
448
+ dimensionsMap: Record<string, string[]>;
449
+ displayMode: string;
450
+ name: string;
451
+ productId: number;
452
+ salesChannel: string;
453
+ skus: VtexLegacyCatalogProductCacheSku[];
454
+ }
455
+ interface VtexLegacyCatalog {
456
+ cache: {
457
+ productWithVariations: Record<string, VtexLegacyCatalogProductCache>;
458
+ };
459
+ getProductWithVariations: () => {};
460
+ getShippingValue: () => {};
461
+ setProductWithVariationsCache: () => {};
462
+ }
463
+ declare global {
464
+ interface Window extends VtexWindow {
465
+ }
466
+ }