@profitstudio/booking-engine 0.0.0-stage → 2.0.0-beta.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +562 -0
  2. package/LICENSE +21 -0
  3. package/README.md +18 -2
  4. package/THIRD_PARTY_NOTICES.md +41 -0
  5. package/bin/booking-engine.mjs +575 -0
  6. package/bin/connect.mjs +408 -0
  7. package/bin/photos.mjs +82 -0
  8. package/dist/admin/BookingAdmin.d.ts +22 -0
  9. package/dist/admin/BookingAdmin.js +337 -0
  10. package/dist/admin/admin.css +1423 -0
  11. package/dist/admin/alerts.d.ts +10 -0
  12. package/dist/admin/alerts.js +11 -0
  13. package/dist/admin/booking-detail.d.ts +37 -0
  14. package/dist/admin/booking-detail.js +149 -0
  15. package/dist/admin/content-inputs.d.ts +15 -0
  16. package/dist/admin/content-inputs.js +105 -0
  17. package/dist/admin/context.d.ts +37 -0
  18. package/dist/admin/context.js +8 -0
  19. package/dist/admin/drawer.d.ts +14 -0
  20. package/dist/admin/drawer.js +56 -0
  21. package/dist/admin/feedback.d.ts +32 -0
  22. package/dist/admin/feedback.js +70 -0
  23. package/dist/admin/fields.d.ts +27 -0
  24. package/dist/admin/fields.js +146 -0
  25. package/dist/admin/fonts/OFL-Geist-Mono.txt +93 -0
  26. package/dist/admin/fonts/OFL-Geist.txt +93 -0
  27. package/dist/admin/fonts/geist-latin-wght-normal.woff2 +0 -0
  28. package/dist/admin/fonts/geist-mono-latin-wght-normal.woff2 +0 -0
  29. package/dist/admin/icons.d.ts +66 -0
  30. package/dist/admin/icons.js +72 -0
  31. package/dist/admin/image-upload.d.ts +58 -0
  32. package/dist/admin/image-upload.js +111 -0
  33. package/dist/admin/index.d.ts +6 -0
  34. package/dist/admin/index.js +6 -0
  35. package/dist/admin/lucide.generated.d.ts +521 -0
  36. package/dist/admin/lucide.generated.js +76 -0
  37. package/dist/admin/sections/BookingsSection.d.ts +1 -0
  38. package/dist/admin/sections/BookingsSection.js +137 -0
  39. package/dist/admin/sections/EmailSection.d.ts +8 -0
  40. package/dist/admin/sections/EmailSection.js +182 -0
  41. package/dist/admin/sections/HoursSection.d.ts +1 -0
  42. package/dist/admin/sections/HoursSection.js +110 -0
  43. package/dist/admin/sections/OverviewSection.d.ts +1 -0
  44. package/dist/admin/sections/OverviewSection.js +427 -0
  45. package/dist/admin/sections/ServicesSection.d.ts +1 -0
  46. package/dist/admin/sections/ServicesSection.js +236 -0
  47. package/dist/admin/sections/SettingsSection.d.ts +10 -0
  48. package/dist/admin/sections/SettingsSection.js +96 -0
  49. package/dist/admin/sections/WebsiteSection.d.ts +1 -0
  50. package/dist/admin/sections/WebsiteSection.js +228 -0
  51. package/dist/admin/sections.d.ts +22 -0
  52. package/dist/admin/sections.js +29 -0
  53. package/dist/admin/setup.d.ts +1 -0
  54. package/dist/admin/setup.js +45 -0
  55. package/dist/admin/today.d.ts +43 -0
  56. package/dist/admin/today.js +115 -0
  57. package/dist/admin/ui.d.ts +134 -0
  58. package/dist/admin/ui.js +220 -0
  59. package/dist/calendar.d.ts +64 -0
  60. package/dist/calendar.js +139 -0
  61. package/dist/client.d.ts +147 -0
  62. package/dist/client.js +507 -0
  63. package/dist/config.d.ts +25 -0
  64. package/dist/config.js +120 -0
  65. package/dist/content/image.d.ts +20 -0
  66. package/dist/content/image.js +90 -0
  67. package/dist/content/resolve.d.ts +12 -0
  68. package/dist/content/resolve.js +73 -0
  69. package/dist/content/schema.d.ts +119 -0
  70. package/dist/content/schema.js +53 -0
  71. package/dist/content/store.d.ts +48 -0
  72. package/dist/content/store.js +123 -0
  73. package/dist/content/validate.d.ts +33 -0
  74. package/dist/content/validate.js +177 -0
  75. package/dist/errors.d.ts +19 -0
  76. package/dist/errors.js +94 -0
  77. package/dist/generated/manifest.d.ts +6 -0
  78. package/dist/generated/manifest.js +7 -0
  79. package/dist/index.d.ts +20 -0
  80. package/dist/index.js +20 -0
  81. package/dist/presets/hair-salon.d.ts +8 -0
  82. package/dist/presets/hair-salon.js +94 -0
  83. package/dist/presets/index.d.ts +5 -0
  84. package/dist/presets/index.js +6 -0
  85. package/dist/preview.d.ts +18 -0
  86. package/dist/preview.js +134 -0
  87. package/dist/semver.d.ts +16 -0
  88. package/dist/semver.js +55 -0
  89. package/dist/time.d.ts +31 -0
  90. package/dist/time.js +138 -0
  91. package/dist/types.d.ts +477 -0
  92. package/dist/types.js +3 -0
  93. package/dist/vite.d.ts +52 -0
  94. package/dist/vite.js +150 -0
  95. package/docs/BUILD-A-SITE.md +203 -0
  96. package/docs/EMAIL-SETUP.md +224 -0
  97. package/docs/INTEGRATION.md +1109 -0
  98. package/engine.manifest.json +90 -0
  99. package/functions/booking-mailer/deno.json +6 -0
  100. package/functions/booking-mailer/index.ts +44 -0
  101. package/functions/booking-mailer/mailer.js +156 -0
  102. package/functions/booking-mailer/providers/index.js +42 -0
  103. package/functions/booking-mailer/providers/resend.js +75 -0
  104. package/functions/booking-mailer/templates.js +345 -0
  105. package/migrations/0001_core.sql +1673 -0
  106. package/migrations/0002_security_hardening.sql +711 -0
  107. package/migrations/0003_private_definers_and_holds.sql +808 -0
  108. package/migrations/0004_verified_requests.sql +1702 -0
  109. package/migrations/0005_scoped_mailer_credential.sql +347 -0
  110. package/migrations/0006_trusted_client_ip.sql +56 -0
  111. package/migrations/0007_site_content.sql +380 -0
  112. package/migrations/0008_service_images_opening_times.sql +328 -0
  113. package/package.json +85 -4
  114. package/templates/BOOKING_ENGINE.md +61 -0
@@ -0,0 +1,64 @@
1
+ import type { AvailabilityDay, Slot, Weekday } from './types.js';
2
+ /** The month of a calendar date: "2026-11-12" → "2026-11". */
3
+ export declare function monthOf(date: string): string;
4
+ /** A month plus n months: ("2026-11", 2) → "2027-01". */
5
+ export declare function addMonths(month: string, months: number): string;
6
+ /** Number of days in a month: "2028-02" → 29. */
7
+ export declare function daysInMonth(month: string): number;
8
+ /**
9
+ * The first day of the week in a locale, as an ISO weekday (1 = Monday …
10
+ * 7 = Sunday): 7 for "en-US", 1 for "fr-FR". Pass the business locale so the
11
+ * calendar matches the salon's customers, not the visitor's device.
12
+ */
13
+ export declare function firstDayOfWeek(locale?: string): Weekday;
14
+ /** The first date of the week that contains `date`. `weekStartsOn` is an ISO weekday (1 = Monday, 7 = Sunday). */
15
+ export declare function startOfWeek(date: string, weekStartsOn?: Weekday): string;
16
+ /** The 7 dates of the week that contains `date` — a week strip. */
17
+ export declare function weekDates(date: string, weekStartsOn?: Weekday): string[];
18
+ export interface MonthGrid {
19
+ /** "YYYY-MM". */
20
+ month: string;
21
+ /**
22
+ * Whole weeks (4–6 of them), 7 dates each, including the days of the
23
+ * adjacent months that complete the first and last week.
24
+ */
25
+ weeks: string[][];
26
+ /** First and last date of the grid: the range to request with getAvailability (never more than 42 days). */
27
+ from: string;
28
+ to: string;
29
+ }
30
+ /**
31
+ * A month as a calendar grid, and the date range to request for it:
32
+ * `getAvailability({ serviceId, from: grid.from, to: grid.to })` — one call
33
+ * per visible month. Every week of the grid is complete, so a week strip that
34
+ * shows any week of the month is covered by the same call.
35
+ */
36
+ export declare function monthGrid(month: string, weekStartsOn?: Weekday): MonthGrid;
37
+ export type PartOfDay = 'morning' | 'afternoon' | 'evening';
38
+ /** In display order. */
39
+ export declare const PARTS_OF_DAY: readonly PartOfDay[];
40
+ /**
41
+ * The part of the day of a business-local "HH:MM" slot time (`slot.time`):
42
+ * before 12:00 morning, before 17:00 afternoon, otherwise evening.
43
+ */
44
+ export declare function partOfDay(time: string): PartOfDay;
45
+ /**
46
+ * A day's slots by part of the day: always the three parts, in order, each
47
+ * with its slots in the order given (possibly none) — so a segmented control
48
+ * keeps its shape from day to day. Groups by `slot.time`, the server's
49
+ * business-local label: no time zone involved.
50
+ */
51
+ export declare function groupSlotsByPartOfDay<T extends Pick<Slot, 'time'>>(slots: readonly T[]): Array<{
52
+ part: PartOfDay;
53
+ slots: T[];
54
+ }>;
55
+ /** A bookable day with this many times or fewer counts as "few left". */
56
+ export declare const FEW_LEFT_MAX = 3;
57
+ /** True when a day is bookable but only a few times are left (1 to `max`). */
58
+ export declare function isFewLeft(day: Pick<AvailabilityDay, 'status' | 'slots'>, max?: number): boolean;
59
+ /**
60
+ * The first day with bookable times in data already loaded — strictly after
61
+ * `after` when given ("fully booked — next available: …"), otherwise the
62
+ * soonest. Null when the loaded days have none: load the next range instead.
63
+ */
64
+ export declare function nextAvailableDay<T extends Pick<AvailabilityDay, 'date' | 'status' | 'slots'>>(days: readonly T[], after?: string): T | null;
@@ -0,0 +1,139 @@
1
+ // Calendar view helpers for a booking UI (INTEGRATION.md §8–§9).
2
+ //
3
+ // Pure functions over calendar-date strings ("YYYY-MM-DD", business-local) and
4
+ // the data getAvailability() returned. They only reshape what the server sent:
5
+ // they never compute or guess free times, and they involve no time zone maths
6
+ // (no `Date` in local time — calendar arithmetic runs on UTC dates only).
7
+ import { addDays, weekdayOf } from './time.js';
8
+ const MONTH_RE = /^(\d{4})-(\d{2})$/;
9
+ const DATE_RE = /^(\d{4})-(\d{2})-\d{2}$/;
10
+ const TIME_RE = /^(\d{2}):(\d{2})$/;
11
+ function parseMonth(month) {
12
+ const m = MONTH_RE.exec(month);
13
+ if (!m || Number(m[2]) < 1 || Number(m[2]) > 12)
14
+ throw new Error(`Expected a month like 2026-11, got "${month}"`);
15
+ return [Number(m[1]), Number(m[2])];
16
+ }
17
+ const pad = (n) => String(n).padStart(2, '0');
18
+ /** The month of a calendar date: "2026-11-12" → "2026-11". */
19
+ export function monthOf(date) {
20
+ const m = DATE_RE.exec(date);
21
+ if (!m)
22
+ throw new Error(`Expected a date like 2026-11-03, got "${date}"`);
23
+ return `${m[1]}-${m[2]}`;
24
+ }
25
+ /** A month plus n months: ("2026-11", 2) → "2027-01". */
26
+ export function addMonths(month, months) {
27
+ const [y, m] = parseMonth(month);
28
+ const t = new Date(Date.UTC(y, m - 1 + months, 1));
29
+ return `${t.getUTCFullYear()}-${pad(t.getUTCMonth() + 1)}`;
30
+ }
31
+ /** Number of days in a month: "2028-02" → 29. */
32
+ export function daysInMonth(month) {
33
+ const [y, m] = parseMonth(month);
34
+ return new Date(Date.UTC(y, m, 0)).getUTCDate();
35
+ }
36
+ // Regions whose calendars start the week on Sunday or Saturday (CLDR weekData);
37
+ // everywhere else starts on Monday. Only used when the browser cannot say.
38
+ const SUNDAY_FIRST = new Set('AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW'.split(' '));
39
+ const SATURDAY_FIRST = new Set('AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY'.split(' '));
40
+ /**
41
+ * The first day of the week in a locale, as an ISO weekday (1 = Monday …
42
+ * 7 = Sunday): 7 for "en-US", 1 for "fr-FR". Pass the business locale so the
43
+ * calendar matches the salon's customers, not the visitor's device.
44
+ */
45
+ export function firstDayOfWeek(locale) {
46
+ try {
47
+ const loc = new Intl.Locale(locale ?? new Intl.DateTimeFormat().resolvedOptions().locale);
48
+ const info = typeof loc.getWeekInfo === 'function' ? loc.getWeekInfo() : loc.weekInfo;
49
+ if (info && info.firstDay >= 1 && info.firstDay <= 7)
50
+ return info.firstDay;
51
+ const region = loc.maximize().region ?? '';
52
+ if (SUNDAY_FIRST.has(region))
53
+ return 7;
54
+ if (SATURDAY_FIRST.has(region))
55
+ return 6;
56
+ }
57
+ catch {
58
+ // An unknown locale tag: fall back to the ISO week.
59
+ }
60
+ return 1;
61
+ }
62
+ /** The first date of the week that contains `date`. `weekStartsOn` is an ISO weekday (1 = Monday, 7 = Sunday). */
63
+ export function startOfWeek(date, weekStartsOn = 1) {
64
+ return addDays(date, -((weekdayOf(date) - weekStartsOn + 7) % 7));
65
+ }
66
+ /** The 7 dates of the week that contains `date` — a week strip. */
67
+ export function weekDates(date, weekStartsOn = 1) {
68
+ const first = startOfWeek(date, weekStartsOn);
69
+ return Array.from({ length: 7 }, (_, i) => addDays(first, i));
70
+ }
71
+ /**
72
+ * A month as a calendar grid, and the date range to request for it:
73
+ * `getAvailability({ serviceId, from: grid.from, to: grid.to })` — one call
74
+ * per visible month. Every week of the grid is complete, so a week strip that
75
+ * shows any week of the month is covered by the same call.
76
+ */
77
+ export function monthGrid(month, weekStartsOn = 1) {
78
+ const first = `${month}-01`;
79
+ const last = `${month}-${pad(daysInMonth(month))}`;
80
+ const from = startOfWeek(first, weekStartsOn);
81
+ const to = addDays(startOfWeek(last, weekStartsOn), 6);
82
+ const weeks = [];
83
+ for (let start = from; start <= to; start = addDays(start, 7)) {
84
+ weeks.push(Array.from({ length: 7 }, (_, i) => addDays(start, i)));
85
+ }
86
+ return { month, weeks, from, to };
87
+ }
88
+ /** In display order. */
89
+ export const PARTS_OF_DAY = ['morning', 'afternoon', 'evening'];
90
+ /**
91
+ * The part of the day of a business-local "HH:MM" slot time (`slot.time`):
92
+ * before 12:00 morning, before 17:00 afternoon, otherwise evening.
93
+ */
94
+ export function partOfDay(time) {
95
+ const m = TIME_RE.exec(time);
96
+ if (!m)
97
+ throw new Error(`Expected a time like 09:30, got "${time}"`);
98
+ const hour = Number(m[1]);
99
+ if (hour < 12)
100
+ return 'morning';
101
+ if (hour < 17)
102
+ return 'afternoon';
103
+ return 'evening';
104
+ }
105
+ /**
106
+ * A day's slots by part of the day: always the three parts, in order, each
107
+ * with its slots in the order given (possibly none) — so a segmented control
108
+ * keeps its shape from day to day. Groups by `slot.time`, the server's
109
+ * business-local label: no time zone involved.
110
+ */
111
+ export function groupSlotsByPartOfDay(slots) {
112
+ const groups = PARTS_OF_DAY.map((part) => ({ part, slots: [] }));
113
+ for (const slot of slots)
114
+ groups[PARTS_OF_DAY.indexOf(partOfDay(slot.time))].slots.push(slot);
115
+ return groups;
116
+ }
117
+ /** A bookable day with this many times or fewer counts as "few left". */
118
+ export const FEW_LEFT_MAX = 3;
119
+ /** True when a day is bookable but only a few times are left (1 to `max`). */
120
+ export function isFewLeft(day, max = FEW_LEFT_MAX) {
121
+ return day.status === 'available' && day.slots.length > 0 && day.slots.length <= max;
122
+ }
123
+ /**
124
+ * The first day with bookable times in data already loaded — strictly after
125
+ * `after` when given ("fully booked — next available: …"), otherwise the
126
+ * soonest. Null when the loaded days have none: load the next range instead.
127
+ */
128
+ export function nextAvailableDay(days, after) {
129
+ let best = null;
130
+ for (const day of days) {
131
+ if (day.status !== 'available' || day.slots.length === 0)
132
+ continue;
133
+ if (after !== undefined && day.date <= after)
134
+ continue;
135
+ if (!best || day.date < best.date)
136
+ best = day;
137
+ }
138
+ return best;
139
+ }
@@ -0,0 +1,147 @@
1
+ import { type SupabaseClient } from '@supabase/supabase-js';
2
+ import { engineError } from './errors.js';
3
+ import { type PreviewOptions } from './preview.js';
4
+ import type { AdminBooking, AdminSiteContent, AdminIdentity, AdminService, AdminSettings, Availability, AvailabilityException, AvailabilityQuery, BookingConfirmation, BookingListQuery, BookingRequest, BookingStatus, Business, CodeResent, EmailStatus, EngineInfo, EngineMode, ExceptionInput, OpeningHoursInterval, OpeningTimes, OpeningTimesQuery, PendingVerification, Preset, PublishedSiteContent, RequestDiagnostics, RequestReleased, Result, Service, ServiceInput, SettingsPatch, UploadedSiteImage, VerifyBookingInput } from './types.js';
5
+ /** Website content needs this database schema (migration 0007); older ones keep booking. */
6
+ export declare const SITE_CONTENT_SCHEMA = "2.0.0-alpha.7";
7
+ /** Service images and opening times need this database schema (migration 0008); older ones keep everything else. */
8
+ export declare const SERVICE_MEDIA_SCHEMA = "2.0.0-alpha.10";
9
+ /** The Supabase Storage bucket for website images (and, under services/, service photos). */
10
+ export declare const SITE_MEDIA_BUCKET = "booking-site-media";
11
+ export type { PreviewOptions };
12
+ export interface BookingEngineOptions {
13
+ /** Supabase Project URL (e.g. import.meta.env.VITE_SUPABASE_URL). */
14
+ supabaseUrl?: string | null;
15
+ /** Supabase PUBLISHABLE key (sb_publishable_…). Never a secret key. */
16
+ supabaseKey?: string | null;
17
+ /** Alternatively, an existing supabase-js client. */
18
+ supabase?: SupabaseClient;
19
+ /** Fictional data used when no backend is configured AND allowPreview is true. */
20
+ preview?: PreviewOptions;
21
+ /** Allow preview mode. Pass import.meta.env.DEV so production never shows fake data. */
22
+ allowPreview?: boolean;
23
+ }
24
+ export interface AuthApi {
25
+ /** Email + password sign-in for the admin dashboard (Supabase Auth). */
26
+ signIn(email: string, password: string): Promise<Result<{
27
+ email: string;
28
+ }>>;
29
+ signOut(): Promise<Result<null>>;
30
+ getUserEmail(): Promise<string | null>;
31
+ /** Subscribe to sign-in / sign-out. Returns an unsubscribe function. */
32
+ onChange(callback: (signedIn: boolean) => void): () => void;
33
+ }
34
+ export interface AdminApi {
35
+ whoami(): Promise<Result<AdminIdentity>>;
36
+ listBookings(query: BookingListQuery): Promise<Result<AdminBooking[]>>;
37
+ setBookingStatus(bookingId: string, status: Exclude<BookingStatus, 'pending'>): Promise<Result<AdminBooking>>;
38
+ listServices(): Promise<Result<AdminService[]>>;
39
+ saveService(input: ServiceInput): Promise<Result<AdminService>>;
40
+ deleteService(serviceId: string): Promise<Result<{
41
+ deleted: true;
42
+ }>>;
43
+ getWorkingHours(): Promise<Result<OpeningHoursInterval[]>>;
44
+ setWorkingHours(hours: OpeningHoursInterval[]): Promise<Result<OpeningHoursInterval[]>>;
45
+ listExceptions(): Promise<Result<AvailabilityException[]>>;
46
+ addException(input: ExceptionInput): Promise<Result<{
47
+ id: string;
48
+ }>>;
49
+ deleteException(exceptionId: string): Promise<Result<{
50
+ deleted: true;
51
+ }>>;
52
+ getSettings(): Promise<Result<AdminSettings>>;
53
+ updateSettings(patch: SettingsPatch): Promise<Result<AdminSettings>>;
54
+ /** Add a preset's starter services, hours and policies. Only when there are no services yet. */
55
+ applyPreset(preset: Preset): Promise<Result<{
56
+ servicesAdded: number;
57
+ }>>;
58
+ /** How the database identifies this request's caller — for verifying rate limiting on a real host. */
59
+ requestDiagnostics(): Promise<Result<RequestDiagnostics>>;
60
+ /** Email health: last delivery, failures, whether automatic sending is wired up. Never email contents. */
61
+ emailStatus(): Promise<Result<EmailStatus>>;
62
+ /** Queue a test email (at most 10 an hour). A delivered test email unlocks online booking. */
63
+ sendTestEmail(recipient: string): Promise<Result<{
64
+ queued: true;
65
+ }>>;
66
+ /** Send again the emails that failed in the last 23 hours (never twice: the provider de-duplicates). */
67
+ retryFailedEmails(): Promise<Result<{
68
+ requeued: number;
69
+ }>>;
70
+ /** Website content: the draft and the published copy. */
71
+ getSiteContent(): Promise<Result<AdminSiteContent>>;
72
+ /** Save the whole draft. Pass the draftRevision you started from (CONFLICT if another admin saved since). */
73
+ saveSiteContentDraft(values: Record<string, unknown>, baseRevision?: number): Promise<Result<AdminSiteContent>>;
74
+ /** Make the draft what visitors see. */
75
+ publishSiteContent(baseRevision?: number): Promise<Result<AdminSiteContent>>;
76
+ /** Throw the draft away: back to what is published. */
77
+ discardSiteContentDraft(): Promise<Result<AdminSiteContent>>;
78
+ /** Check, scale down if needed, and upload an image to the website's media bucket. */
79
+ uploadSiteImage(file: Blob): Promise<Result<UploadedSiteImage>>;
80
+ /** Paths of every uploaded image (for cleaning up unused ones). */
81
+ listSiteImages(): Promise<Result<Array<{
82
+ path: string;
83
+ createdAt: string | null;
84
+ }>>>;
85
+ /** Delete uploaded images (paths under site/). */
86
+ deleteSiteImages(paths: string[]): Promise<Result<{
87
+ deleted: number;
88
+ }>>;
89
+ /**
90
+ * Check, scale down if needed, and upload a service photo (under services/).
91
+ * Store the result with saveService({ id, image }). Needs schema 2.0.0-alpha.10.
92
+ */
93
+ uploadServiceImage(file: Blob): Promise<Result<UploadedSiteImage>>;
94
+ /** Paths of every uploaded service photo (for cleaning up ones no service uses). */
95
+ listServiceImages(): Promise<Result<Array<{
96
+ path: string;
97
+ createdAt: string | null;
98
+ }>>>;
99
+ /** Delete uploaded service photos (paths under services/). */
100
+ deleteServiceImages(paths: string[]): Promise<Result<{
101
+ deleted: number;
102
+ }>>;
103
+ }
104
+ export interface BookingEngine {
105
+ readonly mode: EngineMode;
106
+ readonly version: string;
107
+ getInfo(): Promise<Result<EngineInfo>>;
108
+ getBusiness(): Promise<Result<Business>>;
109
+ /** The owner's published website content (empty before the first publish: the website shows its defaults). */
110
+ getSiteContent(): Promise<Result<PublishedSiteContent>>;
111
+ /** Public URL of an uploaded image or service photo (null without a backend). */
112
+ mediaUrl(path: string): string | null;
113
+ /** Active services in display order, each with its optional `image`. */
114
+ listServices(): Promise<Result<Service[]>>;
115
+ /**
116
+ * Opening hours of each business-local date after closures (at most 42 days),
117
+ * for "Open now" lines. Display only: bookable times come from getAvailability.
118
+ * On a database older than schema 2.0.0-alpha.10: SCHEMA_INCOMPATIBLE (fall back to Business.openingHours).
119
+ */
120
+ getOpeningTimes(query: OpeningTimesQuery): Promise<Result<OpeningTimes>>;
121
+ getAvailability(query: AvailabilityQuery): Promise<Result<Availability>>;
122
+ /**
123
+ * Step 1 of booking: checks the request, holds the time for the verification
124
+ * window and emails the customer a 6-digit code.
125
+ */
126
+ requestBooking(request: BookingRequest): Promise<Result<PendingVerification>>;
127
+ /** Step 2: the code from the email turns the hold into a request (pending) or a confirmed booking. */
128
+ verifyBooking(input: VerifyBookingInput): Promise<Result<BookingConfirmation>>;
129
+ /** Email a new code for an open request (after 60 s, at most 3 times; the hold is not extended). */
130
+ resendVerificationCode(requestId: string): Promise<Result<CodeResent>>;
131
+ /**
132
+ * Release a request that is still waiting for its code (the visitor chose another
133
+ * time or mistyped their address): the time is free again at once. Safe to call twice.
134
+ */
135
+ cancelBookingRequest(requestId: string): Promise<Result<RequestReleased>>;
136
+ /**
137
+ * @deprecated Since 2.0.0-alpha.4 every booking needs a verified email:
138
+ * use requestBooking + verifyBooking. Always returns VERIFICATION_REQUIRED.
139
+ */
140
+ createBooking(request: BookingRequest): Promise<Result<BookingConfirmation>>;
141
+ readonly auth: AuthApi;
142
+ readonly admin: AdminApi;
143
+ }
144
+ /** Refuse privileged keys in a website: they bypass Row Level Security. */
145
+ export declare function assertPublishableKey(key: string | null | undefined): void;
146
+ export declare function createBookingEngine(options?: BookingEngineOptions): BookingEngine;
147
+ export { engineError };