@decocms/apps 0.23.3 → 0.25.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 (111) 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 +24 -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/productListShelf.ts +159 -0
  64. package/vtex/inline-loaders/productListingPage.ts +10 -34
  65. package/vtex/inline-loaders/relatedProducts.ts +1 -3
  66. package/vtex/inline-loaders/suggestions.ts +36 -39
  67. package/vtex/inline-loaders/workflowProducts.ts +45 -49
  68. package/vtex/invoke.ts +159 -194
  69. package/vtex/loaders/address.ts +49 -54
  70. package/vtex/loaders/brands.ts +19 -26
  71. package/vtex/loaders/cart.ts +24 -21
  72. package/vtex/loaders/catalog.ts +51 -53
  73. package/vtex/loaders/collections.ts +25 -27
  74. package/vtex/loaders/legacy.ts +487 -534
  75. package/vtex/loaders/logistics.ts +33 -37
  76. package/vtex/loaders/navbar.ts +5 -8
  77. package/vtex/loaders/orders.ts +28 -39
  78. package/vtex/loaders/pageType.ts +41 -35
  79. package/vtex/loaders/payment.ts +27 -37
  80. package/vtex/loaders/profile.ts +38 -38
  81. package/vtex/loaders/promotion.ts +5 -8
  82. package/vtex/loaders/search.ts +56 -59
  83. package/vtex/loaders/session.ts +22 -30
  84. package/vtex/loaders/user.ts +39 -41
  85. package/vtex/loaders/wishlist.ts +35 -35
  86. package/vtex/loaders/wishlistProducts.ts +3 -15
  87. package/vtex/loaders/workflow.ts +220 -227
  88. package/vtex/middleware.ts +116 -119
  89. package/vtex/types.ts +201 -201
  90. package/vtex/utils/batch.ts +13 -16
  91. package/vtex/utils/cookies.ts +76 -80
  92. package/vtex/utils/enrichment.ts +62 -42
  93. package/vtex/utils/fetchCache.ts +1 -4
  94. package/vtex/utils/index.ts +6 -6
  95. package/vtex/utils/intelligentSearch.ts +48 -57
  96. package/vtex/utils/legacy.ts +108 -124
  97. package/vtex/utils/pickAndOmit.ts +15 -20
  98. package/vtex/utils/proxy.ts +136 -146
  99. package/vtex/utils/resourceRange.ts +3 -3
  100. package/vtex/utils/segment.ts +100 -111
  101. package/vtex/utils/similars.ts +1 -2
  102. package/vtex/utils/sitemap.ts +91 -91
  103. package/vtex/utils/slugCache.ts +2 -6
  104. package/vtex/utils/slugify.ts +9 -9
  105. package/vtex/utils/transform.ts +1178 -1105
  106. package/vtex/utils/types.ts +1381 -1381
  107. package/vtex/utils/vtexId.ts +44 -47
  108. package/.github/workflows/release.yml +0 -34
  109. package/.releaserc.json +0 -28
  110. package/knip.json +0 -19
  111. package/tsconfig.json +0 -11
@@ -2,67 +2,63 @@
2
2
  * Workflow/collection products loader using Intelligent Search + shared transform.
3
3
  * Maps IS response to schema.org Product[] following deco-cx/apps pattern.
4
4
  */
5
- import { intelligentSearch, getVtexConfig, toFacetPath } from "../client";
6
- import { toProduct, pickSku } from "../utils/transform";
7
- import type { Product as ProductVTEX } from "../utils/types";
5
+
8
6
  import type { Product } from "../../commerce/types/commerce";
7
+ import { getVtexConfig, intelligentSearch, toFacetPath } from "../client";
8
+ import { pickSku, toProduct } from "../utils/transform";
9
+ import type { Product as ProductVTEX } from "../utils/types";
9
10
 
10
11
  export interface WorkflowProductsProps {
11
- props?: {
12
- query?: string;
13
- count?: number;
14
- sort?: string;
15
- collection?: string;
16
- };
17
- page?: number;
18
- pagesize?: number;
12
+ props?: {
13
+ query?: string;
14
+ count?: number;
15
+ sort?: string;
16
+ collection?: string;
17
+ };
18
+ page?: number;
19
+ pagesize?: number;
19
20
  }
20
21
 
21
22
  export default async function vtexWorkflowProducts(
22
- props: WorkflowProductsProps,
23
+ props: WorkflowProductsProps,
23
24
  ): Promise<Product[] | null> {
24
- const inner = props.props ?? props;
25
- const collection = (inner as any).collection;
26
- const query = (inner as any).query ?? "";
27
- const count = (inner as any).count ?? props.pagesize ?? 12;
28
- const sort = (inner as any).sort ?? "";
25
+ const inner = props.props ?? props;
26
+ const collection = (inner as any).collection;
27
+ const query = (inner as any).query ?? "";
28
+ const count = (inner as any).count ?? props.pagesize ?? 12;
29
+ const sort = (inner as any).sort ?? "";
29
30
 
30
- try {
31
- const config = getVtexConfig();
32
- const locale = config.locale ?? "pt-BR";
31
+ try {
32
+ const config = getVtexConfig();
33
+ const locale = config.locale ?? "pt-BR";
33
34
 
34
- const params: Record<string, string> = {
35
- count: String(count),
36
- locale,
37
- page: String((props.page ?? 0) + 1),
38
- };
39
- if (query) params.query = query;
40
- if (sort) params.sort = sort;
35
+ const params: Record<string, string> = {
36
+ count: String(count),
37
+ locale,
38
+ page: String((props.page ?? 0) + 1),
39
+ };
40
+ if (query) params.query = query;
41
+ if (sort) params.sort = sort;
41
42
 
42
- const facetPath = collection
43
- ? toFacetPath([{ key: "productClusterIds", value: collection }])
44
- : "";
43
+ const facetPath = collection
44
+ ? toFacetPath([{ key: "productClusterIds", value: collection }])
45
+ : "";
45
46
 
46
- const endpoint = facetPath
47
- ? `/product_search/${facetPath}`
48
- : "/product_search/";
47
+ const endpoint = facetPath ? `/product_search/${facetPath}` : "/product_search/";
49
48
 
50
- const data = await intelligentSearch<{ products: ProductVTEX[] }>(
51
- endpoint,
52
- params,
53
- );
49
+ const data = await intelligentSearch<{ products: ProductVTEX[] }>(endpoint, params);
54
50
 
55
- const products = data.products ?? [];
56
- const baseUrl = config.publicUrl
57
- ? `https://${config.publicUrl}`
58
- : `https://${config.account}.vtexcommercestable.${config.domain ?? "com.br"}`;
51
+ const products = data.products ?? [];
52
+ const baseUrl = config.publicUrl
53
+ ? `https://${config.publicUrl}`
54
+ : `https://${config.account}.vtexcommercestable.${config.domain ?? "com.br"}`;
59
55
 
60
- return products.map((p) => {
61
- const sku = pickSku(p);
62
- return toProduct(p, sku, 0, { baseUrl, priceCurrency: "BRL" });
63
- });
64
- } catch (error) {
65
- console.error("[VTEX] Workflow products error:", error);
66
- return null;
67
- }
56
+ return products.map((p) => {
57
+ const sku = pickSku(p);
58
+ return toProduct(p, sku, 0, { baseUrl, priceCurrency: "BRL" });
59
+ });
60
+ } catch (error) {
61
+ console.error("[VTEX] Workflow products error:", error);
62
+ return null;
63
+ }
68
64
  }
package/vtex/invoke.ts CHANGED
@@ -22,210 +22,175 @@
22
22
  * ```
23
23
  */
24
24
  import { createInvokeFn } from "@decocms/start/sdk/createInvoke";
25
+ import type { RegionResult } from "./actions/checkout";
25
26
  import {
26
- getOrCreateCart,
27
- addItemsToCart,
28
- updateCartItems,
29
- addCouponToCart,
30
- simulateCart,
31
- getSellersByRegion,
32
- setShippingPostalCode,
33
- updateOrderFormAttachment,
34
- type SimulationItem,
27
+ addCouponToCart,
28
+ addItemsToCart,
29
+ getOrCreateCart,
30
+ getSellersByRegion,
31
+ type SimulationItem,
32
+ setShippingPostalCode,
33
+ simulateCart,
34
+ updateCartItems,
35
+ updateOrderFormAttachment,
35
36
  } from "./actions/checkout";
36
37
  import {
37
- createDocument,
38
- getDocument,
39
- patchDocument,
40
- searchDocuments,
41
- uploadAttachment,
42
- type UploadAttachmentOpts,
43
- type CreateDocumentResult,
38
+ type CreateDocumentResult,
39
+ createDocument,
40
+ getDocument,
41
+ patchDocument,
42
+ searchDocuments,
43
+ type UploadAttachmentOpts,
44
+ uploadAttachment,
44
45
  } from "./actions/masterData";
46
+ import { type NotifyMeProps, notifyMe } from "./actions/misc";
47
+ import { type SubscribeProps, subscribe } from "./actions/newsletter";
45
48
  import { createSession, editSession, type SessionData } from "./actions/session";
46
- import { subscribe, type SubscribeProps } from "./actions/newsletter";
47
- import { notifyMe, type NotifyMeProps } from "./actions/misc";
48
49
  import type { OrderForm } from "./types";
49
- import type { RegionResult } from "./actions/checkout";
50
50
 
51
51
  // ---------------------------------------------------------------------------
52
52
  // invoke.vtex.actions — typed server functions callable from client
53
53
  // ---------------------------------------------------------------------------
54
54
 
55
55
  export const invoke = {
56
- vtex: {
57
- actions: {
58
- // -- Cart (unwrap VtexFetchResult -> OrderForm) -----------------------
59
-
60
- getOrCreateCart: createInvokeFn(
61
- (input: { orderFormId?: string }) =>
62
- getOrCreateCart(input.orderFormId),
63
- { unwrap: true },
64
- ) as unknown as (ctx: { data: { orderFormId?: string } }) => Promise<OrderForm>,
65
-
66
- addItemsToCart: createInvokeFn(
67
- (input: {
68
- orderFormId: string;
69
- orderItems: Array<{
70
- id: string;
71
- seller: string;
72
- quantity: number;
73
- }>;
74
- }) => addItemsToCart(input.orderFormId, input.orderItems),
75
- { unwrap: true },
76
- ) as unknown as (ctx: {
77
- data: {
78
- orderFormId: string;
79
- orderItems: Array<{
80
- id: string;
81
- seller: string;
82
- quantity: number;
83
- }>;
84
- };
85
- }) => Promise<OrderForm>,
86
-
87
- updateCartItems: createInvokeFn(
88
- (input: {
89
- orderFormId: string;
90
- orderItems: Array<{ index: number; quantity: number }>;
91
- }) => updateCartItems(input.orderFormId, input.orderItems),
92
- { unwrap: true },
93
- ) as unknown as (ctx: {
94
- data: {
95
- orderFormId: string;
96
- orderItems: Array<{ index: number; quantity: number }>;
97
- };
98
- }) => Promise<OrderForm>,
99
-
100
- addCouponToCart: createInvokeFn(
101
- (input: { orderFormId: string; text: string }) =>
102
- addCouponToCart(input.orderFormId, input.text),
103
- { unwrap: true },
104
- ) as unknown as (ctx: {
105
- data: { orderFormId: string; text: string };
106
- }) => Promise<OrderForm>,
107
-
108
- simulateCart: createInvokeFn(
109
- (input: {
110
- items: SimulationItem[];
111
- postalCode: string;
112
- country?: string;
113
- }) => simulateCart(input.items, input.postalCode, input.country),
114
- ),
115
-
116
- // -- Shipping / Region ------------------------------------------------
117
-
118
- getSellersByRegion: createInvokeFn(
119
- (input: { postalCode: string; salesChannel?: string }) =>
120
- getSellersByRegion(input.postalCode, input.salesChannel),
121
- ) as (ctx: {
122
- data: { postalCode: string; salesChannel?: string };
123
- }) => Promise<RegionResult | null>,
124
-
125
- setShippingPostalCode: createInvokeFn(
126
- (input: {
127
- orderFormId: string;
128
- postalCode: string;
129
- country?: string;
130
- }) =>
131
- setShippingPostalCode(
132
- input.orderFormId,
133
- input.postalCode,
134
- input.country,
135
- ),
136
- ) as (ctx: {
137
- data: {
138
- orderFormId: string;
139
- postalCode: string;
140
- country?: string;
141
- };
142
- }) => Promise<boolean>,
143
-
144
- updateOrderFormAttachment: createInvokeFn(
145
- (input: {
146
- orderFormId: string;
147
- attachment: string;
148
- body: Record<string, unknown>;
149
- }) =>
150
- updateOrderFormAttachment(
151
- input.orderFormId,
152
- input.attachment,
153
- input.body,
154
- ),
155
- { unwrap: true },
156
- ) as unknown as (ctx: {
157
- data: {
158
- orderFormId: string;
159
- attachment: string;
160
- body: Record<string, unknown>;
161
- };
162
- }) => Promise<OrderForm>,
163
-
164
- // -- Session ----------------------------------------------------------
165
-
166
- createSession: createInvokeFn(
167
- (input: Record<string, any>) => createSession(input),
168
- { unwrap: true },
169
- ),
170
-
171
- editSession: createInvokeFn(
172
- (input: { public: Record<string, { value: string }> }) =>
173
- editSession(input.public),
174
- { unwrap: true },
175
- ) as unknown as (ctx: {
176
- data: { public: Record<string, { value: string }> };
177
- }) => Promise<SessionData>,
178
-
179
- // -- MasterData -------------------------------------------------------
180
-
181
- createDocument: createInvokeFn(
182
- (input: { entity: string; data: Record<string, any> }) =>
183
- createDocument(input.entity, input.data),
184
- ) as (ctx: {
185
- data: { entity: string; data: Record<string, any> };
186
- }) => Promise<CreateDocumentResult>,
187
-
188
- getDocument: createInvokeFn(
189
- (input: { entity: string; documentId: string }) =>
190
- getDocument(input.entity, input.documentId),
191
- ),
192
-
193
- patchDocument: createInvokeFn(
194
- (input: {
195
- entity: string;
196
- documentId: string;
197
- data: Record<string, any>;
198
- }) => patchDocument(input.entity, input.documentId, input.data),
199
- ) as (ctx: {
200
- data: {
201
- entity: string;
202
- documentId: string;
203
- data: Record<string, any>;
204
- };
205
- }) => Promise<void>,
206
-
207
- searchDocuments: createInvokeFn(
208
- (input: { entity: string; filter: string }) =>
209
- searchDocuments(input.entity, input.filter),
210
- ),
211
-
212
- uploadAttachment: createInvokeFn(
213
- (input: UploadAttachmentOpts) => uploadAttachment(input),
214
- ) as (ctx: {
215
- data: UploadAttachmentOpts;
216
- }) => Promise<{ ok: true }>,
217
-
218
- // -- Newsletter -------------------------------------------------------
219
-
220
- subscribe: createInvokeFn(
221
- (input: SubscribeProps) => subscribe(input),
222
- ) as (ctx: { data: SubscribeProps }) => Promise<void>,
223
-
224
- // -- Misc -------------------------------------------------------------
225
-
226
- notifyMe: createInvokeFn(
227
- (input: NotifyMeProps) => notifyMe(input),
228
- ) as (ctx: { data: NotifyMeProps }) => Promise<void>,
229
- },
230
- },
56
+ vtex: {
57
+ actions: {
58
+ // -- Cart (unwrap VtexFetchResult -> OrderForm) -----------------------
59
+
60
+ getOrCreateCart: createInvokeFn(
61
+ (input: { orderFormId?: string }) => getOrCreateCart(input.orderFormId),
62
+ { unwrap: true },
63
+ ) as unknown as (ctx: { data: { orderFormId?: string } }) => Promise<OrderForm>,
64
+
65
+ addItemsToCart: createInvokeFn(
66
+ (input: {
67
+ orderFormId: string;
68
+ orderItems: Array<{
69
+ id: string;
70
+ seller: string;
71
+ quantity: number;
72
+ }>;
73
+ }) => addItemsToCart(input.orderFormId, input.orderItems),
74
+ { unwrap: true },
75
+ ) as unknown as (ctx: {
76
+ data: {
77
+ orderFormId: string;
78
+ orderItems: Array<{
79
+ id: string;
80
+ seller: string;
81
+ quantity: number;
82
+ }>;
83
+ };
84
+ }) => Promise<OrderForm>,
85
+
86
+ updateCartItems: createInvokeFn(
87
+ (input: { orderFormId: string; orderItems: Array<{ index: number; quantity: number }> }) =>
88
+ updateCartItems(input.orderFormId, input.orderItems),
89
+ { unwrap: true },
90
+ ) as unknown as (ctx: {
91
+ data: {
92
+ orderFormId: string;
93
+ orderItems: Array<{ index: number; quantity: number }>;
94
+ };
95
+ }) => Promise<OrderForm>,
96
+
97
+ addCouponToCart: createInvokeFn(
98
+ (input: { orderFormId: string; text: string }) =>
99
+ addCouponToCart(input.orderFormId, input.text),
100
+ { unwrap: true },
101
+ ) as unknown as (ctx: { data: { orderFormId: string; text: string } }) => Promise<OrderForm>,
102
+
103
+ simulateCart: createInvokeFn(
104
+ (input: { items: SimulationItem[]; postalCode: string; country?: string }) =>
105
+ simulateCart(input.items, input.postalCode, input.country),
106
+ ),
107
+
108
+ // -- Shipping / Region ------------------------------------------------
109
+
110
+ getSellersByRegion: createInvokeFn((input: { postalCode: string; salesChannel?: string }) =>
111
+ getSellersByRegion(input.postalCode, input.salesChannel),
112
+ ) as (ctx: {
113
+ data: { postalCode: string; salesChannel?: string };
114
+ }) => Promise<RegionResult | null>,
115
+
116
+ setShippingPostalCode: createInvokeFn(
117
+ (input: { orderFormId: string; postalCode: string; country?: string }) =>
118
+ setShippingPostalCode(input.orderFormId, input.postalCode, input.country),
119
+ ) as (ctx: {
120
+ data: {
121
+ orderFormId: string;
122
+ postalCode: string;
123
+ country?: string;
124
+ };
125
+ }) => Promise<boolean>,
126
+
127
+ updateOrderFormAttachment: createInvokeFn(
128
+ (input: { orderFormId: string; attachment: string; body: Record<string, unknown> }) =>
129
+ updateOrderFormAttachment(input.orderFormId, input.attachment, input.body),
130
+ { unwrap: true },
131
+ ) as unknown as (ctx: {
132
+ data: {
133
+ orderFormId: string;
134
+ attachment: string;
135
+ body: Record<string, unknown>;
136
+ };
137
+ }) => Promise<OrderForm>,
138
+
139
+ // -- Session ----------------------------------------------------------
140
+
141
+ createSession: createInvokeFn((input: Record<string, any>) => createSession(input), {
142
+ unwrap: true,
143
+ }),
144
+
145
+ editSession: createInvokeFn(
146
+ (input: { public: Record<string, { value: string }> }) => editSession(input.public),
147
+ { unwrap: true },
148
+ ) as unknown as (ctx: {
149
+ data: { public: Record<string, { value: string }> };
150
+ }) => Promise<SessionData>,
151
+
152
+ // -- MasterData -------------------------------------------------------
153
+
154
+ createDocument: createInvokeFn((input: { entity: string; data: Record<string, any> }) =>
155
+ createDocument(input.entity, input.data),
156
+ ) as (ctx: {
157
+ data: { entity: string; data: Record<string, any> };
158
+ }) => Promise<CreateDocumentResult>,
159
+
160
+ getDocument: createInvokeFn((input: { entity: string; documentId: string }) =>
161
+ getDocument(input.entity, input.documentId),
162
+ ),
163
+
164
+ patchDocument: createInvokeFn(
165
+ (input: { entity: string; documentId: string; data: Record<string, any> }) =>
166
+ patchDocument(input.entity, input.documentId, input.data),
167
+ ) as (ctx: {
168
+ data: {
169
+ entity: string;
170
+ documentId: string;
171
+ data: Record<string, any>;
172
+ };
173
+ }) => Promise<void>,
174
+
175
+ searchDocuments: createInvokeFn((input: { entity: string; filter: string }) =>
176
+ searchDocuments(input.entity, input.filter),
177
+ ),
178
+
179
+ uploadAttachment: createInvokeFn((input: UploadAttachmentOpts) =>
180
+ uploadAttachment(input),
181
+ ) as (ctx: { data: UploadAttachmentOpts }) => Promise<{ ok: true }>,
182
+
183
+ // -- Newsletter -------------------------------------------------------
184
+
185
+ subscribe: createInvokeFn((input: SubscribeProps) => subscribe(input)) as (ctx: {
186
+ data: SubscribeProps;
187
+ }) => Promise<void>,
188
+
189
+ // -- Misc -------------------------------------------------------------
190
+
191
+ notifyMe: createInvokeFn((input: NotifyMeProps) => notifyMe(input)) as (ctx: {
192
+ data: NotifyMeProps;
193
+ }) => Promise<void>,
194
+ },
195
+ },
231
196
  } as const;
@@ -15,34 +15,34 @@ import { vtexFetch, vtexIOGraphQL } from "../client";
15
15
  // ---------------------------------------------------------------------------
16
16
 
17
17
  export interface PostalAddress {
18
- "@type": "PostalAddress";
19
- postalCode?: string;
20
- addressLocality?: string;
21
- addressRegion?: string;
22
- addressCountry?: string;
23
- streetAddress?: string;
24
- identifier?: string;
25
- areaServed?: string;
26
- description?: string;
27
- disambiguatingDescription?: string;
28
- latitude?: number;
29
- longitude?: number;
18
+ "@type": "PostalAddress";
19
+ postalCode?: string;
20
+ addressLocality?: string;
21
+ addressRegion?: string;
22
+ addressCountry?: string;
23
+ streetAddress?: string;
24
+ identifier?: string;
25
+ areaServed?: string;
26
+ description?: string;
27
+ disambiguatingDescription?: string;
28
+ latitude?: number;
29
+ longitude?: number;
30
30
  }
31
31
 
32
32
  export interface VtexAddress {
33
- addressId: string;
34
- addressType: string;
35
- addressName: string;
36
- city: string;
37
- complement: string;
38
- country: string;
39
- neighborhood: string;
40
- number: string;
41
- postalCode: string;
42
- geoCoordinates: number[];
43
- receiverName: string;
44
- state: string;
45
- street: string;
33
+ addressId: string;
34
+ addressType: string;
35
+ addressName: string;
36
+ city: string;
37
+ complement: string;
38
+ country: string;
39
+ neighborhood: string;
40
+ number: string;
41
+ postalCode: string;
42
+ geoCoordinates: number[];
43
+ receiverName: string;
44
+ state: string;
45
+ street: string;
46
46
  }
47
47
 
48
48
  // ---------------------------------------------------------------------------
@@ -54,27 +54,27 @@ export interface VtexAddress {
54
54
  * @see https://developers.vtex.com/docs/api-reference/checkout-api#get-/api/checkout/pub/postal-code/-countryCode-/-postalCode-
55
55
  */
56
56
  export async function getAddressByPostalCode(
57
- countryCode: string,
58
- postalCode: string,
57
+ countryCode: string,
58
+ postalCode: string,
59
59
  ): Promise<PostalAddress> {
60
- const data = await vtexFetch<Record<string, any>>(
61
- `/api/checkout/pub/postal-code/${countryCode}/${postalCode}`,
62
- );
60
+ const data = await vtexFetch<Record<string, any>>(
61
+ `/api/checkout/pub/postal-code/${countryCode}/${postalCode}`,
62
+ );
63
63
 
64
- return {
65
- "@type": "PostalAddress",
66
- postalCode: data.postalCode,
67
- addressLocality: data.city,
68
- addressRegion: data.state,
69
- addressCountry: data.country,
70
- streetAddress: data.street || undefined,
71
- identifier: data.number || undefined,
72
- areaServed: data.neighborhood || undefined,
73
- description: data.complement || undefined,
74
- disambiguatingDescription: data.reference || undefined,
75
- latitude: data.geoCoordinates?.[0] || undefined,
76
- longitude: data.geoCoordinates?.[1] || undefined,
77
- };
64
+ return {
65
+ "@type": "PostalAddress",
66
+ postalCode: data.postalCode,
67
+ addressLocality: data.city,
68
+ addressRegion: data.state,
69
+ addressCountry: data.country,
70
+ streetAddress: data.street || undefined,
71
+ identifier: data.number || undefined,
72
+ areaServed: data.neighborhood || undefined,
73
+ description: data.complement || undefined,
74
+ disambiguatingDescription: data.reference || undefined,
75
+ latitude: data.geoCoordinates?.[0] ?? undefined,
76
+ longitude: data.geoCoordinates?.[1] ?? undefined,
77
+ };
78
78
  }
79
79
 
80
80
  // ---------------------------------------------------------------------------
@@ -106,15 +106,10 @@ const USER_ADDRESSES_QUERY = `query Addresses @context(scope: "private") {
106
106
  * Fetch addresses for the currently authenticated user.
107
107
  * Requires a valid VTEX auth cookie.
108
108
  */
109
- export async function getUserAddresses(
110
- authCookie: string,
111
- ): Promise<VtexAddress[]> {
112
- const { profile } = await vtexIOGraphQL<{
113
- profile: { addresses: VtexAddress[] };
114
- }>(
115
- { query: USER_ADDRESSES_QUERY },
116
- { cookie: authCookie },
117
- );
109
+ export async function getUserAddresses(authCookie: string): Promise<VtexAddress[]> {
110
+ const { profile } = await vtexIOGraphQL<{
111
+ profile: { addresses: VtexAddress[] };
112
+ }>({ query: USER_ADDRESSES_QUERY }, { cookie: authCookie });
118
113
 
119
- return profile?.addresses ?? [];
114
+ return profile?.addresses ?? [];
120
115
  }