@faststore/api 3.65.1 → 3.68.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.
Files changed (102) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/__generated__/schema.d.ts +80 -0
  3. package/dist/cjs/src/__generated__/schema.d.ts.map +1 -1
  4. package/dist/cjs/src/__generated__/schema.js.map +1 -1
  5. package/dist/cjs/src/index.d.ts +2 -0
  6. package/dist/cjs/src/index.d.ts.map +1 -1
  7. package/dist/cjs/src/platforms/vtex/clients/commerce/index.d.ts +12 -0
  8. package/dist/cjs/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
  9. package/dist/cjs/src/platforms/vtex/clients/commerce/index.js +37 -0
  10. package/dist/cjs/src/platforms/vtex/clients/commerce/index.js.map +1 -1
  11. package/dist/cjs/src/platforms/vtex/clients/commerce/types/PickupPoints.d.ts +37 -0
  12. package/dist/cjs/src/platforms/vtex/clients/commerce/types/PickupPoints.d.ts.map +1 -0
  13. package/dist/cjs/src/platforms/vtex/clients/commerce/types/PickupPoints.js +3 -0
  14. package/dist/cjs/src/platforms/vtex/clients/commerce/types/PickupPoints.js.map +1 -0
  15. package/dist/cjs/src/platforms/vtex/clients/index.d.ts +11 -0
  16. package/dist/cjs/src/platforms/vtex/clients/index.d.ts.map +1 -1
  17. package/dist/cjs/src/platforms/vtex/clients/search/index.d.ts.map +1 -1
  18. package/dist/cjs/src/platforms/vtex/clients/search/index.js +12 -0
  19. package/dist/cjs/src/platforms/vtex/clients/search/index.js.map +1 -1
  20. package/dist/cjs/src/platforms/vtex/index.d.ts +2 -0
  21. package/dist/cjs/src/platforms/vtex/index.d.ts.map +1 -1
  22. package/dist/cjs/src/platforms/vtex/resolvers/facet.d.ts +1 -1
  23. package/dist/cjs/src/platforms/vtex/resolvers/facet.d.ts.map +1 -1
  24. package/dist/cjs/src/platforms/vtex/resolvers/facet.js.map +1 -1
  25. package/dist/cjs/src/platforms/vtex/resolvers/mutation.d.ts +1 -0
  26. package/dist/cjs/src/platforms/vtex/resolvers/mutation.d.ts.map +1 -1
  27. package/dist/cjs/src/platforms/vtex/resolvers/mutation.js +2 -0
  28. package/dist/cjs/src/platforms/vtex/resolvers/mutation.js.map +1 -1
  29. package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts +2 -1
  30. package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
  31. package/dist/cjs/src/platforms/vtex/resolvers/query.js +8 -1
  32. package/dist/cjs/src/platforms/vtex/resolvers/query.js.map +1 -1
  33. package/dist/cjs/src/platforms/vtex/resolvers/setPassword.d.ts +4 -0
  34. package/dist/cjs/src/platforms/vtex/resolvers/setPassword.d.ts.map +1 -0
  35. package/dist/cjs/src/platforms/vtex/resolvers/setPassword.js +19 -0
  36. package/dist/cjs/src/platforms/vtex/resolvers/setPassword.js.map +1 -0
  37. package/dist/cjs/src/platforms/vtex/utils/buildFormData.d.ts +2 -0
  38. package/dist/cjs/src/platforms/vtex/utils/buildFormData.d.ts.map +1 -0
  39. package/dist/cjs/src/platforms/vtex/utils/buildFormData.js +13 -0
  40. package/dist/cjs/src/platforms/vtex/utils/buildFormData.js.map +1 -0
  41. package/dist/cjs/src/typeDefs/mutation.graphql +5 -0
  42. package/dist/cjs/src/typeDefs/password.graphql +43 -0
  43. package/dist/cjs/src/typeDefs/pickupPoints.graphql +79 -0
  44. package/dist/cjs/src/typeDefs/query.graphql +11 -0
  45. package/dist/esm/package.json +1 -1
  46. package/dist/esm/src/__generated__/schema.d.ts +80 -0
  47. package/dist/esm/src/__generated__/schema.d.ts.map +1 -1
  48. package/dist/esm/src/__generated__/schema.js.map +1 -1
  49. package/dist/esm/src/index.d.ts +2 -0
  50. package/dist/esm/src/index.d.ts.map +1 -1
  51. package/dist/esm/src/platforms/vtex/clients/commerce/index.d.ts +12 -0
  52. package/dist/esm/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
  53. package/dist/esm/src/platforms/vtex/clients/commerce/index.js +37 -0
  54. package/dist/esm/src/platforms/vtex/clients/commerce/index.js.map +1 -1
  55. package/dist/esm/src/platforms/vtex/clients/commerce/types/PickupPoints.d.ts +37 -0
  56. package/dist/esm/src/platforms/vtex/clients/commerce/types/PickupPoints.d.ts.map +1 -0
  57. package/dist/esm/src/platforms/vtex/clients/commerce/types/PickupPoints.js +2 -0
  58. package/dist/esm/src/platforms/vtex/clients/commerce/types/PickupPoints.js.map +1 -0
  59. package/dist/esm/src/platforms/vtex/clients/index.d.ts +11 -0
  60. package/dist/esm/src/platforms/vtex/clients/index.d.ts.map +1 -1
  61. package/dist/esm/src/platforms/vtex/clients/search/index.d.ts.map +1 -1
  62. package/dist/esm/src/platforms/vtex/clients/search/index.js +12 -0
  63. package/dist/esm/src/platforms/vtex/clients/search/index.js.map +1 -1
  64. package/dist/esm/src/platforms/vtex/index.d.ts +2 -0
  65. package/dist/esm/src/platforms/vtex/index.d.ts.map +1 -1
  66. package/dist/esm/src/platforms/vtex/resolvers/facet.d.ts +1 -1
  67. package/dist/esm/src/platforms/vtex/resolvers/facet.d.ts.map +1 -1
  68. package/dist/esm/src/platforms/vtex/resolvers/facet.js.map +1 -1
  69. package/dist/esm/src/platforms/vtex/resolvers/mutation.d.ts +1 -0
  70. package/dist/esm/src/platforms/vtex/resolvers/mutation.d.ts.map +1 -1
  71. package/dist/esm/src/platforms/vtex/resolvers/mutation.js +2 -0
  72. package/dist/esm/src/platforms/vtex/resolvers/mutation.js.map +1 -1
  73. package/dist/esm/src/platforms/vtex/resolvers/query.d.ts +2 -1
  74. package/dist/esm/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
  75. package/dist/esm/src/platforms/vtex/resolvers/query.js +8 -1
  76. package/dist/esm/src/platforms/vtex/resolvers/query.js.map +1 -1
  77. package/dist/esm/src/platforms/vtex/resolvers/setPassword.d.ts +4 -0
  78. package/dist/esm/src/platforms/vtex/resolvers/setPassword.d.ts.map +1 -0
  79. package/dist/esm/src/platforms/vtex/resolvers/setPassword.js +15 -0
  80. package/dist/esm/src/platforms/vtex/resolvers/setPassword.js.map +1 -0
  81. package/dist/esm/src/platforms/vtex/utils/buildFormData.d.ts +2 -0
  82. package/dist/esm/src/platforms/vtex/utils/buildFormData.d.ts.map +1 -0
  83. package/dist/esm/src/platforms/vtex/utils/buildFormData.js +9 -0
  84. package/dist/esm/src/platforms/vtex/utils/buildFormData.js.map +1 -0
  85. package/dist/esm/src/typeDefs/mutation.graphql +5 -0
  86. package/dist/esm/src/typeDefs/password.graphql +43 -0
  87. package/dist/esm/src/typeDefs/pickupPoints.graphql +79 -0
  88. package/dist/esm/src/typeDefs/query.graphql +11 -0
  89. package/package.json +2 -2
  90. package/src/__generated__/schema.ts +90 -0
  91. package/src/platforms/vtex/clients/commerce/index.ts +67 -0
  92. package/src/platforms/vtex/clients/commerce/types/PickupPoints.ts +40 -0
  93. package/src/platforms/vtex/clients/search/index.ts +20 -0
  94. package/src/platforms/vtex/resolvers/facet.ts +4 -4
  95. package/src/platforms/vtex/resolvers/mutation.ts +2 -0
  96. package/src/platforms/vtex/resolvers/query.ts +17 -1
  97. package/src/platforms/vtex/resolvers/setPassword.ts +26 -0
  98. package/src/platforms/vtex/utils/buildFormData.ts +12 -0
  99. package/src/typeDefs/mutation.graphql +5 -0
  100. package/src/typeDefs/password.graphql +43 -0
  101. package/src/typeDefs/pickupPoints.graphql +79 -0
  102. package/src/typeDefs/query.graphql +11 -0
@@ -129,6 +129,16 @@ export type AvailableDeliveryWindows = {
129
129
  tax?: Maybe<Scalars['Int']>;
130
130
  };
131
131
 
132
+ export type BusinessHour = {
133
+ __typename?: 'BusinessHour';
134
+ /** Business hour closing time. */
135
+ closingTime?: Maybe<Scalars['String']>;
136
+ /** Number that represents the day of the week. */
137
+ dayOfWeek?: Maybe<Scalars['Int']>;
138
+ /** Business hour opening time. */
139
+ openingTime?: Maybe<Scalars['String']>;
140
+ };
141
+
132
142
  /** Commercial Authorization dimension status. */
133
143
  export type CommercialAuthorizationDimensionStatus = {
134
144
  __typename?: 'CommercialAuthorizationDimensionStatus';
@@ -370,6 +380,20 @@ export type IProcessOrderAuthorization = {
370
380
  ruleId: Scalars['String'];
371
381
  };
372
382
 
383
+ /** Input type for setting a new password. */
384
+ export type ISetPassword = {
385
+ /** Optional access key for the user, used in some authentication flows. */
386
+ accesskey?: Maybe<Scalars['String']>;
387
+ /** The current password of the user, required for verification before changing to the new password. */
388
+ currentPassword: Scalars['String'];
389
+ /** The email of the user for whom the password is being set. */
390
+ email: Scalars['String'];
391
+ /** The new password to be set for the user. */
392
+ newPassword: Scalars['String'];
393
+ /** Optional reCAPTCHA token for security verification. */
394
+ recaptcha?: Maybe<Scalars['String']>;
395
+ };
396
+
373
397
  /** Shipping Simulation item input. */
374
398
  export type IShippingItem = {
375
399
  /** ShippingItem ID / Sku. */
@@ -627,6 +651,11 @@ export type Mutation = {
627
651
  cancelOrder?: Maybe<UserOrderCancel>;
628
652
  /** Process Order Authorization */
629
653
  processOrderAuthorization?: Maybe<ProcessOrderAuthorizationResponse>;
654
+ /**
655
+ * Sets a new password for the user.
656
+ * This mutation is used to change the user's password, typically after a password reset or when the user wants to update their password.
657
+ */
658
+ setPassword?: Maybe<SetPasswordResponse>;
630
659
  /** Subscribes a new person to the newsletter list. */
631
660
  subscribeToNewsletter?: Maybe<PersonNewsletter>;
632
661
  /** Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns `null`. */
@@ -646,6 +675,11 @@ export type MutationProcessOrderAuthorizationArgs = {
646
675
  };
647
676
 
648
677
 
678
+ export type MutationSetPasswordArgs = {
679
+ data: ISetPassword;
680
+ };
681
+
682
+
649
683
  export type MutationSubscribeToNewsletterArgs = {
650
684
  data: IPersonNewsletter;
651
685
  };
@@ -699,6 +733,46 @@ export type PickupAddress = {
699
733
  street?: Maybe<Scalars['String']>;
700
734
  };
701
735
 
736
+ export type PickupPointAddress = {
737
+ __typename?: 'PickupPointAddress';
738
+ /** Address city. */
739
+ city?: Maybe<Scalars['String']>;
740
+ /** Address neighborhood. */
741
+ neighborhood?: Maybe<Scalars['String']>;
742
+ /** Address number. */
743
+ number?: Maybe<Scalars['String']>;
744
+ /** Address postal code. */
745
+ postalCode?: Maybe<Scalars['String']>;
746
+ /** Address state. */
747
+ state?: Maybe<Scalars['String']>;
748
+ /** Address street. */
749
+ street?: Maybe<Scalars['String']>;
750
+ };
751
+
752
+ export type PickupPointDistance = {
753
+ __typename?: 'PickupPointDistance';
754
+ /** Pickup point address. */
755
+ address?: Maybe<PickupPointAddress>;
756
+ /** Pickup point business hours. */
757
+ businessHours?: Maybe<Array<Maybe<BusinessHour>>>;
758
+ /** Pickup point distance. */
759
+ distance?: Maybe<Scalars['Float']>;
760
+ /** Whether the pickup point is active. */
761
+ isActive?: Maybe<Scalars['Boolean']>;
762
+ /** Pickup point ID. */
763
+ pickupId?: Maybe<Scalars['String']>;
764
+ /** Pickup point name. */
765
+ pickupName?: Maybe<Scalars['String']>;
766
+ };
767
+
768
+ export type PickupPoints = {
769
+ __typename?: 'PickupPoints';
770
+ /** List of pickup point distances for the given location. */
771
+ pickupPointDistances?: Maybe<Array<Maybe<PickupPointDistance>>>;
772
+ /** Hash of the pickup points data. */
773
+ pickupPointsHash?: Maybe<Scalars['String']>;
774
+ };
775
+
702
776
  export type PickupStoreInfo = {
703
777
  __typename?: 'PickupStoreInfo';
704
778
  /** PickupStoreInfo additional information. */
@@ -789,6 +863,8 @@ export type Query = {
789
863
  collection: StoreCollection;
790
864
  /** Returns information about the list of Orders that the User can view. */
791
865
  listUserOrders?: Maybe<UserOrderListMinimalResult>;
866
+ /** Returns a list of pickup points near to the given geo coordinates. */
867
+ pickupPoints?: Maybe<PickupPoints>;
792
868
  /** Returns the details of a product based on the specified locator. */
793
869
  product: StoreProduct;
794
870
  /** Returns the total product count information based on a specific location accessible through the VTEX segment cookie. */
@@ -840,6 +916,11 @@ export type QueryListUserOrdersArgs = {
840
916
  };
841
917
 
842
918
 
919
+ export type QueryPickupPointsArgs = {
920
+ geoCoordinates?: Maybe<IStoreGeoCoordinates>;
921
+ };
922
+
923
+
843
924
  export type QueryProductArgs = {
844
925
  locator: Array<IStoreSelectedFacet>;
845
926
  };
@@ -921,6 +1002,15 @@ export type SellersData = {
921
1002
  sellers?: Maybe<Array<Maybe<SellerInfo>>>;
922
1003
  };
923
1004
 
1005
+ /** Response type for setting a new password. */
1006
+ export type SetPasswordResponse = {
1007
+ __typename?: 'SetPasswordResponse';
1008
+ /** Message providing additional information about the operation. */
1009
+ message?: Maybe<Scalars['String']>;
1010
+ /** Indicates whether the password was successfully set. */
1011
+ success: Scalars['Boolean'];
1012
+ };
1013
+
924
1014
  /** Shipping Simulation information. */
925
1015
  export type ShippingData = {
926
1016
  __typename?: 'ShippingData';
@@ -14,6 +14,7 @@ import type {
14
14
  UserOrderListResult,
15
15
  } from '../../../..'
16
16
  import type { Context, Options } from '../../index'
17
+ import { buildFormData } from '../../utils/buildFormData'
17
18
  import type { Channel } from '../../utils/channel'
18
19
  import {
19
20
  getStoreCookie,
@@ -26,6 +27,7 @@ import type { Brand } from './types/Brand'
26
27
  import type { CategoryTree } from './types/CategoryTree'
27
28
  import type { MasterDataResponse } from './types/Newsletter'
28
29
  import type { OrderForm, OrderFormInputItem } from './types/OrderForm'
30
+ import type { PickupPoints, PickupPointsInput } from './types/PickupPoints'
29
31
  import type { PortalPagetype } from './types/Portal'
30
32
  import type { PortalProduct } from './types/Product'
31
33
  import type { Region, RegionInput } from './types/Region'
@@ -392,6 +394,30 @@ export const VtexCommerce = (
392
394
  {}
393
395
  )
394
396
  },
397
+ pickupPoints: ({
398
+ geoCoordinates,
399
+ }: PickupPointsInput): Promise<PickupPoints> => {
400
+ if (!geoCoordinates) {
401
+ throw new Error(
402
+ 'Missing required parameter for listing pickup points.'
403
+ )
404
+ }
405
+
406
+ const headers: HeadersInit = withCookie({
407
+ 'content-type': 'application/json',
408
+ 'X-FORWARDED-HOST': forwardedHost,
409
+ })
410
+
411
+ return fetchAPI(
412
+ `${base}/api/logistics-shipping/pickuppoints/_search`,
413
+ {
414
+ method: 'POST',
415
+ headers,
416
+ body: JSON.stringify({ coordinate: geoCoordinates }),
417
+ },
418
+ { storeCookies }
419
+ )
420
+ },
395
421
  },
396
422
  session: (search: string): Promise<Session> => {
397
423
  const params = new URLSearchParams(search)
@@ -678,6 +704,47 @@ export const VtexCommerce = (
678
704
  { storeCookies }
679
705
  )
680
706
  },
707
+ setPassword: async ({
708
+ email,
709
+ newPassword,
710
+ currentPassword,
711
+ accesskey,
712
+ recaptcha,
713
+ }: {
714
+ email: string
715
+ newPassword: string
716
+ currentPassword: string
717
+ accesskey?: string
718
+ recaptcha?: string
719
+ }): Promise<{ success: boolean; message?: string }> => {
720
+ const headers: HeadersInit = withAutCookie(forwardedHost, account)
721
+
722
+ const body = buildFormData({
723
+ login: email,
724
+ newPassword,
725
+ currentPassword,
726
+ accesskey,
727
+ recaptcha,
728
+ })
729
+
730
+ const result = await fetchAPI(
731
+ `${base}/api/vtexid/pub/authentication/classic/setpassword?expireSessions=true`,
732
+ {
733
+ method: 'POST',
734
+ headers,
735
+ body,
736
+ },
737
+ { storeCookies }
738
+ )
739
+
740
+ if ((result?.authStatus ?? '').toLowerCase() === 'success') {
741
+ return { success: true }
742
+ }
743
+ return {
744
+ success: false,
745
+ message: result?.authStatus ?? 'Unknown error',
746
+ }
747
+ },
681
748
  },
682
749
  }
683
750
  }
@@ -0,0 +1,40 @@
1
+ interface GeoCoordinates {
2
+ latitude: number
3
+ longitude: number
4
+ }
5
+
6
+ export interface PickupPointsInput {
7
+ country?: string | null
8
+ geoCoordinates?: GeoCoordinates | null
9
+ postalCode?: string | null
10
+ }
11
+
12
+ interface Address {
13
+ city: string
14
+ geoCoordinates: [number, number] // [longitude, latitude]
15
+ neighborhood: string
16
+ number: string
17
+ postalCode: string
18
+ street: string
19
+ state: string
20
+ }
21
+
22
+ interface BusinessHour {
23
+ dayOfWeek: number
24
+ openingTime: string
25
+ closingTime: string
26
+ }
27
+
28
+ interface PickupPointDistance {
29
+ pickupId: string
30
+ distance: number
31
+ pickupName: string
32
+ isActive: boolean
33
+ address: Address
34
+ businessHours: BusinessHour[]
35
+ }
36
+
37
+ export interface PickupPoints {
38
+ pickupPointDistances: PickupPointDistance[]
39
+ pickupPointsHash: string
40
+ }
@@ -52,12 +52,16 @@ const POLICY_KEY = 'trade-policy'
52
52
  const REGION_KEY = 'region-id'
53
53
  const FUZZY_KEY = 'fuzzy'
54
54
  const OPERATOR_KEY = 'operator'
55
+ const PICKUP_POINT_KEY = 'pickupPoint'
56
+ const SHIPPING_KEY = 'shipping'
55
57
 
56
58
  const EXTRA_FACETS_KEYS = new Set([
57
59
  POLICY_KEY,
58
60
  REGION_KEY,
59
61
  FUZZY_KEY,
60
62
  OPERATOR_KEY,
63
+ PICKUP_POINT_KEY,
64
+ SHIPPING_KEY,
61
65
  ])
62
66
 
63
67
  export const isFacetBoolean = (
@@ -142,12 +146,22 @@ export const IntelligentSearch = (
142
146
  ({ key }) => !EXTRA_FACETS_KEYS.has(key)
143
147
  )
144
148
 
149
+ const shippingFacet =
150
+ facets.find(
151
+ ({ key, value }) =>
152
+ key === SHIPPING_KEY && value !== 'all-delivery-methods'
153
+ ) ?? null
154
+
145
155
  const policyFacet =
146
156
  facets.find(({ key }) => key === POLICY_KEY) ?? getPolicyFacet()
147
157
 
148
158
  const regionFacet =
149
159
  facets.find(({ key }) => key === REGION_KEY) ?? getRegionFacet()
150
160
 
161
+ if (shippingFacet !== null) {
162
+ withDefaultFacets.push(shippingFacet)
163
+ }
164
+
151
165
  if (policyFacet !== null) {
152
166
  withDefaultFacets.push(policyFacet)
153
167
  }
@@ -165,6 +179,8 @@ export const IntelligentSearch = (
165
179
  ) => {
166
180
  const fuzzyFacet = facets.find(({ key }) => key === FUZZY_KEY) ?? null
167
181
  const operatorFacet = facets.find(({ key }) => key === OPERATOR_KEY) ?? null
182
+ const pickupPointFacet =
183
+ facets.find(({ key }) => key === PICKUP_POINT_KEY) ?? null
168
184
 
169
185
  if (fuzzyFacet && isFuzzyFacet(fuzzyFacet)) {
170
186
  params.append(FUZZY_KEY, fuzzyFacet.value)
@@ -173,6 +189,10 @@ export const IntelligentSearch = (
173
189
  if (operatorFacet && isOperatorFacet(operatorFacet)) {
174
190
  params.append(OPERATOR_KEY, operatorFacet.value)
175
191
  }
192
+
193
+ if (pickupPointFacet) {
194
+ params.append(PICKUP_POINT_KEY, pickupPointFacet.value)
195
+ }
176
196
  }
177
197
 
178
198
  const search = <T>({
@@ -1,11 +1,11 @@
1
- import { parseRange } from '../utils/facets'
2
- import { min } from '../utils/orderStatistics'
1
+ import type { Resolver } from '..'
3
2
  import type {
4
- FacetValueBoolean,
5
3
  Facet,
4
+ FacetValueBoolean,
6
5
  FacetValueRange,
7
6
  } from '../clients/search/types/FacetSearchResult'
8
- import type { Resolver } from '..'
7
+ import { parseRange } from '../utils/facets'
8
+ import { min } from '../utils/orderStatistics'
9
9
 
10
10
  export type Root = Facet
11
11
 
@@ -1,5 +1,6 @@
1
1
  import { cancelOrder } from './cancelOrder'
2
2
  import { processOrderAuthorization } from './processOrderAuthorization'
3
+ import { setPassword } from './setPassword'
3
4
  import { subscribeToNewsletter } from './subscribeToNewsletter'
4
5
  import { validateCart } from './validateCart'
5
6
  import { validateSession } from './validateSession'
@@ -10,4 +11,5 @@ export const Mutation = {
10
11
  subscribeToNewsletter,
11
12
  cancelOrder,
12
13
  processOrderAuthorization,
14
+ setPassword,
13
15
  }
@@ -4,6 +4,7 @@ import type {
4
4
  QueryAllProductsArgs,
5
5
  QueryCollectionArgs,
6
6
  QueryListUserOrdersArgs,
7
+ QueryPickupPointsArgs,
7
8
  QueryProductArgs,
8
9
  QueryProductCountArgs,
9
10
  QueryProfileArgs,
@@ -19,6 +20,7 @@ import type { CategoryTree } from '../clients/commerce/types/CategoryTree'
19
20
  import type { ProfileAddress } from '../clients/commerce/types/Profile'
20
21
  import type { SearchArgs } from '../clients/search'
21
22
  import type { Context } from '../index'
23
+ import { extractRuleForAuthorization } from '../utils/commercialAuth'
22
24
  import { mutateChannelContext, mutateLocaleContext } from '../utils/contex'
23
25
  import { getAuthCookie, parseJwt } from '../utils/cookies'
24
26
  import { enhanceSku } from '../utils/enhanceSku'
@@ -33,7 +35,6 @@ import {
33
35
  import { isValidSkuId, pickBestSku } from '../utils/sku'
34
36
  import { SORT_MAP } from '../utils/sort'
35
37
  import { FACET_CROSS_SELLING_MAP } from './../utils/facets'
36
- import { extractRuleForAuthorization } from '../utils/commercialAuth'
37
38
  import { StoreCollection } from './collection'
38
39
 
39
40
  export const Query = {
@@ -601,4 +602,19 @@ export const Query = {
601
602
  // createdAt: '',
602
603
  }
603
604
  },
605
+ pickupPoints: async (
606
+ _: unknown,
607
+ { geoCoordinates }: QueryPickupPointsArgs,
608
+ ctx: Context
609
+ ) => {
610
+ const {
611
+ clients: { commerce },
612
+ } = ctx
613
+
614
+ const result = await commerce.checkout.pickupPoints({
615
+ geoCoordinates,
616
+ })
617
+
618
+ return result
619
+ },
604
620
  }
@@ -0,0 +1,26 @@
1
+ import type { Context } from '..'
2
+ import type {
3
+ MutationSetPasswordArgs,
4
+ SetPasswordResponse,
5
+ } from '../../../__generated__/schema'
6
+ import { BadRequestError } from '../../errors'
7
+
8
+ export const setPassword = async (
9
+ _: any,
10
+ { data }: MutationSetPasswordArgs,
11
+ { clients: { commerce } }: Context
12
+ ): Promise<SetPasswordResponse> => {
13
+ if (!data?.email) {
14
+ throw new BadRequestError('Missing email')
15
+ }
16
+
17
+ const response = await commerce.vtexid.setPassword({
18
+ email: data.email,
19
+ newPassword: data.newPassword,
20
+ currentPassword: data.currentPassword,
21
+ accesskey: data?.accesskey ?? '',
22
+ recaptcha: data?.recaptcha ?? '',
23
+ })
24
+
25
+ return { success: response.success, message: response?.message ?? '' }
26
+ }
@@ -0,0 +1,12 @@
1
+ export const buildFormData = (
2
+ valueObject: Record<string, string | number | boolean | null | undefined>
3
+ ) => {
4
+ const form = new FormData()
5
+
6
+ Object.keys(valueObject).forEach((key) => {
7
+ const value = valueObject[key]
8
+ form.append(key, value == null ? '' : String(value))
9
+ })
10
+
11
+ return form
12
+ }
@@ -21,4 +21,9 @@ type Mutation {
21
21
  processOrderAuthorization(
22
22
  data: IProcessOrderAuthorization!
23
23
  ): ProcessOrderAuthorizationResponse
24
+ """
25
+ Sets a new password for the user.
26
+ This mutation is used to change the user's password, typically after a password reset or when the user wants to update their password.
27
+ """
28
+ setPassword(data: ISetPassword!): SetPasswordResponse
24
29
  }
@@ -0,0 +1,43 @@
1
+ """
2
+ Input type for setting a new password.
3
+ """
4
+ input ISetPassword {
5
+ """
6
+ The email of the user for whom the password is being set.
7
+ """
8
+ email: String!
9
+
10
+ """
11
+ The new password to be set for the user.
12
+ """
13
+ newPassword: String!
14
+
15
+ """
16
+ The current password of the user, required for verification before changing to the new password.
17
+ """
18
+ currentPassword: String!
19
+
20
+ """
21
+ Optional access key for the user, used in some authentication flows.
22
+ """
23
+ accesskey: String
24
+
25
+ """
26
+ Optional reCAPTCHA token for security verification.
27
+ """
28
+ recaptcha: String
29
+ }
30
+
31
+ """
32
+ Response type for setting a new password.
33
+ """
34
+ type SetPasswordResponse {
35
+ """
36
+ Indicates whether the password was successfully set.
37
+ """
38
+ success: Boolean!
39
+ """
40
+ Message providing additional information about the operation.
41
+ """
42
+ message: String
43
+ }
@@ -0,0 +1,79 @@
1
+ type PickupPointAddress {
2
+ """
3
+ Address city.
4
+ """
5
+ city: String
6
+ """
7
+ Address neighborhood.
8
+ """
9
+ neighborhood: String
10
+ """
11
+ Address number.
12
+ """
13
+ number: String
14
+ """
15
+ Address postal code.
16
+ """
17
+ postalCode: String
18
+ """
19
+ Address street.
20
+ """
21
+ street: String
22
+ """
23
+ Address state.
24
+ """
25
+ state: String
26
+ }
27
+
28
+ type BusinessHour {
29
+ """
30
+ Number that represents the day of the week.
31
+ """
32
+ dayOfWeek: Int
33
+ """
34
+ Business hour opening time.
35
+ """
36
+ openingTime: String
37
+ """
38
+ Business hour closing time.
39
+ """
40
+ closingTime: String
41
+ }
42
+
43
+ type PickupPointDistance {
44
+ """
45
+ Pickup point ID.
46
+ """
47
+ pickupId: String
48
+ """
49
+ Pickup point distance.
50
+ """
51
+ distance: Float
52
+ """
53
+ Pickup point name.
54
+ """
55
+ pickupName: String
56
+ """
57
+ Whether the pickup point is active.
58
+ """
59
+ isActive: Boolean
60
+ """
61
+ Pickup point address.
62
+ """
63
+ address: PickupPointAddress
64
+ """
65
+ Pickup point business hours.
66
+ """
67
+ businessHours: [BusinessHour]
68
+ }
69
+
70
+ type PickupPoints {
71
+ """
72
+ List of pickup point distances for the given location.
73
+ """
74
+ pickupPointDistances: [PickupPointDistance]
75
+ """
76
+ Hash of the pickup points data.
77
+ """
78
+ pickupPointsHash: String
79
+ }
@@ -437,6 +437,17 @@ type Query {
437
437
  """
438
438
  validateUser: ValidateUserData
439
439
  @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
440
+
441
+ """
442
+ Returns a list of pickup points near to the given geo coordinates.
443
+ """
444
+ pickupPoints(
445
+ """
446
+ Geo coordinates input.
447
+ """
448
+ geoCoordinates: IStoreGeoCoordinates
449
+ ): PickupPoints
450
+ @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
440
451
  }
441
452
 
442
453
  type ValidateUserData {