@jay-framework/wix-bookings 0.25.1 → 0.25.5

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.
@@ -2,8 +2,9 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import yaml from "js-yaml";
4
4
  const CONFIG_FILE = ".wix-bookings.yaml";
5
+ const WIX_BOOKINGS_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
5
6
  const DEFAULTS = {
6
- bookingAppId: "",
7
+ bookingAppId: WIX_BOOKINGS_APP_ID,
7
8
  staffResourceTypeId: "",
8
9
  slotWindowDays: 14,
9
10
  postCheckoutUrl: "/"
@@ -15,7 +16,7 @@ function loadWixBookingsConfig(projectRoot) {
15
16
  }
16
17
  const raw = yaml.load(fs.readFileSync(configPath, "utf-8"));
17
18
  return {
18
- bookingAppId: raw.bookingAppId ?? DEFAULTS.bookingAppId,
19
+ bookingAppId: raw.bookingAppId || DEFAULTS.bookingAppId,
19
20
  staffResourceTypeId: raw.staffResourceTypeId ?? DEFAULTS.staffResourceTypeId,
20
21
  slotWindowDays: raw.slotWindowDays ?? DEFAULTS.slotWindowDays,
21
22
  postCheckoutUrl: raw.postCheckoutUrl ?? DEFAULTS.postCheckoutUrl
@@ -0,0 +1,378 @@
1
+ import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
2
+ import { Signals } from '@jay-framework/fullstack-component';
3
+ import * as _jay_framework_component from '@jay-framework/component';
4
+ import * as _jay_framework_runtime from '@jay-framework/runtime';
5
+ import { HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
6
+ import { WixClient } from '@wix/sdk';
7
+
8
+ interface WixBookingsConfig {
9
+ bookingAppId: string;
10
+ staffResourceTypeId: string;
11
+ slotWindowDays: number;
12
+ postCheckoutUrl: string;
13
+ }
14
+
15
+ declare const init: _jay_framework_fullstack_component.JayInit<{
16
+ config: WixBookingsConfig;
17
+ }>;
18
+
19
+ interface ServiceOfBookingFlowViewState {
20
+ id: string,
21
+ name: string,
22
+ description: string,
23
+ type: string,
24
+ durationLabel: string,
25
+ priceLabel: string,
26
+ formId: string
27
+ }
28
+
29
+ interface SlotOfBookingFlowViewState {
30
+ id: string,
31
+ label: string,
32
+ localStartDate: string,
33
+ localEndDate: string,
34
+ scheduleId: string,
35
+ eventId: string
36
+ }
37
+
38
+ interface FormFieldOfBookingFlowViewState {
39
+ target: string,
40
+ label: string,
41
+ type: string,
42
+ required: boolean
43
+ }
44
+
45
+ interface BookingFlowViewState {
46
+ services: Array<ServiceOfBookingFlowViewState>,
47
+ servicesLoading: boolean,
48
+ showNoServices: boolean,
49
+ hasSlots: boolean,
50
+ servicesError: string,
51
+ showServices: boolean,
52
+ showSlots: boolean,
53
+ showForm: boolean,
54
+ selectedServiceName: string,
55
+ slots: Array<SlotOfBookingFlowViewState>,
56
+ slotsLoading: boolean,
57
+ slotsMessage: string,
58
+ formFields: Array<FormFieldOfBookingFlowViewState>,
59
+ formLoading: boolean,
60
+ isBooking: boolean,
61
+ bookingStatus: string,
62
+ bookingError: string
63
+ }
64
+
65
+ type BookingFlowSlowViewState = {};
66
+
67
+ type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
68
+ services: Array<BookingFlowViewState['services'][number]>;
69
+ slots: Array<BookingFlowViewState['slots'][number]>;
70
+ formFields: Array<BookingFlowViewState['formFields'][number]>;
71
+ };
72
+
73
+ type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
74
+ services: Array<BookingFlowViewState['services'][number]>;
75
+ slots: Array<BookingFlowViewState['slots'][number]>;
76
+ formFields: Array<BookingFlowViewState['formFields'][number]>;
77
+ };
78
+
79
+
80
+ interface BookingFlowRefs {
81
+ bookButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
82
+ backButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
83
+ services: {
84
+ serviceButtons: HTMLElementCollectionProxy<ServiceOfBookingFlowViewState, HTMLButtonElement>
85
+ },
86
+ slots: {
87
+ slotButtons: HTMLElementCollectionProxy<SlotOfBookingFlowViewState, HTMLButtonElement>
88
+ },
89
+ formFields: {
90
+ formInputs: HTMLElementCollectionProxy<FormFieldOfBookingFlowViewState, HTMLInputElement>
91
+ }
92
+ }
93
+
94
+ type BookingServiceType = 'APPOINTMENT' | 'CLASS';
95
+ interface BookingServiceView {
96
+ id: string;
97
+ name: string;
98
+ type: BookingServiceType;
99
+ description: string;
100
+ priceLabel: string;
101
+ durationLabel: string;
102
+ formId: string;
103
+ }
104
+ interface BookingSlotView {
105
+ id: string;
106
+ localStartDate: string;
107
+ localEndDate: string;
108
+ label: string;
109
+ scheduleId?: string;
110
+ eventId?: string;
111
+ serviceType: BookingServiceType;
112
+ }
113
+ interface BookingFormFieldView {
114
+ target: string;
115
+ label: string;
116
+ type: 'STRING' | 'EMAIL' | 'PHONE' | 'NUMBER' | 'URL';
117
+ required: boolean;
118
+ }
119
+ type CreateBookingOutcome =
120
+ /** Booked with nothing to pay: `orderId` is the placed order (Wix's thank-you page is /thank-you-page/<orderId>). */
121
+ {
122
+ outcome: 'confirmed';
123
+ orderId?: string;
124
+ } | {
125
+ outcome: 'redirect';
126
+ redirectUrl: string;
127
+ };
128
+
129
+ interface WixBookingsService {
130
+ listServices(): Promise<BookingServiceView[]>;
131
+ listSlots(input: {
132
+ serviceId: string;
133
+ serviceType: BookingServiceType;
134
+ timezone?: string;
135
+ windowDays?: number;
136
+ }): Promise<BookingSlotView[]>;
137
+ createBooking(input: {
138
+ serviceId: string;
139
+ serviceType: BookingServiceType;
140
+ slot: {
141
+ localStartDate: string;
142
+ localEndDate: string;
143
+ scheduleId?: string;
144
+ eventId?: string;
145
+ };
146
+ formValues: Record<string, string>;
147
+ timezone: string;
148
+ siteOrigin: string;
149
+ paymentPreference?: 'ONLINE' | 'OFFLINE';
150
+ }): Promise<CreateBookingOutcome>;
151
+ }
152
+ declare const WIX_BOOKINGS_SERVICE: _jay_framework_fullstack_component.ServiceMarker<WixBookingsService>;
153
+
154
+ interface BookingFlowCarryForward {
155
+ services: BookingServiceView[];
156
+ servicesError?: string;
157
+ }
158
+ declare const bookingFlow: _jay_framework_fullstack_component.JayStackComponentDefinition<BookingFlowRefs, BookingFlowSlowViewState, BookingFlowFastViewState, BookingFlowInteractiveViewState, [BookingFlowCarryForward, WixBookingsService], [Signals<BookingFlowFastViewState>, BookingFlowCarryForward], object, {}, _jay_framework_component.JayComponentCore<object, BookingFlowInteractiveViewState>>;
159
+
160
+ declare const listServices: _jay_framework_fullstack_component.JayAction<Record<string, never>, {
161
+ services: BookingServiceView[];
162
+ }> & _jay_framework_fullstack_component.JayActionDefinition<Record<string, never>, {
163
+ services: BookingServiceView[];
164
+ }, [WixBookingsService]>;
165
+ declare const listSlots: _jay_framework_fullstack_component.JayAction<{
166
+ serviceId: string;
167
+ serviceType: "APPOINTMENT" | "CLASS";
168
+ timezone?: string;
169
+ windowDays?: number;
170
+ }, {
171
+ slots: BookingSlotView[];
172
+ }> & _jay_framework_fullstack_component.JayActionDefinition<{
173
+ serviceId: string;
174
+ serviceType: "APPOINTMENT" | "CLASS";
175
+ timezone?: string;
176
+ windowDays?: number;
177
+ }, {
178
+ slots: BookingSlotView[];
179
+ }, [WixBookingsService]>;
180
+ declare const createBooking: _jay_framework_fullstack_component.JayAction<{
181
+ serviceId: string;
182
+ serviceType: "APPOINTMENT" | "CLASS";
183
+ slot: {
184
+ localStartDate: string;
185
+ localEndDate: string;
186
+ scheduleId?: string;
187
+ eventId?: string;
188
+ };
189
+ formValues: Record<string, string>;
190
+ timezone: string;
191
+ siteOrigin: string;
192
+ paymentPreference?: "ONLINE" | "OFFLINE";
193
+ }, CreateBookingOutcome> & _jay_framework_fullstack_component.JayActionDefinition<{
194
+ serviceId: string;
195
+ serviceType: "APPOINTMENT" | "CLASS";
196
+ slot: {
197
+ localStartDate: string;
198
+ localEndDate: string;
199
+ scheduleId?: string;
200
+ eventId?: string;
201
+ };
202
+ formValues: Record<string, string>;
203
+ timezone: string;
204
+ siteOrigin: string;
205
+ paymentPreference?: "ONLINE" | "OFFLINE";
206
+ }, CreateBookingOutcome, [WixBookingsService]>;
207
+
208
+ interface RawBookingService {
209
+ _id?: string;
210
+ id?: string;
211
+ name?: string;
212
+ type?: string;
213
+ description?: string;
214
+ hidden?: boolean;
215
+ payment?: {
216
+ fixed?: {
217
+ price?: {
218
+ currency?: string;
219
+ value?: string;
220
+ };
221
+ };
222
+ options?: {
223
+ online?: boolean;
224
+ inPerson?: boolean;
225
+ };
226
+ };
227
+ schedule?: {
228
+ availabilityConstraints?: {
229
+ sessionDurations?: number[];
230
+ };
231
+ };
232
+ form?: {
233
+ _id?: string;
234
+ };
235
+ }
236
+
237
+ /**
238
+ * Bookings in the browser, with the visitor's (or member's) own Wix client: for sites served without a Jay
239
+ * server (a static export), where the server actions cannot run. Visitor tokens may query services and
240
+ * availability and create bookings and checkouts, as Wix's own booking widgets do.
241
+ */
242
+ /** Which booking features the site's plan includes (`bookings-settings` FEATURES). */
243
+ interface BookingFeatures {
244
+ /** CLASS services */
245
+ groups: boolean;
246
+ /** APPOINTMENT services */
247
+ appointments: boolean;
248
+ /** COURSE services */
249
+ courses: boolean;
250
+ payments: boolean;
251
+ }
252
+ type BookingStep = 'serviceList' | 'calendar' | 'form';
253
+ /**
254
+ * Whether Wix lets a visitor go on with a service at a booking step, as its widgets decide: a service type the
255
+ * site's plan does not include stops the visitor ("not yet available for online bookings"). The service list
256
+ * and service page let courses through (they start at the form); the form checks every type.
257
+ */
258
+ declare function canBookOnline(features: BookingFeatures, type: BookingServiceType | 'COURSE', step: BookingStep): boolean;
259
+ /** One time slot as `service-availability` returns it (the fields Wix's calendar uses). */
260
+ interface TimeSlot {
261
+ serviceId?: string;
262
+ localStartDate?: string;
263
+ localEndDate?: string;
264
+ bookable?: boolean;
265
+ totalCapacity?: number;
266
+ remainingCapacity?: number;
267
+ bookableCapacity?: number;
268
+ eventInfo?: {
269
+ eventId?: string;
270
+ };
271
+ location?: {
272
+ id?: string;
273
+ name?: string;
274
+ formattedAddress?: string;
275
+ locationType?: string;
276
+ };
277
+ availableResources?: {
278
+ resourceTypeId?: string;
279
+ resources?: {
280
+ id?: string;
281
+ name?: string;
282
+ }[];
283
+ }[];
284
+ bookingPolicyViolations?: {
285
+ tooEarlyToBook?: boolean;
286
+ tooLateToBook?: boolean;
287
+ bookOnlineDisabled?: boolean;
288
+ };
289
+ }
290
+ interface TimeSlotsQuery {
291
+ serviceIds: string[];
292
+ timeZone: string;
293
+ fromLocalDate: string;
294
+ toLocalDate: string;
295
+ /** Only the first slot of each day (the calendar's month view marks days that have one). */
296
+ maxSlotsPerDay?: number;
297
+ includeNonBookable?: boolean;
298
+ limit?: number;
299
+ }
300
+ interface WixBookingsContext {
301
+ /** The booking features of the site's plan (read once per page). */
302
+ features(): Promise<BookingFeatures>;
303
+ /** The business time zone, which Wix's calendar shows availability in by default. */
304
+ timeZone(): Promise<string>;
305
+ /** A bookable service by one of its URL slugs (`/booking-calendar/<slug>`, `/service-page/<slug>`). */
306
+ serviceBySlug(slug: string): Promise<RawBookingService | undefined>;
307
+ /** A service by its id (the booking form gets the id of the slot chosen on the calendar). */
308
+ serviceById(id: string): Promise<RawBookingService | undefined>;
309
+ /** Class sessions (and appointment openings) in a local date range, as Wix's calendar queries them. */
310
+ timeSlots(query: TimeSlotsQuery): Promise<TimeSlot[]>;
311
+ /** Create the booking and continue to checkout (or confirm a free booking), as the server action does. */
312
+ createBooking: WixBookingsService['createBooking'];
313
+ /**
314
+ * A placed order (a confirmed booking's `orderId`) as its buyer reads it, with the texts Wix's thank-you page
315
+ * shows; undefined for anyone else.
316
+ */
317
+ orderById(orderId: string): Promise<BookingOrder | undefined>;
318
+ /**
319
+ * The visitor's or member's own confirmed and pending bookings of a service (Wix's booking form asks "Book this
320
+ * again?" when there is one).
321
+ */
322
+ serviceBookings(serviceId: string): Promise<{
323
+ id?: string;
324
+ startDate?: string;
325
+ status?: string;
326
+ }[]>;
327
+ /** One of the visitor's or member's own bookings (an order's line item names it), with its start and end. */
328
+ bookingById(bookingId: string): Promise<{
329
+ id?: string;
330
+ startDate?: string;
331
+ endDate?: string;
332
+ status?: string;
333
+ } | undefined>;
334
+ }
335
+ /** The parts of an eCommerce order Wix's thank-you page shows. */
336
+ interface BookingOrder {
337
+ id: string;
338
+ number?: string;
339
+ billingInfo?: {
340
+ contactDetails?: {
341
+ firstName?: string;
342
+ lastName?: string;
343
+ };
344
+ };
345
+ buyerInfo?: {
346
+ email?: string;
347
+ };
348
+ lineItems?: {
349
+ productName?: {
350
+ original?: string;
351
+ translated?: string;
352
+ };
353
+ /** For a booking: the booking's id. */
354
+ catalogReference?: {
355
+ catalogItemId?: string;
356
+ appId?: string;
357
+ };
358
+ descriptionLines?: {
359
+ plainText?: {
360
+ original?: string;
361
+ translated?: string;
362
+ };
363
+ }[];
364
+ image?: {
365
+ url?: string;
366
+ };
367
+ price?: {
368
+ formattedAmount?: string;
369
+ };
370
+ }[];
371
+ priceSummary?: Record<string, {
372
+ formattedAmount?: string;
373
+ } | undefined>;
374
+ }
375
+ declare const WIX_BOOKINGS_CONTEXT: _jay_framework_runtime.ContextMarker<WixBookingsContext>;
376
+ declare function createWixBookingsContext(wixClient: WixClient, config: WixBookingsConfig): WixBookingsContext;
377
+
378
+ export { type BookingServiceView as B, type CreateBookingOutcome as C, type TimeSlot as T, type WixBookingsConfig as W, type WixBookingsService as a, bookingFlow as b, listSlots as c, createBooking as d, WIX_BOOKINGS_SERVICE as e, type BookingSlotView as f, type BookingFormFieldView as g, WIX_BOOKINGS_CONTEXT as h, init as i, canBookOnline as j, createWixBookingsContext as k, listServices as l, type BookingFeatures as m, type BookingStep as n, type TimeSlotsQuery as o, type WixBookingsContext as p, type BookingOrder as q };
@@ -1,4 +1,5 @@
1
- export { f as BookingFormFieldView, B as BookingServiceView, e as BookingSlotView, C as CreateBookingOutcome, b as bookingFlow, c as createBooking, i as init, l as listServices, a as listSlots } from './index.client-CBlxQDjy.js';
1
+ export { m as BookingFeatures, g as BookingFormFieldView, q as BookingOrder, B as BookingServiceView, f as BookingSlotView, n as BookingStep, C as CreateBookingOutcome, T as TimeSlot, o as TimeSlotsQuery, h as WIX_BOOKINGS_CONTEXT, p as WixBookingsContext, b as bookingFlow, j as canBookOnline, d as createBooking, k as createWixBookingsContext, i as init, l as listServices, c as listSlots } from './index.client-DHSnbb5_.js';
2
2
  import '@jay-framework/fullstack-component';
3
3
  import '@jay-framework/component';
4
4
  import '@jay-framework/runtime';
5
+ import '@wix/sdk';