@wodira/browser 0.1.0 → 0.3.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 (53) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +210 -17
  3. package/dist/index.cjs +33 -5
  4. package/dist/index.d.ts +50 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +33 -4
  7. package/dist/types.d.ts +56 -2
  8. package/dist/types.d.ts.map +1 -1
  9. package/dist/ui/boxes/cdn.d.ts +2 -0
  10. package/dist/ui/boxes/cdn.d.ts.map +1 -0
  11. package/dist/ui/boxes/cdn.js +743 -0
  12. package/dist/ui/boxes/client.d.ts +30 -0
  13. package/dist/ui/boxes/client.d.ts.map +1 -0
  14. package/dist/ui/boxes/components.d.ts +246 -0
  15. package/dist/ui/boxes/components.d.ts.map +1 -0
  16. package/dist/ui/boxes/i18n.d.ts +107 -0
  17. package/dist/ui/boxes/i18n.d.ts.map +1 -0
  18. package/dist/ui/boxes/index.d.ts +16 -0
  19. package/dist/ui/boxes/index.d.ts.map +1 -0
  20. package/dist/ui/boxes/index.js +3071 -0
  21. package/dist/ui/boxes/styles.d.ts +2 -0
  22. package/dist/ui/boxes/styles.d.ts.map +1 -0
  23. package/dist/ui/boxes/types.d.ts +105 -0
  24. package/dist/ui/boxes/types.d.ts.map +1 -0
  25. package/dist/ui/components.d.ts +158 -4
  26. package/dist/ui/components.d.ts.map +1 -1
  27. package/dist/ui/events.d.ts +1 -1
  28. package/dist/ui/events.d.ts.map +1 -1
  29. package/dist/ui/i18n.d.ts +4 -1
  30. package/dist/ui/i18n.d.ts.map +1 -1
  31. package/dist/ui/index.d.ts +19 -3
  32. package/dist/ui/index.d.ts.map +1 -1
  33. package/dist/ui/index.js +9869 -610
  34. package/dist/ui/layout-styles.d.ts +3 -0
  35. package/dist/ui/layout-styles.d.ts.map +1 -0
  36. package/dist/ui/registration-eligibility.d.ts +52 -0
  37. package/dist/ui/registration-eligibility.d.ts.map +1 -0
  38. package/dist/ui/shirt-sponsors/cdn.d.ts +2 -0
  39. package/dist/ui/shirt-sponsors/cdn.d.ts.map +1 -0
  40. package/dist/ui/shirt-sponsors/cdn.js +83 -0
  41. package/dist/ui/shirt-sponsors/index.d.ts +9 -0
  42. package/dist/ui/shirt-sponsors/index.d.ts.map +1 -0
  43. package/dist/ui/shirt-sponsors/index.js +1669 -0
  44. package/dist/ui/shirt-sponsors/shirt-auction.d.ts +51 -0
  45. package/dist/ui/shirt-sponsors/shirt-auction.d.ts.map +1 -0
  46. package/dist/ui/signature-pad.d.ts +29 -0
  47. package/dist/ui/signature-pad.d.ts.map +1 -0
  48. package/dist/ui/styles.d.ts.map +1 -1
  49. package/dist/ui/theme.d.ts +63 -0
  50. package/dist/ui/theme.d.ts.map +1 -0
  51. package/dist/ui/validators.d.ts +1 -1
  52. package/dist/ui/validators.d.ts.map +1 -1
  53. package/package.json +33 -12
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 — 2026-11-11
4
+
5
+ ### Added
6
+
7
+ - Lit components for event discovery, registration, signature capture and registration receipts, with theme tokens and customization through slots and CSS parts.
8
+ - Boxes widgets for calendars, plans and trial classes, with a versioned CDN bundle and integrity verification.
9
+ - Registration support for category availability, supplements, custom fields, signatures and promotional codes.
10
+
11
+ ### Fixed
12
+
13
+ - Published TypeScript declarations resolve correctly in strict NodeNext projects as well as frontend bundlers.
14
+ - Registration components preserve API validation messages and recover when a promotional code is removed.
package/README.md CHANGED
@@ -39,6 +39,30 @@ if (session.sessionUrl) window.location.href = session.sessionUrl;
39
39
 
40
40
  Las URLs de éxito/cancelación deben pertenecer a un origen permitido en la publishable key.
41
41
 
42
+ ## Widgets públicos de Boxes: `@wodira/browser/ui/boxes`
43
+
44
+ Las instalaciones de Boxes se crean desde el constructor **Box → Widgets web**. Cada una entrega un `installation-id` y una clave publicable exclusiva para un origen.
45
+
46
+ ```ts
47
+ import { defineWodiraBoxElements } from '@wodira/browser/ui/boxes';
48
+
49
+ defineWodiraBoxElements();
50
+ ```
51
+
52
+ ```html
53
+ <wodira-box-widget
54
+ installation-id="widget_..."
55
+ publishable-key="wpk_live_..."
56
+ locale="auto"
57
+ ></wodira-box-widget>
58
+ ```
59
+
60
+ También están disponibles `<wodira-box-calendar>`, `<wodira-box-trial>` y `<wodira-box-plans>`. Aplican automáticamente logo, banner y colores del box; son responsive por contenedor; soportan `es`, `en` y `pt`; y permiten personalización con variables `--wodira-box-*` y partes como `shell`, `hero`, `logo`, `card`, `class-cta`, `trial-cta` y `plan-cta`.
61
+
62
+ Las selecciones emiten `wodira:box-class-selected`, `wodira:box-trial-selected` y `wodira:box-plan-selected`. La identificación, confirmación y pago continúan en WODira Boxes; nunca se expone una clave secreta en el embed.
63
+
64
+ La guía completa de instalación, CSP, privacidad y despliegue está en [`docs/boxes/public-widgets.md`](../../docs/boxes/public-widgets.md).
65
+
42
66
  ## Web Components: `@wodira/browser/ui`
43
67
 
44
68
  `@wodira/browser/ui` incluye Web Components basados en Lit para incrustar el embudo de inscripción en webs de organizadores. Los componentes usan publishable keys, CSS variables y `::part()` para personalización visual.
@@ -112,29 +136,198 @@ Atributos principales: `publishable-key`, `base-url`, `event-id`, `success-url`,
112
136
  ### Production notes
113
137
 
114
138
  - Los componentes hacen validación cliente antes de crear Checkout Session: comprador, atletas, campos obligatorios, términos y waivers requeridos.
139
+ - En categorías de equipo elegibles, cada plaza salvo la del capitán permite elegir **Completar ahora** o **Invitar después**. Las plazas aplazadas conservan su género reservado y se completan mediante un enlace compartible después del pago.
140
+ - La disponibilidad de **Invitar después** la decide `teamCompletion` en el resumen. No se ofrece para categorías individuales, cuando hay firmas obligatorias o cuando ha vencido el plazo de finalización.
141
+ - Cuando quedan plazas pendientes, la sesión devuelve `participantDataStatus`, `pendingParticipantCount` y `teamManageToken`; en pagos Stripe, WODira añade además `teamToken` al fragmento de la URL de éxito para continuar la gestión del equipo.
115
142
  - Si el evento expone suplementos activos, el formulario renderiza extras y selecciona automáticamente los obligatorios.
116
143
  - El resumen de precio se recalcula con `getRegistrationSummary` cuando hay `purchaserEmail` válido, categoría y extras/promocode.
117
- - `locale="en-US"` cambia los textos base a inglés; cualquier otro locale usa español por defecto y se usa para fecha/moneda.
144
+ - `locale` explícito tiene prioridad sobre el idioma del documento anfitrión; `en`/`en-*` usa inglés y los idiomas no soportados usan español. Fechas e importes utilizan `Intl`.
118
145
  - `auto-redirect` está activo por defecto; si se desactiva, escucha `wodira:checkout-created` o `wodira:redirect` para gestionar la navegación.
119
146
 
120
147
  ### CSS variables soportadas
121
148
 
122
- | Variable | Uso |
123
- | ---------------------------------------- | -------------------- |
124
- | `--wodira-color-primary` | Botones principales |
125
- | `--wodira-color-primary-contrast` | Texto sobre primario |
126
- | `--wodira-color-accent` | Precios y foco |
127
- | `--wodira-color-surface` | Tarjetas e inputs |
128
- | `--wodira-color-muted` | Fondos secundarios |
129
- | `--wodira-color-border` | Bordes |
130
- | `--wodira-color-text` | Texto principal |
131
- | `--wodira-color-text-muted` | Texto secundario |
132
- | `--wodira-color-danger` | Errores |
133
- | `--wodira-radius` / `--wodira-radius-sm` | Radios |
134
- | `--wodira-space` | Espaciado base |
135
- | `--wodira-font-family` | Tipografía |
136
- | `--wodira-shadow` | Sombra de tarjetas |
149
+ | Variable | Uso |
150
+ | ---------------------------------------- | ----------------------------------------------- |
151
+ | `--wodira-color-primary` | Botones principales |
152
+ | `--wodira-color-primary-contrast` | Texto sobre primario |
153
+ | `--wodira-color-accent` | Precios y foco |
154
+ | `--wodira-color-accent-contrast` | Texto sobre acento |
155
+ | `--wodira-color-surface` | Tarjetas e inputs |
156
+ | `--wodira-color-muted` | Fondos secundarios |
157
+ | `--wodira-color-border` | Bordes |
158
+ | `--wodira-color-text` | Texto principal |
159
+ | `--wodira-color-text-muted` | Texto secundario |
160
+ | `--wodira-color-danger` | Errores |
161
+ | `--wodira-color-success` | Confirmaciones |
162
+ | `--wodira-radius` / `--wodira-radius-sm` | Radios |
163
+ | `--wodira-space` | Espaciado base |
164
+ | `--wodira-font-family` | Tipografía |
165
+ | `--wodira-font-size` | Tamaño base (1rem) |
166
+ | `--wodira-color-scheme` | Esquema de controles nativos (`light` / `dark`) |
167
+ | `--wodira-shadow` | Sombra de tarjetas |
168
+ | `--wodira-control-height` | Altura mínima de controles (2.75rem) |
169
+ | `--wodira-card-padding` | Espacio interior de tarjetas |
170
+ | `--wodira-grid-min` | Ancho mínimo de columna, limitado al contenedor |
171
+ | `--wodira-content-width` | Ancho máximo del checkout (76rem) |
172
+ | `--wodira-summary-width` | Ancho del resumen lateral (21rem) |
173
+ | `--wodira-sticky-offset` | Separación superior del resumen lateral (1rem) |
137
174
 
138
175
  ### Parts principales
139
176
 
140
- `card`, `event-card`, `pricing-card`, `registration-form`, `summary`, `button`, `input`, `select`, `textarea`, `checkbox`, `label`, `title`, `price`, `meta`, `hint`, `error`, `field-error`, `loader`, `empty`, `waiver`, `supplement`.
177
+ `card`, `event-card`, `pricing-card`, `registration-form`, `summary`, `button`, `input`, `select`, `textarea`, `checkbox`, `label`, `title`, `price`, `meta`, `hint`, `error`, `field-error`, `loader`, `empty`, `waiver`, `supplement`, `participant-mode`, `participant-mode-button`, `deferred-participant-hint`.
178
+
179
+ También: `registration-layout`, `registration-fields`, `registration-title`, `checkout-sidebar`, `summary-row`, `summary-total`, `submit`, `progress`, `progress-step`, `step-number`, `eligibility-summary` y `gender-composition`. Los compuestos propagan las partes públicas de sus hijos con `exportparts`: `wodira-checkout-flow::part(submit)` alcanza el botón real dentro del formulario, y `wodira-box-widget::part(class-cta)` alcanza la reserva del calendario.
180
+
181
+ ### Temas heredables, sin recrear los componentes
182
+
183
+ Los valores por defecto se resuelven como fallbacks: ningún componente sobrescribe las variables públicas del integrador. Puedes aplicar un tema al contenedor de varios widgets, a un widget concreto o con CSS. La fuente se hereda de la web anfitriona.
184
+
185
+ ```ts
186
+ import { applyWodiraTheme, wodiraThemes, type WodiraTheme } from '@wodira/browser/ui';
187
+ // También disponibles desde @wodira/browser/ui/boxes.
188
+
189
+ const brand: WodiraTheme = {
190
+ ...wodiraThemes.light,
191
+ primary: '#00564b',
192
+ primaryContrast: '#ffffff',
193
+ accent: '#006b58',
194
+ radius: '0.5rem',
195
+ fontFamily: 'inherit',
196
+ };
197
+ applyWodiraTheme(container, brand);
198
+ applyWodiraTheme(container, wodiraThemes.dark);
199
+ applyWodiraTheme(container, { radius: null }); // Restaura la herencia/default.
200
+ ```
201
+
202
+ `applyWodiraTheme` aplica un parche: las claves omitidas no cambian y `null` elimina sólo esa sobrescritura. `createWodiraCheckoutFlow(container, { ...options, theme: brand })` acepta el mismo objeto. No se pierden los datos del formulario al cambiar el tema. `wodiraThemeTokens` expone la correspondencia tipada entre las claves y sus variables CSS.
203
+
204
+ En Boxes se mantiene la API `--wodira-box-*`. Precedencia: variable específica de Boxes → variable genérica `--wodira-*` → marca recibida del servidor (primario/acento) → valores por defecto. Los colores del servidor no pisan la personalización del integrador.
205
+
206
+ Los presets claro y oscuro tienen colores de texto, error y acento coordinados. Si cambias colores, comprueba el contraste de texto (4.5:1 normal, 3:1 grande) y foco; no reduzcas los controles por debajo de un tamaño táctil cómodo. La densidad no oculta campos ni elimina validaciones.
207
+
208
+ ### Contenido mediante slots
209
+
210
+ | Componente | Slots aditivos |
211
+ | -------------------------------------- | ------------------------------------------------------------------------- |
212
+ | `wodira-checkout-flow` | `header`, `footer`, `registration-intro`, `checkout-help`, `after-submit` |
213
+ | `wodira-registration-form` | `intro`, `checkout-help`, `after-submit` |
214
+ | `wodira-box-widget` | `header`, `footer`, `calendar-intro`, `trial-intro`, `plans-intro` |
215
+ | Calendario, prueba y planes standalone | `header`, `intro`, `footer` |
216
+
217
+ ```html
218
+ <wodira-checkout-flow publishable-key="wpk_live_..." event-id="evt_...">
219
+ <p slot="registration-intro">Ten a mano tus datos de participante.</p>
220
+ <p slot="checkout-help">¿Necesitas ayuda? Contacta con nuestro equipo.</p>
221
+ </wodira-checkout-flow>
222
+ ```
223
+
224
+ Los slots añaden contenido; no sustituyen campos, aceptación legal, waivers o atribución de WODira. Usa contenido de confianza y conserva los contratos de los eventos DOM existentes.
225
+
226
+ ### Layout, accesibilidad y catálogo local
227
+
228
+ El registro separa los datos del resumen. A partir de **56rem de ancho del contenedor** el resumen queda en una columna lateral sticky; por debajo sigue el flujo del documento, sin barras fijas que tapen controles. Incluye progreso de pasos, foco en el formulario al seleccionar categoría y en el primer campo inválido al enviar. Respeta `prefers-reduced-motion` y mantiene los botones y pestañas operables con teclado.
229
+
230
+ ```bash
231
+ pnpm --filter @wodira/browser preview:ui
232
+ # http://127.0.0.1:4179 · Datos ficticios, sin llamadas a producción ni pagos.
233
+ pnpm --filter @wodira/browser test
234
+ pnpm --filter @wodira/browser test:ui:browser
235
+ ```
236
+
237
+ El catálogo permite cambiar marca, tema claro/oscuro, acento, densidad, radios e idioma sobre los componentes reales. Las pruebas de Chromium cubren 320/768/1024/1440px, herencia a través de Shadow DOM, `::part()`, foco, teclado, estados y accesibilidad con axe. Requieren Chromium de Playwright instalado (`pnpm exec playwright install chromium`).
238
+
239
+ El instalador CDN sigue fijado al artefacto publicado y su SRI. Antes de distribuir una nueva versión del paquete, publica con una **versión nueva** y actualiza conjuntamente `boxes-cdn-manifest.json` y el instalador de `apps/web`; no cambies el SRI de una URL versionada ya publicada.
240
+
241
+ ## Camiseta 3D y pujas en una web de evento
242
+
243
+ `@wodira/browser/ui/shirt-sponsors` proporciona el componente Lit
244
+ `<wodira-shirt-auction>`. La camiseta y los espacios se muestran en una vista
245
+ WODira aislada; el inicio de sesión y Stripe Checkout se abren en ventanas.
246
+ El visitante conserva abierta la web del evento. El componente espera la
247
+ confirmación del servidor antes de mostrar una puja como pagada.
248
+
249
+ ```ts
250
+ import { defineWodiraShirtElements } from '@wodira/browser/ui/shirt-sponsors';
251
+ defineWodiraShirtElements();
252
+ ```
253
+
254
+ ```html
255
+ <wodira-shirt-auction campaign-id="ID_DE_LA_CAMPANA" locale="es"></wodira-shirt-auction>
256
+ ```
257
+
258
+ También queda registrado con `defineWodiraElements()` desde `@wodira/browser/ui`.
259
+ Para HTML sin bundler, ejecuta `pnpm --filter @wodira/browser build`, copia
260
+ `packages/browser/dist/ui/shirt-sponsors/cdn.js` a los recursos de tu web y carga:
261
+
262
+ ```html
263
+ <script type="module" src="/assets/wodira-shirt-auction.js"></script>
264
+ <wodira-shirt-auction campaign-id="ID_DE_LA_CAMPANA" locale="es"></wodira-shirt-auction>
265
+ ```
266
+
267
+ | Atributo | Uso |
268
+ | ------------- | ------------------------------------------------------------------------ |
269
+ | `campaign-id` | ID de una campaña pública de patrocinio. |
270
+ | `locale` | `es`, `en`, `pt` o `auto` (idioma de la página). |
271
+ | `app-url` | URL de WODira; por defecto `https://wodira.app`. HTTP solo en localhost. |
272
+
273
+ La altura se adapta al contenido. Se exponen las partes CSS `container`, `frame`
274
+ y `footer`; la camiseta y el formulario mantienen el diseño de WODira.
275
+ Las variables `--wodira-primary`, `--wodira-text`, `--wodira-border`,
276
+ `--wodira-background` y `--wodira-radius` personalizan el contenedor.
277
+
278
+ ```js
279
+ document
280
+ .querySelector('wodira-shirt-auction')
281
+ .addEventListener('wodira:shirt:paid', ({ detail }) => {
282
+ console.log('Puja confirmada en la campaña', detail.campaignId);
283
+ });
284
+ ```
285
+
286
+ Este evento es una señal de interfaz, no una prueba de pago para un servidor.
287
+ No contiene email, tokens, datos de tarjeta ni identificadores privados de puja.
288
+ La sesión se mantiene en memoria dentro del marco de WODira y se obtiene con una
289
+ ventana del mismo origen; no depende de cookies de terceros ni se entrega a la
290
+ web del evento. Si se recarga el componente hay que iniciar sesión de nuevo.
291
+
292
+ ### Desarrollo y despliegue
293
+
294
+ - Vista: `/es/embed/shirt-sponsors/:id` (también `/en/` y `/pt/`).
295
+ - En desarrollo sin localización: `/embed/shirt-sponsors/:id`.
296
+ - Backend: aplicar `20260924190000_shirt_bid_checkout` antes de desplegar.
297
+ - Configurar `FRONTEND_URL` con la URL pública de la app de WODira.
298
+ - El webhook de Stripe debe entregar `checkout.session.completed`,
299
+ `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`
300
+ y `checkout.session.expired`, además de los eventos de pago ya utilizados.
301
+ - La campaña debe estar publicada y el organizador conectado con Stripe.
302
+ - La web que integra el componente debe permitir `frame-src https://wodira.app`
303
+ en su CSP y las ventanas de inicio de sesión/pago.
304
+ - El bundle se distribuye con `@wodira/browser`; utiliza una versión publicada y conserva el SRI exacto de esa versión.
305
+
306
+ Preview local: `pnpm --filter @wodira/browser preview:ui`, después abre
307
+ `http://127.0.0.1:4179/shirt-auction?app-url=http://localhost:4200&campaign-id=ID`.
308
+ Sin parámetros, la preview usa una campaña ficticia sin pagos.
309
+
310
+ Prueba del flujo completo con la app local y Stripe/autenticación simulados:
311
+ `pnpm exec node scripts/sponsor-studio/check-widget-flow.mjs` desde la raíz.
312
+ Los argumentos opcionales son la URL de la app, del API y de la preview,
313
+ respectivamente. Guarda capturas desktop/móvil en `output/tmp/shirt-widget`.
314
+ Para producción, sirve también la web anfitriona por HTTPS.
315
+
316
+ ### Disponibilidad y formulario de inscripción
317
+
318
+ El flujo Lit aplica la apertura y el cierre de inscripciones (incluido el cierre predeterminado
319
+ anterior al inicio del evento), la venta por categoría y los cupos. El servidor vuelve a validar
320
+ la disponibilidad al reservar las plazas. Los límites se actualizan automáticamente si la página
321
+ permanece abierta durante el cambio de horario.
322
+
323
+ Comprador e invitados tienen campos y suplementos independientes. Se admiten opciones de
324
+ suplementos y cantidades, todos los tipos de campo configurables, documentos por categoría y
325
+ firma electrónica con representación de menores. Las casillas obligatorias y las opciones
326
+ configuradas se validan también en la API.
327
+
328
+ El idioma por defecto es español; `locale` tiene prioridad sobre el idioma del documento anfitrión.
329
+ Los reintentos de una misma compra conservan su identidad mientras no cambien los datos. No guardes
330
+ ni publiques el secreto de reanudación que acompaña al intento de checkout.
331
+
332
+ Consulta la revisión y su matriz de comprobaciones en
333
+ [`docs/reviews/2026-11-10-lit-registration.md`](../../docs/reviews/2026-11-10-lit-registration.md).
package/dist/index.cjs CHANGED
@@ -39,12 +39,11 @@ var __export = (target, all) => {
39
39
  // src/index.ts
40
40
  var exports_src = {};
41
41
  __export(exports_src, {
42
- createWodiraBrowserClient: () => createWodiraBrowserClient,
42
+ WodiraBrowserApiError: () => WodiraBrowserApiError,
43
43
  WodiraBrowserClient: () => WodiraBrowserClient,
44
- WodiraBrowserApiError: () => WodiraBrowserApiError
44
+ createWodiraBrowserClient: () => createWodiraBrowserClient
45
45
  });
46
46
  module.exports = __toCommonJS(exports_src);
47
-
48
47
  class WodiraBrowserApiError extends Error {
49
48
  status;
50
49
  statusText;
@@ -65,6 +64,7 @@ class WodiraBrowserClient {
65
64
  baseUrl;
66
65
  fetcher;
67
66
  headers;
67
+ checkoutSecrets = new Map;
68
68
  constructor(options) {
69
69
  if (!options.publishableKey?.trim()) {
70
70
  throw new Error("WodiraBrowserClient requires a publishableKey.");
@@ -98,9 +98,36 @@ class WodiraBrowserClient {
98
98
  });
99
99
  }
100
100
  createRegistrationCheckoutSession(input, signal) {
101
+ let secret = input.checkoutResumeSecret;
102
+ if (!secret && input.idempotencyKey) {
103
+ secret = this.checkoutSecrets.get(input.idempotencyKey);
104
+ if (!secret) {
105
+ secret = globalThis.crypto.randomUUID();
106
+ if (this.checkoutSecrets.size >= 128)
107
+ this.checkoutSecrets.delete(this.checkoutSecrets.keys().next().value);
108
+ this.checkoutSecrets.set(input.idempotencyKey, secret);
109
+ }
110
+ }
101
111
  return this.request("/checkout/registration/session", {
102
112
  method: "POST",
103
- body: serializeRegistrationInput(input),
113
+ body: serializeRegistrationInput({
114
+ ...input,
115
+ ...secret ? { checkoutResumeSecret: secret } : {}
116
+ }),
117
+ signal
118
+ });
119
+ }
120
+ lookupRegistrationReceipts(eventId, input, signal) {
121
+ return this.request(`/events/${encodeURIComponent(eventId)}/registration-receipts/lookup`, {
122
+ method: "POST",
123
+ body: input,
124
+ signal
125
+ });
126
+ }
127
+ sendRegistrationReceipts(eventId, input, signal) {
128
+ return this.request(`/events/${encodeURIComponent(eventId)}/registration-receipts/send`, {
129
+ method: "POST",
130
+ body: input,
104
131
  signal
105
132
  });
106
133
  }
@@ -145,7 +172,8 @@ async function readResponsePayload(response) {
145
172
  function extractErrorMessage(payload, response) {
146
173
  if (typeof payload === "string")
147
174
  return payload;
148
- const message = payload?.message;
175
+ const outerMessage = payload?.message;
176
+ const message = outerMessage !== null && typeof outerMessage === "object" && "message" in outerMessage ? outerMessage.message : outerMessage;
149
177
  if (typeof message === "string")
150
178
  return message;
151
179
  if (Array.isArray(message))
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { WodiraAthleteInput, WodiraCustomFieldInput, WodiraEvent, WodiraPaginatedResponse, WodiraPricingCardsResponse, WodiraSearchEventsInput } from './types';
2
- export type * from './types';
1
+ import type { WodiraAthleteInput, WodiraCustomFieldInput, WodiraEvent, WodiraGender, WodiraPaginatedResponse, WodiraPricingCardsResponse, WodiraRegistrationReceiptLookup, WodiraRegistrationReceiptSendResult, WodiraSearchEventsInput, WodiraSupplementSelection } from './types.js';
2
+ export type * from './types.js';
3
3
  export interface WodiraBrowserApiErrorPayload {
4
4
  message?: unknown;
5
5
  error?: unknown;
@@ -27,18 +27,37 @@ export interface WodiraBrowserClientOptions {
27
27
  export interface WodiraGuestRegistrationSummaryInput {
28
28
  categoryId: string;
29
29
  selectedSupplementIds?: string[];
30
+ supplementSelections?: WodiraSupplementSelection[];
30
31
  }
31
32
  export interface WodiraRegistrationSummaryInput {
32
33
  categoryId: string;
33
34
  purchaserEmail: string;
34
35
  promocode?: string;
35
36
  selectedSupplementIds?: string[];
37
+ supplementSelections?: WodiraSupplementSelection[];
36
38
  guestRegistrations?: WodiraGuestRegistrationSummaryInput[];
37
39
  }
38
40
  export interface WodiraBrowserAthleteInput extends WodiraAthleteInput {
39
41
  phone: string;
40
42
  idNumber: string;
41
43
  }
44
+ export interface WodiraLegalSignatureInput {
45
+ signerName: string;
46
+ signerIdNumber: string;
47
+ authorityAccepted: true;
48
+ minorRelationship?: string;
49
+ guardianAuthorityAccepted?: true;
50
+ locale: 'es' | 'en' | 'pt';
51
+ waiverVersions: Array<{
52
+ waiverId: string;
53
+ version: number;
54
+ }>;
55
+ strokes: Array<Array<{
56
+ x: number;
57
+ y: number;
58
+ t: number;
59
+ }>>;
60
+ }
42
61
  export interface WodiraGuestRegistrationInput {
43
62
  guestEmail: string;
44
63
  guestName: string;
@@ -49,6 +68,7 @@ export interface WodiraGuestRegistrationInput {
49
68
  customFields?: WodiraCustomFieldInput[];
50
69
  waiversAccepted?: Record<string, boolean>;
51
70
  selectedSupplementIds?: string[];
71
+ supplementSelections?: WodiraSupplementSelection[];
52
72
  }
53
73
  export interface WodiraRegistrationCheckoutSessionInput extends WodiraRegistrationSummaryInput {
54
74
  eventId: string;
@@ -56,14 +76,25 @@ export interface WodiraRegistrationCheckoutSessionInput extends WodiraRegistrati
56
76
  club?: string;
57
77
  purchaserName: string;
58
78
  athletes: WodiraBrowserAthleteInput[];
79
+ deferredTeamCompletion?: WodiraDeferredTeamCompletionInput;
59
80
  guestRegistrations?: WodiraGuestRegistrationInput[];
60
81
  customFields?: WodiraCustomFieldInput[];
61
82
  termsAccepted: boolean;
62
83
  waiversAccepted?: Record<string, boolean>;
84
+ legalSignature?: WodiraLegalSignatureInput;
63
85
  idempotencyKey?: string;
86
+ checkoutResumeSecret?: string;
64
87
  successUrl: string;
65
88
  cancelUrl: string;
66
89
  }
90
+ export interface WodiraDeferredTeamCompletionInput {
91
+ pendingParticipantCount: number;
92
+ pendingParticipantPositions?: number[];
93
+ slotGenders?: WodiraGender[];
94
+ participantWaivers: Array<{
95
+ waiversAccepted: Record<string, boolean>;
96
+ }>;
97
+ }
67
98
  export interface WodiraAppliedCoupon {
68
99
  code: string;
69
100
  discount: number;
@@ -83,6 +114,7 @@ export interface WodiraRegistrationSummary {
83
114
  applicationFee: number;
84
115
  applicationFeePercentage: number;
85
116
  processingFee: number;
117
+ checkoutFeePayer: 'BUYER' | 'ORGANIZER';
86
118
  total: number;
87
119
  organizerReceives: number;
88
120
  currency: string;
@@ -94,24 +126,40 @@ export interface WodiraRegistrationSummary {
94
126
  supplementsTotal: number;
95
127
  subtotal: number;
96
128
  }>;
129
+ teamCompletion?: WodiraTeamCompletionDecision;
130
+ }
131
+ export interface WodiraTeamCompletionDecision {
132
+ available: boolean;
133
+ deadlineAt?: string;
134
+ unavailableReason?: 'INDIVIDUAL_CATEGORY' | 'SIGNATURE_REQUIRED' | 'DEADLINE_PASSED';
97
135
  }
98
136
  export interface WodiraRegistrationCheckoutSession {
99
137
  sessionId: string | null;
100
138
  sessionUrl: string | null;
101
139
  orderId: string;
102
140
  completed: boolean;
141
+ receiptToken: string;
142
+ participantDataStatus?: 'READY' | 'PENDING_PARTICIPANTS';
143
+ pendingParticipantCount?: number;
144
+ teamManageToken?: string;
145
+ }
146
+ export interface WodiraRegistrationReceiptRequestInput {
147
+ email: string;
103
148
  }
104
149
  export declare class WodiraBrowserClient {
105
150
  private readonly publishableKey;
106
151
  private readonly baseUrl;
107
152
  private readonly fetcher;
108
153
  private readonly headers;
154
+ private readonly checkoutSecrets;
109
155
  constructor(options: WodiraBrowserClientOptions);
110
156
  searchEvents(input?: Omit<WodiraSearchEventsInput, 'status'>, signal?: AbortSignal): Promise<WodiraPaginatedResponse<WodiraEvent>>;
111
157
  getEvent(eventId: string, signal?: AbortSignal): Promise<WodiraEvent>;
112
158
  getPricingCards(eventId: string, signal?: AbortSignal): Promise<WodiraPricingCardsResponse>;
113
159
  getRegistrationSummary(input: WodiraRegistrationSummaryInput, signal?: AbortSignal): Promise<WodiraRegistrationSummary>;
114
160
  createRegistrationCheckoutSession(input: WodiraRegistrationCheckoutSessionInput, signal?: AbortSignal): Promise<WodiraRegistrationCheckoutSession>;
161
+ lookupRegistrationReceipts(eventId: string, input: WodiraRegistrationReceiptRequestInput, signal?: AbortSignal): Promise<WodiraRegistrationReceiptLookup>;
162
+ sendRegistrationReceipts(eventId: string, input: WodiraRegistrationReceiptRequestInput, signal?: AbortSignal): Promise<WodiraRegistrationReceiptSendResult>;
115
163
  private request;
116
164
  }
117
165
  export declare function createWodiraBrowserClient(options: WodiraBrowserClientOptions): WodiraBrowserClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,SAAS,CAAC;AACjB,mBAAmB,SAAS,CAAC;AAE7B,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM,GAAG,IAAI,CAAC;gBAEnD,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,4BAA4B,GAAG,MAAM,GAAG,IAAI,CAAC;KACvD;CAOF;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK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E,MAAM,CAAC,EAAE,WAAW,iDAMrF;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,wBAE7C;IAED,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,uCAKpD;IAED,sBAAsB,CAAC,KAAK,EAAE,8BAA8B,EAAE,MAAM,CAAC,EAAE,WAAW,sCAMjF;IAED,iCAAiC,CAC/B,KAAK,EAAE,sCAAsC,EAC7C,MAAM,CAAC,EAAE,WAAW,8CAoBrB;IAED,0BAA0B,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,qCAAqC,EAC5C,MAAM,CAAC,EAAE,WAAW,4CAUrB;IAED,wBAAwB,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,qCAAqC,EAC5C,MAAM,CAAC,EAAE,WAAW,gDAUrB;YAEa,OAAO;CA0BtB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,uBAE5E"}
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ class WodiraBrowserClient {
19
19
  baseUrl;
20
20
  fetcher;
21
21
  headers;
22
+ checkoutSecrets = new Map;
22
23
  constructor(options) {
23
24
  if (!options.publishableKey?.trim()) {
24
25
  throw new Error("WodiraBrowserClient requires a publishableKey.");
@@ -52,9 +53,36 @@ class WodiraBrowserClient {
52
53
  });
53
54
  }
54
55
  createRegistrationCheckoutSession(input, signal) {
56
+ let secret = input.checkoutResumeSecret;
57
+ if (!secret && input.idempotencyKey) {
58
+ secret = this.checkoutSecrets.get(input.idempotencyKey);
59
+ if (!secret) {
60
+ secret = globalThis.crypto.randomUUID();
61
+ if (this.checkoutSecrets.size >= 128)
62
+ this.checkoutSecrets.delete(this.checkoutSecrets.keys().next().value);
63
+ this.checkoutSecrets.set(input.idempotencyKey, secret);
64
+ }
65
+ }
55
66
  return this.request("/checkout/registration/session", {
56
67
  method: "POST",
57
- body: serializeRegistrationInput(input),
68
+ body: serializeRegistrationInput({
69
+ ...input,
70
+ ...secret ? { checkoutResumeSecret: secret } : {}
71
+ }),
72
+ signal
73
+ });
74
+ }
75
+ lookupRegistrationReceipts(eventId, input, signal) {
76
+ return this.request(`/events/${encodeURIComponent(eventId)}/registration-receipts/lookup`, {
77
+ method: "POST",
78
+ body: input,
79
+ signal
80
+ });
81
+ }
82
+ sendRegistrationReceipts(eventId, input, signal) {
83
+ return this.request(`/events/${encodeURIComponent(eventId)}/registration-receipts/send`, {
84
+ method: "POST",
85
+ body: input,
58
86
  signal
59
87
  });
60
88
  }
@@ -99,7 +127,8 @@ async function readResponsePayload(response) {
99
127
  function extractErrorMessage(payload, response) {
100
128
  if (typeof payload === "string")
101
129
  return payload;
102
- const message = payload?.message;
130
+ const outerMessage = payload?.message;
131
+ const message = outerMessage !== null && typeof outerMessage === "object" && "message" in outerMessage ? outerMessage.message : outerMessage;
103
132
  if (typeof message === "string")
104
133
  return message;
105
134
  if (Array.isArray(message))
@@ -127,7 +156,7 @@ function serializeAthleteInput(athlete) {
127
156
  };
128
157
  }
129
158
  export {
130
- createWodiraBrowserClient,
159
+ WodiraBrowserApiError,
131
160
  WodiraBrowserClient,
132
- WodiraBrowserApiError
161
+ createWodiraBrowserClient
133
162
  };