@faststore/api 2.0.158-alpha.0 → 2.0.162-alpha.0
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/dist/__generated__/schema.d.ts +70 -4
- package/dist/api.cjs.development.js +103 -22
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +103 -22
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/platforms/vtex/clients/commerce/index.d.ts +6 -0
- package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +8 -1
- package/dist/platforms/vtex/clients/commerce/types/Region.d.ts +2 -2
- package/dist/platforms/vtex/clients/commerce/types/ShippingData.d.ts +5 -0
- package/dist/platforms/vtex/clients/index.d.ts +6 -0
- package/dist/platforms/vtex/index.d.ts +4 -0
- package/dist/platforms/vtex/resolvers/query.d.ts +5 -1
- package/package.json +2 -2
- package/src/__generated__/schema.ts +94 -21
- package/src/platforms/vtex/clients/commerce/index.ts +105 -40
- package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +9 -1
- package/src/platforms/vtex/clients/commerce/types/Region.ts +2 -2
- package/src/platforms/vtex/clients/commerce/types/ShippingData.ts +6 -0
- package/src/platforms/vtex/resolvers/query.ts +22 -3
- package/src/platforms/vtex/resolvers/validateCart.ts +54 -27
- package/src/typeDefs/query.graphql +66 -0
- package/src/typeDefs/session.graphql +40 -6
- package/src/typeDefs/shipping.graphql +27 -0
package/dist/index.d.ts
CHANGED
|
@@ -148,6 +148,10 @@ export declare const getResolvers: (options: Options) => {
|
|
|
148
148
|
totals: import("./platforms/vtex/clients/commerce/types/Simulation").Total[];
|
|
149
149
|
itemMetadata: null;
|
|
150
150
|
}>;
|
|
151
|
+
sellers: (_: unknown, { postalCode, geoCoordinates, country, salesChannel }: import("./__generated__/schema").QuerySellersArgs, ctx: import("./platforms/vtex").Context) => Promise<{
|
|
152
|
+
id: string;
|
|
153
|
+
sellers: import("./platforms/vtex/clients/commerce/types/Region").Seller[];
|
|
154
|
+
}>;
|
|
151
155
|
};
|
|
152
156
|
Mutation: {
|
|
153
157
|
validateCart: (_: unknown, { cart: { order }, session }: import("./__generated__/schema").MutationValidateCartArgs, ctx: import("./platforms/vtex").Context) => Promise<{
|
|
@@ -38,6 +38,12 @@ export declare const VtexCommerce: ({ account, environment, incrementAddress }:
|
|
|
38
38
|
checkout: {
|
|
39
39
|
simulation: (args: SimulationArgs, { salesChannel }?: SimulationOptions) => Promise<Simulation>;
|
|
40
40
|
incrementAddress: (country: string, postalCode: string) => Promise<IncrementedAddress>;
|
|
41
|
+
getDeliveryWindows: ({ id, index, deliveryMode, body, }: {
|
|
42
|
+
id: string;
|
|
43
|
+
index: number;
|
|
44
|
+
deliveryMode?: DeliveryMode | null | undefined;
|
|
45
|
+
body: ShippingDataBody;
|
|
46
|
+
}, incrementedAddress?: IncrementedAddress | undefined) => Promise<OrderForm>;
|
|
41
47
|
shippingData: ({ id, index, deliveryMode, body, }: {
|
|
42
48
|
id: string;
|
|
43
49
|
index: number;
|
|
@@ -270,7 +270,7 @@ export interface SLA {
|
|
|
270
270
|
shippingEstimate: string;
|
|
271
271
|
shippingEstimateDate: string | null;
|
|
272
272
|
lockTTL: string | null;
|
|
273
|
-
availableDeliveryWindows:
|
|
273
|
+
availableDeliveryWindows: AvailableDeliveryWindows[];
|
|
274
274
|
deliveryWindow: string | null;
|
|
275
275
|
price: number;
|
|
276
276
|
listPrice: number;
|
|
@@ -287,6 +287,13 @@ export interface SLA {
|
|
|
287
287
|
polygonName: string | null;
|
|
288
288
|
transitTime: string | null;
|
|
289
289
|
}
|
|
290
|
+
export interface AvailableDeliveryWindows {
|
|
291
|
+
startDateUtc: string;
|
|
292
|
+
endDateUtc: string;
|
|
293
|
+
price: number;
|
|
294
|
+
listPrice: number;
|
|
295
|
+
tax: number;
|
|
296
|
+
}
|
|
290
297
|
export interface DeliveryId {
|
|
291
298
|
courierId: string;
|
|
292
299
|
warehouseId: string;
|
|
@@ -21,6 +21,10 @@ export interface GeoCoordinates {
|
|
|
21
21
|
latitude: GLfloat;
|
|
22
22
|
longitude: GLfloat;
|
|
23
23
|
}
|
|
24
|
+
export interface DeliveryWindow {
|
|
25
|
+
startDate: string;
|
|
26
|
+
endDate: string;
|
|
27
|
+
}
|
|
24
28
|
export interface LogisticsInfo {
|
|
25
29
|
itemIndex?: number;
|
|
26
30
|
selectedDeliveryChannel?: string;
|
|
@@ -29,4 +33,5 @@ export interface LogisticsInfo {
|
|
|
29
33
|
export interface DeliveryMode {
|
|
30
34
|
deliveryChannel?: string;
|
|
31
35
|
deliveryMethod?: string;
|
|
36
|
+
deliveryWindow?: DeliveryWindow | null;
|
|
32
37
|
}
|
|
@@ -30,6 +30,12 @@ export declare const getClients: (options: Options, ctx: Context) => {
|
|
|
30
30
|
checkout: {
|
|
31
31
|
simulation: (args: import("./commerce/types/Simulation").SimulationArgs, { salesChannel }?: import("./commerce/types/Simulation").SimulationOptions) => Promise<import("./commerce/types/Simulation").Simulation>;
|
|
32
32
|
incrementAddress: (country: string, postalCode: string) => Promise<import("./commerce/types/IncrementedAddress").IncrementedAddress>;
|
|
33
|
+
getDeliveryWindows: ({ id, index, deliveryMode, body, }: {
|
|
34
|
+
id: string;
|
|
35
|
+
index: number;
|
|
36
|
+
deliveryMode?: import("./commerce/types/ShippingData").DeliveryMode | null | undefined;
|
|
37
|
+
body: import("./commerce/types/ShippingData").ShippingDataBody;
|
|
38
|
+
}, incrementedAddress?: import("./commerce/types/IncrementedAddress").IncrementedAddress | undefined) => Promise<import("./commerce/types/OrderForm").OrderForm>;
|
|
33
39
|
shippingData: ({ id, index, deliveryMode, body, }: {
|
|
34
40
|
id: string;
|
|
35
41
|
index: number;
|
|
@@ -177,6 +177,10 @@ export declare const getResolvers: (_: Options) => {
|
|
|
177
177
|
totals: import("./clients/commerce/types/Simulation").Total[];
|
|
178
178
|
itemMetadata: null;
|
|
179
179
|
}>;
|
|
180
|
+
sellers: (_: unknown, { postalCode, geoCoordinates, country, salesChannel }: import("../..").QuerySellersArgs, ctx: Context) => Promise<{
|
|
181
|
+
id: string;
|
|
182
|
+
sellers: import("./clients/commerce/types/Region").Seller[];
|
|
183
|
+
}>;
|
|
180
184
|
};
|
|
181
185
|
Mutation: {
|
|
182
186
|
validateCart: (_: unknown, { cart: { order }, session }: import("../..").MutationValidateCartArgs, ctx: Context) => Promise<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryAllCollectionsArgs, QueryAllProductsArgs, QueryCollectionArgs, QueryProductArgs, QuerySearchArgs, QueryShippingArgs } from "../../../__generated__/schema";
|
|
1
|
+
import type { QueryAllCollectionsArgs, QueryAllProductsArgs, QueryCollectionArgs, QueryProductArgs, QuerySearchArgs, QuerySellersArgs, QueryShippingArgs } from "../../../__generated__/schema";
|
|
2
2
|
import type { CategoryTree } from "../clients/commerce/types/CategoryTree";
|
|
3
3
|
import type { Context } from "../index";
|
|
4
4
|
import { SearchArgs } from "../clients/search";
|
|
@@ -62,4 +62,8 @@ export declare const Query: {
|
|
|
62
62
|
totals: import("../clients/commerce/types/Simulation").Total[];
|
|
63
63
|
itemMetadata: null;
|
|
64
64
|
}>;
|
|
65
|
+
sellers: (_: unknown, { postalCode, geoCoordinates, country, salesChannel }: QuerySellersArgs, ctx: Context) => Promise<{
|
|
66
|
+
id: string;
|
|
67
|
+
sellers: import("../clients/commerce/types/Region").Seller[];
|
|
68
|
+
}>;
|
|
65
69
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.162-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"graphql": "^15.6.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "cd6e9dd9d3e2cc8560a806466dcabfe3b8d5b62e"
|
|
53
53
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export type Maybe<T> = T | null;
|
|
2
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
3
2
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
4
3
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
|
5
4
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
|
@@ -100,6 +99,20 @@ export type Address = {
|
|
|
100
99
|
street?: Maybe<Scalars['String']>;
|
|
101
100
|
};
|
|
102
101
|
|
|
102
|
+
export type AvailableDeliveryWindows = {
|
|
103
|
+
__typename?: 'AvailableDeliveryWindows';
|
|
104
|
+
/** Available delivery window end date in UTC */
|
|
105
|
+
endDateUtc?: Maybe<Scalars['String']>;
|
|
106
|
+
/** Available delivery window list price */
|
|
107
|
+
listPrice?: Maybe<Scalars['Int']>;
|
|
108
|
+
/** Available delivery window price */
|
|
109
|
+
price?: Maybe<Scalars['Int']>;
|
|
110
|
+
/** Available delivery window start date in UTC */
|
|
111
|
+
startDateUtc?: Maybe<Scalars['String']>;
|
|
112
|
+
/** Available delivery window tax */
|
|
113
|
+
tax?: Maybe<Scalars['Int']>;
|
|
114
|
+
};
|
|
115
|
+
|
|
103
116
|
export type DeliveryIds = {
|
|
104
117
|
__typename?: 'DeliveryIds';
|
|
105
118
|
/** DeliveryIds courier id */
|
|
@@ -114,6 +127,13 @@ export type DeliveryIds = {
|
|
|
114
127
|
warehouseId?: Maybe<Scalars['String']>;
|
|
115
128
|
};
|
|
116
129
|
|
|
130
|
+
export type IGeoCoordinates = {
|
|
131
|
+
/** The latitude of the geographic coordinates. */
|
|
132
|
+
latitude: Scalars['Float'];
|
|
133
|
+
/** The longitude of the geographic coordinates. */
|
|
134
|
+
longitude: Scalars['Float'];
|
|
135
|
+
};
|
|
136
|
+
|
|
117
137
|
/** Person data input to the newsletter. */
|
|
118
138
|
export type IPersonNewsletter = {
|
|
119
139
|
/** Person's email. */
|
|
@@ -146,10 +166,20 @@ export type IStoreCurrency = {
|
|
|
146
166
|
};
|
|
147
167
|
|
|
148
168
|
export type IStoreDeliveryMode = {
|
|
149
|
-
/** The
|
|
169
|
+
/** The delivery channel information of the session. */
|
|
150
170
|
deliveryChannel: Scalars['String'];
|
|
151
|
-
/** The
|
|
171
|
+
/** The delivery method information of the session. */
|
|
152
172
|
deliveryMethod: Scalars['String'];
|
|
173
|
+
/** The delivery window information of the session. */
|
|
174
|
+
deliveryWindow?: Maybe<IStoreDeliveryWindow>;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** Delivery window information. */
|
|
178
|
+
export type IStoreDeliveryWindow = {
|
|
179
|
+
/** The delivery window end date information. */
|
|
180
|
+
endDate: Scalars['String'];
|
|
181
|
+
/** The delivery window start date information. */
|
|
182
|
+
startDate: Scalars['String'];
|
|
153
183
|
};
|
|
154
184
|
|
|
155
185
|
export type IStoreGeoCoordinates = {
|
|
@@ -188,7 +218,7 @@ export type IStoreOrder = {
|
|
|
188
218
|
/** ID of the order in [VTEX order management](https://help.vtex.com/en/tutorial/license-manager-resources-oms--60QcBsvWeum02cFi3GjBzg#). */
|
|
189
219
|
orderNumber: Scalars['String'];
|
|
190
220
|
/** Indicates whether or not items with attachments should be split. */
|
|
191
|
-
shouldSplitItem?:
|
|
221
|
+
shouldSplitItem?: Maybe<Scalars['Boolean']>;
|
|
192
222
|
};
|
|
193
223
|
|
|
194
224
|
/** Organization input. */
|
|
@@ -212,7 +242,7 @@ export type IStorePerson = {
|
|
|
212
242
|
/** Product input. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on. */
|
|
213
243
|
export type IStoreProduct = {
|
|
214
244
|
/** Custom Product Additional Properties. */
|
|
215
|
-
additionalProperty?:
|
|
245
|
+
additionalProperty?: Maybe<Array<IStorePropertyValue>>;
|
|
216
246
|
/** Array of product images. */
|
|
217
247
|
image: Array<IStoreImage>;
|
|
218
248
|
/** Product name. */
|
|
@@ -225,7 +255,7 @@ export type IStorePropertyValue = {
|
|
|
225
255
|
/** Property name. */
|
|
226
256
|
name: Scalars['String'];
|
|
227
257
|
/** Property id. This propert changes according to the content of the object. */
|
|
228
|
-
propertyID?:
|
|
258
|
+
propertyID?: Maybe<Scalars['String']>;
|
|
229
259
|
/** Property value. May hold a string or the string representation of an object. */
|
|
230
260
|
value: Scalars['ObjectOrString'];
|
|
231
261
|
/** Specifies the nature of the value */
|
|
@@ -245,7 +275,7 @@ export type IStoreSession = {
|
|
|
245
275
|
/** Session input address type. */
|
|
246
276
|
addressType?: Maybe<Scalars['String']>;
|
|
247
277
|
/** Session input channel. */
|
|
248
|
-
channel?:
|
|
278
|
+
channel?: Maybe<Scalars['String']>;
|
|
249
279
|
/** Session input country. */
|
|
250
280
|
country: Scalars['String'];
|
|
251
281
|
/** Session input currency. */
|
|
@@ -253,13 +283,13 @@ export type IStoreSession = {
|
|
|
253
283
|
/** Session input delivery mode. */
|
|
254
284
|
deliveryMode?: Maybe<IStoreDeliveryMode>;
|
|
255
285
|
/** Session input geoCoordinates. */
|
|
256
|
-
geoCoordinates?:
|
|
286
|
+
geoCoordinates?: Maybe<IStoreGeoCoordinates>;
|
|
257
287
|
/** Session input locale. */
|
|
258
288
|
locale: Scalars['String'];
|
|
259
289
|
/** Session input person. */
|
|
260
|
-
person?:
|
|
290
|
+
person?: Maybe<IStorePerson>;
|
|
261
291
|
/** Session input postal code. */
|
|
262
|
-
postalCode?:
|
|
292
|
+
postalCode?: Maybe<Scalars['String']>;
|
|
263
293
|
};
|
|
264
294
|
|
|
265
295
|
export type LogisticsInfo = {
|
|
@@ -344,7 +374,7 @@ export type MutationSubscribeToNewsletterArgs = {
|
|
|
344
374
|
|
|
345
375
|
export type MutationValidateCartArgs = {
|
|
346
376
|
cart: IStoreCart;
|
|
347
|
-
session?:
|
|
377
|
+
session?: Maybe<IStoreSession>;
|
|
348
378
|
};
|
|
349
379
|
|
|
350
380
|
|
|
@@ -416,19 +446,21 @@ export type Query = {
|
|
|
416
446
|
product: StoreProduct;
|
|
417
447
|
/** Returns the result of a product, facet, or suggestion search. */
|
|
418
448
|
search: StoreSearchResult;
|
|
449
|
+
/** Returns a list of sellers available for a specific localization. */
|
|
450
|
+
sellers?: Maybe<SellersData>;
|
|
419
451
|
/** Returns information about shipping simulation. */
|
|
420
452
|
shipping?: Maybe<ShippingData>;
|
|
421
453
|
};
|
|
422
454
|
|
|
423
455
|
|
|
424
456
|
export type QueryAllCollectionsArgs = {
|
|
425
|
-
after?:
|
|
457
|
+
after?: Maybe<Scalars['String']>;
|
|
426
458
|
first: Scalars['Int'];
|
|
427
459
|
};
|
|
428
460
|
|
|
429
461
|
|
|
430
462
|
export type QueryAllProductsArgs = {
|
|
431
|
-
after?:
|
|
463
|
+
after?: Maybe<Scalars['String']>;
|
|
432
464
|
first: Scalars['Int'];
|
|
433
465
|
};
|
|
434
466
|
|
|
@@ -444,11 +476,19 @@ export type QueryProductArgs = {
|
|
|
444
476
|
|
|
445
477
|
|
|
446
478
|
export type QuerySearchArgs = {
|
|
447
|
-
after?:
|
|
479
|
+
after?: Maybe<Scalars['String']>;
|
|
448
480
|
first: Scalars['Int'];
|
|
449
|
-
selectedFacets?:
|
|
450
|
-
sort?:
|
|
451
|
-
term?:
|
|
481
|
+
selectedFacets?: Maybe<Array<IStoreSelectedFacet>>;
|
|
482
|
+
sort?: Maybe<StoreSort>;
|
|
483
|
+
term?: Maybe<Scalars['String']>;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
export type QuerySellersArgs = {
|
|
488
|
+
country: Scalars['String'];
|
|
489
|
+
geoCoordinates?: Maybe<IGeoCoordinates>;
|
|
490
|
+
postalCode?: Maybe<Scalars['String']>;
|
|
491
|
+
salesChannel?: Maybe<Scalars['String']>;
|
|
452
492
|
};
|
|
453
493
|
|
|
454
494
|
|
|
@@ -467,6 +507,26 @@ export type SearchMetadata = {
|
|
|
467
507
|
logicalOperator: Scalars['String'];
|
|
468
508
|
};
|
|
469
509
|
|
|
510
|
+
/** Information of sellers. */
|
|
511
|
+
export type SellerInfo = {
|
|
512
|
+
__typename?: 'SellerInfo';
|
|
513
|
+
/** Identification of the seller */
|
|
514
|
+
id?: Maybe<Scalars['String']>;
|
|
515
|
+
/** Logo of the seller */
|
|
516
|
+
logo?: Maybe<Scalars['String']>;
|
|
517
|
+
/** Name of the seller */
|
|
518
|
+
name?: Maybe<Scalars['String']>;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/** Regionalization with sellers information. */
|
|
522
|
+
export type SellersData = {
|
|
523
|
+
__typename?: 'SellersData';
|
|
524
|
+
/** Identification of region. */
|
|
525
|
+
id?: Maybe<Scalars['String']>;
|
|
526
|
+
/** List of sellers. */
|
|
527
|
+
sellers?: Maybe<Array<Maybe<SellerInfo>>>;
|
|
528
|
+
};
|
|
529
|
+
|
|
470
530
|
/** Shipping Simulation information. */
|
|
471
531
|
export type ShippingData = {
|
|
472
532
|
__typename?: 'ShippingData';
|
|
@@ -482,6 +542,8 @@ export type ShippingData = {
|
|
|
482
542
|
|
|
483
543
|
export type ShippingSla = {
|
|
484
544
|
__typename?: 'ShippingSLA';
|
|
545
|
+
/** ShippingSLA available delivery windows. */
|
|
546
|
+
availableDeliveryWindows?: Maybe<Array<Maybe<AvailableDeliveryWindows>>>;
|
|
485
547
|
/** ShippingSLA carrier. */
|
|
486
548
|
carrier?: Maybe<Scalars['String']>;
|
|
487
549
|
/** ShippingSLA delivery channel. */
|
|
@@ -540,12 +602,12 @@ export type SkuVariants = {
|
|
|
540
602
|
|
|
541
603
|
|
|
542
604
|
export type SkuVariantsAvailableVariationsArgs = {
|
|
543
|
-
dominantVariantName?:
|
|
605
|
+
dominantVariantName?: Maybe<Scalars['String']>;
|
|
544
606
|
};
|
|
545
607
|
|
|
546
608
|
|
|
547
609
|
export type SkuVariantsSlugsMapArgs = {
|
|
548
|
-
dominantVariantName?:
|
|
610
|
+
dominantVariantName?: Maybe<Scalars['String']>;
|
|
549
611
|
};
|
|
550
612
|
|
|
551
613
|
/** Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers. */
|
|
@@ -692,10 +754,21 @@ export type StoreCurrency = {
|
|
|
692
754
|
/** Delivery mode information. */
|
|
693
755
|
export type StoreDeliveryMode = {
|
|
694
756
|
__typename?: 'StoreDeliveryMode';
|
|
695
|
-
/** The
|
|
757
|
+
/** The delivery channel information of the session. */
|
|
696
758
|
deliveryChannel: Scalars['String'];
|
|
697
|
-
/** The
|
|
759
|
+
/** The delivery method information of the session. */
|
|
698
760
|
deliveryMethod: Scalars['String'];
|
|
761
|
+
/** The delivery window information of the session. */
|
|
762
|
+
deliveryWindow?: Maybe<StoreDeliveryWindow>;
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
/** Delivery window information. */
|
|
766
|
+
export type StoreDeliveryWindow = {
|
|
767
|
+
__typename?: 'StoreDeliveryWindow';
|
|
768
|
+
/** The delivery window end date information. */
|
|
769
|
+
endDate: Scalars['String'];
|
|
770
|
+
/** The delivery window start date information. */
|
|
771
|
+
startDate: Scalars['String'];
|
|
699
772
|
};
|
|
700
773
|
|
|
701
774
|
export type StoreFacet = StoreFacetBoolean | StoreFacetRange;
|
|
@@ -22,7 +22,6 @@ import type { Address, AddressInput } from './types/Address'
|
|
|
22
22
|
import { DeliveryMode, ShippingDataBody } from './types/ShippingData'
|
|
23
23
|
import { IncrementedAddress } from './types/IncrementedAddress'
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
type ValueOf<T> = T extends Record<string, infer K> ? K : never
|
|
27
26
|
|
|
28
27
|
const BASE_INIT = {
|
|
@@ -97,52 +96,117 @@ export const VtexCommerce = (
|
|
|
97
96
|
country: string,
|
|
98
97
|
postalCode: string
|
|
99
98
|
): Promise<IncrementedAddress> => {
|
|
100
|
-
|
|
101
99
|
return incrementAddress
|
|
102
|
-
? fetchAPI(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
? fetchAPI(
|
|
101
|
+
`${base}/api/checkout/pub/postal-code/${country}/${postalCode}`,
|
|
102
|
+
{
|
|
103
|
+
method: 'GET',
|
|
104
|
+
headers: {
|
|
105
|
+
'content-type': 'application/json',
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
: Promise.resolve(undefined)
|
|
109
110
|
},
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
getDeliveryWindows: (
|
|
113
|
+
{
|
|
114
|
+
id,
|
|
115
|
+
index,
|
|
116
|
+
deliveryMode,
|
|
117
|
+
body,
|
|
118
|
+
}: {
|
|
119
|
+
id: string
|
|
120
|
+
index: number
|
|
121
|
+
deliveryMode?: DeliveryMode | null
|
|
122
|
+
body: ShippingDataBody
|
|
123
|
+
},
|
|
124
|
+
incrementedAddress?: IncrementedAddress
|
|
125
|
+
): Promise<OrderForm> => {
|
|
126
|
+
const mappedBody = {
|
|
127
|
+
logisticsInfo: Array.from({ length: index }, (_, itemIndex) => ({
|
|
128
|
+
itemIndex,
|
|
129
|
+
selectedDeliveryChannel: deliveryMode?.deliveryChannel,
|
|
130
|
+
selectedSla: deliveryMode?.deliveryMethod,
|
|
131
|
+
})),
|
|
132
|
+
selectedAddresses: body?.selectedAddresses?.map((address) => ({
|
|
133
|
+
addressType: address.addressType || null,
|
|
134
|
+
receiverName: address.receiverName || null,
|
|
135
|
+
postalCode:
|
|
136
|
+
address.postalCode || incrementedAddress?.postalCode || null,
|
|
137
|
+
city: incrementedAddress?.city || null,
|
|
138
|
+
state: incrementedAddress?.state || null,
|
|
139
|
+
country: address.country || incrementedAddress?.country || null,
|
|
140
|
+
street: incrementedAddress?.street || null,
|
|
141
|
+
number: incrementedAddress?.number || null,
|
|
142
|
+
neighborhood: incrementedAddress?.neighborhood || null,
|
|
143
|
+
complement: incrementedAddress?.complement || null,
|
|
144
|
+
reference: incrementedAddress?.reference || null,
|
|
145
|
+
geoCoordinates:
|
|
146
|
+
address.geoCoordinates ||
|
|
147
|
+
incrementedAddress?.geoCoordinates ||
|
|
148
|
+
[],
|
|
149
|
+
})),
|
|
150
|
+
}
|
|
112
151
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
deliveryMode?: DeliveryMode | null
|
|
121
|
-
body: ShippingDataBody
|
|
152
|
+
return fetchAPI(
|
|
153
|
+
`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`,
|
|
154
|
+
{
|
|
155
|
+
...BASE_INIT,
|
|
156
|
+
body: JSON.stringify(mappedBody),
|
|
157
|
+
}
|
|
158
|
+
)
|
|
122
159
|
},
|
|
123
|
-
|
|
160
|
+
|
|
161
|
+
shippingData: (
|
|
162
|
+
{
|
|
163
|
+
id,
|
|
164
|
+
index,
|
|
165
|
+
deliveryMode,
|
|
166
|
+
body,
|
|
167
|
+
}: {
|
|
168
|
+
id: string
|
|
169
|
+
index: number
|
|
170
|
+
deliveryMode?: DeliveryMode | null
|
|
171
|
+
body: ShippingDataBody
|
|
172
|
+
},
|
|
173
|
+
incrementedAddress?: IncrementedAddress
|
|
174
|
+
): Promise<OrderForm> => {
|
|
175
|
+
const hasDeliveryWindow = deliveryMode?.deliveryWindow ? true : false
|
|
176
|
+
|
|
177
|
+
const deliveryWindow = hasDeliveryWindow
|
|
178
|
+
? {
|
|
179
|
+
startDateUtc: deliveryMode?.deliveryWindow?.startDate,
|
|
180
|
+
endDateUtc: deliveryMode?.deliveryWindow?.endDate,
|
|
181
|
+
}
|
|
182
|
+
: null
|
|
124
183
|
|
|
125
184
|
const mappedBody = {
|
|
126
|
-
|
|
185
|
+
logisticsInfo: Array.from({ length: index }, (_, itemIndex) => ({
|
|
127
186
|
itemIndex,
|
|
128
187
|
selectedDeliveryChannel: deliveryMode?.deliveryChannel,
|
|
129
|
-
selectedSla: deliveryMode?.deliveryMethod
|
|
188
|
+
selectedSla: deliveryMode?.deliveryMethod,
|
|
189
|
+
deliveryWindow: deliveryWindow,
|
|
130
190
|
})),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
191
|
+
selectedAddresses: body?.selectedAddresses?.map((address) => ({
|
|
192
|
+
addressType: address.addressType || null,
|
|
193
|
+
receiverName: address.receiverName || null,
|
|
194
|
+
postalCode:
|
|
195
|
+
address.postalCode || incrementedAddress?.postalCode || null,
|
|
196
|
+
city: incrementedAddress?.city || null,
|
|
197
|
+
state: incrementedAddress?.state || null,
|
|
198
|
+
country: address.country || incrementedAddress?.country || null,
|
|
199
|
+
street: incrementedAddress?.street || null,
|
|
200
|
+
number: incrementedAddress?.number || null,
|
|
201
|
+
neighborhood: incrementedAddress?.neighborhood || null,
|
|
202
|
+
complement: incrementedAddress?.complement || null,
|
|
203
|
+
reference: incrementedAddress?.reference || null,
|
|
204
|
+
geoCoordinates:
|
|
205
|
+
address.geoCoordinates ||
|
|
206
|
+
incrementedAddress?.geoCoordinates ||
|
|
207
|
+
[],
|
|
208
|
+
})),
|
|
209
|
+
}
|
|
146
210
|
|
|
147
211
|
return fetchAPI(
|
|
148
212
|
`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`,
|
|
@@ -152,6 +216,7 @@ export const VtexCommerce = (
|
|
|
152
216
|
}
|
|
153
217
|
)
|
|
154
218
|
},
|
|
219
|
+
|
|
155
220
|
orderForm: ({
|
|
156
221
|
id,
|
|
157
222
|
refreshOutdatedData = true,
|
|
@@ -236,9 +301,9 @@ export const VtexCommerce = (
|
|
|
236
301
|
postalCode
|
|
237
302
|
? params.append('postalCode', postalCode)
|
|
238
303
|
: params.append(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
304
|
+
'geoCoordinates',
|
|
305
|
+
`${geoCoordinates?.longitude};${geoCoordinates?.latitude}`
|
|
306
|
+
)
|
|
242
307
|
|
|
243
308
|
const url = `${base}/api/checkout/pub/regions/?${params.toString()}`
|
|
244
309
|
return fetchAPI(url)
|
|
@@ -287,7 +287,7 @@ export interface SLA {
|
|
|
287
287
|
shippingEstimate: string
|
|
288
288
|
shippingEstimateDate: string | null
|
|
289
289
|
lockTTL: string | null
|
|
290
|
-
availableDeliveryWindows:
|
|
290
|
+
availableDeliveryWindows: AvailableDeliveryWindows[]
|
|
291
291
|
deliveryWindow: string | null
|
|
292
292
|
price: number
|
|
293
293
|
listPrice: number
|
|
@@ -305,6 +305,14 @@ export interface SLA {
|
|
|
305
305
|
transitTime: string | null
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
export interface AvailableDeliveryWindows {
|
|
309
|
+
startDateUtc: string,
|
|
310
|
+
endDateUtc: string,
|
|
311
|
+
price: number,
|
|
312
|
+
listPrice: number,
|
|
313
|
+
tax: number,
|
|
314
|
+
}
|
|
315
|
+
|
|
308
316
|
export interface DeliveryId {
|
|
309
317
|
courierId: string
|
|
310
318
|
warehouseId: string
|
|
@@ -24,6 +24,11 @@ export interface GeoCoordinates {
|
|
|
24
24
|
longitude: GLfloat;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export interface DeliveryWindow {
|
|
28
|
+
startDate: string;
|
|
29
|
+
endDate: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
export interface LogisticsInfo {
|
|
28
33
|
itemIndex?: number;
|
|
29
34
|
selectedDeliveryChannel?: string;
|
|
@@ -33,4 +38,5 @@ export interface LogisticsInfo {
|
|
|
33
38
|
export interface DeliveryMode {
|
|
34
39
|
deliveryChannel?: string;
|
|
35
40
|
deliveryMethod?: string;
|
|
41
|
+
deliveryWindow?: DeliveryWindow | null ;
|
|
36
42
|
}
|
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
QueryCollectionArgs,
|
|
19
19
|
QueryProductArgs,
|
|
20
20
|
QuerySearchArgs,
|
|
21
|
+
QuerySellersArgs,
|
|
21
22
|
QueryShippingArgs,
|
|
22
23
|
} from "../../../__generated__/schema"
|
|
23
24
|
import type { CategoryTree } from "../clients/commerce/types/CategoryTree"
|
|
@@ -142,9 +143,8 @@ export const Query = {
|
|
|
142
143
|
productId: crossSelling.value,
|
|
143
144
|
})
|
|
144
145
|
|
|
145
|
-
query = `product:${
|
|
146
|
-
|
|
147
|
-
}`
|
|
146
|
+
query = `product:${products.map((x) => x.productId).slice(0, first).join(";")
|
|
147
|
+
}`
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const after = maybeAfter ? Number(maybeAfter) : 0
|
|
@@ -273,4 +273,23 @@ export const Query = {
|
|
|
273
273
|
address,
|
|
274
274
|
}
|
|
275
275
|
},
|
|
276
|
+
|
|
277
|
+
sellers: async (
|
|
278
|
+
_: unknown,
|
|
279
|
+
{ postalCode, geoCoordinates, country, salesChannel }: QuerySellersArgs,
|
|
280
|
+
ctx: Context
|
|
281
|
+
) => {
|
|
282
|
+
const {
|
|
283
|
+
clients: { commerce },
|
|
284
|
+
} = ctx
|
|
285
|
+
|
|
286
|
+
const regionData = await commerce.checkout.region({ postalCode, geoCoordinates, country, salesChannel })
|
|
287
|
+
const region = regionData?.[0]
|
|
288
|
+
const { id, sellers } = region
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
id,
|
|
292
|
+
sellers
|
|
293
|
+
}
|
|
294
|
+
},
|
|
276
295
|
}
|