@faststore/api 2.0.2-alpha.0 → 2.0.3-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/index.d.ts CHANGED
@@ -78,6 +78,12 @@ export declare const getResolvers: (options: Options) => {
78
78
  } & {
79
79
  attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
80
80
  }, unknown, any>>;
81
+ ShippingSLA: Record<string, import("./platforms/vtex").Resolver<{
82
+ name?: string | undefined;
83
+ friendlyName?: string | undefined;
84
+ price?: number | undefined;
85
+ shippingEstimate?: string | undefined;
86
+ }, unknown, any>>;
81
87
  ObjectOrString: import("graphql").GraphQLScalarType;
82
88
  Query: {
83
89
  product: (_: unknown, { locator }: import("./__generated__/schema").QueryProductArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/utils/enhanceSku").EnhancedSku>;
@@ -128,6 +134,23 @@ export declare const getResolvers: (options: Options) => {
128
134
  cursor: string;
129
135
  }[];
130
136
  }>;
137
+ shipping: (_: unknown, { country, items, postalCode }: import("./__generated__/schema").QueryShippingArgs, ctx: import("./platforms/vtex").Context) => Promise<{
138
+ address: import("./platforms/vtex/clients/commerce/types/Address").Address;
139
+ items: import("./platforms/vtex/clients/commerce/types/Simulation").Item[];
140
+ ratesAndBenefitsData: import("./platforms/vtex/clients/commerce/types/Simulation").RatesAndBenefitsData;
141
+ paymentData: import("./platforms/vtex/clients/commerce/types/Simulation").PaymentData;
142
+ selectableGifts: any[];
143
+ marketingData: import("./platforms/vtex/clients/commerce/types/Simulation").MarketingData;
144
+ postalCode: null;
145
+ country: null;
146
+ logisticsInfo: import("./platforms/vtex/clients/commerce/types/Simulation").LogisticsInfo[];
147
+ messages: any[];
148
+ purchaseConditions: import("./platforms/vtex/clients/commerce/types/Simulation").PurchaseConditions;
149
+ pickupPoints: any[];
150
+ subscriptionData: null;
151
+ totals: import("./platforms/vtex/clients/commerce/types/Simulation").Total[];
152
+ itemMetadata: null;
153
+ }>;
131
154
  };
132
155
  Mutation: {
133
156
  validateCart: (_: unknown, { cart: { order }, session }: import("./__generated__/schema").MutationValidateCartArgs, ctx: import("./platforms/vtex").Context) => Promise<{
@@ -11,6 +11,7 @@ import type { Session } from './types/Session';
11
11
  import type { Channel } from '../../utils/channel';
12
12
  import type { SalesChannel } from './types/SalesChannel';
13
13
  import { MasterDataResponse } from './types/Newsletter';
14
+ import type { Address, AddressInput } from './types/Address';
14
15
  declare type ValueOf<T> = T extends Record<string, infer K> ? K : never;
15
16
  export declare const VtexCommerce: ({ account, environment }: Options, ctx: Context) => {
16
17
  catalog: {
@@ -56,6 +57,7 @@ export declare const VtexCommerce: ({ account, environment }: Options, ctx: Cont
56
57
  value: string;
57
58
  }) => Promise<OrderForm>;
58
59
  region: ({ postalCode, country, salesChannel, }: RegionInput) => Promise<Region>;
60
+ address: ({ postalCode, country, }: AddressInput) => Promise<Address>;
59
61
  };
60
62
  session: (search: string) => Promise<Session>;
61
63
  subscribeToNewsletter: (data: {
@@ -0,0 +1,16 @@
1
+ export interface AddressInput {
2
+ postalCode: string;
3
+ country: string;
4
+ }
5
+ export interface Address {
6
+ postalCode: string;
7
+ city: string;
8
+ state: string;
9
+ country: string;
10
+ street: string;
11
+ number: string;
12
+ neighborhood: string;
13
+ complement: string;
14
+ reference: string;
15
+ geoCoordinates: [number];
16
+ }
@@ -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[];
@@ -51,6 +51,7 @@ export declare const getClients: (options: Options, ctx: Context) => {
51
51
  value: string;
52
52
  }) => Promise<import("./commerce/types/OrderForm").OrderForm>;
53
53
  region: ({ postalCode, country, salesChannel, }: import("./commerce/types/Region").RegionInput) => Promise<import("./commerce/types/Region").Region>;
54
+ address: ({ postalCode, country, }: import("./commerce/types/Address").AddressInput) => Promise<import("./commerce/types/Address").Address>;
54
55
  };
55
56
  session: (search: string) => Promise<import("./commerce/types/Session").Session>;
56
57
  subscribeToNewsletter: (data: {
@@ -106,6 +106,12 @@ export declare const getResolvers: (_: Options) => {
106
106
  } & {
107
107
  attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
108
108
  }, unknown, any>>;
109
+ ShippingSLA: Record<string, Resolver<{
110
+ name?: string | undefined;
111
+ friendlyName?: string | undefined;
112
+ price?: number | undefined;
113
+ shippingEstimate?: string | undefined;
114
+ }, unknown, any>>;
109
115
  ObjectOrString: import("graphql").GraphQLScalarType;
110
116
  Query: {
111
117
  product: (_: unknown, { locator }: import("../..").QueryProductArgs, ctx: Context) => Promise<import("./utils/enhanceSku").EnhancedSku>;
@@ -156,6 +162,23 @@ export declare const getResolvers: (_: Options) => {
156
162
  cursor: string;
157
163
  }[];
158
164
  }>;
165
+ shipping: (_: unknown, { country, items, postalCode }: import("../..").QueryShippingArgs, ctx: Context) => Promise<{
166
+ address: import("./clients/commerce/types/Address").Address;
167
+ items: import("./clients/commerce/types/Simulation").Item[];
168
+ ratesAndBenefitsData: import("./clients/commerce/types/Simulation").RatesAndBenefitsData;
169
+ paymentData: import("./clients/commerce/types/Simulation").PaymentData;
170
+ selectableGifts: any[];
171
+ marketingData: import("./clients/commerce/types/Simulation").MarketingData;
172
+ postalCode: null;
173
+ country: null;
174
+ logisticsInfo: import("./clients/commerce/types/Simulation").LogisticsInfo[];
175
+ messages: any[];
176
+ purchaseConditions: import("./clients/commerce/types/Simulation").PurchaseConditions;
177
+ pickupPoints: any[];
178
+ subscriptionData: null;
179
+ totals: import("./clients/commerce/types/Simulation").Total[];
180
+ itemMetadata: null;
181
+ }>;
159
182
  };
160
183
  Mutation: {
161
184
  validateCart: (_: unknown, { cart: { order }, session }: import("../..").MutationValidateCartArgs, ctx: Context) => Promise<{
@@ -2,7 +2,7 @@ import type { Context, Options } from '..';
2
2
  export declare type Loaders = ReturnType<typeof getLoaders>;
3
3
  export declare const getLoaders: (options: Options, { clients }: Context) => {
4
4
  skuLoader: import("dataloader")<string, import("../utils/enhanceSku").EnhancedSku, string>;
5
- simulationLoader: import("dataloader")<import("../clients/commerce/types/Simulation").PayloadItem[], import("../clients/commerce/types/Simulation").Simulation, import("../clients/commerce/types/Simulation").PayloadItem[]>;
5
+ simulationLoader: import("dataloader")<import("../clients/commerce/types/Simulation").SimulationArgs, import("../clients/commerce/types/Simulation").Simulation, import("../clients/commerce/types/Simulation").SimulationArgs>;
6
6
  collectionLoader: import("dataloader")<string, import("../clients/commerce/types/Portal").CollectionPageType, string>;
7
7
  salesChannelLoader: import("dataloader")<string, import("../clients/commerce/types/SalesChannel").SalesChannel, string>;
8
8
  };
@@ -1,5 +1,5 @@
1
1
  import DataLoader from 'dataloader';
2
- import type { PayloadItem, Simulation } from '../clients/commerce/types/Simulation';
3
2
  import type { Options } from '..';
4
3
  import type { Clients } from '../clients';
5
- export declare const getSimulationLoader: (_: Options, clients: Clients) => DataLoader<PayloadItem[], Simulation, PayloadItem[]>;
4
+ import type { Simulation, SimulationArgs } from '../clients/commerce/types/Simulation';
5
+ export declare const getSimulationLoader: (_: Options, clients: Clients) => DataLoader<SimulationArgs, Simulation, SimulationArgs>;
@@ -1,4 +1,4 @@
1
- import type { QueryAllCollectionsArgs, QueryAllProductsArgs, QueryCollectionArgs, QueryProductArgs, QuerySearchArgs } from "../../../__generated__/schema";
1
+ import type { QueryAllCollectionsArgs, QueryAllProductsArgs, QueryCollectionArgs, QueryProductArgs, QuerySearchArgs, QueryShippingArgs } from "../../../__generated__/schema";
2
2
  import type { CategoryTree } from "../clients/commerce/types/CategoryTree";
3
3
  import type { Context } from "../index";
4
4
  export declare const Query: {
@@ -50,4 +50,21 @@ export declare const Query: {
50
50
  cursor: string;
51
51
  }[];
52
52
  }>;
53
+ shipping: (_: unknown, { country, items, postalCode }: QueryShippingArgs, ctx: Context) => Promise<{
54
+ address: import("../clients/commerce/types/Address").Address;
55
+ items: import("../clients/commerce/types/Simulation").Item[];
56
+ ratesAndBenefitsData: import("../clients/commerce/types/Simulation").RatesAndBenefitsData;
57
+ paymentData: import("../clients/commerce/types/Simulation").PaymentData;
58
+ selectableGifts: any[];
59
+ marketingData: import("../clients/commerce/types/Simulation").MarketingData;
60
+ postalCode: null;
61
+ country: null;
62
+ logisticsInfo: import("../clients/commerce/types/Simulation").LogisticsInfo[];
63
+ messages: any[];
64
+ purchaseConditions: import("../clients/commerce/types/Simulation").PurchaseConditions;
65
+ pickupPoints: any[];
66
+ subscriptionData: null;
67
+ totals: import("../clients/commerce/types/Simulation").Total[];
68
+ itemMetadata: null;
69
+ }>;
53
70
  };
@@ -0,0 +1,14 @@
1
+ import type { Resolver } from '..';
2
+ /**
3
+ * Transforms estimate (e.g 3bd) into friendly format (e.g Up to 3 business days)
4
+ * based on https://github.com/vtex-apps/shipping-estimate-translator/blob/13e17055d6353dd3f3f4c31bae77ab049002809b/messages/en.json
5
+ */
6
+ export declare const getLocalizedEstimates: (estimate: string) => string;
7
+ declare type Root = {
8
+ name?: string;
9
+ friendlyName?: string;
10
+ price?: number;
11
+ shippingEstimate?: string;
12
+ };
13
+ export declare const ShippingSLA: Record<string, Resolver<Root>>;
14
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "2.0.2-alpha.0",
3
+ "version": "2.0.3-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": "^2.0.2-alpha.0",
33
+ "@faststore/shared": "^2.0.3-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": "cd0461ed88fced9b8eb49fcff9edc320b0a6ccf5"
49
+ "gitHead": "6743690f41d38a7f6a1060f541775c8a6f82e2f5"
50
50
  }