@forgebuild/sidon-booking-widget 1.3.0 → 2.0.1

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.
@@ -13,7 +13,7 @@
13
13
  const GUEST_PREFIX = '/api/marina/guest/';
14
14
  // Vercel's function body limit; OTA's own upload cap (4 MiB) is stricter.
15
15
  const MAX_BODY_BYTES = 4_500_000;
16
- const REQUEST_HEADERS = ['content-type', 'x-file-name', 'x-booking-token', 'user-agent'];
16
+ const REQUEST_HEADERS = ['content-type', 'x-file-name', 'x-booking-token', 'x-sailor-token', 'user-agent'];
17
17
  // Never content-encoding/content-length: Node's fetch has already decoded
18
18
  // the body but keeps those headers. Never set-cookie or location.
19
19
  const RESPONSE_HEADERS = ['content-type', 'cache-control', 'retry-after', 'ratelimit'];
@@ -1,119 +1,124 @@
1
- // Hand-written typings for <sidon-booking-widget> and <sidon-berth-map>.
2
- // The entry modules only register the elements (side-effect imports), so
3
- // generated declarations come out as an empty `export {}`. The build copies
4
- // this file verbatim to dist/elements.d.ts and both entry .d.ts files
5
- // re-export it (scripts/write-element-types.mjs), which is why it imports
6
- // nothing: a relative import would dangle in dist/.
7
- //
8
- // Keep it in step with the `props` blocks in BookingWidget.svelte and
9
- // BerthMap.svelte and the events they emit. `npm run check` skips .d.ts
10
- // files (skipLibCheck), so check an edit with:
11
- // npx tsc --ignoreConfig --noEmit --skipLibCheck false --lib es2023,dom src/elements.d.ts
12
-
13
- /** Peer-marina logo pin. Mirrors OtherMarina in lib/types.ts. */
14
- export interface OtherMarina {
15
- name: string;
16
- lat: number;
17
- lng: number;
18
- logoMark: string | null;
19
- /** Always host-supplied: the package owns no site's routing. */
20
- href: string | null;
21
- }
22
-
23
- /** OTA booking status. An expired booking reports `cancelled`. */
24
- export type SidonBookingStatus = 'hold' | 'pending' | 'confirmed' | 'declined' | 'cancelled';
25
-
26
- export interface SidonStepChangeDetail { step: 1 | 2 | 3 }
27
- /** The booking widget fires this from the wizard only, never in booking-page mode. */
28
- export interface SidonLoaChangeDetail { loa: number }
29
- /** `bookingId` is OTA's booking UUID, `marina` the marina slug. */
30
- export interface SidonBookedDetail { bookingId: string; marina: string }
31
- export interface SidonBookingStatusDetail { bookingId: string; status: SidonBookingStatus }
32
- /** A berth label, or null when deselected. */
33
- export interface SidonBerthSelectedDetail { berthId: string | null }
34
- /** Dates are `YYYY-MM-DD`; `berth` is a berth label. */
35
- export interface SidonQuickbookSubmitDetail { from: string | null; to: string | null; length: number; berth: string | null }
36
-
37
- // Element properties mirror the attributes, camelCased; optional like them.
38
- export interface SidonBookingWidgetElement extends HTMLElement {
39
- /** OTA marina slug. */
40
- marina?: string;
41
- /** '' (default) = this page's origin, where the forwarder route lives. */
42
- apiOrigin?: string;
43
- from?: string;
44
- to?: string;
45
- length?: number;
46
- berth?: string;
47
- /** en/it/fr/es (first two letters). Unset: the wizard is English and the
48
- booking page follows the booking's own locale. */
49
- locale?: string;
50
- currencySymbol?: string;
51
- variant?: 'navy' | 'dark';
52
- /** Present (even empty) = booking-page mode; a value overrides `?booking=`. */
53
- bookingId?: string | null;
54
- mapsApiKey?: string;
55
- mapStyle?: 'chart' | 'coastal';
56
- mapHeight?: string;
57
- mapWidth?: string;
58
- mapGap?: string;
59
- width?: string;
60
- layout?: 'stacked' | 'overlay';
61
- logoMark?: string | null;
62
- marinaName?: string;
63
- otherMarinas?: OtherMarina[];
64
- }
65
-
66
- export interface SidonBerthMapElement extends HTMLElement {
67
- /** OTA marina slug. */
68
- marina?: string;
69
- mapsApiKey?: string;
70
- /** '' (default) = this page's origin, where the forwarder route lives. */
71
- apiOrigin?: string;
72
- mapStyle?: 'chart' | 'coastal';
73
- locale?: string;
74
- currencySymbol?: string;
75
- from?: string;
76
- to?: string;
77
- length?: number;
78
- berth?: string;
79
- /** 'staff' (the OTA dashboard): every listed berth is clickable and fires
80
- sidon-berth-selected, occupied berths are painted for [from, to), and
81
- from/to follow their attributes. No card, availability or boat-length
82
- checks. Default 'guest'. */
83
- mode?: 'guest' | 'staff';
84
- /** Re-reads the map payload. Undefined until the element has mounted
85
- (a microtask after it is connected), so call `el.refresh?.()`. */
86
- readonly refresh?: () => void;
87
- bookPath?: string;
88
- logoMark?: string | null;
89
- marinaName?: string;
90
- otherMarinas?: OtherMarina[];
91
- mapHeight?: string;
92
- showWeather?: boolean;
93
- eyebrow?: string;
94
- cardTitle?: string;
95
- intro?: string;
96
- rangeLabel?: string;
97
- rangePlaceholder?: string;
98
- lengthLabel?: string;
99
- selectedLabel?: string;
100
- selectedPlaceholder?: string;
101
- ctaLabel?: string;
102
- }
103
-
104
- declare global {
105
- interface HTMLElementTagNameMap {
106
- 'sidon-booking-widget': SidonBookingWidgetElement;
107
- 'sidon-berth-map': SidonBerthMapElement;
108
- }
109
- // Dispatched with bubbles + composed, so listeners on any ancestor
110
- // element get the typed detail too.
111
- interface HTMLElementEventMap {
112
- 'sidon-step-change': CustomEvent<SidonStepChangeDetail>;
113
- 'sidon-loa-change': CustomEvent<SidonLoaChangeDetail>;
114
- 'sidon-booked': CustomEvent<SidonBookedDetail>;
115
- 'sidon-booking-status': CustomEvent<SidonBookingStatusDetail>;
116
- 'sidon-berth-selected': CustomEvent<SidonBerthSelectedDetail>;
117
- 'sidon-quickbook-submit': CustomEvent<SidonQuickbookSubmitDetail>;
118
- }
119
- }
1
+ // Hand-written typings for <sidon-booking-widget> and <sidon-berth-map>.
2
+ // The entry modules only register the elements (side-effect imports), so
3
+ // generated declarations come out as an empty `export {}`. The build copies
4
+ // this file verbatim to dist/elements.d.ts and both entry .d.ts files
5
+ // re-export it (scripts/write-element-types.mjs), which is why it imports
6
+ // nothing: a relative import would dangle in dist/.
7
+ //
8
+ // Keep it in step with the `props` blocks in BookingWidget.svelte and
9
+ // BerthMap.svelte and the events they emit. `npm run check` skips .d.ts
10
+ // files (skipLibCheck), so check an edit with:
11
+ // npx tsc --ignoreConfig --noEmit --skipLibCheck false --lib es2023,dom src/elements.d.ts
12
+
13
+ /** Peer-marina logo pin. Mirrors OtherMarina in lib/types.ts. */
14
+ export interface OtherMarina {
15
+ name: string;
16
+ lat: number;
17
+ lng: number;
18
+ logoMark: string | null;
19
+ /** Always host-supplied: the package owns no site's routing. */
20
+ href: string | null;
21
+ }
22
+
23
+ /** OTA booking status. An expired booking reports `cancelled`. */
24
+ export type SidonBookingStatus = 'hold' | 'pending' | 'confirmed' | 'declined' | 'cancelled';
25
+
26
+ /** 1 Documents, 2 Details, 3 Payment, 4 Booking. */
27
+ export interface SidonStepChangeDetail { step: 1 | 2 | 3 | 4 }
28
+ /** The booking widget fires this from the wizard only, never in booking-page mode. */
29
+ export interface SidonLoaChangeDetail { loa: number }
30
+ /** `bookingId` is OTA's booking UUID, `marina` the marina slug. */
31
+ export interface SidonBookedDetail { bookingId: string; marina: string }
32
+ export interface SidonBookingStatusDetail { bookingId: string; status: SidonBookingStatus }
33
+ /** A berth label, or null when deselected. */
34
+ export interface SidonBerthSelectedDetail { berthId: string | null }
35
+ /** Dates are `YYYY-MM-DD`; `berth` is a berth label. */
36
+ export interface SidonQuickbookSubmitDetail { from: string | null; to: string | null; length: number; berth: string | null }
37
+
38
+ // Element properties mirror the attributes, camelCased; optional like them.
39
+ export interface SidonBookingWidgetElement extends HTMLElement {
40
+ /** OTA marina slug. */
41
+ marina?: string;
42
+ /** '' (default) = this page's origin, where the forwarder route lives. */
43
+ apiOrigin?: string;
44
+ from?: string;
45
+ to?: string;
46
+ length?: number;
47
+ berth?: string;
48
+ /** en/it/fr/es (first two letters). Unset: the wizard is English and the
49
+ booking page follows the booking's own locale. */
50
+ locale?: string;
51
+ currencySymbol?: string;
52
+ variant?: 'navy' | 'dark';
53
+ /** Present (even empty) = booking-page mode; a value overrides `?booking=`. */
54
+ bookingId?: string | null;
55
+ mapsApiKey?: string;
56
+ mapStyle?: 'chart' | 'coastal';
57
+ mapHeight?: string;
58
+ mapWidth?: string;
59
+ mapGap?: string;
60
+ width?: string;
61
+ layout?: 'stacked' | 'overlay';
62
+ logoMark?: string | null;
63
+ marinaName?: string;
64
+ otherMarinas?: OtherMarina[];
65
+ /** The site's own Clerk publishable key (Sidon sign-in on the Documents step). */
66
+ clerkPublishableKey?: string;
67
+ /** Origin serving OTA's /api/sailor/documents; '' (default) = this page's origin. */
68
+ sailorApiOrigin?: string;
69
+ }
70
+
71
+ export interface SidonBerthMapElement extends HTMLElement {
72
+ /** OTA marina slug. */
73
+ marina?: string;
74
+ mapsApiKey?: string;
75
+ /** '' (default) = this page's origin, where the forwarder route lives. */
76
+ apiOrigin?: string;
77
+ mapStyle?: 'chart' | 'coastal';
78
+ locale?: string;
79
+ currencySymbol?: string;
80
+ from?: string;
81
+ to?: string;
82
+ length?: number;
83
+ berth?: string;
84
+ /** 'staff' (the OTA dashboard): every listed berth is clickable and fires
85
+ sidon-berth-selected, occupied berths are painted for [from, to), and
86
+ from/to follow their attributes. No card, availability or boat-length
87
+ checks. Default 'guest'. */
88
+ mode?: 'guest' | 'staff';
89
+ /** Re-reads the map payload. Undefined until the element has mounted
90
+ (a microtask after it is connected), so call `el.refresh?.()`. */
91
+ readonly refresh?: () => void;
92
+ bookPath?: string;
93
+ logoMark?: string | null;
94
+ marinaName?: string;
95
+ otherMarinas?: OtherMarina[];
96
+ mapHeight?: string;
97
+ showWeather?: boolean;
98
+ eyebrow?: string;
99
+ cardTitle?: string;
100
+ intro?: string;
101
+ rangeLabel?: string;
102
+ rangePlaceholder?: string;
103
+ lengthLabel?: string;
104
+ selectedLabel?: string;
105
+ selectedPlaceholder?: string;
106
+ ctaLabel?: string;
107
+ }
108
+
109
+ declare global {
110
+ interface HTMLElementTagNameMap {
111
+ 'sidon-booking-widget': SidonBookingWidgetElement;
112
+ 'sidon-berth-map': SidonBerthMapElement;
113
+ }
114
+ // Dispatched with bubbles + composed, so listeners on any ancestor
115
+ // element get the typed detail too.
116
+ interface HTMLElementEventMap {
117
+ 'sidon-step-change': CustomEvent<SidonStepChangeDetail>;
118
+ 'sidon-loa-change': CustomEvent<SidonLoaChangeDetail>;
119
+ 'sidon-booked': CustomEvent<SidonBookedDetail>;
120
+ 'sidon-booking-status': CustomEvent<SidonBookingStatusDetail>;
121
+ 'sidon-berth-selected': CustomEvent<SidonBerthSelectedDetail>;
122
+ 'sidon-quickbook-submit': CustomEvent<SidonQuickbookSubmitDetail>;
123
+ }
124
+ }
@@ -4874,18 +4874,19 @@ var Ga = class extends Error {
4874
4874
  super(e), this.status = t;
4875
4875
  }
4876
4876
  };
4877
- async function Ka(e, t, n) {
4878
- let r;
4877
+ async function Ka(e, t, n, r = !1) {
4878
+ let i;
4879
4879
  try {
4880
- r = await fetch(e, n);
4880
+ i = await fetch(e, n);
4881
4881
  } catch {
4882
4882
  throw new Ga(t, 0);
4883
4883
  }
4884
- if (!r.ok) throw new Ga(await ji(r, t), r.status);
4884
+ if (!i.ok) throw new Ga(await ji(i, t), i.status);
4885
+ if (r) return null;
4885
4886
  try {
4886
- return await r.json();
4887
+ return await i.json();
4887
4888
  } catch {
4888
- throw new Ga(t, r.status);
4889
+ throw new Ga(t, i.status);
4889
4890
  }
4890
4891
  }
4891
4892
  async function qa(e, t, n) {