@faststore/api 1.12.38 → 1.12.40

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.
@@ -44,11 +44,12 @@ export declare const VtexCommerce: ({ account, environment }: Options, ctx: Cont
44
44
  refreshOutdatedData?: boolean | undefined;
45
45
  channel?: Required<Channel> | undefined;
46
46
  }) => Promise<OrderForm>;
47
- updateOrderFormItems: ({ id, orderItems, allowOutdatedData, salesChannel, }: {
47
+ updateOrderFormItems: ({ id, orderItems, allowOutdatedData, salesChannel, shouldSplitItem, }: {
48
48
  id: string;
49
49
  orderItems: OrderFormInputItem[];
50
50
  allowOutdatedData?: "paymentData" | undefined;
51
51
  salesChannel?: string | undefined;
52
+ shouldSplitItem?: boolean | null | undefined;
52
53
  }) => Promise<OrderForm>;
53
54
  setCustomData: ({ id, appId, key, value, }: {
54
55
  id: string;
@@ -38,11 +38,12 @@ export declare const getClients: (options: Options, ctx: Context) => {
38
38
  refreshOutdatedData?: boolean | undefined;
39
39
  channel?: Required<import("../utils/channel").Channel> | undefined;
40
40
  }) => Promise<import("./commerce/types/OrderForm").OrderForm>;
41
- updateOrderFormItems: ({ id, orderItems, allowOutdatedData, salesChannel, }: {
41
+ updateOrderFormItems: ({ id, orderItems, allowOutdatedData, salesChannel, shouldSplitItem, }: {
42
42
  id: string;
43
43
  orderItems: import("./commerce/types/OrderForm").OrderFormInputItem[];
44
44
  allowOutdatedData?: "paymentData" | undefined;
45
45
  salesChannel?: string | undefined;
46
+ shouldSplitItem?: boolean | null | undefined;
46
47
  }) => Promise<import("./commerce/types/OrderForm").OrderForm>;
47
48
  setCustomData: ({ id, appId, key, value, }: {
48
49
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.12.38",
3
+ "version": "1.12.40",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -46,5 +46,5 @@
46
46
  "peerDependencies": {
47
47
  "graphql": "^15.6.0"
48
48
  },
49
- "gitHead": "659eb1ff4c96f85004b3edd1f924f5753fc7a275"
49
+ "gitHead": "950ce98d6df648dba88bf714286798208ac2bf7c"
50
50
  }
@@ -133,7 +133,7 @@ export type IShippingItem = {
133
133
 
134
134
  /** Shopping cart input. */
135
135
  export type IStoreCart = {
136
- /** Order information, including `orderNumber` and `acceptedOffer`. */
136
+ /** Order information, including `orderNumber`, `acceptedOffer` and `shouldSplitItem`. */
137
137
  order: IStoreOrder;
138
138
  };
139
139
 
@@ -172,6 +172,8 @@ export type IStoreOrder = {
172
172
  acceptedOffer: Array<IStoreOffer>;
173
173
  /** ID of the order in [VTEX order management](https://help.vtex.com/en/tutorial/license-manager-resources-oms--60QcBsvWeum02cFi3GjBzg#). */
174
174
  orderNumber: Scalars['String'];
175
+ /** Indicates whether or not items with attachments should be split. */
176
+ shouldSplitItem?: Maybe<Scalars['Boolean']>;
175
177
  };
176
178
 
177
179
  /** Organization input. */
@@ -129,11 +129,13 @@ export const VtexCommerce = (
129
129
  orderItems,
130
130
  allowOutdatedData = 'paymentData',
131
131
  salesChannel = ctx.storage.channel.salesChannel,
132
+ shouldSplitItem = true,
132
133
  }: {
133
134
  id: string
134
135
  orderItems: OrderFormInputItem[]
135
136
  allowOutdatedData?: 'paymentData'
136
137
  salesChannel?: string
138
+ shouldSplitItem?: boolean | null
137
139
  }): Promise<OrderForm> => {
138
140
  const params = new URLSearchParams({
139
141
  allowOutdatedData,
@@ -144,7 +146,10 @@ export const VtexCommerce = (
144
146
  `${base}/api/checkout/pub/orderForm/${id}/items?${params}`,
145
147
  {
146
148
  ...BASE_INIT,
147
- body: JSON.stringify({ orderItems }),
149
+ body: JSON.stringify({
150
+ orderItems,
151
+ noSplitItem: !shouldSplitItem,
152
+ }),
148
153
  method: 'PATCH',
149
154
  }
150
155
  )
@@ -1,7 +1,16 @@
1
1
  import fetch from 'isomorphic-unfetch'
2
+ import packageJson from '../../../../package.json'
3
+
4
+ const USER_AGENT = `${packageJson.name}@${packageJson.version}`
2
5
 
3
6
  export const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {
4
- const response = await fetch(info, init)
7
+ const response = await fetch(info, {
8
+ ...init,
9
+ headers: {
10
+ ...init?.headers,
11
+ 'User-Agent': USER_AGENT,
12
+ },
13
+ })
5
14
 
6
15
  if (response.ok) {
7
16
  return response.status !== 204 ? response.json() : undefined
@@ -266,7 +266,7 @@ export const validateCart = async (
266
266
  { cart: { order }, session }: MutationValidateCartArgs,
267
267
  ctx: Context
268
268
  ) => {
269
- const { orderNumber: orderNumberFromCart, acceptedOffer } = order
269
+ const { orderNumber: orderNumberFromCart, acceptedOffer, shouldSplitItem } = order
270
270
  const {
271
271
  clients: { commerce },
272
272
  loaders: { skuLoader },
@@ -363,6 +363,7 @@ export const validateCart = async (
363
363
  .updateOrderFormItems({
364
364
  id: orderForm.orderFormId,
365
365
  orderItems: changes,
366
+ shouldSplitItem,
366
367
  })
367
368
  // update orderForm etag so we know last time we touched this orderForm
368
369
  .then((form) =>
@@ -31,7 +31,7 @@ Shopping cart input.
31
31
  """
32
32
  input IStoreCart {
33
33
  """
34
- Order information, including `orderNumber` and `acceptedOffer`.
34
+ Order information, including `orderNumber`, `acceptedOffer` and `shouldSplitItem`.
35
35
  """
36
36
  order: IStoreOrder!
37
37
  }
@@ -24,4 +24,8 @@ input IStoreOrder {
24
24
  Array with information on each accepted offer.
25
25
  """
26
26
  acceptedOffer: [IStoreOffer!]!
27
+ """
28
+ Indicates whether or not items with attachments should be split.
29
+ """
30
+ shouldSplitItem: Boolean
27
31
  }
@@ -0,0 +1,4 @@
1
+ declare module '*.json' {
2
+ const value: any;
3
+ export default value;
4
+ }