@faststore/api 1.12.21 → 2.0.0-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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.12.29](https://github.com/vtex/faststore/compare/v1.12.28...v1.12.29) (2022-11-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * Shipping Simulation Integration ([#1440](https://github.com/vtex/faststore/issues/1440)) ([8eacba4](https://github.com/vtex/faststore/commit/8eacba46a40f53be7fdca72dc04ff838dbf449c7))
12
+
13
+
14
+
6
15
  ## [1.12.21](https://github.com/vtex/faststore/compare/v1.12.20...v1.12.21) (2022-10-31)
7
16
 
8
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.12.21",
3
+ "version": "2.0.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "p-limit": "^3.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@faststore/shared": "^1.12.20",
33
+ "@faststore/shared": "^2.0.0-alpha.0",
34
34
  "@graphql-codegen/cli": "2.2.0",
35
35
  "@graphql-codegen/typescript": "2.2.2",
36
36
  "concurrently": "^6.2.1",
@@ -46,5 +46,5 @@
46
46
  "peerDependencies": {
47
47
  "graphql": "^15.6.0"
48
48
  },
49
- "gitHead": "7546e4da77bd1f9a4facaafea854110a8a94c372"
49
+ "gitHead": "82a6325bd801a6c3a36a2d2aa294ea36a5e9b18d"
50
50
  }
@@ -74,6 +74,45 @@ export type Scalars = {
74
74
  VariantsByName: any;
75
75
  };
76
76
 
77
+ /** Address information. */
78
+ export type Address = {
79
+ __typename?: 'Address';
80
+ /** Address city */
81
+ city?: Maybe<Scalars['String']>;
82
+ /** Address complement */
83
+ complement?: Maybe<Scalars['String']>;
84
+ /** Address country */
85
+ country?: Maybe<Scalars['String']>;
86
+ /** Address geoCoordinates */
87
+ geoCoordinates?: Maybe<Array<Maybe<Scalars['Float']>>>;
88
+ /** Address neighborhood */
89
+ neighborhood?: Maybe<Scalars['String']>;
90
+ /** Address number */
91
+ number?: Maybe<Scalars['String']>;
92
+ /** Address postal code */
93
+ postalCode?: Maybe<Scalars['String']>;
94
+ /** Address reference */
95
+ reference?: Maybe<Scalars['String']>;
96
+ /** Address state */
97
+ state?: Maybe<Scalars['String']>;
98
+ /** Address street */
99
+ street?: Maybe<Scalars['String']>;
100
+ };
101
+
102
+ export type DeliveryIds = {
103
+ __typename?: 'DeliveryIds';
104
+ /** DeliveryIds courier id */
105
+ courierId?: Maybe<Scalars['String']>;
106
+ /** DeliveryIds courier name */
107
+ courierName?: Maybe<Scalars['String']>;
108
+ /** DeliveryIds dock id */
109
+ dockId?: Maybe<Scalars['String']>;
110
+ /** DeliveryIds quantity */
111
+ quantity?: Maybe<Scalars['Int']>;
112
+ /** DeliveryIds warehouse id */
113
+ warehouseId?: Maybe<Scalars['String']>;
114
+ };
115
+
77
116
  /** Person data input to the newsletter. */
78
117
  export type IPersonNewsletter = {
79
118
  /** Person's email. */
@@ -82,6 +121,16 @@ export type IPersonNewsletter = {
82
121
  name: Scalars['String'];
83
122
  };
84
123
 
124
+ /** Shipping Simulation item input. */
125
+ export type IShippingItem = {
126
+ /** ShippingItem ID / Sku. */
127
+ id: Scalars['String'];
128
+ /** Number of items. */
129
+ quantity: Scalars['Int'];
130
+ /** Seller responsible for the ShippingItem. */
131
+ seller: Scalars['String'];
132
+ };
133
+
85
134
  /** Shopping cart input. */
86
135
  export type IStoreCart = {
87
136
  /** Order information, including `orderNumber` and `acceptedOffer`. */
@@ -190,6 +239,70 @@ export type IStoreSession = {
190
239
  postalCode?: Maybe<Scalars['String']>;
191
240
  };
192
241
 
242
+ export type LogisticsInfo = {
243
+ __typename?: 'LogisticsInfo';
244
+ /** LogisticsInfo itemIndex. */
245
+ itemIndex?: Maybe<Scalars['String']>;
246
+ /** LogisticsInfo selectedSla. */
247
+ selectedSla?: Maybe<Scalars['String']>;
248
+ /** List of LogisticsInfo ShippingSLA. */
249
+ slas?: Maybe<Array<Maybe<ShippingSla>>>;
250
+ };
251
+
252
+ /** Shipping Simulation Logistic Item. */
253
+ export type LogisticsItem = {
254
+ __typename?: 'LogisticsItem';
255
+ /** LogisticsItem availability. */
256
+ availability?: Maybe<Scalars['String']>;
257
+ /** LogisticsItem ID / Sku. */
258
+ id?: Maybe<Scalars['String']>;
259
+ /** LogisticsItem listPrice. */
260
+ listPrice?: Maybe<Scalars['Int']>;
261
+ /** LogisticsItem measurementUnit. */
262
+ measurementUnit?: Maybe<Scalars['String']>;
263
+ /** LogisticsItem price. */
264
+ price?: Maybe<Scalars['Int']>;
265
+ /** Next date in which price is scheduled to change. If there is no scheduled change, this will be set a year in the future from current time. */
266
+ priceValidUntil?: Maybe<Scalars['String']>;
267
+ /** Number of items. */
268
+ quantity?: Maybe<Scalars['Int']>;
269
+ requestIndex?: Maybe<Scalars['Int']>;
270
+ /** LogisticsItem rewardValue. */
271
+ rewardValue?: Maybe<Scalars['Int']>;
272
+ /** Seller responsible for the ShippingItem. */
273
+ seller?: Maybe<Scalars['String']>;
274
+ /** List of Sellers. */
275
+ sellerChain?: Maybe<Array<Maybe<Scalars['String']>>>;
276
+ /** LogisticsItem sellingPrice. */
277
+ sellingPrice?: Maybe<Scalars['Int']>;
278
+ /** LogisticsItem tax. */
279
+ tax?: Maybe<Scalars['Int']>;
280
+ /** LogisticsItem unitMultiplier. */
281
+ unitMultiplier?: Maybe<Scalars['Int']>;
282
+ };
283
+
284
+ export type MessageFields = {
285
+ __typename?: 'MessageFields';
286
+ /** MessageFields ean. */
287
+ ean?: Maybe<Scalars['String']>;
288
+ /** MessageFields item index. */
289
+ itemIndex?: Maybe<Scalars['String']>;
290
+ /** MessageFields sku name. */
291
+ skuName?: Maybe<Scalars['String']>;
292
+ };
293
+
294
+ export type MessageInfo = {
295
+ __typename?: 'MessageInfo';
296
+ /** MessageInfo code. */
297
+ code?: Maybe<Scalars['String']>;
298
+ /** MessageInfo fields. */
299
+ fields?: Maybe<MessageFields>;
300
+ /** MessageInfo status. */
301
+ status?: Maybe<Scalars['String']>;
302
+ /** MessageInfo text. */
303
+ text?: Maybe<Scalars['String']>;
304
+ };
305
+
193
306
  export type Mutation = {
194
307
  __typename?: 'Mutation';
195
308
  /** Subscribes a new person to the newsletter list. */
@@ -224,6 +337,50 @@ export type PersonNewsletter = {
224
337
  id: Scalars['String'];
225
338
  };
226
339
 
340
+ export type PickupAddress = {
341
+ __typename?: 'PickupAddress';
342
+ /** PickupAddress address id. */
343
+ addressId?: Maybe<Scalars['String']>;
344
+ /** PickupAddress address type. */
345
+ addressType?: Maybe<Scalars['String']>;
346
+ /** PickupAddress city. */
347
+ city?: Maybe<Scalars['String']>;
348
+ /** PickupAddress complement. */
349
+ complement?: Maybe<Scalars['String']>;
350
+ /** PickupAddress country. */
351
+ country?: Maybe<Scalars['String']>;
352
+ /** PickupAddress geo coordinates. */
353
+ geoCoordinates?: Maybe<Array<Maybe<Scalars['Float']>>>;
354
+ /** PickupAddress neighborhood. */
355
+ neighborhood?: Maybe<Scalars['String']>;
356
+ /** PickupAddress number. */
357
+ number?: Maybe<Scalars['String']>;
358
+ /** PickupAddress postal code. */
359
+ postalCode?: Maybe<Scalars['String']>;
360
+ /** PickupAddress receiver name. */
361
+ receiverName?: Maybe<Scalars['String']>;
362
+ /** PickupAddress reference. */
363
+ reference?: Maybe<Scalars['String']>;
364
+ /** PickupAddress state. */
365
+ state?: Maybe<Scalars['String']>;
366
+ /** PickupAddress street. */
367
+ street?: Maybe<Scalars['String']>;
368
+ };
369
+
370
+ export type PickupStoreInfo = {
371
+ __typename?: 'PickupStoreInfo';
372
+ /** PickupStoreInfo additional information. */
373
+ additionalInfo?: Maybe<Scalars['String']>;
374
+ /** PickupStoreInfo address. */
375
+ address?: Maybe<PickupAddress>;
376
+ /** PickupStoreInfo dock id. */
377
+ dockId?: Maybe<Scalars['String']>;
378
+ /** PickupStoreInfo friendly name. */
379
+ friendlyName?: Maybe<Scalars['String']>;
380
+ /** Information if the store has pickup enable. */
381
+ isPickupStore?: Maybe<Scalars['Boolean']>;
382
+ };
383
+
227
384
  export type Query = {
228
385
  __typename?: 'Query';
229
386
  /** Returns information about all collections. */
@@ -236,6 +393,8 @@ export type Query = {
236
393
  product: StoreProduct;
237
394
  /** Returns the result of a product, facet, or suggestion search. */
238
395
  search: StoreSearchResult;
396
+ /** Returns information about shipping simulation. */
397
+ shipping?: Maybe<ShippingData>;
239
398
  };
240
399
 
241
400
 
@@ -269,6 +428,59 @@ export type QuerySearchArgs = {
269
428
  term?: Maybe<Scalars['String']>;
270
429
  };
271
430
 
431
+
432
+ export type QueryShippingArgs = {
433
+ country: Scalars['String'];
434
+ items: Array<IShippingItem>;
435
+ postalCode: Scalars['String'];
436
+ };
437
+
438
+ /** Shipping Simulation information. */
439
+ export type ShippingData = {
440
+ __typename?: 'ShippingData';
441
+ /** Address information. */
442
+ address?: Maybe<Address>;
443
+ /** List of LogisticsItem. */
444
+ items?: Maybe<Array<Maybe<LogisticsItem>>>;
445
+ /** List of LogisticsInfo. */
446
+ logisticsInfo?: Maybe<Array<Maybe<LogisticsInfo>>>;
447
+ /** List of MessageInfo. */
448
+ messages?: Maybe<Array<Maybe<MessageInfo>>>;
449
+ };
450
+
451
+ export type ShippingSla = {
452
+ __typename?: 'ShippingSLA';
453
+ /** ShippingSLA carrier. */
454
+ carrier?: Maybe<Scalars['String']>;
455
+ /** ShippingSLA delivery channel. */
456
+ deliveryChannel?: Maybe<Scalars['String']>;
457
+ /** List of ShippingSLA delivery ids. */
458
+ deliveryIds?: Maybe<Array<Maybe<DeliveryIds>>>;
459
+ /** ShippingSLA friendly name. */
460
+ friendlyName?: Maybe<Scalars['String']>;
461
+ /** ShippingSLA id. */
462
+ id?: Maybe<Scalars['String']>;
463
+ /**
464
+ * ShippingSLA localized shipping estimate.
465
+ * Note: this will always return a localized string for locale `en-US`.
466
+ */
467
+ localizedEstimates?: Maybe<Scalars['String']>;
468
+ /** ShippingSLA name. */
469
+ name?: Maybe<Scalars['String']>;
470
+ /** ShippingSLA pickup distance. */
471
+ pickupDistance?: Maybe<Scalars['Float']>;
472
+ /** ShippingSLA pickup point id. */
473
+ pickupPointId?: Maybe<Scalars['String']>;
474
+ /** ShippingSLA pickup store info. */
475
+ pickupStoreInfo?: Maybe<PickupStoreInfo>;
476
+ /** ShippingSLA price. */
477
+ price?: Maybe<Scalars['Float']>;
478
+ /** ShippingSLA shipping estimate. */
479
+ shippingEstimate?: Maybe<Scalars['String']>;
480
+ /** ShippingSLA shipping estimate date. */
481
+ shippingEstimateDate?: Maybe<Scalars['String']>;
482
+ };
483
+
272
484
  export type SkuVariants = {
273
485
  __typename?: 'SkuVariants';
274
486
  /** SKU property values for the current SKU. */
@@ -17,6 +17,7 @@ import type { Session } from './types/Session'
17
17
  import type { Channel } from '../../utils/channel'
18
18
  import type { SalesChannel } from './types/SalesChannel'
19
19
  import { MasterDataResponse } from './types/Newsletter'
20
+ import type { Address, AddressInput } from './types/Address'
20
21
 
21
22
  type ValueOf<T> = T extends Record<string, infer K> ? K : never
22
23
 
@@ -172,6 +173,14 @@ export const VtexCommerce = (
172
173
  }`
173
174
  )
174
175
  },
176
+ address: async ({
177
+ postalCode,
178
+ country,
179
+ }: AddressInput): Promise<Address> => {
180
+ return fetchAPI(
181
+ `${base}/api/checkout/pub/postal-code/${country}/${postalCode}`
182
+ )
183
+ },
175
184
  },
176
185
  session: (search: string): Promise<Session> => {
177
186
  const params = new URLSearchParams(search)
@@ -0,0 +1,17 @@
1
+ export interface AddressInput {
2
+ postalCode: string
3
+ country: string
4
+ }
5
+
6
+ export interface Address {
7
+ postalCode: string
8
+ city: string
9
+ state: string
10
+ country: string
11
+ street: string
12
+ number: string
13
+ neighborhood: string
14
+ complement: string
15
+ reference: string
16
+ geoCoordinates: [number]
17
+ }
@@ -1,4 +1,4 @@
1
- export interface PayloadItem {
1
+ export interface ShippingItem {
2
2
  id: string
3
3
  quantity: number
4
4
  seller: string
@@ -12,7 +12,7 @@ export interface ShippingData {
12
12
 
13
13
  export interface SimulationArgs {
14
14
  country?: string
15
- items: PayloadItem[]
15
+ items: ShippingItem[]
16
16
  postalCode?: string
17
17
  isCheckedIn?: boolean
18
18
  priceTables?: string[]
@@ -19,6 +19,7 @@ import { Query } from './resolvers/query'
19
19
  import { StoreReview } from './resolvers/review'
20
20
  import { StoreSearchResult } from './resolvers/searchResult'
21
21
  import { StoreSeo } from './resolvers/seo'
22
+ import { ShippingSLA } from './resolvers/shippingSLA'
22
23
  import { SkuVariants } from './resolvers/skuVariations'
23
24
  import ChannelMarshal from './utils/channel'
24
25
  import type { Loaders } from './loaders'
@@ -82,6 +83,7 @@ const Resolvers = {
82
83
  StoreSearchResult,
83
84
  StorePropertyValue,
84
85
  SkuVariants,
86
+ ShippingSLA,
85
87
  ObjectOrString,
86
88
  Query,
87
89
  Mutation,
@@ -1,12 +1,13 @@
1
1
  import DataLoader from 'dataloader'
2
2
  import pLimit from 'p-limit'
3
3
 
4
+ import type { Options } from '..'
5
+ import type { Clients } from '../clients'
4
6
  import type {
5
- PayloadItem,
7
+ ShippingItem,
6
8
  Simulation,
9
+ SimulationArgs,
7
10
  } from '../clients/commerce/types/Simulation'
8
- import type { Options } from '..'
9
- import type { Clients } from '../clients'
10
11
 
11
12
  // Limits concurrent requests to the API per request cycle
12
13
  const CONCURRENT_REQUESTS_MAX = 1
@@ -14,9 +15,15 @@ const CONCURRENT_REQUESTS_MAX = 1
14
15
  export const getSimulationLoader = (_: Options, clients: Clients) => {
15
16
  const limit = pLimit(CONCURRENT_REQUESTS_MAX)
16
17
 
17
- const loader = async (allItems: readonly PayloadItem[][]) => {
18
+ const loader = async (simulationArgs: readonly SimulationArgs[]) => {
19
+ const allItems = simulationArgs.reduce((acc, { items }: SimulationArgs) => {
20
+ return [...acc, items]
21
+ }, [] as ShippingItem[][])
22
+
18
23
  const items = [...allItems.flat()]
19
24
  const simulation = await clients.commerce.checkout.simulation({
25
+ country: simulationArgs[0].country,
26
+ postalCode: simulationArgs[0].postalCode,
20
27
  items,
21
28
  })
22
29
 
@@ -45,10 +52,10 @@ export const getSimulationLoader = (_: Options, clients: Clients) => {
45
52
  }))
46
53
  }
47
54
 
48
- const limited = async (allItems: readonly PayloadItem[][]) =>
55
+ const limited = async (allItems: readonly SimulationArgs[]) =>
49
56
  limit(loader, allItems)
50
57
 
51
- return new DataLoader<PayloadItem[], Simulation>(limited, {
58
+ return new DataLoader<SimulationArgs, Simulation>(limited, {
52
59
  maxBatchSize: 50,
53
60
  })
54
61
  }
@@ -18,6 +18,7 @@ import type {
18
18
  QueryCollectionArgs,
19
19
  QueryProductArgs,
20
20
  QuerySearchArgs,
21
+ QueryShippingArgs,
21
22
  } from "../../../__generated__/schema"
22
23
  import type { CategoryTree } from "../clients/commerce/types/CategoryTree"
23
24
  import type { Context } from "../index"
@@ -249,4 +250,24 @@ export const Query = {
249
250
  })),
250
251
  }
251
252
  },
253
+ shipping: async (
254
+ _: unknown,
255
+ { country, items, postalCode }: QueryShippingArgs,
256
+ ctx: Context
257
+ ) => {
258
+ const {
259
+ loaders: { simulationLoader },
260
+ clients: { commerce },
261
+ } = ctx
262
+
263
+ const [simulation, address] = await Promise.all([
264
+ simulationLoader.load({ country, items, postalCode }),
265
+ commerce.checkout.address({ postalCode, country }),
266
+ ])
267
+
268
+ return {
269
+ ...simulation,
270
+ address,
271
+ }
272
+ },
252
273
  }
@@ -0,0 +1,64 @@
1
+ import type { Resolver } from '..'
2
+
3
+ type Unit = 'bd' | 'd' | 'h' | 'm'
4
+ const units = ['bd', 'd', 'h', 'm'] as const
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ const isUnit = (x: any): x is Unit => units.includes(x)
8
+
9
+ const localizedEstimates: Record<string, Record<string, string>> = {
10
+ bd: {
11
+ 0: 'Today',
12
+ 1: 'In 1 business day',
13
+ other: `Up to # business days`,
14
+ },
15
+ d: {
16
+ 0: 'Today',
17
+ 1: 'In 1 day',
18
+ other: 'Up to # days',
19
+ },
20
+ h: {
21
+ 0: 'Now',
22
+ 1: 'In 1 hour',
23
+ other: 'Up to # hours',
24
+ },
25
+ m: {
26
+ 0: 'Now',
27
+ 1: 'In 1 minute',
28
+ other: 'Up to # minutes',
29
+ },
30
+ }
31
+
32
+ /**
33
+ * Transforms estimate (e.g 3bd) into friendly format (e.g Up to 3 business days)
34
+ * based on https://github.com/vtex-apps/shipping-estimate-translator/blob/13e17055d6353dd3f3f4c31bae77ab049002809b/messages/en.json
35
+ */
36
+
37
+ export const getLocalizedEstimates = (estimate: string): string => {
38
+ const [amount, unit] = [estimate.split(/\D+/)[0], estimate.split(/[0-9]+/)[1]]
39
+
40
+ const isAmountNumber = amount !== '' && !Number.isNaN(Number(amount))
41
+ const isUnitValid = isUnit(unit)
42
+
43
+ if (!isAmountNumber || !isUnitValid) {
44
+ return ''
45
+ }
46
+
47
+ const amountKey = Number(amount) < 2 ? Number(amount) : 'other'
48
+
49
+ return localizedEstimates[unit][amountKey].replace('#', amount) ?? ''
50
+ }
51
+
52
+ type Root = {
53
+ name?: string
54
+ friendlyName?: string
55
+ price?: number
56
+ shippingEstimate?: string
57
+ }
58
+
59
+ export const ShippingSLA: Record<string, Resolver<Root>> = {
60
+ carrier: (root) => root?.friendlyName ?? root?.name ?? '',
61
+ price: (root) => (root?.price ? root.price / 100 : root?.price),
62
+ localizedEstimates: (root) =>
63
+ root?.shippingEstimate ? getLocalizedEstimates(root.shippingEstimate) : '',
64
+ }
@@ -0,0 +1,45 @@
1
+ """
2
+ Address information.
3
+ """
4
+ type Address {
5
+ """
6
+ Address postal code
7
+ """
8
+ postalCode: String
9
+ """
10
+ Address city
11
+ """
12
+ city: String
13
+ """
14
+ Address state
15
+ """
16
+ state: String
17
+ """
18
+ Address country
19
+ """
20
+ country: String
21
+ """
22
+ Address street
23
+ """
24
+ street: String
25
+ """
26
+ Address number
27
+ """
28
+ number: String
29
+ """
30
+ Address neighborhood
31
+ """
32
+ neighborhood: String
33
+ """
34
+ Address complement
35
+ """
36
+ complement: String
37
+ """
38
+ Address reference
39
+ """
40
+ reference: String
41
+ """
42
+ Address geoCoordinates
43
+ """
44
+ geoCoordinates: [Float]
45
+ }
@@ -1,35 +1,38 @@
1
1
  import { print } from 'graphql'
2
2
 
3
+ import Address from './address.graphql'
3
4
  import AggregateOffer from './aggregateOffer.graphql'
4
5
  import AggregateRating from './aggregateRating.graphql'
5
6
  import Author from './author.graphql'
6
7
  import Brand from './brand.graphql'
7
8
  import Breadcrumb from './breadcrumb.graphql'
9
+ import Cart from './cart.graphql'
8
10
  import Collection from './collection.graphql'
9
11
  import Facet from './facet.graphql'
10
12
  import Image from './image.graphql'
11
13
  import Mutation from './mutation.graphql'
14
+ import Newsletter from './newsletter.graphql'
15
+ import ObjectOrString from './objectOrString.graphql'
12
16
  import Offer from './offer.graphql'
13
17
  import Order from './order.graphql'
14
18
  import Organization from './organization.graphql'
15
19
  import PageInfo from './pageInfo.graphql'
20
+ import Person from './person.graphql'
16
21
  import Product from './product.graphql'
17
22
  import ProductGroup from './productGroup.graphql'
23
+ import PropertyValue from './propertyValue.graphql'
18
24
  import Query from './query.graphql'
19
25
  import Review from './review.graphql'
20
26
  import Seo from './seo.graphql'
21
- import Cart from './cart.graphql'
22
- import Status from './status.graphql'
23
- import PropertyValue from './propertyValue.graphql'
24
- import Person from './person.graphql'
25
- import ObjectOrString from './objectOrString.graphql'
26
27
  import Session from './session.graphql'
27
- import Newsletter from './newsletter.graphql'
28
+ import ShippingSimulation from './shipping.graphql'
28
29
  import SkuVariants from './skuVariants.graphql'
30
+ import Status from './status.graphql'
29
31
 
30
32
  export const typeDefs = [
31
33
  Query,
32
34
  Mutation,
35
+ Address,
33
36
  Brand,
34
37
  Breadcrumb,
35
38
  Collection,
@@ -54,6 +57,7 @@ export const typeDefs = [
54
57
  Session,
55
58
  Newsletter,
56
59
  SkuVariants,
60
+ ShippingSimulation,
57
61
  ]
58
62
  .map(print)
59
63
  .join('\n')
@@ -245,4 +245,23 @@ type Query {
245
245
  after: String
246
246
  ): StoreCollectionConnection!
247
247
  @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
248
+
249
+ """
250
+ Returns information about shipping simulation.
251
+ """
252
+ shipping(
253
+ """
254
+ List of SKU products
255
+ """
256
+ items: [IShippingItem!]!
257
+ """
258
+ Postal code to freight calculator
259
+ """
260
+ postalCode: String!
261
+ """
262
+ Country of postal code
263
+ """
264
+ country: String!
265
+ ): ShippingData
266
+ @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
248
267
  }
@@ -0,0 +1,304 @@
1
+ """
2
+ Shipping Simulation item input.
3
+ """
4
+ input IShippingItem {
5
+ """
6
+ ShippingItem ID / Sku.
7
+ """
8
+ id: String!
9
+ """
10
+ Number of items.
11
+ """
12
+ quantity: Int!
13
+ """
14
+ Seller responsible for the ShippingItem.
15
+ """
16
+ seller: String!
17
+ }
18
+
19
+ """
20
+ Shipping Simulation information.
21
+ """
22
+ type ShippingData {
23
+ """
24
+ List of LogisticsItem.
25
+ """
26
+ items: [LogisticsItem]
27
+ """
28
+ List of LogisticsInfo.
29
+ """
30
+ logisticsInfo: [LogisticsInfo]
31
+ """
32
+ List of MessageInfo.
33
+ """
34
+ messages: [MessageInfo]
35
+ """
36
+ Address information.
37
+ """
38
+ address: Address
39
+ }
40
+
41
+ """
42
+ Shipping Simulation Logistic Item.
43
+ """
44
+ type LogisticsItem {
45
+ """
46
+ LogisticsItem ID / Sku.
47
+ """
48
+ id: String
49
+ requestIndex: Int
50
+ """
51
+ Number of items.
52
+ """
53
+ quantity: Int
54
+ """
55
+ Seller responsible for the ShippingItem.
56
+ """
57
+ seller: String
58
+ """
59
+ List of Sellers.
60
+ """
61
+ sellerChain: [String]
62
+ """
63
+ LogisticsItem tax.
64
+ """
65
+ tax: Int
66
+ """
67
+ Next date in which price is scheduled to change. If there is no scheduled change, this will be set a year in the future from current time.
68
+ """
69
+ priceValidUntil: String
70
+ """
71
+ LogisticsItem price.
72
+ """
73
+ price: Int
74
+ """
75
+ LogisticsItem listPrice.
76
+ """
77
+ listPrice: Int
78
+ """
79
+ LogisticsItem rewardValue.
80
+ """
81
+ rewardValue: Int
82
+ """
83
+ LogisticsItem sellingPrice.
84
+ """
85
+ sellingPrice: Int
86
+ """
87
+ LogisticsItem measurementUnit.
88
+ """
89
+ measurementUnit: String
90
+ """
91
+ LogisticsItem unitMultiplier.
92
+ """
93
+ unitMultiplier: Int
94
+ """
95
+ LogisticsItem availability.
96
+ """
97
+ availability: String
98
+ }
99
+
100
+ type LogisticsInfo {
101
+ """
102
+ LogisticsInfo itemIndex.
103
+ """
104
+ itemIndex: String
105
+ """
106
+ LogisticsInfo selectedSla.
107
+ """
108
+ selectedSla: String
109
+ """
110
+ List of LogisticsInfo ShippingSLA.
111
+ """
112
+ slas: [ShippingSLA]
113
+ }
114
+
115
+ type ShippingSLA {
116
+ """
117
+ ShippingSLA id.
118
+ """
119
+ id: String
120
+ """
121
+ ShippingSLA name.
122
+ """
123
+ name: String
124
+ """
125
+ ShippingSLA price.
126
+ """
127
+ price: Float
128
+ """
129
+ ShippingSLA shipping estimate.
130
+ """
131
+ shippingEstimate: String
132
+ """
133
+ ShippingSLA localized shipping estimate.
134
+ Note: this will always return a localized string for locale `en-US`.
135
+ """
136
+ localizedEstimates: String
137
+ """
138
+ ShippingSLA shipping estimate date.
139
+ """
140
+ shippingEstimateDate: String
141
+ """
142
+ List of ShippingSLA delivery ids.
143
+ """
144
+ deliveryIds: [DeliveryIds]
145
+ """
146
+ ShippingSLA delivery channel.
147
+ """
148
+ deliveryChannel: String
149
+ """
150
+ ShippingSLA friendly name.
151
+ """
152
+ friendlyName: String
153
+ """
154
+ ShippingSLA carrier.
155
+ """
156
+ carrier: String
157
+ """
158
+ ShippingSLA pickup point id.
159
+ """
160
+ pickupPointId: String
161
+ """
162
+ ShippingSLA pickup store info.
163
+ """
164
+ pickupStoreInfo: PickupStoreInfo
165
+ """
166
+ ShippingSLA pickup distance.
167
+ """
168
+ pickupDistance: Float
169
+ }
170
+
171
+ type DeliveryIds {
172
+ """
173
+ DeliveryIds courier id
174
+ """
175
+ courierId: String
176
+ """
177
+ DeliveryIds warehouse id
178
+ """
179
+ warehouseId: String
180
+ """
181
+ DeliveryIds dock id
182
+ """
183
+ dockId: String
184
+ """
185
+ DeliveryIds courier name
186
+ """
187
+ courierName: String
188
+ """
189
+ DeliveryIds quantity
190
+ """
191
+ quantity: Int
192
+ }
193
+
194
+ type PickupStoreInfo {
195
+ """
196
+ PickupStoreInfo friendly name.
197
+ """
198
+ friendlyName: String
199
+ """
200
+ PickupStoreInfo address.
201
+ """
202
+ address: PickupAddress
203
+ """
204
+ PickupStoreInfo additional information.
205
+ """
206
+ additionalInfo: String
207
+ """
208
+ PickupStoreInfo dock id.
209
+ """
210
+ dockId: String
211
+ """
212
+ Information if the store has pickup enable.
213
+ """
214
+ isPickupStore: Boolean
215
+ }
216
+
217
+ type PickupAddress {
218
+ """
219
+ PickupAddress address type.
220
+ """
221
+ addressType: String
222
+ """
223
+ PickupAddress receiver name.
224
+ """
225
+ receiverName: String
226
+ """
227
+ PickupAddress address id.
228
+ """
229
+ addressId: String
230
+ """
231
+ PickupAddress postal code.
232
+ """
233
+ postalCode: String
234
+ """
235
+ PickupAddress city.
236
+ """
237
+ city: String
238
+ """
239
+ PickupAddress state.
240
+ """
241
+ state: String
242
+ """
243
+ PickupAddress country.
244
+ """
245
+ country: String
246
+ """
247
+ PickupAddress street.
248
+ """
249
+ street: String
250
+ """
251
+ PickupAddress number.
252
+ """
253
+ number: String
254
+ """
255
+ PickupAddress neighborhood.
256
+ """
257
+ neighborhood: String
258
+ """
259
+ PickupAddress complement.
260
+ """
261
+ complement: String
262
+ """
263
+ PickupAddress reference.
264
+ """
265
+ reference: String
266
+ """
267
+ PickupAddress geo coordinates.
268
+ """
269
+ geoCoordinates: [Float]
270
+ }
271
+
272
+ type MessageInfo {
273
+ """
274
+ MessageInfo code.
275
+ """
276
+ code: String
277
+ """
278
+ MessageInfo text.
279
+ """
280
+ text: String
281
+ """
282
+ MessageInfo status.
283
+ """
284
+ status: String
285
+ """
286
+ MessageInfo fields.
287
+ """
288
+ fields: MessageFields
289
+ }
290
+
291
+ type MessageFields {
292
+ """
293
+ MessageFields item index.
294
+ """
295
+ itemIndex: String
296
+ """
297
+ MessageFields ean.
298
+ """
299
+ ean: String
300
+ """
301
+ MessageFields sku name.
302
+ """
303
+ skuName: String
304
+ }