@faststore/api 2.0.157-alpha.0 → 2.0.158-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.
@@ -12,7 +12,7 @@ import type { Channel } from '../../utils/channel';
12
12
  import type { SalesChannel } from './types/SalesChannel';
13
13
  import { MasterDataResponse } from './types/Newsletter';
14
14
  import type { Address, AddressInput } from './types/Address';
15
- import { ShippingDataBody } from './types/ShippingData';
15
+ import { DeliveryMode, ShippingDataBody } from './types/ShippingData';
16
16
  import { IncrementedAddress } from './types/IncrementedAddress';
17
17
  declare type ValueOf<T> = T extends Record<string, infer K> ? K : never;
18
18
  export declare const VtexCommerce: ({ account, environment, incrementAddress }: Options, ctx: Context) => {
@@ -38,8 +38,10 @@ 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
- shippingData: ({ id, body, }: {
41
+ shippingData: ({ id, index, deliveryMode, body, }: {
42
42
  id: string;
43
+ index: number;
44
+ deliveryMode?: DeliveryMode | null | undefined;
43
45
  body: ShippingDataBody;
44
46
  }, incrementedAddress?: IncrementedAddress | undefined) => Promise<OrderForm>;
45
47
  orderForm: ({ id, refreshOutdatedData, channel, }: {
@@ -26,3 +26,7 @@ export interface LogisticsInfo {
26
26
  selectedDeliveryChannel?: string;
27
27
  selectedSla?: string;
28
28
  }
29
+ export interface DeliveryMode {
30
+ deliveryChannel?: string;
31
+ deliveryMethod?: string;
32
+ }
@@ -30,8 +30,10 @@ 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
- shippingData: ({ id, body, }: {
33
+ shippingData: ({ id, index, deliveryMode, body, }: {
34
34
  id: string;
35
+ index: number;
36
+ deliveryMode?: import("./commerce/types/ShippingData").DeliveryMode | null | undefined;
35
37
  body: import("./commerce/types/ShippingData").ShippingDataBody;
36
38
  }, incrementedAddress?: import("./commerce/types/IncrementedAddress").IncrementedAddress | undefined) => Promise<import("./commerce/types/OrderForm").OrderForm>;
37
39
  orderForm: ({ id, refreshOutdatedData, channel, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "2.0.157-alpha.0",
3
+ "version": "2.0.158-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": "2fe3d9c5452955ce2444486eefb015a9b9921ccf"
52
+ "gitHead": "2b36429ccda9ac1ee8cac50ebf229ad9425aba8e"
53
53
  }
@@ -145,6 +145,13 @@ export type IStoreCurrency = {
145
145
  symbol: Scalars['String'];
146
146
  };
147
147
 
148
+ export type IStoreDeliveryMode = {
149
+ /** The latitude of the geographic coordinates. */
150
+ deliveryChannel: Scalars['String'];
151
+ /** The longitude of the geographic coordinates. */
152
+ deliveryMethod: Scalars['String'];
153
+ };
154
+
148
155
  export type IStoreGeoCoordinates = {
149
156
  /** The latitude of the geographic coordinates. */
150
157
  latitude: Scalars['Float'];
@@ -235,7 +242,7 @@ export type IStoreSelectedFacet = {
235
242
 
236
243
  /** Session input. */
237
244
  export type IStoreSession = {
238
- /** Session input address Type. */
245
+ /** Session input address type. */
239
246
  addressType?: Maybe<Scalars['String']>;
240
247
  /** Session input channel. */
241
248
  channel?: InputMaybe<Scalars['String']>;
@@ -243,6 +250,8 @@ export type IStoreSession = {
243
250
  country: Scalars['String'];
244
251
  /** Session input currency. */
245
252
  currency: IStoreCurrency;
253
+ /** Session input delivery mode. */
254
+ deliveryMode?: Maybe<IStoreDeliveryMode>;
246
255
  /** Session input geoCoordinates. */
247
256
  geoCoordinates?: InputMaybe<IStoreGeoCoordinates>;
248
257
  /** Session input locale. */
@@ -680,6 +689,15 @@ export type StoreCurrency = {
680
689
  symbol: Scalars['String'];
681
690
  };
682
691
 
692
+ /** Delivery mode information. */
693
+ export type StoreDeliveryMode = {
694
+ __typename?: 'StoreDeliveryMode';
695
+ /** The latitude of the geographic coordinates. */
696
+ deliveryChannel: Scalars['String'];
697
+ /** The longitude of the geographic coordinates. */
698
+ deliveryMethod: Scalars['String'];
699
+ };
700
+
683
701
  export type StoreFacet = StoreFacetBoolean | StoreFacetRange;
684
702
 
685
703
  /** Search facet boolean information. */
@@ -968,7 +986,7 @@ export type StoreSeo = {
968
986
  /** Session information. */
969
987
  export type StoreSession = {
970
988
  __typename?: 'StoreSession';
971
- /** Session address Type. */
989
+ /** Session address type. */
972
990
  addressType?: Maybe<Scalars['String']>;
973
991
  /** Session channel. */
974
992
  channel?: Maybe<Scalars['String']>;
@@ -976,6 +994,8 @@ export type StoreSession = {
976
994
  country: Scalars['String'];
977
995
  /** Session currency. */
978
996
  currency: StoreCurrency;
997
+ /** Session delivery mode. */
998
+ deliveryMode?: Maybe<StoreDeliveryMode>;
979
999
  /** Session input geoCoordinates. */
980
1000
  geoCoordinates?: Maybe<StoreGeoCoordinates>;
981
1001
  /** Session locale. */
@@ -19,7 +19,7 @@ import { getCookie } from '../../utils/getCookies'
19
19
  import type { SalesChannel } from './types/SalesChannel'
20
20
  import { MasterDataResponse } from './types/Newsletter'
21
21
  import type { Address, AddressInput } from './types/Address'
22
- import { ShippingDataBody } from './types/ShippingData'
22
+ import { DeliveryMode, ShippingDataBody } from './types/ShippingData'
23
23
  import { IncrementedAddress } from './types/IncrementedAddress'
24
24
 
25
25
 
@@ -111,15 +111,23 @@ export const VtexCommerce = (
111
111
  shippingData: ({
112
112
 
113
113
  id,
114
+ index,
115
+ deliveryMode,
114
116
  body,
115
117
  }: {
116
118
  id: string
119
+ index: number
120
+ deliveryMode?: DeliveryMode | null
117
121
  body: ShippingDataBody
118
122
  },
119
123
  incrementedAddress?: IncrementedAddress): Promise<OrderForm> => {
120
124
 
121
-
122
125
  const mappedBody = {
126
+ "logisticsInfo": Array.from({ length: index }, (_, itemIndex) => ({
127
+ itemIndex,
128
+ selectedDeliveryChannel: deliveryMode?.deliveryChannel,
129
+ selectedSla: deliveryMode?.deliveryMethod
130
+ })),
123
131
  "selectedAddresses": body?.selectedAddresses?.map(address => ({
124
132
  "addressType": address.addressType || null,
125
133
  "receiverName": address.receiverName || null,
@@ -133,7 +141,6 @@ export const VtexCommerce = (
133
141
  "complement": incrementedAddress?.complement || null,
134
142
  "reference": incrementedAddress?.reference || null,
135
143
  "geoCoordinates": address.geoCoordinates || incrementedAddress?.geoCoordinates || []
136
-
137
144
  }))
138
145
  };
139
146
 
@@ -29,3 +29,8 @@ export interface LogisticsInfo {
29
29
  selectedDeliveryChannel?: string;
30
30
  selectedSla?: string;
31
31
  }
32
+
33
+ export interface DeliveryMode {
34
+ deliveryChannel?: string;
35
+ deliveryMethod?: string;
36
+ }
@@ -246,12 +246,15 @@ const getOrderForm = async (
246
246
 
247
247
  if (shouldUpdateShippingData) {
248
248
  let incrementedAddress: IncrementedAddress | undefined;
249
+
249
250
  if (session.postalCode) {
250
251
  incrementedAddress = await commerce.checkout.incrementAddress(session.country, session.postalCode)
251
-
252
252
  }
253
+
253
254
  return commerce.checkout.shippingData({
254
255
  id: orderForm.orderFormId,
256
+ index: orderForm.items.length,
257
+ deliveryMode: session.deliveryMode,
255
258
  body: {
256
259
  selectedAddresses: [session],
257
260
  },
@@ -48,6 +48,31 @@ input IStoreGeoCoordinates {
48
48
  longitude: Float!
49
49
  }
50
50
 
51
+ """
52
+ Delivery mode information.
53
+ """
54
+ type StoreDeliveryMode {
55
+ """
56
+ The latitude of the geographic coordinates.
57
+ """
58
+ deliveryChannel: String!
59
+ """
60
+ The longitude of the geographic coordinates.
61
+ """
62
+ deliveryMethod: String!
63
+ }
64
+
65
+ input IStoreDeliveryMode {
66
+ """
67
+ The latitude of the geographic coordinates.
68
+ """
69
+ deliveryChannel: String!
70
+ """
71
+ The longitude of the geographic coordinates.
72
+ """
73
+ deliveryMethod: String!
74
+ }
75
+
51
76
  """
52
77
  Session information.
53
78
  """
@@ -69,7 +94,12 @@ type StoreSession {
69
94
  """
70
95
  channel: String
71
96
  """
72
- Session address Type.
97
+
98
+ Session delivery mode.
99
+ """
100
+ deliveryMode: StoreDeliveryMode
101
+ """
102
+ Session address type.
73
103
  """
74
104
  addressType: String
75
105
  """
@@ -107,7 +137,12 @@ input IStoreSession {
107
137
  """
108
138
  channel: String
109
139
  """
110
- Session input address Type.
140
+
141
+ Session input delivery mode.
142
+ """
143
+ deliveryMode: IStoreDeliveryMode
144
+ """
145
+ Session input address type.
111
146
  """
112
147
  addressType: String
113
148
  """