@faststore/api 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +333 -0
- package/README.md +115 -0
- package/dist/__generated__/schema.d.ts +281 -0
- package/dist/api.cjs.development.js +2226 -0
- package/dist/api.cjs.development.js.map +1 -0
- package/dist/api.cjs.production.min.js +2 -0
- package/dist/api.cjs.production.min.js.map +1 -0
- package/dist/api.esm.js +2217 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +8 -0
- package/dist/platforms/vtex/clients/commerce/index.d.ts +29 -0
- package/dist/platforms/vtex/clients/commerce/types/Brand.d.ts +8 -0
- package/dist/platforms/vtex/clients/commerce/types/CategoryTree.d.ts +9 -0
- package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +347 -0
- package/dist/platforms/vtex/clients/commerce/types/Simulation.d.ts +154 -0
- package/dist/platforms/vtex/clients/fetch.d.ts +1 -0
- package/dist/platforms/vtex/clients/index.d.ts +32 -0
- package/dist/platforms/vtex/clients/search/index.d.ts +22 -0
- package/dist/platforms/vtex/clients/search/types/AttributeSearchResult.d.ts +56 -0
- package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +199 -0
- package/dist/platforms/vtex/index.d.ts +144 -0
- package/dist/platforms/vtex/loaders/index.d.ts +7 -0
- package/dist/platforms/vtex/loaders/simulation.d.ts +5 -0
- package/dist/platforms/vtex/loaders/sku.d.ts +6 -0
- package/dist/platforms/vtex/resolvers/aggregateOffer.d.ts +7 -0
- package/dist/platforms/vtex/resolvers/aggregateRating.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/collection.d.ts +8 -0
- package/dist/platforms/vtex/resolvers/facet.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/facetValue.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/mutation.d.ts +58 -0
- package/dist/platforms/vtex/resolvers/offer.d.ts +11 -0
- package/dist/platforms/vtex/resolvers/organization.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/product.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/productGroup.d.ts +3 -0
- package/dist/platforms/vtex/resolvers/query.d.ts +51 -0
- package/dist/platforms/vtex/resolvers/review.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/searchResult.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/seo.d.ts +7 -0
- package/dist/platforms/vtex/resolvers/validateCart.d.ts +71 -0
- package/dist/platforms/vtex/utils/enhanceSku.d.ts +5 -0
- package/dist/platforms/vtex/utils/facets.d.ts +12 -0
- package/dist/platforms/vtex/utils/slugify.d.ts +1 -0
- package/dist/platforms/vtex/utils/sort.d.ts +10 -0
- package/dist/typeDefs/index.d.ts +1 -0
- package/package.json +44 -0
- package/src/__generated__/schema.ts +324 -0
- package/src/index.ts +33 -0
- package/src/platforms/vtex/clients/commerce/index.ts +100 -0
- package/src/platforms/vtex/clients/commerce/types/Brand.ts +8 -0
- package/src/platforms/vtex/clients/commerce/types/CategoryTree.ts +9 -0
- package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +371 -0
- package/src/platforms/vtex/clients/commerce/types/Simulation.ts +170 -0
- package/src/platforms/vtex/clients/fetch.ts +13 -0
- package/src/platforms/vtex/clients/index.ts +15 -0
- package/src/platforms/vtex/clients/search/index.ts +83 -0
- package/src/platforms/vtex/clients/search/types/AttributeSearchResult.ts +61 -0
- package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +223 -0
- package/src/platforms/vtex/index.ts +62 -0
- package/src/platforms/vtex/loaders/index.ts +16 -0
- package/src/platforms/vtex/loaders/simulation.ts +42 -0
- package/src/platforms/vtex/loaders/sku.ts +61 -0
- package/src/platforms/vtex/resolvers/aggregateOffer.ts +20 -0
- package/src/platforms/vtex/resolvers/aggregateRating.ts +7 -0
- package/src/platforms/vtex/resolvers/collection.ts +43 -0
- package/src/platforms/vtex/resolvers/facet.ts +11 -0
- package/src/platforms/vtex/resolvers/facetValue.ts +11 -0
- package/src/platforms/vtex/resolvers/mutation.ts +5 -0
- package/src/platforms/vtex/resolvers/offer.ts +26 -0
- package/src/platforms/vtex/resolvers/organization.ts +5 -0
- package/src/platforms/vtex/resolvers/product.ts +75 -0
- package/src/platforms/vtex/resolvers/productGroup.ts +9 -0
- package/src/platforms/vtex/resolvers/query.ts +115 -0
- package/src/platforms/vtex/resolvers/review.ts +11 -0
- package/src/platforms/vtex/resolvers/searchResult.ts +46 -0
- package/src/platforms/vtex/resolvers/seo.ts +10 -0
- package/src/platforms/vtex/resolvers/validateCart.ts +166 -0
- package/src/platforms/vtex/utils/enhanceSku.ts +8 -0
- package/src/platforms/vtex/utils/facets.ts +31 -0
- package/src/platforms/vtex/utils/slugify.ts +4 -0
- package/src/platforms/vtex/utils/sort.ts +10 -0
- package/src/typeDefs/aggregateOffer.graphql +10 -0
- package/src/typeDefs/aggregateRating.graphql +4 -0
- package/src/typeDefs/author.graphql +3 -0
- package/src/typeDefs/brand.graphql +3 -0
- package/src/typeDefs/breadcrumb.graphql +10 -0
- package/src/typeDefs/cart.graphql +13 -0
- package/src/typeDefs/collection.graphql +26 -0
- package/src/typeDefs/facet.graphql +14 -0
- package/src/typeDefs/image.graphql +9 -0
- package/src/typeDefs/index.ts +47 -0
- package/src/typeDefs/mutation.graphql +4 -0
- package/src/typeDefs/offer.graphql +21 -0
- package/src/typeDefs/order.graphql +9 -0
- package/src/typeDefs/organization.graphql +7 -0
- package/src/typeDefs/pageInfo.graphql +8 -0
- package/src/typeDefs/product.graphql +25 -0
- package/src/typeDefs/productGroup.graphql +5 -0
- package/src/typeDefs/query.graphql +64 -0
- package/src/typeDefs/review.graphql +9 -0
- package/src/typeDefs/seo.graphql +6 -0
- package/src/typeDefs/status.graphql +5 -0
- package/src/typings/schema.d.ts +7 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
export interface OrderFormInputItem {
|
|
2
|
+
id: string
|
|
3
|
+
quantity: number
|
|
4
|
+
seller: string
|
|
5
|
+
index?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface OrderFormItem {
|
|
9
|
+
id: string
|
|
10
|
+
name: string
|
|
11
|
+
detailUrl: string
|
|
12
|
+
imageUrl: string
|
|
13
|
+
skuName: string
|
|
14
|
+
quantity: number
|
|
15
|
+
uniqueId: string
|
|
16
|
+
productId: string
|
|
17
|
+
refId: string
|
|
18
|
+
ean: string
|
|
19
|
+
priceValidUntil: string
|
|
20
|
+
price: number
|
|
21
|
+
tax: number
|
|
22
|
+
listPrice: number
|
|
23
|
+
sellingPrice: number
|
|
24
|
+
rewardValue: number
|
|
25
|
+
isGift: boolean
|
|
26
|
+
parentItemIndex: number | null
|
|
27
|
+
parentAssemblyBinding: string | null
|
|
28
|
+
productCategoryIds: string
|
|
29
|
+
priceTags: string[]
|
|
30
|
+
manualPrice: number
|
|
31
|
+
measurementUnit: string
|
|
32
|
+
additionalInfo: {
|
|
33
|
+
brandName: string
|
|
34
|
+
brandId: string
|
|
35
|
+
offeringInfo: any | null
|
|
36
|
+
offeringType: any | null
|
|
37
|
+
offeringTypeId: any | null
|
|
38
|
+
}
|
|
39
|
+
productCategories: Record<string, string>
|
|
40
|
+
productRefId: string
|
|
41
|
+
seller: string
|
|
42
|
+
sellerChain: string[]
|
|
43
|
+
availability: string
|
|
44
|
+
unitMultiplier: number
|
|
45
|
+
skuSpecifications: SKUSpecification[]
|
|
46
|
+
priceDefinition: {
|
|
47
|
+
calculatedSellingPrice: number
|
|
48
|
+
sellingPrices: SellingPrice[]
|
|
49
|
+
total: number
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SKUSpecification {
|
|
54
|
+
fieldName: string
|
|
55
|
+
fieldValues: string[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface AdditionalInfo {
|
|
59
|
+
dimension: null
|
|
60
|
+
brandName: string
|
|
61
|
+
brandId: string
|
|
62
|
+
offeringInfo: null
|
|
63
|
+
offeringType: null
|
|
64
|
+
offeringTypeId: null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PriceDefinition {
|
|
68
|
+
calculatedSellingPrice: number
|
|
69
|
+
total: number
|
|
70
|
+
sellingPrices: SellingPrice[]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SellingPrice {
|
|
74
|
+
value: number
|
|
75
|
+
quantity: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface PriceTag {
|
|
79
|
+
name: string
|
|
80
|
+
value: number
|
|
81
|
+
rawValue: number
|
|
82
|
+
isPercentual: boolean
|
|
83
|
+
identifier: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface OrderForm {
|
|
87
|
+
orderFormId: string
|
|
88
|
+
salesChannel: string
|
|
89
|
+
loggedIn: boolean
|
|
90
|
+
isCheckedIn: boolean
|
|
91
|
+
storeId: string | null
|
|
92
|
+
checkedInPickupPointId: string | null
|
|
93
|
+
allowManualPrice: boolean
|
|
94
|
+
canEditData: boolean
|
|
95
|
+
userProfileId: string | null
|
|
96
|
+
userType: string | null
|
|
97
|
+
ignoreProfileData: boolean
|
|
98
|
+
value: number
|
|
99
|
+
messages: any[]
|
|
100
|
+
items: OrderFormItem[]
|
|
101
|
+
selectableGifts: any[]
|
|
102
|
+
totalizers: Array<{
|
|
103
|
+
id: string
|
|
104
|
+
name: string
|
|
105
|
+
value: number
|
|
106
|
+
}>
|
|
107
|
+
shippingData: ShippingData | null
|
|
108
|
+
clientProfileData: ClientProfileData | null
|
|
109
|
+
paymentData: PaymentData
|
|
110
|
+
marketingData: OrderFormMarketingData | null
|
|
111
|
+
sellers: Array<{
|
|
112
|
+
id: string
|
|
113
|
+
name: string
|
|
114
|
+
logo: string
|
|
115
|
+
}>
|
|
116
|
+
clientPreferencesData: {
|
|
117
|
+
locale: string
|
|
118
|
+
optinNewsLetter: any | null
|
|
119
|
+
}
|
|
120
|
+
commercialConditionData: any | null
|
|
121
|
+
storePreferencesData: {
|
|
122
|
+
countryCode: string
|
|
123
|
+
currencyCode: string
|
|
124
|
+
currencyFormatInfo: {
|
|
125
|
+
currencyDecimalDigits: number
|
|
126
|
+
currencyDecimalSeparator: string
|
|
127
|
+
currencyGroupSeparator: string
|
|
128
|
+
currencyGroupSize: number
|
|
129
|
+
startsWithCurrencySymbol: boolean
|
|
130
|
+
}
|
|
131
|
+
currencyLocale: string
|
|
132
|
+
currencySymbol: string
|
|
133
|
+
saveUserData: boolean
|
|
134
|
+
timeZone: string
|
|
135
|
+
}
|
|
136
|
+
giftRegistryData: any | null
|
|
137
|
+
openTextField: any | null
|
|
138
|
+
invoiceData: any | null
|
|
139
|
+
customData: any | null
|
|
140
|
+
itemMetadata: {
|
|
141
|
+
items: MetadataItem[]
|
|
142
|
+
}
|
|
143
|
+
hooksData: any | null
|
|
144
|
+
ratesAndBenefitsData: {
|
|
145
|
+
rateAndBenefitsIdentifiers: any[]
|
|
146
|
+
teaser: any[]
|
|
147
|
+
}
|
|
148
|
+
subscriptionData: SubscriptionData | null
|
|
149
|
+
itemsOrdination: any | null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface OrderFormMarketingData {
|
|
153
|
+
utmCampaign?: string
|
|
154
|
+
utmMedium?: string
|
|
155
|
+
utmSource?: string
|
|
156
|
+
utmiCampaign?: string
|
|
157
|
+
utmiPart?: string
|
|
158
|
+
utmipage?: string
|
|
159
|
+
marketingTags?: string
|
|
160
|
+
coupon?: string
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface PaymentData {
|
|
164
|
+
installmentOptions: Array<{
|
|
165
|
+
paymentSystem: string
|
|
166
|
+
bin: string | null
|
|
167
|
+
paymentName: string | null
|
|
168
|
+
paymentGroupName: string | null
|
|
169
|
+
value: number
|
|
170
|
+
installments: Array<{
|
|
171
|
+
count: number
|
|
172
|
+
hasInterestRate: false
|
|
173
|
+
interestRate: number
|
|
174
|
+
value: number
|
|
175
|
+
total: number
|
|
176
|
+
sellerMerchantInstallments: Array<{
|
|
177
|
+
count: number
|
|
178
|
+
hasInterestRate: false
|
|
179
|
+
interestRate: number
|
|
180
|
+
value: number
|
|
181
|
+
total: number
|
|
182
|
+
}>
|
|
183
|
+
}>
|
|
184
|
+
}>
|
|
185
|
+
paymentSystems: Array<{
|
|
186
|
+
id: string
|
|
187
|
+
name: string
|
|
188
|
+
groupName: string
|
|
189
|
+
validator: {
|
|
190
|
+
regex: string
|
|
191
|
+
mask: string
|
|
192
|
+
cardCodeRegex: string
|
|
193
|
+
cardCodeMask: string
|
|
194
|
+
weights: number[]
|
|
195
|
+
useCvv: boolean
|
|
196
|
+
useExpirationDate: boolean
|
|
197
|
+
useCardHolderName: boolean
|
|
198
|
+
useBillingAddress: boolean
|
|
199
|
+
}
|
|
200
|
+
stringId: string
|
|
201
|
+
template: string
|
|
202
|
+
requiresDocument: boolean
|
|
203
|
+
isCustom: boolean
|
|
204
|
+
description: string | null
|
|
205
|
+
requiresAuthentication: boolean
|
|
206
|
+
dueDate: string
|
|
207
|
+
availablePayments: any | null
|
|
208
|
+
}>
|
|
209
|
+
payments: any[]
|
|
210
|
+
giftCards: any[]
|
|
211
|
+
giftCardMessages: any[]
|
|
212
|
+
availableAccounts: any[]
|
|
213
|
+
availableTokens: any[]
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface ClientProfileData {
|
|
217
|
+
email: string
|
|
218
|
+
firstName: string
|
|
219
|
+
lastName: string
|
|
220
|
+
document: string
|
|
221
|
+
documentType: string
|
|
222
|
+
phone: string
|
|
223
|
+
corporateName: string
|
|
224
|
+
tradeName: string
|
|
225
|
+
corporateDocument: string
|
|
226
|
+
stateInscription: string
|
|
227
|
+
corporatePhone: string
|
|
228
|
+
isCorporate: boolean
|
|
229
|
+
profileCompleteOnLoading: boolean
|
|
230
|
+
profileErrorOnLoading: boolean
|
|
231
|
+
customerClass: string
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface ShippingData {
|
|
235
|
+
address: CheckoutAddress | null
|
|
236
|
+
logisticsInfo: LogisticsInfo[]
|
|
237
|
+
selectedAddresses: CheckoutAddress[]
|
|
238
|
+
availableAddresses: CheckoutAddress[]
|
|
239
|
+
pickupPoints: PickupPoint[]
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface PickupPoint {
|
|
243
|
+
friendlyName: string
|
|
244
|
+
address: CheckoutAddress
|
|
245
|
+
additionalInfo: string
|
|
246
|
+
id: string
|
|
247
|
+
businessHours: BusinessHour[]
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface BusinessHour {
|
|
251
|
+
DayOfWeek: number
|
|
252
|
+
ClosingTime: string
|
|
253
|
+
OpeningTime: string
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface LogisticsInfo {
|
|
257
|
+
addressId: string | null
|
|
258
|
+
deliveryChannels: DeliveryChannel[]
|
|
259
|
+
itemId: string
|
|
260
|
+
itemIndex: number
|
|
261
|
+
shipsTo: string[]
|
|
262
|
+
slas: SLA[]
|
|
263
|
+
selectedDeliveryChannel: string | null
|
|
264
|
+
selectedSla: string | null
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface SLA {
|
|
268
|
+
id: string
|
|
269
|
+
deliveryChannel: string
|
|
270
|
+
name: string
|
|
271
|
+
deliveryIds: DeliveryId[]
|
|
272
|
+
shippingEstimate: string
|
|
273
|
+
shippingEstimateDate: string | null
|
|
274
|
+
lockTTL: string | null
|
|
275
|
+
availableDeliveryWindows: any[]
|
|
276
|
+
deliveryWindow: string | null
|
|
277
|
+
price: number
|
|
278
|
+
listPrice: number
|
|
279
|
+
tax: number
|
|
280
|
+
pickupStoreInfo: {
|
|
281
|
+
isPickupStore: boolean
|
|
282
|
+
friendlyName: string | null
|
|
283
|
+
address: CheckoutAddress | null
|
|
284
|
+
additionalInfo: any | null
|
|
285
|
+
dockId: string | null
|
|
286
|
+
}
|
|
287
|
+
pickupPointId: string | null
|
|
288
|
+
pickupDistance: number | null
|
|
289
|
+
polygonName: string | null
|
|
290
|
+
transitTime: string | null
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface DeliveryId {
|
|
294
|
+
courierId: string
|
|
295
|
+
warehouseId: string
|
|
296
|
+
dockId: string
|
|
297
|
+
courierName: string
|
|
298
|
+
quantity: number
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface DeliveryChannel {
|
|
302
|
+
id: string
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface CheckoutAddress {
|
|
306
|
+
addressId: string
|
|
307
|
+
addressType: string
|
|
308
|
+
city: string | null
|
|
309
|
+
complement: string | null
|
|
310
|
+
country: string
|
|
311
|
+
geoCoordinates: number[]
|
|
312
|
+
neighborhood: string | null
|
|
313
|
+
number: string | null
|
|
314
|
+
postalCode: string | null
|
|
315
|
+
receiverName: string | null
|
|
316
|
+
reference: string | null
|
|
317
|
+
state: string | null
|
|
318
|
+
street: string | null
|
|
319
|
+
isDisposable: boolean
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface MetadataItem {
|
|
323
|
+
id: string
|
|
324
|
+
name: string
|
|
325
|
+
imageUrl: string
|
|
326
|
+
detailUrl: string
|
|
327
|
+
seller: string
|
|
328
|
+
assemblyOptions: AssemblyOption[]
|
|
329
|
+
skuName: string
|
|
330
|
+
productId: string
|
|
331
|
+
refId: string
|
|
332
|
+
ean: string | null
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface AssemblyOption {
|
|
336
|
+
id: string
|
|
337
|
+
name: string
|
|
338
|
+
composition: Composition | null
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface SubscriptionDataEntry {
|
|
342
|
+
executionCount: number
|
|
343
|
+
itemIndex: number
|
|
344
|
+
plan: {
|
|
345
|
+
frequency: {
|
|
346
|
+
interval: number
|
|
347
|
+
periodicity: 'YEAR' | 'MONTH' | 'WEEK' | 'DAY'
|
|
348
|
+
}
|
|
349
|
+
type: string
|
|
350
|
+
validity: unknown
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface CompositionItem {
|
|
355
|
+
id: string
|
|
356
|
+
minQuantity: number
|
|
357
|
+
maxQuantity: number
|
|
358
|
+
initialQuantity: number
|
|
359
|
+
priceTable: string
|
|
360
|
+
seller: string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface Composition {
|
|
364
|
+
minQuantity: number
|
|
365
|
+
maxQuantity: number
|
|
366
|
+
items: CompositionItem[]
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface SubscriptionData {
|
|
370
|
+
subscriptions: SubscriptionDataEntry[]
|
|
371
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export interface PayloadItem {
|
|
2
|
+
id: string
|
|
3
|
+
quantity: number
|
|
4
|
+
seller: string
|
|
5
|
+
parentItemIndex?: number | null
|
|
6
|
+
parentAssemblyBinding?: string | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ShippingData {
|
|
10
|
+
logisticsInfo?: Array<{ regionId?: string | null }>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SimulationArgs {
|
|
14
|
+
country?: string
|
|
15
|
+
items: PayloadItem[]
|
|
16
|
+
postalCode?: string
|
|
17
|
+
isCheckedIn?: boolean
|
|
18
|
+
priceTables?: string[]
|
|
19
|
+
marketingData?: Record<string, string>
|
|
20
|
+
shippingData?: ShippingData
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SimulationOptions {
|
|
24
|
+
salesChannel: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Simulation {
|
|
28
|
+
items: Item[]
|
|
29
|
+
ratesAndBenefitsData: RatesAndBenefitsData
|
|
30
|
+
paymentData: PaymentData
|
|
31
|
+
selectableGifts: any[]
|
|
32
|
+
marketingData: MarketingData
|
|
33
|
+
postalCode: null
|
|
34
|
+
country: null
|
|
35
|
+
logisticsInfo: LogisticsInfo[]
|
|
36
|
+
messages: any[]
|
|
37
|
+
purchaseConditions: PurchaseConditions
|
|
38
|
+
pickupPoints: any[]
|
|
39
|
+
subscriptionData: null
|
|
40
|
+
totals: Total[]
|
|
41
|
+
itemMetadata: null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Item {
|
|
45
|
+
id: string
|
|
46
|
+
requestIndex: number
|
|
47
|
+
quantity: number
|
|
48
|
+
seller: string
|
|
49
|
+
sellerChain: string[]
|
|
50
|
+
tax: number
|
|
51
|
+
priceValidUntil: Date
|
|
52
|
+
price: number
|
|
53
|
+
listPrice: number
|
|
54
|
+
rewardValue: number
|
|
55
|
+
sellingPrice: number
|
|
56
|
+
offerings: any[]
|
|
57
|
+
priceTags: any[]
|
|
58
|
+
measurementUnit: string
|
|
59
|
+
unitMultiplier: number
|
|
60
|
+
parentItemIndex: null
|
|
61
|
+
parentAssemblyBinding: null
|
|
62
|
+
availability: string
|
|
63
|
+
catalogProvider: string
|
|
64
|
+
priceDefinition: PriceDefinition
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PriceDefinition {
|
|
68
|
+
calculatedSellingPrice: number
|
|
69
|
+
total: number
|
|
70
|
+
sellingPrices: SellingPrice[]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SellingPrice {
|
|
74
|
+
value: number
|
|
75
|
+
quantity: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface LogisticsInfo {
|
|
79
|
+
itemIndex: number
|
|
80
|
+
addressId: null
|
|
81
|
+
selectedSla: null
|
|
82
|
+
selectedDeliveryChannel: null
|
|
83
|
+
quantity: number
|
|
84
|
+
shipsTo: string[]
|
|
85
|
+
slas: any[]
|
|
86
|
+
deliveryChannels: DeliveryChannel[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface DeliveryChannel {
|
|
90
|
+
id: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface MarketingData {
|
|
94
|
+
utmSource: null
|
|
95
|
+
utmMedium: null
|
|
96
|
+
utmCampaign: null
|
|
97
|
+
utmipage: null
|
|
98
|
+
utmiPart: null
|
|
99
|
+
utmiCampaign: null
|
|
100
|
+
coupon: null
|
|
101
|
+
marketingTags: string[]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface PaymentData {
|
|
105
|
+
installmentOptions: InstallmentOption[]
|
|
106
|
+
paymentSystems: PaymentSystem[]
|
|
107
|
+
payments: any[]
|
|
108
|
+
giftCards: any[]
|
|
109
|
+
giftCardMessages: any[]
|
|
110
|
+
availableAccounts: any[]
|
|
111
|
+
availableTokens: any[]
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface InstallmentOption {
|
|
115
|
+
paymentSystem: string
|
|
116
|
+
bin: null
|
|
117
|
+
paymentName: string
|
|
118
|
+
paymentGroupName: string
|
|
119
|
+
value: number
|
|
120
|
+
installments: Installment[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface Installment {
|
|
124
|
+
count: number
|
|
125
|
+
hasInterestRate: boolean
|
|
126
|
+
interestRate: number
|
|
127
|
+
value: number
|
|
128
|
+
total: number
|
|
129
|
+
sellerMerchantInstallments?: Installment[]
|
|
130
|
+
id?: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface PaymentSystem {
|
|
134
|
+
id: number
|
|
135
|
+
name: string
|
|
136
|
+
groupName: string
|
|
137
|
+
validator: null
|
|
138
|
+
stringId: string
|
|
139
|
+
template: string
|
|
140
|
+
requiresDocument: boolean
|
|
141
|
+
isCustom: boolean
|
|
142
|
+
description: null | string
|
|
143
|
+
requiresAuthentication: boolean
|
|
144
|
+
dueDate: Date
|
|
145
|
+
availablePayments: null
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface PurchaseConditions {
|
|
149
|
+
itemPurchaseConditions: ItemPurchaseCondition[]
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ItemPurchaseCondition {
|
|
153
|
+
id: string
|
|
154
|
+
seller: string
|
|
155
|
+
sellerChain: string[]
|
|
156
|
+
slas: any[]
|
|
157
|
+
price: number
|
|
158
|
+
listPrice: number
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface RatesAndBenefitsData {
|
|
162
|
+
rateAndBenefitsIdentifiers: any[]
|
|
163
|
+
teaser: any[]
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface Total {
|
|
167
|
+
id: string
|
|
168
|
+
name: string
|
|
169
|
+
value: number
|
|
170
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fetch from 'isomorphic-unfetch'
|
|
2
|
+
|
|
3
|
+
export const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {
|
|
4
|
+
const response = await fetch(info, init)
|
|
5
|
+
|
|
6
|
+
if (response.ok) {
|
|
7
|
+
return response.json()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const text = await response.text()
|
|
11
|
+
|
|
12
|
+
throw new Error(text)
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VtexCommerce } from './commerce'
|
|
2
|
+
import { IntelligentSearch } from './search'
|
|
3
|
+
import type { Options } from '..'
|
|
4
|
+
|
|
5
|
+
export type Clients = ReturnType<typeof getClients>
|
|
6
|
+
|
|
7
|
+
export const getClients = (options: Options) => {
|
|
8
|
+
const search = IntelligentSearch(options)
|
|
9
|
+
const commerce = VtexCommerce(options)
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
search,
|
|
13
|
+
commerce,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { fetchAPI } from '../fetch'
|
|
2
|
+
import type { SelectedFacet } from '../../utils/facets'
|
|
3
|
+
import type { Options } from '../..'
|
|
4
|
+
import type { ProductSearchResult } from './types/ProductSearchResult'
|
|
5
|
+
import type { AttributeSearchResult } from './types/AttributeSearchResult'
|
|
6
|
+
|
|
7
|
+
export type Sort =
|
|
8
|
+
| 'price:desc'
|
|
9
|
+
| 'price:asc'
|
|
10
|
+
| 'orders:desc'
|
|
11
|
+
| 'name:desc'
|
|
12
|
+
| 'name:asc'
|
|
13
|
+
| 'release:desc'
|
|
14
|
+
| 'discount:desc'
|
|
15
|
+
| ''
|
|
16
|
+
|
|
17
|
+
export interface SearchArgs {
|
|
18
|
+
query?: string
|
|
19
|
+
page: number
|
|
20
|
+
count: number
|
|
21
|
+
type: 'product_search' | 'attribute_search'
|
|
22
|
+
sort?: Sort
|
|
23
|
+
selectedFacets?: SelectedFacet[]
|
|
24
|
+
fuzzy?: '0' | '1'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ProductLocator {
|
|
28
|
+
field: 'id' | 'slug'
|
|
29
|
+
value: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const IntelligentSearch = (opts: Options) => {
|
|
33
|
+
const { channel } = opts
|
|
34
|
+
const base = `http://search.biggylabs.com.br/search-api/v1/${opts.account}`
|
|
35
|
+
|
|
36
|
+
const addDefaultFacets = (facets: SelectedFacet[]) => {
|
|
37
|
+
const facetsObj = Object.fromEntries(
|
|
38
|
+
facets.map(({ key, value }) => [key, value])
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return Object.entries({
|
|
42
|
+
'trade-policy': channel,
|
|
43
|
+
...facetsObj,
|
|
44
|
+
}).map(([key, value]) => ({ key, value }))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const search = <T>({
|
|
48
|
+
query = '',
|
|
49
|
+
page,
|
|
50
|
+
count,
|
|
51
|
+
sort = '',
|
|
52
|
+
selectedFacets = [],
|
|
53
|
+
type,
|
|
54
|
+
fuzzy = '0',
|
|
55
|
+
}: SearchArgs): Promise<T> => {
|
|
56
|
+
const params = new URLSearchParams({
|
|
57
|
+
page: (page + 1).toString(),
|
|
58
|
+
count: count.toString(),
|
|
59
|
+
query,
|
|
60
|
+
sort,
|
|
61
|
+
fuzzy,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const pathname = addDefaultFacets(selectedFacets)
|
|
65
|
+
.map(({ key, value }) => `${key}/${value}`)
|
|
66
|
+
.join('/')
|
|
67
|
+
|
|
68
|
+
return fetchAPI(
|
|
69
|
+
`${base}/api/split/${type}/${pathname}?${params.toString()}`
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const products = (args: Omit<SearchArgs, 'type'>) =>
|
|
74
|
+
search<ProductSearchResult>({ ...args, type: 'product_search' })
|
|
75
|
+
|
|
76
|
+
const facets = (args: Omit<SearchArgs, 'type'>) =>
|
|
77
|
+
search<AttributeSearchResult>({ ...args, type: 'attribute_search' })
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
facets,
|
|
81
|
+
products,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface AttributeSearchResult {
|
|
2
|
+
total: number
|
|
3
|
+
pagination: Pagination
|
|
4
|
+
sampling: boolean
|
|
5
|
+
translated: boolean
|
|
6
|
+
locale: string
|
|
7
|
+
query: string
|
|
8
|
+
operator: string
|
|
9
|
+
fuzzy: string
|
|
10
|
+
attributes: Attribute[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Attribute {
|
|
14
|
+
ids: string[]
|
|
15
|
+
visible: boolean
|
|
16
|
+
values: Value[]
|
|
17
|
+
active: boolean
|
|
18
|
+
key: string
|
|
19
|
+
originalKey: string
|
|
20
|
+
label: string
|
|
21
|
+
originalLabel: string
|
|
22
|
+
type: string
|
|
23
|
+
minValue?: number
|
|
24
|
+
maxValue?: number
|
|
25
|
+
templateURL?: string
|
|
26
|
+
proxyURL?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Value {
|
|
30
|
+
count: number
|
|
31
|
+
active: boolean
|
|
32
|
+
key?: string
|
|
33
|
+
label?: string
|
|
34
|
+
id?: string
|
|
35
|
+
originalKey?: string
|
|
36
|
+
originalLabel?: string
|
|
37
|
+
proxyURL: string
|
|
38
|
+
from?: string
|
|
39
|
+
to?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Pagination {
|
|
43
|
+
count: number
|
|
44
|
+
current: Current
|
|
45
|
+
before: any[]
|
|
46
|
+
after: any[]
|
|
47
|
+
perPage: number
|
|
48
|
+
next: First
|
|
49
|
+
previous: First
|
|
50
|
+
first: First
|
|
51
|
+
last: First
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Current {
|
|
55
|
+
index: number
|
|
56
|
+
proxyURL: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface First {
|
|
60
|
+
index: number
|
|
61
|
+
}
|