@vtex/faststore 0.0.6 → 0.0.8

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 (488) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/dist/actions.json +152 -1
  3. package/dist/catalog.json +2541 -1278
  4. package/dist/cli/UnreachableCaseError-Crd168Vu.js +10 -0
  5. package/dist/cli/UnreachableCaseError-Crd168Vu.js.map +1 -0
  6. package/dist/cli/cacheControl-CEojH_TM.js +158 -0
  7. package/dist/cli/cacheControl-CEojH_TM.js.map +1 -0
  8. package/dist/cli/cachePolicy-m2vASMRW.js +26 -0
  9. package/dist/cli/cachePolicy-m2vASMRW.js.map +1 -0
  10. package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js +10 -0
  11. package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js.map +1 -0
  12. package/dist/cli/default-BCQHcwbL.js +253 -0
  13. package/dist/cli/default-BCQHcwbL.js.map +1 -0
  14. package/dist/cli/disableSuggestions-yO9UqiWn.js +21 -0
  15. package/dist/cli/disableSuggestions-yO9UqiWn.js.map +1 -0
  16. package/dist/cli/dist-C1JhdHfo.js +2001 -0
  17. package/dist/cli/dist-C1JhdHfo.js.map +1 -0
  18. package/dist/cli/graphql-DG9thCDG.js +14589 -0
  19. package/dist/cli/graphql-DG9thCDG.js.map +1 -0
  20. package/dist/cli/index.d.ts +799 -0
  21. package/dist/cli/index.js +36459 -0
  22. package/dist/cli/index.js.map +1 -0
  23. package/dist/cli/index.min-BsIHDfFK.js +613 -0
  24. package/dist/cli/index.min-BsIHDfFK.js.map +1 -0
  25. package/dist/cli/inlineTrace-uLgOJ3TH.js +52 -0
  26. package/dist/cli/inlineTrace-uLgOJ3TH.js.map +1 -0
  27. package/dist/cli/internalPlugin-DnuwN4_4.js +11 -0
  28. package/dist/cli/internalPlugin-DnuwN4_4.js.map +1 -0
  29. package/dist/cli/packageVersion-DQAnIEil.js +6 -0
  30. package/dist/cli/packageVersion-DQAnIEil.js.map +1 -0
  31. package/dist/cli/rolldown-runtime-BMI-E3GI.js +44 -0
  32. package/dist/cli/schemaIsSubgraph-DoGh3OYj.js +17 -0
  33. package/dist/cli/schemaIsSubgraph-DoGh3OYj.js.map +1 -0
  34. package/dist/cli/schemaReporting-K-me-3-v.js +199 -0
  35. package/dist/cli/schemaReporting-K-me-3-v.js.map +1 -0
  36. package/dist/cli/server-runtime.js +49879 -0
  37. package/dist/cli/server-runtime.js.map +1 -0
  38. package/dist/cli/traceTreeBuilder-BIcV2U7b.js +9118 -0
  39. package/dist/cli/traceTreeBuilder-BIcV2U7b.js.map +1 -0
  40. package/dist/cli/usageReporting-Bpl8vSZX.js +10201 -0
  41. package/dist/cli/usageReporting-Bpl8vSZX.js.map +1 -0
  42. package/dist/cli/v4-CBhFvC49.js +42 -0
  43. package/dist/cli/v4-CBhFvC49.js.map +1 -0
  44. package/dist/client.d.ts +5 -1
  45. package/dist/client.js +5 -1
  46. package/dist/components.d.ts +38 -9
  47. package/dist/components.js +42 -13
  48. package/dist/content-types.json +616 -0
  49. package/dist/core/dist/define-component.d.ts +43 -1
  50. package/dist/core/dist/index.d.ts +2 -2
  51. package/dist/docs/account-access-gate.md +4 -4
  52. package/dist/docs/account-address-book.md +519 -0
  53. package/dist/docs/account-entry-point.md +1 -1
  54. package/dist/docs/account-menu-identity.md +160 -0
  55. package/dist/docs/account-menu.md +107 -24
  56. package/dist/docs/alert-dialog.md +2 -2
  57. package/dist/docs/avatar.md +103 -0
  58. package/dist/docs/billing-address.md +17 -9
  59. package/dist/docs/card-entry.md +37 -6
  60. package/dist/docs/cardholder-document.md +16 -14
  61. package/dist/docs/cart-item.md +1 -1
  62. package/dist/docs/cart.md +8 -8
  63. package/dist/docs/client-profile-fieldset.md +7 -5
  64. package/dist/docs/copy-text.md +84 -0
  65. package/dist/docs/document-field.md +8 -8
  66. package/dist/docs/footer-link-group.md +2 -2
  67. package/dist/docs/header-root.md +1 -1
  68. package/dist/docs/incentives.md +2 -2
  69. package/dist/docs/logo.md +5 -5
  70. package/dist/docs/my-account-profile.md +5 -5
  71. package/dist/docs/navigation-link-list.md +2 -2
  72. package/dist/docs/navigation-link.md +3 -3
  73. package/dist/docs/order-cancel.md +52 -0
  74. package/dist/docs/order-delivery-address.md +63 -0
  75. package/dist/docs/order-delivery-group.md +83 -0
  76. package/dist/docs/order-details-back.md +41 -0
  77. package/dist/docs/order-details-header.md +48 -0
  78. package/dist/docs/order-list-row.md +46 -0
  79. package/dist/docs/order-list-search.md +101 -0
  80. package/dist/docs/order-list-views.md +97 -0
  81. package/dist/docs/order-list.md +94 -0
  82. package/dist/docs/order-payment.md +94 -0
  83. package/dist/docs/order-placed-date.md +49 -0
  84. package/dist/docs/order-placed-payment-summary.md +13 -15
  85. package/dist/docs/order-placed.md +225 -0
  86. package/dist/docs/order-progress.md +88 -0
  87. package/dist/docs/order-status-badge.md +91 -0
  88. package/dist/docs/order-summary.md +53 -0
  89. package/dist/docs/payment-method-badges.md +14 -3
  90. package/dist/docs/place-order.md +13 -9
  91. package/dist/docs/product-shelf.md +20 -13
  92. package/dist/docs/saved-cards.md +2 -2
  93. package/dist/docs/select.md +19 -6
  94. package/dist/docs/session.md +1 -1
  95. package/dist/docs/shipping-address.md +1 -1
  96. package/dist/docs/sign-in-redirect.md +6 -6
  97. package/dist/docs/toast.md +7 -3
  98. package/dist/index.d.ts +7 -3
  99. package/dist/index.js +2 -1
  100. package/dist/internal/client.d.ts +6 -1
  101. package/dist/internal/client.js +8 -3
  102. package/dist/internal/content.d.ts +2 -2
  103. package/dist/internal/server.d.ts +8 -1
  104. package/dist/internal/server.js +8 -1
  105. package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
  106. package/dist/matter/account-access-gate/account-access-gate.js +19 -16
  107. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
  108. package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
  109. package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
  110. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
  111. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
  112. package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
  113. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
  114. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
  115. package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
  116. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
  117. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
  118. package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
  119. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
  120. package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
  121. package/dist/matter/account-address-book/account-address-book.js +469 -0
  122. package/dist/matter/account-address-book/account-address-book.js.map +1 -0
  123. package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
  124. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
  125. package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
  126. package/dist/matter/account-address-book/account-address-country.js +151 -0
  127. package/dist/matter/account-address-book/account-address-country.js.map +1 -0
  128. package/dist/matter/account-address-book/account-address-first-line.js +11 -0
  129. package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
  130. package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
  131. package/dist/matter/account-address-book/account-address-form-context.js +14 -0
  132. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
  133. package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
  134. package/dist/matter/account-address-book/account-address-form.js +946 -0
  135. package/dist/matter/account-address-book/account-address-form.js.map +1 -0
  136. package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
  137. package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
  138. package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
  139. package/dist/matter/account-address-book/account-address-record.js +138 -0
  140. package/dist/matter/account-address-book/account-address-record.js.map +1 -0
  141. package/dist/matter/account-entry-point/account-entry-point.js +11 -11
  142. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  143. package/dist/matter/account-menu/account-menu.d.ts +77 -3
  144. package/dist/matter/account-menu/account-menu.js +252 -19
  145. package/dist/matter/account-menu/account-menu.js.map +1 -1
  146. package/dist/matter/account-menu/sign-out-failure.js +50 -0
  147. package/dist/matter/account-menu/sign-out-failure.js.map +1 -0
  148. package/dist/matter/account-menu-identity/account-menu-identity.d.ts +21 -0
  149. package/dist/matter/account-menu-identity/account-menu-identity.js +88 -0
  150. package/dist/matter/account-menu-identity/account-menu-identity.js.map +1 -0
  151. package/dist/matter/billing-address/billing-address.d.ts +30 -17
  152. package/dist/matter/billing-address/billing-address.js +128 -33
  153. package/dist/matter/billing-address/billing-address.js.map +1 -1
  154. package/dist/matter/breadcrumb/breadcrumb.js +2 -2
  155. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  156. package/dist/matter/card-entry/card-capture.js +4 -3
  157. package/dist/matter/card-entry/card-capture.js.map +1 -1
  158. package/dist/matter/card-entry/card-entry.d.ts +5 -3
  159. package/dist/matter/card-entry/card-entry.js +78 -27
  160. package/dist/matter/card-entry/card-entry.js.map +1 -1
  161. package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
  162. package/dist/matter/cardholder-document/cardholder-document.js +36 -16
  163. package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
  164. package/dist/matter/cart/cart.d.ts +7 -2
  165. package/dist/matter/cart/cart.js +29 -26
  166. package/dist/matter/cart/cart.js.map +1 -1
  167. package/dist/matter/cart-item/cart-item.js +2 -2
  168. package/dist/matter/cart-item/cart-item.js.map +1 -1
  169. package/dist/matter/client-preferences/client-preferences-fieldset.js +2 -2
  170. package/dist/matter/client-profile-form/client-profile-fieldset.js +9 -6
  171. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  172. package/dist/matter/identity-edit/identity-edit.js +3 -3
  173. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  174. package/dist/matter/identity-summary/identity-summary.js +4 -3
  175. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  176. package/dist/matter/my-account-profile/my-account-profile.d.ts +6 -3
  177. package/dist/matter/my-account-profile/my-account-profile.js +6 -5
  178. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  179. package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
  180. package/dist/matter/order-cancel/order-cancel.js +344 -0
  181. package/dist/matter/order-cancel/order-cancel.js.map +1 -0
  182. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
  183. package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
  184. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
  185. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
  186. package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
  187. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
  188. package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
  189. package/dist/matter/order-details-header/order-details-header.js +190 -0
  190. package/dist/matter/order-details-header/order-details-header.js.map +1 -0
  191. package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
  192. package/dist/matter/order-list/customer-orders-filter.js +30 -0
  193. package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
  194. package/dist/matter/order-list/order-list.d.ts +121 -0
  195. package/dist/matter/order-list/order-list.js +395 -0
  196. package/dist/matter/order-list/order-list.js.map +1 -0
  197. package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
  198. package/dist/matter/order-list-row/order-list-row.js +127 -0
  199. package/dist/matter/order-list-row/order-list-row.js.map +1 -0
  200. package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
  201. package/dist/matter/order-list-search/order-list-search.js +296 -0
  202. package/dist/matter/order-list-search/order-list-search.js.map +1 -0
  203. package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
  204. package/dist/matter/order-list-views/order-list-views.js +154 -0
  205. package/dist/matter/order-list-views/order-list-views.js.map +1 -0
  206. package/dist/matter/order-payment/order-payment.d.ts +83 -0
  207. package/dist/matter/order-payment/order-payment.js +258 -0
  208. package/dist/matter/order-payment/order-payment.js.map +1 -0
  209. package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
  210. package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
  211. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
  212. package/dist/matter/order-placed/order-placed.d.ts +122 -0
  213. package/dist/matter/order-placed/order-placed.js +452 -0
  214. package/dist/matter/order-placed/order-placed.js.map +1 -0
  215. package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
  216. package/dist/matter/order-placed-date/order-placed-date.js +92 -0
  217. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
  218. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
  219. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
  220. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  221. package/dist/matter/order-progress/order-progress.d.ts +85 -0
  222. package/dist/matter/order-progress/order-progress.js +203 -0
  223. package/dist/matter/order-progress/order-progress.js.map +1 -0
  224. package/dist/matter/order-summary/order-summary.d.ts +81 -0
  225. package/dist/matter/order-summary/order-summary.js +192 -0
  226. package/dist/matter/order-summary/order-summary.js.map +1 -0
  227. package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
  228. package/dist/matter/payment/cardholder-document-rule.js +35 -0
  229. package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
  230. package/dist/matter/payment/payment-card-capture.js +38 -23
  231. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  232. package/dist/matter/payment/payment-controller.js +12 -0
  233. package/dist/matter/payment/payment-controller.js.map +1 -1
  234. package/dist/matter/payment/payment-method-badges.js +4 -2
  235. package/dist/matter/payment/payment-method-badges.js.map +1 -1
  236. package/dist/matter/payment/payment.js +12 -0
  237. package/dist/matter/payment/payment.js.map +1 -1
  238. package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
  239. package/dist/matter/payment/use-payment-method-selection.js +30 -2
  240. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  241. package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
  242. package/dist/matter/payment/use-payment-submit-gate.js +42 -14
  243. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  244. package/dist/matter/place-order/place-order.d.ts +12 -7
  245. package/dist/matter/place-order/place-order.js +126 -103
  246. package/dist/matter/place-order/place-order.js.map +1 -1
  247. package/dist/matter/pricing/pricing.js +5 -5
  248. package/dist/matter/pricing/pricing.js.map +1 -1
  249. package/dist/matter/product-shelf/product-shelf.d.ts +61 -31
  250. package/dist/matter/product-shelf/product-shelf.js +157 -57
  251. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  252. package/dist/matter/region/region.js +1 -1
  253. package/dist/matter/saved-cards/saved-cards.js +27 -15
  254. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  255. package/dist/matter/session/session.js +2 -2
  256. package/dist/matter/session/session.js.map +1 -1
  257. package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
  258. package/dist/matter/shipping-address/country-descriptors.js +23 -1
  259. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  260. package/dist/matter/shipping-address/shipping-address.js +63 -15
  261. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  262. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +1 -1
  263. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  264. package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
  265. package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
  266. package/dist/matter/variant-selector/variant-selector.js +2 -2
  267. package/dist/matter/variant-selector/variant-selector.js.map +1 -1
  268. package/dist/particles/address-summary/address-summary.js +2 -2
  269. package/dist/particles/address-summary/address-summary.js.map +1 -1
  270. package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
  271. package/dist/particles/alert-dialog/alert-dialog.js +5 -2
  272. package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
  273. package/dist/particles/avatar/avatar.d.ts +17 -0
  274. package/dist/particles/avatar/avatar.js +65 -0
  275. package/dist/particles/avatar/avatar.js.map +1 -0
  276. package/dist/particles/copy-text/copy-text.d.ts +28 -0
  277. package/dist/particles/copy-text/copy-text.js +140 -0
  278. package/dist/particles/copy-text/copy-text.js.map +1 -0
  279. package/dist/particles/document-field/document-field.d.ts +34 -5
  280. package/dist/particles/document-field/document-field.js +115 -19
  281. package/dist/particles/document-field/document-field.js.map +1 -1
  282. package/dist/particles/field/field.js +1 -1
  283. package/dist/particles/field/field.js.map +1 -1
  284. package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
  285. package/dist/particles/footer-link-group/footer-link-group.js +18 -7
  286. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  287. package/dist/particles/incentives/incentives.d.ts +6 -2
  288. package/dist/particles/incentives/incentives.js +7 -2
  289. package/dist/particles/incentives/incentives.js.map +1 -1
  290. package/dist/particles/logo/logo.d.ts +3 -2
  291. package/dist/particles/logo/logo.js +20 -8
  292. package/dist/particles/logo/logo.js.map +1 -1
  293. package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
  294. package/dist/particles/navigation-link/navigation-link.js +4 -4
  295. package/dist/particles/navigation-link/navigation-link.js.map +1 -1
  296. package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
  297. package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
  298. package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
  299. package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
  300. package/dist/particles/order-details-back/order-details-back.js +52 -0
  301. package/dist/particles/order-details-back/order-details-back.js.map +1 -0
  302. package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
  303. package/dist/particles/order-status-badge/order-status-badge.js +50 -0
  304. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
  305. package/dist/particles/phone-field/phone-field.js +2 -2
  306. package/dist/particles/phone-field/phone-field.js.map +1 -1
  307. package/dist/particles/select/select.js +6 -6
  308. package/dist/particles/select/select.js.map +1 -1
  309. package/dist/particles/toast/toast.d.ts +1 -1
  310. package/dist/particles/toast/toast.js +32 -6
  311. package/dist/particles/toast/toast.js.map +1 -1
  312. package/dist/schema.graphql +1079 -54
  313. package/dist/sdk/actions/address-action-provider.d.ts +16 -0
  314. package/dist/sdk/actions/address-action-provider.js +20 -0
  315. package/dist/sdk/actions/address-action-provider.js.map +1 -0
  316. package/dist/sdk/actions/analytics-action-provider.js +1 -1
  317. package/dist/sdk/actions/index.d.ts +3 -1
  318. package/dist/sdk/actions/index.js +3 -1
  319. package/dist/sdk/actions/order-action-provider.d.ts +12 -0
  320. package/dist/sdk/actions/order-action-provider.js +16 -0
  321. package/dist/sdk/actions/order-action-provider.js.map +1 -0
  322. package/dist/sdk/actions/types.d.ts +6 -2
  323. package/dist/sdk/address/address-fields.js +38 -0
  324. package/dist/sdk/address/address-fields.js.map +1 -0
  325. package/dist/sdk/address/checkout-readiness.js +17 -0
  326. package/dist/sdk/address/checkout-readiness.js.map +1 -0
  327. package/dist/sdk/address/constants.js +60 -0
  328. package/dist/sdk/address/constants.js.map +1 -0
  329. package/dist/sdk/address/country-display.js +19 -0
  330. package/dist/sdk/address/country-display.js.map +1 -0
  331. package/dist/sdk/address/country-rules.js +30 -0
  332. package/dist/sdk/address/country-rules.js.map +1 -0
  333. package/dist/sdk/address/format-address.js +18 -0
  334. package/dist/sdk/address/format-address.js.map +1 -0
  335. package/dist/sdk/address/iso-countries.js +262 -0
  336. package/dist/sdk/address/iso-countries.js.map +1 -0
  337. package/dist/sdk/address/layouts.js +56 -0
  338. package/dist/sdk/address/layouts.js.map +1 -0
  339. package/dist/sdk/address/messages.js +97 -0
  340. package/dist/sdk/address/messages.js.map +1 -0
  341. package/dist/sdk/address/operations.d.ts +54 -0
  342. package/dist/sdk/address/operations.js +83 -0
  343. package/dist/sdk/address/operations.js.map +1 -0
  344. package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
  345. package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
  346. package/dist/sdk/address/postal-code.js +11 -0
  347. package/dist/sdk/address/postal-code.js.map +1 -0
  348. package/dist/sdk/address/schema.js +14 -0
  349. package/dist/sdk/address/schema.js.map +1 -0
  350. package/dist/sdk/address/server-fields.js +25 -0
  351. package/dist/sdk/address/server-fields.js.map +1 -0
  352. package/dist/sdk/address/switch-country.js +57 -0
  353. package/dist/sdk/address/switch-country.js.map +1 -0
  354. package/dist/sdk/address/types.d.ts +26 -0
  355. package/dist/sdk/address/use-address-actions.d.ts +29 -0
  356. package/dist/sdk/address/use-address-actions.js +247 -0
  357. package/dist/sdk/address/use-address-actions.js.map +1 -0
  358. package/dist/sdk/address/use-address-by-postal-code.js +57 -0
  359. package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
  360. package/dist/sdk/address/validate-address.js +62 -0
  361. package/dist/sdk/address/validate-address.js.map +1 -0
  362. package/dist/sdk/analytics/use-analytics-actions.js +2 -1
  363. package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
  364. package/dist/sdk/cache/storefront-cache.js +29 -4
  365. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  366. package/dist/sdk/cart/use-cart-actions.js +9 -8
  367. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  368. package/dist/sdk/cart/use-cart-validate-on-open.js +2 -1
  369. package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
  370. package/dist/sdk/client/fetch-page-data.d.ts +11 -0
  371. package/dist/sdk/client/fetch-page-data.js +12 -1
  372. package/dist/sdk/client/fetch-page-data.js.map +1 -1
  373. package/dist/sdk/content/create-content-runtime.d.ts +22 -1
  374. package/dist/sdk/content/create-content-runtime.js +90 -9
  375. package/dist/sdk/content/create-content-runtime.js.map +1 -1
  376. package/dist/sdk/data/empty-content-value.js +16 -0
  377. package/dist/sdk/data/empty-content-value.js.map +1 -0
  378. package/dist/sdk/data/failed-fields.js +23 -0
  379. package/dist/sdk/data/failed-fields.js.map +1 -0
  380. package/dist/sdk/data/hot-data-provider.js +2 -1
  381. package/dist/sdk/data/hot-data-provider.js.map +1 -1
  382. package/dist/sdk/data/index.js +1 -1
  383. package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
  384. package/dist/sdk/data/page-reactive-data-root.js +88 -12
  385. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  386. package/dist/sdk/data/variables-from-content.d.ts +43 -0
  387. package/dist/sdk/data/variables-from-content.js +57 -0
  388. package/dist/sdk/data/variables-from-content.js.map +1 -0
  389. package/dist/sdk/generated/fragment-types.js +2 -0
  390. package/dist/sdk/generated/fragment-types.js.map +1 -1
  391. package/dist/sdk/generated/gql.js +4 -1
  392. package/dist/sdk/generated/gql.js.map +1 -1
  393. package/dist/sdk/generated/graphql.d.ts +8 -0
  394. package/dist/sdk/generated/graphql.js +296 -1
  395. package/dist/sdk/generated/graphql.js.map +1 -1
  396. package/dist/sdk/i18n/messages/en-US.js +138 -1
  397. package/dist/sdk/i18n/messages/en-US.json +138 -1
  398. package/dist/sdk/i18n/messages/en-US.json.d.ts +137 -0
  399. package/dist/sdk/i18n/messages/es-ES.js +138 -1
  400. package/dist/sdk/i18n/messages/es-ES.json +138 -1
  401. package/dist/sdk/i18n/messages/pt-BR.js +138 -1
  402. package/dist/sdk/i18n/messages/pt-BR.json +138 -1
  403. package/dist/sdk/identity/use-identity-actions.js +5 -4
  404. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  405. package/dist/sdk/navigation/current-page.js +30 -0
  406. package/dist/sdk/navigation/current-page.js.map +1 -0
  407. package/dist/sdk/navigation/not-found-log.d.ts +28 -0
  408. package/dist/sdk/navigation/not-found-log.js +133 -0
  409. package/dist/sdk/navigation/not-found-log.js.map +1 -0
  410. package/dist/sdk/navigation/path.js +25 -0
  411. package/dist/sdk/navigation/path.js.map +1 -0
  412. package/dist/sdk/navigation/redirect.d.ts +11 -0
  413. package/dist/sdk/navigation/redirect.js +22 -0
  414. package/dist/sdk/navigation/redirect.js.map +1 -0
  415. package/dist/sdk/navigation/report.js +70 -0
  416. package/dist/sdk/navigation/report.js.map +1 -0
  417. package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
  418. package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
  419. package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
  420. package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
  421. package/dist/sdk/navigation/route-identity-provider.js +20 -0
  422. package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
  423. package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
  424. package/dist/sdk/navigation/route-map-provider.js +29 -0
  425. package/dist/sdk/navigation/route-map-provider.js.map +1 -0
  426. package/dist/sdk/navigation/storefront-link.d.ts +16 -0
  427. package/dist/sdk/navigation/storefront-link.js +66 -0
  428. package/dist/sdk/navigation/storefront-link.js.map +1 -0
  429. package/dist/sdk/navigation/types.d.ts +45 -0
  430. package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
  431. package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
  432. package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
  433. package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
  434. package/dist/sdk/navigation/use-storefront-route.js +87 -0
  435. package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
  436. package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
  437. package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
  438. package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
  439. package/dist/sdk/orders/completion-badge.d.ts +8 -0
  440. package/dist/sdk/orders/completion-badge.js +47 -0
  441. package/dist/sdk/orders/completion-badge.js.map +1 -0
  442. package/dist/sdk/orders/order-operations.d.ts +19 -0
  443. package/dist/sdk/orders/order-operations.js +21 -0
  444. package/dist/sdk/orders/order-operations.js.map +1 -0
  445. package/dist/sdk/orders/use-order-actions.d.ts +23 -0
  446. package/dist/sdk/orders/use-order-actions.js +62 -0
  447. package/dist/sdk/orders/use-order-actions.js.map +1 -0
  448. package/dist/sdk/payment/gateway-origin.js +26 -13
  449. package/dist/sdk/payment/gateway-origin.js.map +1 -1
  450. package/dist/sdk/payment/gateway.d.ts +14 -2
  451. package/dist/sdk/payment/gateway.js +32 -14
  452. package/dist/sdk/payment/gateway.js.map +1 -1
  453. package/dist/sdk/payment/operations.js +11 -0
  454. package/dist/sdk/payment/operations.js.map +1 -1
  455. package/dist/sdk/payment/submission-registry.d.ts +2 -1
  456. package/dist/sdk/payment/submission-registry.js +12 -8
  457. package/dist/sdk/payment/submission-registry.js.map +1 -1
  458. package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
  459. package/dist/sdk/payment/use-payment-actions.js +6 -3
  460. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  461. package/dist/sdk/payment/use-place-order.d.ts +6 -3
  462. package/dist/sdk/payment/use-place-order.js +334 -144
  463. package/dist/sdk/payment/use-place-order.js.map +1 -1
  464. package/dist/sdk/region/use-region-actions.js +2 -1
  465. package/dist/sdk/region/use-region-actions.js.map +1 -1
  466. package/dist/sdk/seo/page-alternates.d.ts +55 -0
  467. package/dist/sdk/seo/page-alternates.js +132 -0
  468. package/dist/sdk/seo/page-alternates.js.map +1 -0
  469. package/dist/sdk/session/read-server-session.d.ts +21 -0
  470. package/dist/sdk/session/read-server-session.js +61 -0
  471. package/dist/sdk/session/read-server-session.js.map +1 -0
  472. package/dist/sdk/session/use-session-actions.js +5 -4
  473. package/dist/sdk/session/use-session-actions.js.map +1 -1
  474. package/dist/sdk/session/use-session-revalidation.js +2 -1
  475. package/dist/sdk/session/use-session-revalidation.js.map +1 -1
  476. package/dist/sdk/shipping/use-shipping-actions.js +3 -2
  477. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  478. package/dist/utils/own-value.js +19 -0
  479. package/dist/utils/own-value.js.map +1 -0
  480. package/dist/utils/safe-href.d.ts +11 -0
  481. package/dist/utils/safe-href.js +31 -22
  482. package/dist/utils/safe-href.js.map +1 -1
  483. package/package.json +17 -2
  484. package/skills/storefront-asset/SKILL.md +111 -0
  485. package/skills/storefront-asset/references/api-side.md +153 -0
  486. package/skills/storefront-asset/references/findings.md +40 -0
  487. package/skills/storefront-asset/references/ui-side.md +94 -0
  488. package/src/styles/tailwind.css +27 -0
@@ -0,0 +1,56 @@
1
+ import { isCountryField } from "./constants.js";
2
+ //#region src/sdk/address/layouts.ts
3
+ /**
4
+ * A line is written as it prints, with each field in braces: `{city}, {state} {postalCode}`. The
5
+ * text before a field is its separator. Only the first field of a line has none.
6
+ */
7
+ function parseLine(line) {
8
+ const parts = [];
9
+ let cursor = 0;
10
+ for (const match of line.matchAll(/\{(\w+)\}/g)) {
11
+ const field = match[1] ?? "";
12
+ const separator = line.slice(cursor, match.index);
13
+ cursor = match.index + match[0].length;
14
+ if (!isCountryField(field)) throw new Error(`Unknown address field "${field}" in layout line "${line}"`);
15
+ parts.push(separator === "" ? { field } : {
16
+ field,
17
+ separator
18
+ });
19
+ }
20
+ return parts;
21
+ }
22
+ function layout(...lines) {
23
+ return lines.map(parseLine);
24
+ }
25
+ const NORTH_AMERICA = layout("{number} {street}", "{complement}", "{neighborhood}", "{city}, {state} {postalCode}");
26
+ const ISLES = layout("{number} {street}", "{complement}", "{neighborhood}", "{city}", "{state}", "{postalCode}");
27
+ function withStateLine(street, locality) {
28
+ return layout(street, "{complement}", "{neighborhood}", locality, "{state}");
29
+ }
30
+ /** Used for every country the library does not cover. */
31
+ const DEFAULT_LAYOUT = layout("{street}, {number}", "{complement}", "{neighborhood}", "{city}, {state} {postalCode}");
32
+ /**
33
+ * How each covered country prints an address. The library's field order is the form's, not the
34
+ * mail's, so it cannot stand in for this. Every layout places each of the seven fields once.
35
+ */
36
+ const ADDRESS_LAYOUTS = {
37
+ BRA: layout("{street}, {number} - {complement}", "{neighborhood}", "{city} - {state}", "{postalCode}"),
38
+ USA: NORTH_AMERICA,
39
+ CAN: NORTH_AMERICA,
40
+ GBR: ISLES,
41
+ IRL: ISLES,
42
+ FRA: withStateLine("{number} {street}", "{postalCode} {city}"),
43
+ ITA: layout("{street}, {number}", "{complement}", "{neighborhood}", "{postalCode} {city} {state}"),
44
+ DEU: withStateLine("{street} {number}", "{postalCode} {city}"),
45
+ ARG: withStateLine("{street} {number}", "{postalCode} {city}"),
46
+ ESP: withStateLine("{street}, {number}", "{postalCode} {city}"),
47
+ MEX: layout("{street} {number}", "{complement}", "{neighborhood}", "{postalCode} {city}, {state}"),
48
+ COL: layout("{street} {number}", "{complement}", "{neighborhood}", "{city}, {state}", "{postalCode}"),
49
+ CHL: layout("{street} {number}", "{complement}", "{neighborhood}, {city}", "{state}", "{postalCode}"),
50
+ PER: layout("{street} {number}", "{complement}", "{neighborhood}, {city}", "{state} {postalCode}"),
51
+ ECU: layout("{street} {number}", "{complement}", "{neighborhood}", "{city} {postalCode}", "{state}")
52
+ };
53
+ //#endregion
54
+ export { ADDRESS_LAYOUTS, DEFAULT_LAYOUT };
55
+
56
+ //# sourceMappingURL=layouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.js","names":[],"sources":["../../../src/sdk/address/layouts.ts"],"sourcesContent":["import { isCountryField } from './constants.js';\nimport type { AddressDisplayLine, AddressDisplayPart } from './types.js';\n\n/**\n * A line is written as it prints, with each field in braces: `{city}, {state} {postalCode}`. The\n * text before a field is its separator. Only the first field of a line has none.\n */\nfunction parseLine(line: string): AddressDisplayLine {\n const parts: AddressDisplayPart[] = [];\n let cursor = 0;\n for (const match of line.matchAll(/\\{(\\w+)\\}/g)) {\n const field = match[1] ?? '';\n const separator = line.slice(cursor, match.index);\n cursor = match.index + match[0].length;\n if (!isCountryField(field)) {\n throw new Error(`Unknown address field \"${field}\" in layout line \"${line}\"`);\n }\n parts.push(separator === '' ? { field } : { field, separator });\n }\n return parts;\n}\n\nfunction layout(...lines: string[]): readonly AddressDisplayLine[] {\n return lines.map(parseLine);\n}\n\nconst NORTH_AMERICA = layout('{number} {street}', '{complement}', '{neighborhood}', '{city}, {state} {postalCode}');\n\nconst ISLES = layout('{number} {street}', '{complement}', '{neighborhood}', '{city}', '{state}', '{postalCode}');\n\nfunction withStateLine(street: string, locality: string): readonly AddressDisplayLine[] {\n return layout(street, '{complement}', '{neighborhood}', locality, '{state}');\n}\n\n/** Used for every country the library does not cover. */\nexport const DEFAULT_LAYOUT = layout(\n '{street}, {number}',\n '{complement}',\n '{neighborhood}',\n '{city}, {state} {postalCode}',\n);\n\n/**\n * How each covered country prints an address. The library's field order is the form's, not the\n * mail's, so it cannot stand in for this. Every layout places each of the seven fields once.\n */\nexport const ADDRESS_LAYOUTS: Readonly<Record<string, readonly AddressDisplayLine[]>> = {\n BRA: layout('{street}, {number} - {complement}', '{neighborhood}', '{city} - {state}', '{postalCode}'),\n USA: NORTH_AMERICA,\n CAN: NORTH_AMERICA,\n GBR: ISLES,\n IRL: ISLES,\n FRA: withStateLine('{number} {street}', '{postalCode} {city}'),\n ITA: layout('{street}, {number}', '{complement}', '{neighborhood}', '{postalCode} {city} {state}'),\n DEU: withStateLine('{street} {number}', '{postalCode} {city}'),\n ARG: withStateLine('{street} {number}', '{postalCode} {city}'),\n ESP: withStateLine('{street}, {number}', '{postalCode} {city}'),\n MEX: layout('{street} {number}', '{complement}', '{neighborhood}', '{postalCode} {city}, {state}'),\n COL: layout('{street} {number}', '{complement}', '{neighborhood}', '{city}, {state}', '{postalCode}'),\n CHL: layout('{street} {number}', '{complement}', '{neighborhood}, {city}', '{state}', '{postalCode}'),\n PER: layout('{street} {number}', '{complement}', '{neighborhood}, {city}', '{state} {postalCode}'),\n ECU: layout('{street} {number}', '{complement}', '{neighborhood}', '{city} {postalCode}', '{state}'),\n};\n"],"mappings":";;;;;;AAOA,SAAS,UAAU,MAAkC;CACnD,MAAM,QAA8B,CAAC;CACrC,IAAI,SAAS;CACb,KAAK,MAAM,SAAS,KAAK,SAAS,YAAY,GAAG;EAC/C,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,YAAY,KAAK,MAAM,QAAQ,MAAM,KAAK;EAChD,SAAS,MAAM,QAAQ,MAAM,EAAE,CAAC;EAChC,IAAI,CAAC,eAAe,KAAK,GACvB,MAAM,IAAI,MAAM,0BAA0B,MAAM,oBAAoB,KAAK,EAAE;EAE7E,MAAM,KAAK,cAAc,KAAK,EAAE,MAAM,IAAI;GAAE;GAAO;EAAU,CAAC;CAChE;CACA,OAAO;AACT;AAEA,SAAS,OAAO,GAAG,OAAgD;CACjE,OAAO,MAAM,IAAI,SAAS;AAC5B;AAEA,MAAM,gBAAgB,OAAO,qBAAqB,gBAAgB,kBAAkB,8BAA8B;AAElH,MAAM,QAAQ,OAAO,qBAAqB,gBAAgB,kBAAkB,UAAU,WAAW,cAAc;AAE/G,SAAS,cAAc,QAAgB,UAAiD;CACtF,OAAO,OAAO,QAAQ,gBAAgB,kBAAkB,UAAU,SAAS;AAC7E;;AAGA,MAAa,iBAAiB,OAC5B,sBACA,gBACA,kBACA,8BACF;;;;;AAMA,MAAa,kBAA2E;CACtF,KAAK,OAAO,qCAAqC,kBAAkB,oBAAoB,cAAc;CACrG,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,OAAO,sBAAsB,gBAAgB,kBAAkB,6BAA6B;CACjG,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,cAAc,sBAAsB,qBAAqB;CAC9D,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,8BAA8B;CACjG,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,mBAAmB,cAAc;CACpG,KAAK,OAAO,qBAAqB,gBAAgB,0BAA0B,WAAW,cAAc;CACpG,KAAK,OAAO,qBAAqB,gBAAgB,0BAA0B,sBAAsB;CACjG,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,uBAAuB,SAAS;AACrG"}
@@ -0,0 +1,97 @@
1
+ //#region src/sdk/address/messages.ts
2
+ const POSTAL_CODE_PLACEHOLDER_PREFIX = "country-forms.address.postalCode.placeholder.";
3
+ const POSTAL_CODE_ERROR_PREFIX = "country-forms.validation.postalCode.";
4
+ /** The library's label key for a field, mapped by meaning: `state.label.COL` and `department.label` agree. */
5
+ const LABEL_IDS = {
6
+ "country-forms.address.postalCode.label": "fs/address.field.postal-code",
7
+ "country-forms.address.postalCode.label.GBR": "fs/address.field.postcode",
8
+ "country-forms.address.street.label": "fs/address.field.street",
9
+ "country-forms.address.number.label": "fs/address.field.number",
10
+ "country-forms.address.complement.label": "fs/address.field.complement",
11
+ "country-forms.address.neighborhood.label": "fs/address.field.neighborhood",
12
+ "country-forms.address.neighborhood.label.CHL": "fs/address.field.commune",
13
+ "country-forms.address.neighborhood.label.PER": "fs/address.field.district",
14
+ "country-forms.address.city.label": "fs/address.field.city",
15
+ "country-forms.address.city.label.ECU": "fs/address.field.city",
16
+ "country-forms.address.city.label.GBR": "fs/address.field.town",
17
+ "country-forms.address.city.label.COL": "fs/address.field.municipality",
18
+ "country-forms.address.city.label.PER": "fs/address.field.province",
19
+ "country-forms.address.state.label": "fs/address.field.state",
20
+ "country-forms.address.state.label.CHL": "fs/address.field.region",
21
+ "country-forms.address.state.label.COL": "fs/address.field.department",
22
+ "country-forms.address.state.label.PER": "fs/address.field.department",
23
+ "country-forms.address.state.label.ECU": "fs/address.field.province",
24
+ "country-forms.address.state.label.ITA": "fs/address.field.province",
25
+ "country-forms.address.state.label.GBR": "fs/address.field.county",
26
+ "country-forms.address.state.label.IRL": "fs/address.field.county",
27
+ "country-forms.address.department.label": "fs/address.field.department"
28
+ };
29
+ /** The label of a field whose library key this module does not know. */
30
+ const FIELD_LABEL_IDS = {
31
+ postalCode: "fs/address.field.postal-code",
32
+ street: "fs/address.field.street",
33
+ number: "fs/address.field.number",
34
+ complement: "fs/address.field.complement",
35
+ neighborhood: "fs/address.field.neighborhood",
36
+ state: "fs/address.field.state",
37
+ city: "fs/address.field.city"
38
+ };
39
+ const STREET_PLACEHOLDER_KEY = "country-forms.address.street.placeholder";
40
+ /** Examples in the stored, masked form. The library's own placeholders, one per country. */
41
+ const POSTAL_CODE_EXAMPLES = {
42
+ ARG: "C1425ABC",
43
+ BRA: "01310-100",
44
+ CAN: "K1A 0A9",
45
+ CHL: "8320000",
46
+ COL: "110111",
47
+ DEU: "10115",
48
+ ECU: "170150",
49
+ ESP: "28001",
50
+ FRA: "75001",
51
+ GBR: "SW1A 1AA",
52
+ IRL: "D02 AF30",
53
+ ITA: "00118",
54
+ MEX: "06600",
55
+ PER: "15074",
56
+ USA: "10001-1234"
57
+ };
58
+ function resolveLabelId(key, field, country) {
59
+ if (country === "BRA" && field === "postalCode") return "fs/address.field.cep";
60
+ return LABEL_IDS[key] ?? FIELD_LABEL_IDS[field];
61
+ }
62
+ function resolvePlaceholder(key, country) {
63
+ if (key === "country-forms.address.street.placeholder") return {
64
+ id: "fs/address.placeholder.street",
65
+ values: {}
66
+ };
67
+ const example = POSTAL_CODE_EXAMPLES[country];
68
+ if (key?.startsWith(POSTAL_CODE_PLACEHOLDER_PREFIX) && example !== void 0) return {
69
+ id: "fs/address.placeholder.postal-code",
70
+ values: { example }
71
+ };
72
+ }
73
+ function error(code, messageId, values) {
74
+ return values === void 0 ? {
75
+ code,
76
+ messageId
77
+ } : {
78
+ code,
79
+ messageId,
80
+ values
81
+ };
82
+ }
83
+ /**
84
+ * Turns the message key the library returned for a field into an error. A key this module does not
85
+ * know is `invalid`, so a newer library never produces an error the form cannot word.
86
+ */
87
+ function resolveLibraryError(key, { country, maxLength }) {
88
+ if (key === "country-forms.validation.required") return error("required", "fs/address.error.required");
89
+ if (key === "country-forms.validation.maxLength" && maxLength !== void 0) return error("tooLong", "fs/address.error.too-long", { maxLength });
90
+ const example = POSTAL_CODE_EXAMPLES[country];
91
+ if (key.startsWith(POSTAL_CODE_ERROR_PREFIX) && example !== void 0) return error("invalid", country === "BRA" ? "fs/address.error.cep" : "fs/address.error.postal-code", { example });
92
+ return error("invalid", "fs/address.error.invalid");
93
+ }
94
+ //#endregion
95
+ export { LABEL_IDS, POSTAL_CODE_EXAMPLES, STREET_PLACEHOLDER_KEY, resolveLabelId, resolveLibraryError, resolvePlaceholder };
96
+
97
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","names":[],"sources":["../../../src/sdk/address/messages.ts"],"sourcesContent":["import type { MessageId } from '../i18n/client.js';\nimport type { AddressErrorCode, AddressFieldError, CountryFieldName } from './types.js';\n\nconst POSTAL_CODE_PLACEHOLDER_PREFIX = 'country-forms.address.postalCode.placeholder.';\nconst POSTAL_CODE_ERROR_PREFIX = 'country-forms.validation.postalCode.';\n\n/** The library's label key for a field, mapped by meaning: `state.label.COL` and `department.label` agree. */\nexport const LABEL_IDS: Readonly<Record<string, MessageId>> = {\n 'country-forms.address.postalCode.label': 'fs/address.field.postal-code',\n 'country-forms.address.postalCode.label.GBR': 'fs/address.field.postcode',\n 'country-forms.address.street.label': 'fs/address.field.street',\n 'country-forms.address.number.label': 'fs/address.field.number',\n 'country-forms.address.complement.label': 'fs/address.field.complement',\n 'country-forms.address.neighborhood.label': 'fs/address.field.neighborhood',\n 'country-forms.address.neighborhood.label.CHL': 'fs/address.field.commune',\n 'country-forms.address.neighborhood.label.PER': 'fs/address.field.district',\n 'country-forms.address.city.label': 'fs/address.field.city',\n 'country-forms.address.city.label.ECU': 'fs/address.field.city',\n 'country-forms.address.city.label.GBR': 'fs/address.field.town',\n 'country-forms.address.city.label.COL': 'fs/address.field.municipality',\n 'country-forms.address.city.label.PER': 'fs/address.field.province',\n 'country-forms.address.state.label': 'fs/address.field.state',\n 'country-forms.address.state.label.CHL': 'fs/address.field.region',\n 'country-forms.address.state.label.COL': 'fs/address.field.department',\n 'country-forms.address.state.label.PER': 'fs/address.field.department',\n 'country-forms.address.state.label.ECU': 'fs/address.field.province',\n 'country-forms.address.state.label.ITA': 'fs/address.field.province',\n 'country-forms.address.state.label.GBR': 'fs/address.field.county',\n 'country-forms.address.state.label.IRL': 'fs/address.field.county',\n 'country-forms.address.department.label': 'fs/address.field.department',\n};\n\n/** The label of a field whose library key this module does not know. */\nconst FIELD_LABEL_IDS: Readonly<Record<CountryFieldName, MessageId>> = {\n postalCode: 'fs/address.field.postal-code',\n street: 'fs/address.field.street',\n number: 'fs/address.field.number',\n complement: 'fs/address.field.complement',\n neighborhood: 'fs/address.field.neighborhood',\n state: 'fs/address.field.state',\n city: 'fs/address.field.city',\n};\n\nexport const STREET_PLACEHOLDER_KEY = 'country-forms.address.street.placeholder';\n\n/** Examples in the stored, masked form. The library's own placeholders, one per country. */\nexport const POSTAL_CODE_EXAMPLES: Readonly<Record<string, string>> = {\n ARG: 'C1425ABC',\n BRA: '01310-100',\n CAN: 'K1A 0A9',\n CHL: '8320000',\n COL: '110111',\n DEU: '10115',\n ECU: '170150',\n ESP: '28001',\n FRA: '75001',\n GBR: 'SW1A 1AA',\n IRL: 'D02 AF30',\n ITA: '00118',\n MEX: '06600',\n PER: '15074',\n USA: '10001-1234',\n};\n\nexport function resolveLabelId(key: string, field: CountryFieldName, country: string): MessageId {\n if (country === 'BRA' && field === 'postalCode') {\n return 'fs/address.field.cep';\n }\n return LABEL_IDS[key] ?? FIELD_LABEL_IDS[field];\n}\n\nexport function resolvePlaceholder(\n key: string | undefined,\n country: string,\n): Readonly<{ id: MessageId; values: Readonly<Record<string, string>> }> | undefined {\n if (key === STREET_PLACEHOLDER_KEY) {\n return { id: 'fs/address.placeholder.street', values: {} };\n }\n const example = POSTAL_CODE_EXAMPLES[country];\n if (key?.startsWith(POSTAL_CODE_PLACEHOLDER_PREFIX) && example !== undefined) {\n return { id: 'fs/address.placeholder.postal-code', values: { example } };\n }\n return undefined;\n}\n\nfunction error(code: AddressErrorCode, messageId: MessageId, values?: Record<string, string | number>) {\n return values === undefined ? { code, messageId } : { code, messageId, values };\n}\n\n/**\n * Turns the message key the library returned for a field into an error. A key this module does not\n * know is `invalid`, so a newer library never produces an error the form cannot word.\n */\nexport function resolveLibraryError(\n key: string,\n { country, maxLength }: Readonly<{ country: string; maxLength?: number }>,\n): AddressFieldError {\n if (key === 'country-forms.validation.required') {\n return error('required', 'fs/address.error.required');\n }\n if (key === 'country-forms.validation.maxLength' && maxLength !== undefined) {\n return error('tooLong', 'fs/address.error.too-long', { maxLength });\n }\n const example = POSTAL_CODE_EXAMPLES[country];\n if (key.startsWith(POSTAL_CODE_ERROR_PREFIX) && example !== undefined) {\n return error('invalid', country === 'BRA' ? 'fs/address.error.cep' : 'fs/address.error.postal-code', { example });\n }\n return error('invalid', 'fs/address.error.invalid');\n}\n"],"mappings":";AAGA,MAAM,iCAAiC;AACvC,MAAM,2BAA2B;;AAGjC,MAAa,YAAiD;CAC5D,0CAA0C;CAC1C,8CAA8C;CAC9C,sCAAsC;CACtC,sCAAsC;CACtC,0CAA0C;CAC1C,4CAA4C;CAC5C,gDAAgD;CAChD,gDAAgD;CAChD,oCAAoC;CACpC,wCAAwC;CACxC,wCAAwC;CACxC,wCAAwC;CACxC,wCAAwC;CACxC,qCAAqC;CACrC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,0CAA0C;AAC5C;;AAGA,MAAM,kBAAiE;CACrE,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,OAAO;CACP,MAAM;AACR;AAEA,MAAa,yBAAyB;;AAGtC,MAAa,uBAAyD;CACpE,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAgB,eAAe,KAAa,OAAyB,SAA4B;CAC/F,IAAI,YAAY,SAAS,UAAU,cACjC,OAAO;CAET,OAAO,UAAU,QAAQ,gBAAgB;AAC3C;AAEA,SAAgB,mBACd,KACA,SACmF;CACnF,IAAI,QAAA,4CACF,OAAO;EAAE,IAAI;EAAiC,QAAQ,CAAC;CAAE;CAE3D,MAAM,UAAU,qBAAqB;CACrC,IAAI,KAAK,WAAW,8BAA8B,KAAK,YAAY,KAAA,GACjE,OAAO;EAAE,IAAI;EAAsC,QAAQ,EAAE,QAAQ;CAAE;AAG3E;AAEA,SAAS,MAAM,MAAwB,WAAsB,QAA0C;CACrG,OAAO,WAAW,KAAA,IAAY;EAAE;EAAM;CAAU,IAAI;EAAE;EAAM;EAAW;CAAO;AAChF;;;;;AAMA,SAAgB,oBACd,KACA,EAAE,SAAS,aACQ;CACnB,IAAI,QAAQ,qCACV,OAAO,MAAM,YAAY,2BAA2B;CAEtD,IAAI,QAAQ,wCAAwC,cAAc,KAAA,GAChE,OAAO,MAAM,WAAW,6BAA6B,EAAE,UAAU,CAAC;CAEpE,MAAM,UAAU,qBAAqB;CACrC,IAAI,IAAI,WAAW,wBAAwB,KAAK,YAAY,KAAA,GAC1D,OAAO,MAAM,WAAW,YAAY,QAAQ,yBAAyB,gCAAgC,EAAE,QAAQ,CAAC;CAElH,OAAO,MAAM,WAAW,0BAA0B;AACpD"}
@@ -0,0 +1,54 @@
1
+ import { TypedDocumentNode } from "@apollo/client";
2
+ //#region src/sdk/address/operations.d.ts
3
+ /**
4
+ * The saved-address write documents and the cache-only lookup of the address book.
5
+ *
6
+ * Authored with the hand `gql` tag and excluded from the codegen `documents` glob (see
7
+ * `codegen.ts`), like the identity and region writes: the `gql` tag alone is still plucked by
8
+ * `graphql-codegen`, which would emit duplicates of these hand-written types in `sdk/generated/`.
9
+ *
10
+ * The create and update payloads select every field the list item reads, `__typename` and `id`
11
+ * included, so the response merges into the normalized cache and every subscriber of the entity
12
+ * re-renders with no refetch. A create still needs the list edit the action performs: a new entity
13
+ * is in no list until something appends it.
14
+ *
15
+ * Failures follow ADR-00007's two paths: a refused address arrives as payload `userErrors`, and
16
+ * transport or top-level GraphQL failures are infrastructure, which the handlers map to one
17
+ * client-synthesized code.
18
+ */
19
+ /**
20
+ * A refused write or a client-synthesized failure. `code` is the server's `CustomerAddressErrorCode`
21
+ * (`NOT_FOUND`, `MISSING_REQUIRED_FIELD`, `INVALID_VALUE`, `UNSUPPORTED_COUNTRY`) or one of the two
22
+ * the client adds, `NETWORK_ERROR` and `UNAUTHORIZED`. `field` is a `CustomerAddressField` such as
23
+ * `POSTAL_CODE`, and null when the failure is about the address as a whole.
24
+ */
25
+ export type CustomerAddressUserError = Readonly<{
26
+ code: string;
27
+ message: string;
28
+ field: string | null;
29
+ }>;
30
+ /** The fields an address carries besides its country. */
31
+ export type CustomerAddressFields = Readonly<{
32
+ recipientName?: string;
33
+ street?: string;
34
+ number?: string;
35
+ complement?: string;
36
+ neighborhood?: string;
37
+ city?: string;
38
+ state?: string;
39
+ postalCode?: string;
40
+ reference?: string;
41
+ }>;
42
+ /** Mirrors `CustomerAddressCreateInput`. An omitted or empty field is not written. */
43
+ export type AddressCreatePayload = CustomerAddressFields & Readonly<{
44
+ country: string;
45
+ }>;
46
+ /** Mirrors `CustomerAddressUpdateInput` plus the id. Omit a field to keep it; `''` erases it. */
47
+ export type AddressUpdatePayload = CustomerAddressFields & Readonly<{
48
+ id: string;
49
+ }>;
50
+ export type AddressRemovePayload = Readonly<{
51
+ id: string;
52
+ }>;
53
+ //#endregion
54
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1,83 @@
1
+ import { gql } from "../graphql-tag.js";
2
+ //#region src/sdk/address/operations.ts
3
+ const CUSTOMER_ADDRESS_CREATE = gql`
4
+ mutation CustomerAddressCreate($input: CustomerAddressCreateInput!) {
5
+ customerAddressCreate(input: $input) {
6
+ __typename
7
+ customerAddress {
8
+ __typename
9
+ id
10
+ country
11
+ recipientName
12
+ street
13
+ number
14
+ complement
15
+ neighborhood
16
+ city
17
+ state
18
+ postalCode
19
+ reference
20
+ }
21
+ userErrors {
22
+ code
23
+ message
24
+ field
25
+ }
26
+ }
27
+ }
28
+ `;
29
+ const CUSTOMER_ADDRESS_UPDATE = gql`
30
+ mutation CustomerAddressUpdate($id: ID!, $input: CustomerAddressUpdateInput!) {
31
+ customerAddressUpdate(id: $id, input: $input) {
32
+ __typename
33
+ customerAddress {
34
+ __typename
35
+ id
36
+ country
37
+ recipientName
38
+ street
39
+ number
40
+ complement
41
+ neighborhood
42
+ city
43
+ state
44
+ postalCode
45
+ reference
46
+ }
47
+ userErrors {
48
+ code
49
+ message
50
+ field
51
+ }
52
+ }
53
+ }
54
+ `;
55
+ const CUSTOMER_ADDRESS_DELETE = gql`
56
+ mutation CustomerAddressDelete($id: ID!) {
57
+ customerAddressDelete(id: $id) {
58
+ __typename
59
+ deletedCustomerAddressId
60
+ userErrors {
61
+ code
62
+ message
63
+ field
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ /**
69
+ * Read from the cache only (`cache.readQuery`), never sent: it names the cached address book so a
70
+ * create can append to its list. `null` when no list is mounted.
71
+ */
72
+ const CUSTOMER_ADDRESS_BOOK_IDENTITY = gql`
73
+ query CustomerAddressBookIdentity {
74
+ customerAddressBook {
75
+ __typename
76
+ id
77
+ }
78
+ }
79
+ `;
80
+ //#endregion
81
+ export { CUSTOMER_ADDRESS_BOOK_IDENTITY, CUSTOMER_ADDRESS_CREATE, CUSTOMER_ADDRESS_DELETE, CUSTOMER_ADDRESS_UPDATE };
82
+
83
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","names":[],"sources":["../../../src/sdk/address/operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { gql } from '../graphql-tag.js';\n\n/**\n * The saved-address write documents and the cache-only lookup of the address book.\n *\n * Authored with the hand `gql` tag and excluded from the codegen `documents` glob (see\n * `codegen.ts`), like the identity and region writes: the `gql` tag alone is still plucked by\n * `graphql-codegen`, which would emit duplicates of these hand-written types in `sdk/generated/`.\n *\n * The create and update payloads select every field the list item reads, `__typename` and `id`\n * included, so the response merges into the normalized cache and every subscriber of the entity\n * re-renders with no refetch. A create still needs the list edit the action performs: a new entity\n * is in no list until something appends it.\n *\n * Failures follow ADR-00007's two paths: a refused address arrives as payload `userErrors`, and\n * transport or top-level GraphQL failures are infrastructure, which the handlers map to one\n * client-synthesized code.\n */\n\n/**\n * A refused write or a client-synthesized failure. `code` is the server's `CustomerAddressErrorCode`\n * (`NOT_FOUND`, `MISSING_REQUIRED_FIELD`, `INVALID_VALUE`, `UNSUPPORTED_COUNTRY`) or one of the two\n * the client adds, `NETWORK_ERROR` and `UNAUTHORIZED`. `field` is a `CustomerAddressField` such as\n * `POSTAL_CODE`, and null when the failure is about the address as a whole.\n */\nexport type CustomerAddressUserError = Readonly<{\n code: string;\n message: string;\n field: string | null;\n}>;\n\n/** The fields an address carries besides its country. */\nexport type CustomerAddressFields = Readonly<{\n recipientName?: string;\n street?: string;\n number?: string;\n complement?: string;\n neighborhood?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n reference?: string;\n}>;\n\n/** Mirrors `CustomerAddressCreateInput`. An omitted or empty field is not written. */\nexport type AddressCreatePayload = CustomerAddressFields & Readonly<{ country: string }>;\n\n/** Mirrors `CustomerAddressUpdateInput` plus the id. Omit a field to keep it; `''` erases it. */\nexport type AddressUpdatePayload = CustomerAddressFields & Readonly<{ id: string }>;\n\nexport type AddressRemovePayload = Readonly<{ id: string }>;\n\n/** The `CustomerAddress` slice the create and update payloads select. */\nexport type CustomerAddressEntity = Readonly<{\n __typename?: 'CustomerAddress';\n id: string;\n country: string | null;\n recipientName: string | null;\n street: string | null;\n number: string | null;\n complement: string | null;\n neighborhood: string | null;\n city: string | null;\n state: string | null;\n postalCode: string | null;\n reference: string | null;\n}>;\n\ntype CustomerAddressWriteData<Key extends string> = {\n [K in Key]: Readonly<{\n __typename?: string;\n customerAddress: CustomerAddressEntity | null;\n userErrors: readonly CustomerAddressUserError[];\n }>;\n};\n\nexport type CustomerAddressDeleteData = {\n customerAddressDelete: Readonly<{\n __typename?: 'CustomerAddressDeletePayload';\n deletedCustomerAddressId: string | null;\n userErrors: readonly CustomerAddressUserError[];\n }>;\n};\n\nexport type CustomerAddressBookIdentityData = {\n customerAddressBook: Readonly<{ __typename: 'CustomerAddressBook'; id: string }> | null;\n};\n\nexport const CUSTOMER_ADDRESS_CREATE: TypedDocumentNode<\n CustomerAddressWriteData<'customerAddressCreate'>,\n { input: AddressCreatePayload }\n> = gql`\n mutation CustomerAddressCreate($input: CustomerAddressCreateInput!) {\n customerAddressCreate(input: $input) {\n __typename\n customerAddress {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\nexport const CUSTOMER_ADDRESS_UPDATE: TypedDocumentNode<\n CustomerAddressWriteData<'customerAddressUpdate'>,\n { id: string; input: CustomerAddressFields }\n> = gql`\n mutation CustomerAddressUpdate($id: ID!, $input: CustomerAddressUpdateInput!) {\n customerAddressUpdate(id: $id, input: $input) {\n __typename\n customerAddress {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\nexport const CUSTOMER_ADDRESS_DELETE: TypedDocumentNode<CustomerAddressDeleteData, { id: string }> = gql`\n mutation CustomerAddressDelete($id: ID!) {\n customerAddressDelete(id: $id) {\n __typename\n deletedCustomerAddressId\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\n/**\n * Read from the cache only (`cache.readQuery`), never sent: it names the cached address book so a\n * create can append to its list. `null` when no list is mounted.\n */\nexport const CUSTOMER_ADDRESS_BOOK_IDENTITY: TypedDocumentNode<CustomerAddressBookIdentityData, never> = gql`\n query CustomerAddressBookIdentity {\n customerAddressBook {\n __typename\n id\n }\n }\n`;\n"],"mappings":";;AAyFA,MAAa,0BAGT,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BP,MAAa,0BAGT,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BP,MAAa,0BAAwF,GAAG;;;;;;;;;;;;;;;;;AAkBxG,MAAa,iCAA4F,GAAG"}
@@ -0,0 +1,23 @@
1
+ import { graphql } from "../generated/gql.js";
2
+ //#region src/sdk/address/postal-code-lookup-operations.ts
3
+ /**
4
+ * Postal-code lookup GraphQL operation (specs/sfs-3430-address-by-postal-code.md).
5
+ *
6
+ * Authored via the codegen `graphql()` factory so codegen scans this document and generates
7
+ * `AddressByPostalCodeQuery` and its variables. The selection set is the four fields the platform
8
+ * resolves for a code; `useAddressByPostalCode` maps the result onto the lookup's three outcomes.
9
+ */
10
+ const ADDRESS_BY_POSTAL_CODE = graphql(`
11
+ query AddressByPostalCode($country: String!, $postalCode: String!) {
12
+ addressByPostalCode(country: $country, postalCode: $postalCode) {
13
+ city
14
+ state
15
+ street
16
+ neighborhood
17
+ }
18
+ }
19
+ `);
20
+ //#endregion
21
+ export { ADDRESS_BY_POSTAL_CODE };
22
+
23
+ //# sourceMappingURL=postal-code-lookup-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postal-code-lookup-operations.js","names":[],"sources":["../../../src/sdk/address/postal-code-lookup-operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { graphql } from '../generated/gql.js';\nimport type { AddressByPostalCodeQuery, AddressByPostalCodeQueryVariables } from '../generated/graphql.js';\n\n/**\n * Postal-code lookup GraphQL operation (specs/sfs-3430-address-by-postal-code.md).\n *\n * Authored via the codegen `graphql()` factory so codegen scans this document and generates\n * `AddressByPostalCodeQuery` and its variables. The selection set is the four fields the platform\n * resolves for a code; `useAddressByPostalCode` maps the result onto the lookup's three outcomes.\n */\nexport const ADDRESS_BY_POSTAL_CODE: TypedDocumentNode<AddressByPostalCodeQuery, AddressByPostalCodeQueryVariables> =\n graphql(`\n query AddressByPostalCode($country: String!, $postalCode: String!) {\n addressByPostalCode(country: $country, postalCode: $postalCode) {\n city\n state\n street\n neighborhood\n }\n }\n`);\n"],"mappings":";;;;;;;;;AAWA,MAAa,yBACX,QAAQ;;;;;;;;;CAST"}
@@ -0,0 +1,11 @@
1
+ import { POSTAL_CODE_LOOKUP_COUNTRIES } from "./constants.js";
2
+ import "@vtex/country-forms";
3
+ //#region src/sdk/address/postal-code.ts
4
+ /** Whether the form offers to fill the address from the postal code for this country. */
5
+ function hasPostalCodeLookup(country) {
6
+ return POSTAL_CODE_LOOKUP_COUNTRIES.includes(country.trim().toUpperCase());
7
+ }
8
+ //#endregion
9
+ export { hasPostalCodeLookup };
10
+
11
+ //# sourceMappingURL=postal-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postal-code.js","names":[],"sources":["../../../src/sdk/address/postal-code.ts"],"sourcesContent":["import { formatValue, resolveFieldFormatRef, resolveFieldUnformatRef, unformatValue } from '@vtex/country-forms';\nimport { POSTAL_CODE_LOOKUP_COUNTRIES } from './constants.js';\nimport type { CountryRules } from './types.js';\n\n/**\n * The stored form of a postal code: the country's masked form, such as `01001-000`, `20500-0003`, or\n * `SW1A 1AA`. The library accepts most codes with or without the mask but refuses an unmasked US\n * ZIP+4, so the masked form is the one every country accepts. A country with no mask stores the\n * trimmed value. Apply it to a value that passed `validateAddress`.\n */\nexport function normalizePostalCode(value: string, rules: CountryRules): string {\n const trimmed = value.trim();\n const field = rules.schema.fields.find(({ name }) => name === 'postalCode');\n if (!field) {\n return trimmed;\n }\n const values = { postalCode: trimmed };\n return formatValue(\n resolveFieldFormatRef(field, values),\n unformatValue(resolveFieldUnformatRef(field, values), trimmed),\n );\n}\n\n/** Whether the form offers to fill the address from the postal code for this country. */\nexport function hasPostalCodeLookup(country: string): boolean {\n return POSTAL_CODE_LOOKUP_COUNTRIES.includes(country.trim().toUpperCase());\n}\n"],"mappings":";;;;AAwBA,SAAgB,oBAAoB,SAA0B;CAC5D,OAAO,6BAA6B,SAAS,QAAQ,KAAK,CAAC,CAAC,YAAY,CAAC;AAC3E"}
@@ -0,0 +1,14 @@
1
+ import { COUNTRY_FIELDS } from "./constants.js";
2
+ //#region src/sdk/address/schema.ts
3
+ /** The library only knows the seven country fields. Its state holds strings, never `null`. */
4
+ function toFormValues(values) {
5
+ return Object.fromEntries(COUNTRY_FIELDS.map((name) => [name, values[name] ?? ""]));
6
+ }
7
+ /** The maximum length the library declares for a field, if it declares one. */
8
+ function declaredMaxLength({ validation, maxLength }) {
9
+ return validation?.maxLength?.value ?? maxLength;
10
+ }
11
+ //#endregion
12
+ export { declaredMaxLength, toFormValues };
13
+
14
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../src/sdk/address/schema.ts"],"sourcesContent":["import type { FieldDefinition, FormValues } from '@vtex/country-forms';\nimport { COUNTRY_FIELDS } from './constants.js';\nimport type { AddressValues } from './types.js';\n\n/** The library only knows the seven country fields. Its state holds strings, never `null`. */\nexport function toFormValues(values: AddressValues): FormValues {\n return Object.fromEntries(COUNTRY_FIELDS.map((name) => [name, values[name] ?? '']));\n}\n\n/** The maximum length the library declares for a field, if it declares one. */\nexport function declaredMaxLength({ validation, maxLength }: FieldDefinition): number | undefined {\n return validation?.maxLength?.value ?? maxLength;\n}\n"],"mappings":";;;AAKA,SAAgB,aAAa,QAAmC;CAC9D,OAAO,OAAO,YAAY,eAAe,KAAK,SAAS,CAAC,MAAM,OAAO,SAAS,EAAE,CAAC,CAAC;AACpF;;AAGA,SAAgB,kBAAkB,EAAE,YAAY,aAAkD;CAChG,OAAO,YAAY,WAAW,SAAS;AACzC"}
@@ -0,0 +1,25 @@
1
+ //#region src/sdk/address/server-fields.ts
2
+ /** The `CustomerAddressField` values the server names a refused field with, except `COUNTRY`. */
3
+ const FIELD_NAMES = /* @__PURE__ */ new Map([
4
+ ["RECIPIENT_NAME", "recipientName"],
5
+ ["STREET", "street"],
6
+ ["NUMBER", "number"],
7
+ ["COMPLEMENT", "complement"],
8
+ ["NEIGHBORHOOD", "neighborhood"],
9
+ ["CITY", "city"],
10
+ ["STATE", "state"],
11
+ ["POSTAL_CODE", "postalCode"],
12
+ ["REFERENCE", "reference"]
13
+ ]);
14
+ /**
15
+ * The form field a server `CustomerAddressUserError.field` refers to. `null` for `COUNTRY` (the
16
+ * form never edits it), for a failure about the address as a whole, and for a name this version
17
+ * does not know, so a caller treats all three the same way: no field to mark.
18
+ */
19
+ function toAddressFieldName(field) {
20
+ return field === null ? null : FIELD_NAMES.get(field) ?? null;
21
+ }
22
+ //#endregion
23
+ export { toAddressFieldName };
24
+
25
+ //# sourceMappingURL=server-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-fields.js","names":[],"sources":["../../../src/sdk/address/server-fields.ts"],"sourcesContent":["import type { AddressFieldName } from './types.js';\n\n/** The `CustomerAddressField` values the server names a refused field with, except `COUNTRY`. */\nconst FIELD_NAMES: ReadonlyMap<string, AddressFieldName> = new Map([\n ['RECIPIENT_NAME', 'recipientName'],\n ['STREET', 'street'],\n ['NUMBER', 'number'],\n ['COMPLEMENT', 'complement'],\n ['NEIGHBORHOOD', 'neighborhood'],\n ['CITY', 'city'],\n ['STATE', 'state'],\n ['POSTAL_CODE', 'postalCode'],\n ['REFERENCE', 'reference'],\n]);\n\n/**\n * The form field a server `CustomerAddressUserError.field` refers to. `null` for `COUNTRY` (the\n * form never edits it), for a failure about the address as a whole, and for a name this version\n * does not know, so a caller treats all three the same way: no field to mark.\n */\nexport function toAddressFieldName(field: string | null): AddressFieldName | null {\n return field === null ? null : (FIELD_NAMES.get(field) ?? null);\n}\n"],"mappings":";;AAGA,MAAM,8BAAqD,IAAI,IAAI;CACjE,CAAC,kBAAkB,eAAe;CAClC,CAAC,UAAU,QAAQ;CACnB,CAAC,UAAU,QAAQ;CACnB,CAAC,cAAc,YAAY;CAC3B,CAAC,gBAAgB,cAAc;CAC/B,CAAC,QAAQ,MAAM;CACf,CAAC,SAAS,OAAO;CACjB,CAAC,eAAe,YAAY;CAC5B,CAAC,aAAa,WAAW;AAC3B,CAAC;;;;;;AAOD,SAAgB,mBAAmB,OAA+C;CAChF,OAAO,UAAU,OAAO,OAAQ,YAAY,IAAI,KAAK,KAAK;AAC5D"}
@@ -0,0 +1,57 @@
1
+ import { ACCOUNT_FIELDS, COUNTRY_FIELDS, isCountryField } from "./constants.js";
2
+ import { validateAddress } from "./validate-address.js";
3
+ //#region src/sdk/address/switch-country.ts
4
+ function isBlank(value) {
5
+ return value === null || value === void 0 || value.trim() === "";
6
+ }
7
+ /** The old country's field order, then any field it does not declare, in the default order. */
8
+ function fieldOrder({ schema }) {
9
+ const declared = schema.fields.flatMap(({ name }) => isCountryField(name) ? [name] : []);
10
+ return [...declared, ...COUNTRY_FIELDS.filter((field) => !declared.includes(field))];
11
+ }
12
+ /**
13
+ * Works out what a draft keeps when the shopper changes country. `recipientName`, `reference`, and
14
+ * `name` always stay. A country field stays when the new country declares it, its value passes the
15
+ * new country's rules, and the field it depends on (a city on its state) stays too. Any other
16
+ * non-empty value goes to `setAside`. To go back to the first country, pass `{ ...values, ...setAside }`
17
+ * as the draft: those values pass its rules again, so they return.
18
+ */
19
+ function switchCountry(draft, from, to) {
20
+ const values = {};
21
+ const setAside = {};
22
+ for (const name of ACCOUNT_FIELDS) {
23
+ const value = draft[name];
24
+ if (!isBlank(value)) values[name] = value ?? "";
25
+ }
26
+ const declared = new Map(to.schema.fields.map((field) => [field.name, field]));
27
+ const present = fieldOrder(from).filter((name) => !isBlank(draft[name]));
28
+ const carried = present.filter((name) => declared.has(name));
29
+ const errors = validateAddress(Object.fromEntries(carried.map((name) => [name, draft[name]])), to);
30
+ const fitting = new Set(carried.filter((name) => !errors[name]));
31
+ let dropped = true;
32
+ while (dropped) {
33
+ dropped = false;
34
+ for (const name of fitting) {
35
+ const controller = declared.get(name)?.dependsOn;
36
+ if (controller !== void 0 && !fitting.has(controller)) {
37
+ fitting.delete(name);
38
+ dropped = true;
39
+ }
40
+ }
41
+ }
42
+ const notCarried = [];
43
+ for (const name of present) if (fitting.has(name)) values[name] = draft[name] ?? "";
44
+ else {
45
+ setAside[name] = draft[name] ?? "";
46
+ notCarried.push(name);
47
+ }
48
+ return {
49
+ values,
50
+ setAside,
51
+ notCarried
52
+ };
53
+ }
54
+ //#endregion
55
+ export { switchCountry };
56
+
57
+ //# sourceMappingURL=switch-country.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-country.js","names":[],"sources":["../../../src/sdk/address/switch-country.ts"],"sourcesContent":["import { ACCOUNT_FIELDS, COUNTRY_FIELDS, isCountryField } from './constants.js';\nimport type { AddressFieldName, AddressValues, CountryFieldName, CountryRules, CountrySwitch } from './types.js';\nimport { validateAddress } from './validate-address.js';\n\nfunction isBlank(value: string | null | undefined): boolean {\n return value === null || value === undefined || value.trim() === '';\n}\n\n/** The old country's field order, then any field it does not declare, in the default order. */\nfunction fieldOrder({ schema }: CountryRules): readonly CountryFieldName[] {\n const declared = schema.fields.flatMap(({ name }) => (isCountryField(name) ? [name] : []));\n return [...declared, ...COUNTRY_FIELDS.filter((field) => !declared.includes(field))];\n}\n\n/**\n * Works out what a draft keeps when the shopper changes country. `recipientName`, `reference`, and\n * `name` always stay. A country field stays when the new country declares it, its value passes the\n * new country's rules, and the field it depends on (a city on its state) stays too. Any other\n * non-empty value goes to `setAside`. To go back to the first country, pass `{ ...values, ...setAside }`\n * as the draft: those values pass its rules again, so they return.\n */\nexport function switchCountry(draft: AddressValues, from: CountryRules, to: CountryRules): CountrySwitch {\n const values: Partial<Record<AddressFieldName, string>> = {};\n const setAside: Partial<Record<AddressFieldName, string>> = {};\n\n for (const name of ACCOUNT_FIELDS) {\n const value = draft[name];\n if (!isBlank(value)) {\n values[name] = value ?? '';\n }\n }\n\n const declared = new Map(to.schema.fields.map((field) => [field.name, field]));\n const present = fieldOrder(from).filter((name) => !isBlank(draft[name]));\n const carried = present.filter((name) => declared.has(name));\n const errors = validateAddress(Object.fromEntries(carried.map((name) => [name, draft[name]])), to);\n\n const fitting = new Set<string>(carried.filter((name) => !errors[name]));\n let dropped = true;\n while (dropped) {\n dropped = false;\n for (const name of fitting) {\n const controller = declared.get(name)?.dependsOn;\n if (controller !== undefined && !fitting.has(controller)) {\n fitting.delete(name);\n dropped = true;\n }\n }\n }\n\n const notCarried: AddressFieldName[] = [];\n for (const name of present) {\n if (fitting.has(name)) {\n values[name] = draft[name] ?? '';\n } else {\n setAside[name] = draft[name] ?? '';\n notCarried.push(name);\n }\n }\n\n return { values, setAside, notCarried };\n}\n"],"mappings":";;;AAIA,SAAS,QAAQ,OAA2C;CAC1D,OAAO,UAAU,QAAQ,UAAU,KAAA,KAAa,MAAM,KAAK,MAAM;AACnE;;AAGA,SAAS,WAAW,EAAE,UAAqD;CACzE,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,WAAY,eAAe,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAE;CACzF,OAAO,CAAC,GAAG,UAAU,GAAG,eAAe,QAAQ,UAAU,CAAC,SAAS,SAAS,KAAK,CAAC,CAAC;AACrF;;;;;;;;AASA,SAAgB,cAAc,OAAsB,MAAoB,IAAiC;CACvG,MAAM,SAAoD,CAAC;CAC3D,MAAM,WAAsD,CAAC;CAE7D,KAAK,MAAM,QAAQ,gBAAgB;EACjC,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,QAAQ,KAAK,GAChB,OAAO,QAAQ,SAAS;CAE5B;CAEA,MAAM,WAAW,IAAI,IAAI,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,MAAM,MAAM,KAAK,CAAC,CAAC;CAC7E,MAAM,UAAU,WAAW,IAAI,CAAC,CAAC,QAAQ,SAAS,CAAC,QAAQ,MAAM,KAAK,CAAC;CACvE,MAAM,UAAU,QAAQ,QAAQ,SAAS,SAAS,IAAI,IAAI,CAAC;CAC3D,MAAM,SAAS,gBAAgB,OAAO,YAAY,QAAQ,KAAK,SAAS,CAAC,MAAM,MAAM,KAAK,CAAC,CAAC,GAAG,EAAE;CAEjG,MAAM,UAAU,IAAI,IAAY,QAAQ,QAAQ,SAAS,CAAC,OAAO,KAAK,CAAC;CACvE,IAAI,UAAU;CACd,OAAO,SAAS;EACd,UAAU;EACV,KAAK,MAAM,QAAQ,SAAS;GAC1B,MAAM,aAAa,SAAS,IAAI,IAAI,CAAC,EAAE;GACvC,IAAI,eAAe,KAAA,KAAa,CAAC,QAAQ,IAAI,UAAU,GAAG;IACxD,QAAQ,OAAO,IAAI;IACnB,UAAU;GACZ;EACF;CACF;CAEA,MAAM,aAAiC,CAAC;CACxC,KAAK,MAAM,QAAQ,SACjB,IAAI,QAAQ,IAAI,IAAI,GAClB,OAAO,QAAQ,MAAM,SAAS;MACzB;EACL,SAAS,QAAQ,MAAM,SAAS;EAChC,WAAW,KAAK,IAAI;CACtB;CAGF,OAAO;EAAE;EAAQ;EAAU;CAAW;AACxC"}
@@ -0,0 +1,26 @@
1
+ import { MessageId } from "../i18n/locales.js";
2
+ import "../i18n/client.js";
3
+ import { FormSchema } from "@vtex/country-forms";
4
+ //#region src/sdk/address/types.d.ts
5
+ /** The seven fields `@vtex/country-forms` address schemas declare, spelled as on `CustomerAddress`. */
6
+ export type CountryFieldName = 'postalCode' | 'street' | 'number' | 'complement' | 'neighborhood' | 'state' | 'city';
7
+ /** Fields no country declares; the account's own rules cover them. `name` is the shopper's label. */
8
+ export type AccountFieldName = 'recipientName' | 'reference' | 'name';
9
+ export type AddressFieldName = CountryFieldName | AccountFieldName;
10
+ export type AddressErrorCode = 'required' | 'invalid' | 'tooLong';
11
+ export type AddressFieldError = Readonly<{
12
+ code: AddressErrorCode;
13
+ messageId: MessageId;
14
+ /** The values the message interpolates, such as `{ maxLength: 750 }` or `{ example: '01310-100' }`. */
15
+ values?: Readonly<Record<string, string | number>>;
16
+ }>;
17
+ export type CountryRules = Readonly<{
18
+ /** ISO 3166-1 alpha-3, upper case. */
19
+ country: string;
20
+ /** In the library's list of address countries. `false` means the library's fallback form. */
21
+ covered: boolean;
22
+ /** Read only by this module. */
23
+ schema: FormSchema;
24
+ }>;
25
+ //#endregion
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,29 @@
1
+ import "../../core/dist/index.js";
2
+ import { AddressCreatePayload, AddressRemovePayload, AddressUpdatePayload, CustomerAddressUserError } from "./operations.js";
3
+ //#region src/sdk/address/use-address-actions.d.ts
4
+ /**
5
+ * The `address` action namespace: the one sanctioned client write surface for the shopper's saved
6
+ * addresses (docs/storefront-core/adr-0010-actions-own-the-write-side.md,
7
+ * docs/features/my-account-address-book/rfc.md § Address actions).
8
+ *
9
+ * Every method is async and pessimistic: the cache changes only after the server answers. Each
10
+ * resolves to the payload's `userErrors` (empty on success), with their `field`, so the caller can
11
+ * mark the field. None rejects for an expected outcome. ADR-0010 has handlers surface `userErrors`
12
+ * through the `notifications` action; that action does not exist yet, so the caller presents them.
13
+ */
14
+ export type AddressActions = Readonly<{
15
+ /** Save a new address. Appends it to the cached address book on success. Never rejects. */
16
+ create: (payload: AddressCreatePayload) => Promise<readonly CustomerAddressUserError[]>;
17
+ /**
18
+ * Change a saved address. Omit a field to keep it; an empty string erases it. Subscribers update
19
+ * through the normalized cache. Never rejects.
20
+ */
21
+ update: (payload: AddressUpdatePayload) => Promise<readonly CustomerAddressUserError[]>;
22
+ /**
23
+ * Remove a saved address. The list changes only once the server confirms. A `NOT_FOUND` answer
24
+ * means the server no longer has it, so it leaves the cache too. Never rejects.
25
+ */
26
+ remove: (payload: AddressRemovePayload) => Promise<readonly CustomerAddressUserError[]>;
27
+ }>;
28
+ //#endregion
29
+ //# sourceMappingURL=use-address-actions.d.ts.map