@decocms/apps 0.23.3 → 0.24.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 (110) hide show
  1. package/LICENSE +21 -0
  2. package/commerce/components/Image.tsx +129 -143
  3. package/commerce/components/JsonLd.tsx +192 -201
  4. package/commerce/components/Picture.tsx +65 -75
  5. package/commerce/sdk/analytics.ts +15 -15
  6. package/commerce/sdk/formatPrice.ts +13 -16
  7. package/commerce/sdk/url.ts +7 -7
  8. package/commerce/sdk/useOffer.ts +46 -57
  9. package/commerce/sdk/useVariantPossibilities.ts +25 -25
  10. package/commerce/types/commerce.ts +868 -875
  11. package/commerce/utils/canonical.ts +5 -8
  12. package/commerce/utils/constants.ts +5 -6
  13. package/commerce/utils/filters.ts +4 -4
  14. package/commerce/utils/productToAnalyticsItem.ts +52 -56
  15. package/commerce/utils/stateByZip.ts +42 -42
  16. package/package.json +23 -4
  17. package/shopify/actions/cart/addItems.ts +24 -25
  18. package/shopify/actions/cart/updateCoupons.ts +19 -20
  19. package/shopify/actions/cart/updateItems.ts +19 -20
  20. package/shopify/actions/user/signIn.ts +25 -30
  21. package/shopify/actions/user/signUp.ts +19 -24
  22. package/shopify/client.ts +24 -24
  23. package/shopify/index.ts +20 -18
  24. package/shopify/init.ts +18 -21
  25. package/shopify/loaders/ProductDetailsPage.ts +16 -20
  26. package/shopify/loaders/ProductList.ts +66 -69
  27. package/shopify/loaders/ProductListingPage.ts +150 -158
  28. package/shopify/loaders/RelatedProducts.ts +24 -27
  29. package/shopify/loaders/cart.ts +53 -52
  30. package/shopify/loaders/shop.ts +22 -27
  31. package/shopify/loaders/user.ts +27 -32
  32. package/shopify/utils/admin/admin.ts +33 -34
  33. package/shopify/utils/admin/queries.ts +2 -2
  34. package/shopify/utils/cart.ts +18 -14
  35. package/shopify/utils/cookies.ts +62 -65
  36. package/shopify/utils/enums.ts +424 -424
  37. package/shopify/utils/graphql.ts +44 -55
  38. package/shopify/utils/storefront/queries.ts +24 -29
  39. package/shopify/utils/storefront/storefront.graphql.gen.ts +55 -55
  40. package/shopify/utils/transform.ts +370 -376
  41. package/shopify/utils/types.ts +118 -118
  42. package/shopify/utils/user.ts +11 -11
  43. package/shopify/utils/utils.ts +135 -140
  44. package/vtex/actions/address.ts +86 -86
  45. package/vtex/actions/auth.ts +14 -27
  46. package/vtex/actions/checkout.ts +36 -49
  47. package/vtex/actions/masterData.ts +10 -27
  48. package/vtex/actions/misc.ts +101 -111
  49. package/vtex/actions/newsletter.ts +48 -52
  50. package/vtex/actions/orders.ts +13 -16
  51. package/vtex/actions/profile.ts +55 -55
  52. package/vtex/actions/session.ts +36 -35
  53. package/vtex/actions/trigger.ts +25 -25
  54. package/vtex/actions/wishlist.ts +51 -53
  55. package/vtex/client.ts +14 -42
  56. package/vtex/hooks/index.ts +4 -4
  57. package/vtex/hooks/useAutocomplete.ts +42 -48
  58. package/vtex/hooks/useCart.ts +153 -165
  59. package/vtex/hooks/useUser.ts +40 -40
  60. package/vtex/hooks/useWishlist.ts +70 -70
  61. package/vtex/inline-loaders/productDetailsPage.ts +1 -3
  62. package/vtex/inline-loaders/productList.ts +121 -127
  63. package/vtex/inline-loaders/productListingPage.ts +10 -34
  64. package/vtex/inline-loaders/relatedProducts.ts +1 -3
  65. package/vtex/inline-loaders/suggestions.ts +36 -39
  66. package/vtex/inline-loaders/workflowProducts.ts +45 -49
  67. package/vtex/invoke.ts +159 -194
  68. package/vtex/loaders/address.ts +49 -54
  69. package/vtex/loaders/brands.ts +19 -26
  70. package/vtex/loaders/cart.ts +24 -21
  71. package/vtex/loaders/catalog.ts +51 -53
  72. package/vtex/loaders/collections.ts +25 -27
  73. package/vtex/loaders/legacy.ts +487 -534
  74. package/vtex/loaders/logistics.ts +33 -37
  75. package/vtex/loaders/navbar.ts +5 -8
  76. package/vtex/loaders/orders.ts +28 -39
  77. package/vtex/loaders/pageType.ts +41 -35
  78. package/vtex/loaders/payment.ts +27 -37
  79. package/vtex/loaders/profile.ts +38 -38
  80. package/vtex/loaders/promotion.ts +5 -8
  81. package/vtex/loaders/search.ts +56 -59
  82. package/vtex/loaders/session.ts +22 -30
  83. package/vtex/loaders/user.ts +39 -41
  84. package/vtex/loaders/wishlist.ts +35 -35
  85. package/vtex/loaders/wishlistProducts.ts +3 -15
  86. package/vtex/loaders/workflow.ts +220 -227
  87. package/vtex/middleware.ts +116 -119
  88. package/vtex/types.ts +201 -201
  89. package/vtex/utils/batch.ts +13 -16
  90. package/vtex/utils/cookies.ts +76 -80
  91. package/vtex/utils/enrichment.ts +62 -42
  92. package/vtex/utils/fetchCache.ts +1 -4
  93. package/vtex/utils/index.ts +6 -6
  94. package/vtex/utils/intelligentSearch.ts +48 -57
  95. package/vtex/utils/legacy.ts +108 -124
  96. package/vtex/utils/pickAndOmit.ts +15 -20
  97. package/vtex/utils/proxy.ts +136 -146
  98. package/vtex/utils/resourceRange.ts +3 -3
  99. package/vtex/utils/segment.ts +100 -111
  100. package/vtex/utils/similars.ts +1 -2
  101. package/vtex/utils/sitemap.ts +91 -91
  102. package/vtex/utils/slugCache.ts +2 -6
  103. package/vtex/utils/slugify.ts +9 -9
  104. package/vtex/utils/transform.ts +1012 -1105
  105. package/vtex/utils/types.ts +1381 -1381
  106. package/vtex/utils/vtexId.ts +44 -47
  107. package/.github/workflows/release.yml +0 -34
  108. package/.releaserc.json +0 -28
  109. package/knip.json +0 -19
  110. package/tsconfig.json +0 -11
@@ -18,22 +18,22 @@ import { vtexFetch } from "../client";
18
18
  // ---------------------------------------------------------------------------
19
19
 
20
20
  export interface ProductBalance {
21
- warehouseId: string;
22
- warehouseName: string;
23
- totalQuantity: number;
24
- reservedQuantity: number;
25
- hasUnlimitedQuantity: boolean;
21
+ warehouseId: string;
22
+ warehouseName: string;
23
+ totalQuantity: number;
24
+ reservedQuantity: number;
25
+ hasUnlimitedQuantity: boolean;
26
26
  }
27
27
 
28
28
  export interface PickupPointsByLocationOpts {
29
- geoCoordinates?: number[];
30
- postalCode?: string;
31
- countryCode?: string;
29
+ geoCoordinates?: number[];
30
+ postalCode?: string;
31
+ countryCode?: string;
32
32
  }
33
33
 
34
34
  export interface PickupPointsResponse<T = any> {
35
- paging: { page: number; pageSize: number; total: number; pages: number };
36
- items: Array<{ distance: number; pickupPoint: T }>;
35
+ paging: { page: number; pageSize: number; total: number; pages: number };
36
+ items: Array<{ distance: number; pickupPoint: T }>;
37
37
  }
38
38
 
39
39
  // ---------------------------------------------------------------------------
@@ -45,7 +45,7 @@ export interface PickupPointsResponse<T = any> {
45
45
  * @see https://developers.vtex.com/docs/api-reference/catalog-api#get-/api/catalog_system/pub/saleschannel/-salesChannelId-
46
46
  */
47
47
  export async function getSalesChannelById<T = any>(id: string): Promise<T> {
48
- return vtexFetch<T>(`/api/catalog_system/pub/saleschannel/${id}`);
48
+ return vtexFetch<T>(`/api/catalog_system/pub/saleschannel/${id}`);
49
49
  }
50
50
 
51
51
  /**
@@ -53,7 +53,7 @@ export async function getSalesChannelById<T = any>(id: string): Promise<T> {
53
53
  * @see https://developers.vtex.com/docs/api-reference/catalog-api#get-/api/catalog_system/pvt/saleschannel/list
54
54
  */
55
55
  export async function listSalesChannels<T = any>(): Promise<T[]> {
56
- return vtexFetch<T[]>("/api/catalog_system/pvt/saleschannel/list");
56
+ return vtexFetch<T[]>("/api/catalog_system/pvt/saleschannel/list");
57
57
  }
58
58
 
59
59
  // ---------------------------------------------------------------------------
@@ -65,7 +65,7 @@ export async function listSalesChannels<T = any>(): Promise<T[]> {
65
65
  * @see https://developers.vtex.com/docs/api-reference/logistics-api#get-/api/logistics/pvt/configuration/pickuppoints
66
66
  */
67
67
  export async function listPickupPoints<T = any>(): Promise<T[]> {
68
- return vtexFetch<T[]>("/api/logistics/pvt/configuration/pickuppoints");
68
+ return vtexFetch<T[]>("/api/logistics/pvt/configuration/pickuppoints");
69
69
  }
70
70
 
71
71
  /**
@@ -75,19 +75,17 @@ export async function listPickupPoints<T = any>(): Promise<T[]> {
75
75
  * @see https://developers.vtex.com/docs/api-reference/checkout-api#get-/api/checkout/pub/pickup-points
76
76
  */
77
77
  export async function listPickupPointsByLocation<T = any>(
78
- opts: PickupPointsByLocationOpts,
78
+ opts: PickupPointsByLocationOpts,
79
79
  ): Promise<PickupPointsResponse<T>> {
80
- const params = new URLSearchParams();
81
- if (opts.geoCoordinates) {
82
- params.set("geoCoordinates", opts.geoCoordinates.join(","));
83
- } else {
84
- if (opts.postalCode) params.set("postalCode", opts.postalCode);
85
- if (opts.countryCode) params.set("countryCode", opts.countryCode);
86
- }
80
+ const params = new URLSearchParams();
81
+ if (opts.geoCoordinates) {
82
+ params.set("geoCoordinates", opts.geoCoordinates.join(","));
83
+ } else {
84
+ if (opts.postalCode) params.set("postalCode", opts.postalCode);
85
+ if (opts.countryCode) params.set("countryCode", opts.countryCode);
86
+ }
87
87
 
88
- return vtexFetch<PickupPointsResponse<T>>(
89
- `/api/checkout/pub/pickup-points?${params}`,
90
- );
88
+ return vtexFetch<PickupPointsResponse<T>>(`/api/checkout/pub/pickup-points?${params}`);
91
89
  }
92
90
 
93
91
  // ---------------------------------------------------------------------------
@@ -98,18 +96,16 @@ export async function listPickupPointsByLocation<T = any>(
98
96
  * List inventory balances for a SKU across all warehouses.
99
97
  * @see https://developers.vtex.com/docs/api-reference/logistics-api#get-/api/logistics/pvt/inventory/skus/-skuId-
100
98
  */
101
- export async function listStockByStore(
102
- skuId: number,
103
- ): Promise<ProductBalance[]> {
104
- try {
105
- const result = await vtexFetch<{
106
- skuId?: string;
107
- balance?: ProductBalance[];
108
- }>(`/api/logistics/pvt/inventory/skus/${skuId}`);
99
+ export async function listStockByStore(skuId: number): Promise<ProductBalance[]> {
100
+ try {
101
+ const result = await vtexFetch<{
102
+ skuId?: string;
103
+ balance?: ProductBalance[];
104
+ }>(`/api/logistics/pvt/inventory/skus/${skuId}`);
109
105
 
110
- return result.balance ?? [];
111
- } catch (error) {
112
- console.error("[listStockByStore]", error);
113
- return [];
114
- }
106
+ return result.balance ?? [];
107
+ } catch (error) {
108
+ console.error("[listStockByStore]", error);
109
+ return [];
110
+ }
115
111
  }
@@ -7,10 +7,11 @@
7
7
  *
8
8
  * @see https://developers.vtex.com/docs/api-reference/catalog-api#get-/api/catalog_system/pub/category/tree/-categoryLevels-
9
9
  */
10
+
11
+ import type { SiteNavigationElement } from "../../commerce/types/commerce";
10
12
  import { vtexFetch } from "../client";
11
13
  import { categoryTreeToNavbar } from "../utils/transform";
12
14
  import type { Category } from "../utils/types";
13
- import type { SiteNavigationElement } from "../../commerce/types/commerce";
14
15
 
15
16
  /**
16
17
  * Fetch the category tree and transform it into an array of
@@ -18,12 +19,8 @@ import type { SiteNavigationElement } from "../../commerce/types/commerce";
18
19
  *
19
20
  * @param levels - Depth of the category tree (default: 2)
20
21
  */
21
- export async function getNavbar(
22
- levels: number = 2,
23
- ): Promise<SiteNavigationElement[]> {
24
- const tree = await vtexFetch<Category[]>(
25
- `/api/catalog_system/pub/category/tree/${levels}`,
26
- );
22
+ export async function getNavbar(levels: number = 2): Promise<SiteNavigationElement[]> {
23
+ const tree = await vtexFetch<Category[]>(`/api/catalog_system/pub/category/tree/${levels}`);
27
24
 
28
- return categoryTreeToNavbar(tree);
25
+ return categoryTreeToNavbar(tree);
29
26
  }
@@ -20,13 +20,10 @@ import { vtexFetch } from "../client";
20
20
  *
21
21
  * @see https://developers.vtex.com/docs/api-reference/orders-api#get-/api/oms/user/orders/-orderId-
22
22
  */
23
- export async function getOrderById<T = any>(
24
- orderId: string,
25
- authCookie: string,
26
- ): Promise<T> {
27
- return vtexFetch<T>(`/api/oms/user/orders/${orderId}`, {
28
- headers: { cookie: authCookie },
29
- });
23
+ export async function getOrderById<T = any>(orderId: string, authCookie: string): Promise<T> {
24
+ return vtexFetch<T>(`/api/oms/user/orders/${orderId}`, {
25
+ headers: { cookie: authCookie },
26
+ });
30
27
  }
31
28
 
32
29
  // ---------------------------------------------------------------------------
@@ -34,9 +31,9 @@ export async function getOrderById<T = any>(
34
31
  // ---------------------------------------------------------------------------
35
32
 
36
33
  export interface ListOrdersOpts {
37
- clientEmail: string;
38
- page?: string;
39
- perPage?: string;
34
+ clientEmail: string;
35
+ page?: string;
36
+ perPage?: string;
40
37
  }
41
38
 
42
39
  /**
@@ -45,20 +42,17 @@ export interface ListOrdersOpts {
45
42
  *
46
43
  * @see https://developers.vtex.com/docs/api-reference/orders-api#get-/api/oms/user/orders
47
44
  */
48
- export async function listOrders<T = any>(
49
- opts: ListOrdersOpts,
50
- authCookie: string,
51
- ): Promise<T> {
52
- const { clientEmail, page = "0", perPage = "15" } = opts;
53
- const params = new URLSearchParams({
54
- clientEmail,
55
- page,
56
- per_page: perPage,
57
- });
45
+ export async function listOrders<T = any>(opts: ListOrdersOpts, authCookie: string): Promise<T> {
46
+ const { clientEmail, page = "0", perPage = "15" } = opts;
47
+ const params = new URLSearchParams({
48
+ clientEmail,
49
+ page,
50
+ per_page: perPage,
51
+ });
58
52
 
59
- return vtexFetch<T>(`/api/oms/user/orders?${params}`, {
60
- headers: { cookie: authCookie },
61
- });
53
+ return vtexFetch<T>(`/api/oms/user/orders?${params}`, {
54
+ headers: { cookie: authCookie },
55
+ });
62
56
  }
63
57
 
64
58
  // ---------------------------------------------------------------------------
@@ -81,23 +75,18 @@ export async function listOrders<T = any>(
81
75
  *
82
76
  * @see https://developers.vtex.com/docs/api-reference/checkout-api#get-/api/checkout/pub/orders/order-group/-orderGroupId-
83
77
  */
84
- export async function getOrderPlaced<T = any>(
85
- orderId: string,
86
- authCookie: string,
87
- ): Promise<T[]> {
88
- const isOrderGroup = !orderId.includes("-");
78
+ export async function getOrderPlaced<T = any>(orderId: string, authCookie: string): Promise<T[]> {
79
+ const isOrderGroup = !orderId.includes("-");
89
80
 
90
- if (isOrderGroup) {
91
- return vtexFetch<T[]>(
92
- `/api/checkout/pub/orders/order-group/${orderId}`,
93
- { headers: { cookie: authCookie } },
94
- );
95
- }
81
+ if (isOrderGroup) {
82
+ return vtexFetch<T[]>(`/api/checkout/pub/orders/order-group/${orderId}`, {
83
+ headers: { cookie: authCookie },
84
+ });
85
+ }
96
86
 
97
- const order = await vtexFetch<T>(
98
- `/api/checkout/pub/orders/${orderId}`,
99
- { headers: { cookie: authCookie } },
100
- );
87
+ const order = await vtexFetch<T>(`/api/checkout/pub/orders/${orderId}`, {
88
+ headers: { cookie: authCookie },
89
+ });
101
90
 
102
- return [order];
91
+ return [order];
103
92
  }
@@ -6,20 +6,20 @@
6
6
  *
7
7
  * @see https://developers.vtex.com/docs/api-reference/catalog-api#get-/api/catalog_system/pub/portal/pagetype/-path-
8
8
  */
9
- import { vtexFetch, type PageType } from "../client";
9
+ import { type PageType, vtexFetch } from "../client";
10
10
 
11
11
  export type { PageType };
12
12
 
13
13
  export type VtexPageKind =
14
- | "product"
15
- | "category"
16
- | "department"
17
- | "subcategory"
18
- | "brand"
19
- | "collection"
20
- | "search"
21
- | "fulltext"
22
- | "notfound";
14
+ | "product"
15
+ | "category"
16
+ | "department"
17
+ | "subcategory"
18
+ | "brand"
19
+ | "collection"
20
+ | "search"
21
+ | "fulltext"
22
+ | "notfound";
23
23
 
24
24
  /**
25
25
  * Resolve a URL path to a VTEX page type.
@@ -28,35 +28,41 @@ export type VtexPageKind =
28
28
  * @returns The page type with kind normalization, or null on error
29
29
  */
30
30
  export async function resolvePageType(
31
- urlPath: string,
31
+ urlPath: string,
32
32
  ): Promise<{ pageType: PageType; kind: VtexPageKind } | null> {
33
- const cleanPath = urlPath.replace(/^\//, "").replace(/\/$/, "");
34
- if (!cleanPath) return null;
33
+ const cleanPath = urlPath.replace(/^\//, "").replace(/\/$/, "");
34
+ if (!cleanPath) return null;
35
35
 
36
- try {
37
- const pt = await vtexFetch<PageType>(
38
- `/api/catalog_system/pub/portal/pagetype/${cleanPath}`,
39
- );
36
+ try {
37
+ const pt = await vtexFetch<PageType>(`/api/catalog_system/pub/portal/pagetype/${cleanPath}`);
40
38
 
41
- const kind = normalizeKind(pt.pageType);
42
- return { pageType: pt, kind };
43
- } catch {
44
- return null;
45
- }
39
+ const kind = normalizeKind(pt.pageType);
40
+ return { pageType: pt, kind };
41
+ } catch {
42
+ return null;
43
+ }
46
44
  }
47
45
 
48
46
  function normalizeKind(pageType: PageType["pageType"]): VtexPageKind {
49
- switch (pageType) {
50
- case "Product": return "product";
51
- case "Category": return "category";
52
- case "Department": return "department";
53
- case "SubCategory": return "subcategory";
54
- case "Brand": return "brand";
55
- case "Collection":
56
- case "Cluster": return "collection";
57
- case "Search": return "search";
58
- case "FullText": return "fulltext";
59
- case "NotFound":
60
- default: return "notfound";
61
- }
47
+ switch (pageType) {
48
+ case "Product":
49
+ return "product";
50
+ case "Category":
51
+ return "category";
52
+ case "Department":
53
+ return "department";
54
+ case "SubCategory":
55
+ return "subcategory";
56
+ case "Brand":
57
+ return "brand";
58
+ case "Collection":
59
+ case "Cluster":
60
+ return "collection";
61
+ case "Search":
62
+ return "search";
63
+ case "FullText":
64
+ return "fulltext";
65
+ default:
66
+ return "notfound";
67
+ }
62
68
  }
@@ -13,26 +13,26 @@ import { vtexIOGraphQL } from "../client";
13
13
  // ---------------------------------------------------------------------------
14
14
 
15
15
  export interface PaymentSystem {
16
- name: string;
17
- groupName: string;
18
- requiresDocument: boolean;
19
- displayDocument: boolean;
20
- validator: {
21
- regex: string | null;
22
- mask: string | null;
23
- cardCodeMask: string | null;
24
- cardCodeRegex: string | null;
25
- };
16
+ name: string;
17
+ groupName: string;
18
+ requiresDocument: boolean;
19
+ displayDocument: boolean;
20
+ validator: {
21
+ regex: string | null;
22
+ mask: string | null;
23
+ cardCodeMask: string | null;
24
+ cardCodeRegex: string | null;
25
+ };
26
26
  }
27
27
 
28
28
  export interface Payment {
29
- accountStatus: string | null;
30
- cardNumber: string;
31
- expirationDate: string;
32
- id: string;
33
- isExpired: boolean;
34
- paymentSystem: string;
35
- paymentSystemName: string;
29
+ accountStatus: string | null;
30
+ cardNumber: string;
31
+ expirationDate: string;
32
+ id: string;
33
+ isExpired: boolean;
34
+ paymentSystem: string;
35
+ paymentSystemName: string;
36
36
  }
37
37
 
38
38
  // ---------------------------------------------------------------------------
@@ -58,17 +58,12 @@ const PAYMENT_SYSTEMS_QUERY = `query getPaymentSystems {
58
58
  * List available payment systems for the authenticated user.
59
59
  * Requires a valid VTEX auth cookie.
60
60
  */
61
- export async function getPaymentSystems(
62
- authCookie: string,
63
- ): Promise<PaymentSystem[]> {
64
- const { paymentSystems } = await vtexIOGraphQL<{
65
- paymentSystems: PaymentSystem[];
66
- }>(
67
- { query: PAYMENT_SYSTEMS_QUERY },
68
- { cookie: authCookie },
69
- );
61
+ export async function getPaymentSystems(authCookie: string): Promise<PaymentSystem[]> {
62
+ const { paymentSystems } = await vtexIOGraphQL<{
63
+ paymentSystems: PaymentSystem[];
64
+ }>({ query: PAYMENT_SYSTEMS_QUERY }, { cookie: authCookie });
70
65
 
71
- return paymentSystems;
66
+ return paymentSystems;
72
67
  }
73
68
 
74
69
  // ---------------------------------------------------------------------------
@@ -93,15 +88,10 @@ const USER_PAYMENTS_QUERY = `query getUserPayments {
93
88
  * List saved payment methods for the authenticated user.
94
89
  * Requires a valid VTEX auth cookie.
95
90
  */
96
- export async function getUserPayments(
97
- authCookie: string,
98
- ): Promise<Payment[]> {
99
- const data = await vtexIOGraphQL<{
100
- profile: { payments: Payment[] } | null;
101
- }>(
102
- { query: USER_PAYMENTS_QUERY },
103
- { cookie: authCookie },
104
- );
91
+ export async function getUserPayments(authCookie: string): Promise<Payment[]> {
92
+ const data = await vtexIOGraphQL<{
93
+ profile: { payments: Payment[] } | null;
94
+ }>({ query: USER_PAYMENTS_QUERY }, { cookie: authCookie });
105
95
 
106
- return data.profile?.payments ?? [];
96
+ return data.profile?.payments ?? [];
107
97
  }
@@ -31,26 +31,26 @@ const ADDRESS_FIELDS = `
31
31
  `;
32
32
 
33
33
  export interface Profile {
34
- id: string;
35
- cacheId: string;
36
- email: string;
37
- firstName: string;
38
- lastName: string;
39
- document: string;
40
- userId: string;
41
- birthDate: string;
42
- gender: string;
43
- homePhone: string;
44
- businessPhone: string;
45
- addresses: Record<string, unknown>[];
46
- isCorporate: boolean;
47
- tradeName: string;
48
- corporateName: string;
49
- corporateDocument: string;
50
- stateRegistration: string;
51
- payments: Record<string, unknown>[];
52
- customFields: Array<{ key: string; value: string }>;
53
- passwordLastUpdate: string;
34
+ id: string;
35
+ cacheId: string;
36
+ email: string;
37
+ firstName: string;
38
+ lastName: string;
39
+ document: string;
40
+ userId: string;
41
+ birthDate: string;
42
+ gender: string;
43
+ homePhone: string;
44
+ businessPhone: string;
45
+ addresses: Record<string, unknown>[];
46
+ isCorporate: boolean;
47
+ tradeName: string;
48
+ corporateName: string;
49
+ corporateDocument: string;
50
+ stateRegistration: string;
51
+ payments: Record<string, unknown>[];
52
+ customFields: Array<{ key: string; value: string }>;
53
+ passwordLastUpdate: string;
54
54
  }
55
55
 
56
56
  // ---------------------------------------------------------------------------
@@ -100,18 +100,18 @@ const PROFILE_QUERY = `query getUserProfile($customFields: String) {
100
100
  * Requires a valid VTEX auth cookie.
101
101
  */
102
102
  export async function getCurrentProfile(
103
- authCookie: string,
104
- customFields?: string[],
103
+ authCookie: string,
104
+ customFields?: string[],
105
105
  ): Promise<Profile> {
106
- const { profile } = await vtexIOGraphQL<{ profile: Profile }>(
107
- {
108
- query: PROFILE_QUERY,
109
- variables: { customFields: customFields?.join(",") },
110
- },
111
- { cookie: authCookie },
112
- );
106
+ const { profile } = await vtexIOGraphQL<{ profile: Profile }>(
107
+ {
108
+ query: PROFILE_QUERY,
109
+ variables: { customFields: customFields?.join(",") },
110
+ },
111
+ { cookie: authCookie },
112
+ );
113
113
 
114
- return profile;
114
+ return profile;
115
115
  }
116
116
 
117
117
  // ---------------------------------------------------------------------------
@@ -125,14 +125,14 @@ export async function getCurrentProfile(
125
125
  * @see https://developers.vtex.com/docs/api-reference/checkout-api#get-/api/checkout/pub/profiles
126
126
  */
127
127
  export async function getProfileByEmail<T = any>(
128
- email: string,
129
- authCookie: string,
130
- ensureComplete?: boolean,
128
+ email: string,
129
+ authCookie: string,
130
+ ensureComplete?: boolean,
131
131
  ): Promise<T> {
132
- const params = new URLSearchParams({ email });
133
- if (ensureComplete) params.set("ensureComplete", "true");
132
+ const params = new URLSearchParams({ email });
133
+ if (ensureComplete) params.set("ensureComplete", "true");
134
134
 
135
- return vtexFetch<T>(`/api/checkout/pub/profiles?${params}`, {
136
- headers: { cookie: authCookie },
137
- });
135
+ return vtexFetch<T>(`/api/checkout/pub/profiles?${params}`, {
136
+ headers: { cookie: authCookie },
137
+ });
138
138
  }
@@ -20,14 +20,11 @@ import type { Document } from "../utils/types";
20
20
  * @param authCookie - Optional cookie string for authenticated requests
21
21
  */
22
22
  export async function getPromotionById(
23
- promotionId: string,
24
- authCookie?: string,
23
+ promotionId: string,
24
+ authCookie?: string,
25
25
  ): Promise<Document[]> {
26
- const headers: Record<string, string> = {};
27
- if (authCookie) headers.cookie = authCookie;
26
+ const headers: Record<string, string> = {};
27
+ if (authCookie) headers.cookie = authCookie;
28
28
 
29
- return vtexFetch<Document[]>(
30
- `/api/rnb/pvt/calculatorconfiguration/${promotionId}`,
31
- { headers },
32
- );
29
+ return vtexFetch<Document[]>(`/api/rnb/pvt/calculatorconfiguration/${promotionId}`, { headers });
33
30
  }