@ecomiq/storefront 1.1.5 → 2.0.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 (134) hide show
  1. package/README.md +26 -417
  2. package/bin/ecomiq.mjs +154 -0
  3. package/package.json +72 -84
  4. package/src/api-proxy.ts +194 -0
  5. package/src/auth/create-storefront-auth.ts +35 -0
  6. package/src/auth/ecomiq-oauth-password-client.ts +26 -0
  7. package/src/auth/ecomiq-oauth-password-constants.ts +26 -0
  8. package/src/auth/ecomiq-oauth-password-plugin.ts +299 -0
  9. package/src/auth/ecomiq-oauth-password-types.ts +25 -0
  10. package/src/auth/ecomiq-storefront-sign-in.ts +47 -0
  11. package/src/auth/env.ts +7 -0
  12. package/src/cart-session.ts +241 -0
  13. package/src/client.ts +48 -0
  14. package/src/codegen.mjs +603 -0
  15. package/src/components/checkout/cart-sync.ts +143 -0
  16. package/src/components/checkout/checkout-external-update-banner.tsx +15 -0
  17. package/src/components/checkout/checkout-form-controls.tsx +139 -0
  18. package/src/components/checkout/checkout-line-items.tsx +43 -0
  19. package/src/components/checkout/checkout-order-summary.tsx +156 -0
  20. package/src/components/checkout/checkout-payment-section.tsx +215 -0
  21. package/src/components/checkout/checkout-session-view.tsx +240 -0
  22. package/src/components/checkout/checkout-shipping-address-section.tsx +266 -0
  23. package/src/components/checkout/checkout-shipping-section.tsx +90 -0
  24. package/src/components/checkout/checkout-states.tsx +73 -0
  25. package/src/components/checkout/form-schema.ts +229 -0
  26. package/src/components/checkout/format.ts +27 -0
  27. package/src/components/checkout/index.ts +51 -0
  28. package/src/components/checkout/types.ts +43 -0
  29. package/src/components/checkout/use-checkout-geo.ts +50 -0
  30. package/src/components/checkout/use-checkout-session.ts +583 -0
  31. package/src/components/hero.tsx +291 -0
  32. package/src/config.d.ts +69 -0
  33. package/src/config.mjs +165 -0
  34. package/src/index.ts +274 -0
  35. package/src/link.tsx +2 -0
  36. package/src/pages/checkout.$checkoutId.tsx +60 -0
  37. package/src/pages/checkout.tsx +31 -0
  38. package/src/pages/thank-you.tsx +53 -0
  39. package/src/providers/auth.tsx +69 -0
  40. package/src/providers/cart.tsx +275 -0
  41. package/src/providers/ecomiq.ts +137 -0
  42. package/src/providers/index.ts +26 -0
  43. package/src/public-config.ts +44 -0
  44. package/src/review-submission.ts +89 -0
  45. package/src/runtime/context.ts +1 -0
  46. package/src/runtime/default-layout.tsx +80 -0
  47. package/src/runtime/head.ts +126 -0
  48. package/src/runtime/page.tsx +82 -0
  49. package/src/runtime/postcss-browser-stub.mjs +5 -0
  50. package/src/server-config-store.ts +26 -0
  51. package/src/server.ts +279 -0
  52. package/src/styles.css +76 -0
  53. package/src/ui/badge.tsx +32 -0
  54. package/src/ui/button.tsx +31 -0
  55. package/src/ui/card.tsx +31 -0
  56. package/src/ui/carousel.tsx +218 -0
  57. package/src/ui/cn.ts +6 -0
  58. package/src/ui/index.ts +8 -0
  59. package/src/ui/separator.tsx +6 -0
  60. package/src/ui/skeleton.tsx +6 -0
  61. package/src/ui/storefront-error.tsx +49 -0
  62. package/src/utils.ts +36 -0
  63. package/src/vite-inline.mjs +95 -0
  64. package/templates/__root.tsx +77 -0
  65. package/templates/router.tsx +19 -0
  66. package/dist/chunk-3QGB55R6.js +0 -157
  67. package/dist/chunk-3QGB55R6.js.map +0 -1
  68. package/dist/chunk-64GLOWMJ.js +0 -216
  69. package/dist/chunk-64GLOWMJ.js.map +0 -1
  70. package/dist/chunk-ASFU32ZM.js +0 -236
  71. package/dist/chunk-ASFU32ZM.js.map +0 -1
  72. package/dist/chunk-Q4U5OEUT.js +0 -21
  73. package/dist/chunk-Q4U5OEUT.js.map +0 -1
  74. package/dist/chunk-QRR7EPCH.js +0 -176
  75. package/dist/chunk-QRR7EPCH.js.map +0 -1
  76. package/dist/chunk-S7CPZ4UE.js +0 -6
  77. package/dist/chunk-S7CPZ4UE.js.map +0 -1
  78. package/dist/chunk-ZG2XUYGZ.js +0 -1281
  79. package/dist/chunk-ZG2XUYGZ.js.map +0 -1
  80. package/dist/chunks/client.css +0 -984
  81. package/dist/chunks/client.css.map +0 -1
  82. package/dist/chunks/client.d.ts +0 -10041
  83. package/dist/chunks/client.js +0 -5363
  84. package/dist/chunks/client.js.map +0 -1
  85. package/dist/chunks/config.d.ts +0 -31
  86. package/dist/chunks/config.js +0 -5
  87. package/dist/chunks/config.js.map +0 -1
  88. package/dist/chunks/core-public.d.ts +0 -130
  89. package/dist/chunks/core-public.js +0 -92
  90. package/dist/chunks/core-public.js.map +0 -1
  91. package/dist/chunks/server-nextjs.d.ts +0 -33
  92. package/dist/chunks/server-nextjs.js +0 -47
  93. package/dist/chunks/server-nextjs.js.map +0 -1
  94. package/dist/chunks/server-tanstack.d.ts +0 -22
  95. package/dist/chunks/server-tanstack.js +0 -34
  96. package/dist/chunks/server-tanstack.js.map +0 -1
  97. package/dist/collection-C6bWDLiw.d.ts +0 -3926
  98. package/dist/ecomiq-oauth-password-plugin-J5wDFqzL.d.ts +0 -3629
  99. package/dist/ecomiq-shell-ui-SWIFLQVM.js +0 -8
  100. package/dist/ecomiq-shell-ui-SWIFLQVM.js.map +0 -1
  101. package/dist/index.d.ts +0 -9
  102. package/dist/index.js +0 -1
  103. package/dist/index.js.map +0 -1
  104. package/dist/index.server.d.ts +0 -9
  105. package/dist/index.server.js +0 -8
  106. package/dist/index.server.js.map +0 -1
  107. package/dist/nextjs/api.d.ts +0 -45
  108. package/dist/nextjs/api.js +0 -32
  109. package/dist/nextjs/api.js.map +0 -1
  110. package/dist/nextjs/globals.css +0 -13
  111. package/dist/nextjs.d.ts +0 -2
  112. package/dist/nextjs.js +0 -2
  113. package/dist/nextjs.js.map +0 -1
  114. package/dist/nextjs.server.d.ts +0 -1
  115. package/dist/nextjs.server.js +0 -1
  116. package/dist/nextjs.server.js.map +0 -1
  117. package/dist/postcss.config.mjs +0 -6
  118. package/dist/react/checkout-page.css +0 -855
  119. package/dist/react/client.css +0 -984
  120. package/dist/react/payment-provider.css +0 -91
  121. package/dist/react/thank-you-page.css +0 -105
  122. package/dist/react.d.ts +0 -1
  123. package/dist/react.js +0 -2
  124. package/dist/react.js.map +0 -1
  125. package/dist/store-proxy-handler-CNzKlTFA.d.ts +0 -10
  126. package/dist/tanstack/api.d.ts +0 -41
  127. package/dist/tanstack/api.js +0 -30
  128. package/dist/tanstack/api.js.map +0 -1
  129. package/dist/tanstack.d.ts +0 -2
  130. package/dist/tanstack.js +0 -2
  131. package/dist/tanstack.js.map +0 -1
  132. package/dist/tanstack.server.d.ts +0 -1
  133. package/dist/tanstack.server.js +0 -1
  134. package/dist/tanstack.server.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ export type { CheckoutContactForm, BillingChoice } from './types'
2
+ export { emptyCheckoutContact } from './types'
3
+
4
+ export {
5
+ buildCheckoutFormValidationSchema,
6
+ checkoutValidationInputFromContext,
7
+ firstInvalidFieldId,
8
+ focusCheckoutField,
9
+ mapZodIssuesToFieldErrors,
10
+ CHECKOUT_FIELD_IDS,
11
+ CHECKOUT_FIELD_FOCUS_ORDER,
12
+ type CheckoutFieldId,
13
+ type CheckoutFormValidationContext,
14
+ } from './form-schema'
15
+
16
+ export {
17
+ areCartSignaturesEqual,
18
+ cartItemsSignature,
19
+ cartSessionSignature,
20
+ findCartReconciliationActions,
21
+ isCheckoutCartAlreadyPurchased,
22
+ methodUsesProviderCheckoutUi,
23
+ toSignatureItems,
24
+ type CartLineSignatureItem,
25
+ type CartReconcileAction,
26
+ } from './cart-sync'
27
+
28
+ export { formatMoney, paymentRedirectUrl, thankYouUrl, processingUrl } from './format'
29
+ export { useCheckoutSession } from './use-checkout-session'
30
+ export { useCheckoutGeo } from './use-checkout-geo'
31
+
32
+ export { CheckoutSessionView } from './checkout-session-view'
33
+ export { CheckoutShippingAddressSection } from './checkout-shipping-address-section'
34
+ export { CheckoutShippingSection } from './checkout-shipping-section'
35
+ export { CheckoutPaymentSection } from './checkout-payment-section'
36
+ export { CheckoutOrderSummary } from './checkout-order-summary'
37
+ export { CheckoutOrderBumps } from './checkout-line-items'
38
+ export { CheckoutExternalUpdateBanner } from './checkout-external-update-banner'
39
+ export {
40
+ CheckoutAlreadyPurchasedState,
41
+ CheckoutEmptyState,
42
+ CheckoutErrorState,
43
+ CheckoutLoadingState,
44
+ } from './checkout-states'
45
+ export {
46
+ CheckoutTextField,
47
+ CheckoutSelectField,
48
+ CheckoutPhoneField,
49
+ FieldError,
50
+ fieldClass,
51
+ } from './checkout-form-controls'
@@ -0,0 +1,43 @@
1
+ export type CheckoutContactForm = {
2
+ email: string
3
+ firstName: string
4
+ lastName: string
5
+ company: string
6
+ address: string
7
+ address2: string
8
+ /** Distrito (nombre); en PE se sincroniza con districtName. */
9
+ city: string
10
+ /** Provincia/región (nombre). */
11
+ province: string
12
+ postalCode: string
13
+ phone: string
14
+ countryCode: string
15
+ departmentCode: string
16
+ departmentName: string
17
+ provinceCode: string
18
+ provinceName: string
19
+ districtCode: string
20
+ districtName: string
21
+ }
22
+
23
+ export type BillingChoice = 'same_as_shipping' | 'different'
24
+
25
+ export const emptyCheckoutContact = (countryCode = 'PE'): CheckoutContactForm => ({
26
+ email: '',
27
+ firstName: '',
28
+ lastName: '',
29
+ company: '',
30
+ address: '',
31
+ address2: '',
32
+ city: '',
33
+ province: '',
34
+ postalCode: '',
35
+ phone: '',
36
+ countryCode,
37
+ departmentCode: '',
38
+ departmentName: '',
39
+ provinceCode: '',
40
+ provinceName: '',
41
+ districtCode: '',
42
+ districtName: '',
43
+ })
@@ -0,0 +1,50 @@
1
+ import { useEffect, useState } from 'react'
2
+ import type { Country, Department, District, Province } from '@ecomiq/core'
3
+ import { serverApi } from '../../server'
4
+
5
+ /** Carga cascada geo INEI (PE) + países. */
6
+ export function useCheckoutGeo(countryCode: string, departmentCode: string, provinceCode: string) {
7
+ const [countries, setCountries] = useState<Country[]>([])
8
+ const [departments, setDepartments] = useState<Department[]>([])
9
+ const [provinces, setProvinces] = useState<Province[]>([])
10
+ const [districts, setDistricts] = useState<District[]>([])
11
+
12
+ useEffect(() => {
13
+ void serverApi.getCountries().then(setCountries).catch(() => setCountries([]))
14
+ }, [])
15
+
16
+ useEffect(() => {
17
+ if (countryCode.toUpperCase() !== 'PE') {
18
+ setDepartments([])
19
+ return
20
+ }
21
+ void serverApi
22
+ .getDepartments({ countryCode: 'PE' })
23
+ .then(setDepartments)
24
+ .catch(() => setDepartments([]))
25
+ }, [countryCode])
26
+
27
+ useEffect(() => {
28
+ if (!departmentCode) {
29
+ setProvinces([])
30
+ return
31
+ }
32
+ void serverApi
33
+ .getProvinces({ countryCode: 'PE', departmentCode })
34
+ .then(setProvinces)
35
+ .catch(() => setProvinces([]))
36
+ }, [departmentCode])
37
+
38
+ useEffect(() => {
39
+ if (!provinceCode) {
40
+ setDistricts([])
41
+ return
42
+ }
43
+ void serverApi
44
+ .getDistricts({ countryCode: 'PE', provinceCode })
45
+ .then(setDistricts)
46
+ .catch(() => setDistricts([]))
47
+ }, [provinceCode])
48
+
49
+ return { countries, departments, provinces, districts }
50
+ }