@jay-framework/wix-bookings 0.26.4 → 0.26.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.
- package/CHANGELOG.md +38 -0
- package/agent-kit/plugin/wix-bookings-setup.md +49 -7
- package/agent-kit/plugin/wix-bookings-troubleshooting.md +41 -15
- package/dist/actions/create-booking.jay-action +12 -2
- package/dist/actions/get-participant-form.jay-action +28 -0
- package/dist/contracts/booking-flow.jay-contract +122 -4
- package/dist/contracts/booking-flow.jay-contract.d.ts +171 -1
- package/dist/{index.client-oaMPI34g.d.ts → index.client-BzhFjOWZ.d.ts} +215 -45
- package/dist/index.client.d.ts +2 -1
- package/dist/index.client.js +1323 -613
- package/dist/index.d.ts +3 -2
- package/dist/index.js +410 -101
- package/dist/{query-services-B1MS77NZ.js → query-services-XDLgzwiL.js} +4 -6
- package/dist/tools.d.ts +16 -1
- package/dist/tools.js +100 -6
- package/package.json +16 -14
- package/plugin.yaml +7 -0
|
@@ -3,6 +3,8 @@ import { Signals } from '@jay-framework/fullstack-component';
|
|
|
3
3
|
import * as _jay_framework_component from '@jay-framework/component';
|
|
4
4
|
import * as _jay_framework_runtime from '@jay-framework/runtime';
|
|
5
5
|
import { HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
|
|
6
|
+
import * as _jay_framework_wix_forms from '@jay-framework/wix-forms';
|
|
7
|
+
import { PhoneRules, FieldViewData, AddressValue, FormFieldOptionView, LayoutPart, WixFormsService, ProjectedForm } from '@jay-framework/wix-forms';
|
|
6
8
|
import { WixClient } from '@wix/sdk';
|
|
7
9
|
|
|
8
10
|
interface WixBookingsConfig {
|
|
@@ -53,6 +55,118 @@ interface FormFieldOfBookingFlowViewState {
|
|
|
53
55
|
required: boolean
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
interface OptionOfCountryOfAddressOfBookingFlowViewState {
|
|
59
|
+
value: string,
|
|
60
|
+
label: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface CountryOfAddressOfBookingFlowViewState {
|
|
64
|
+
label: string,
|
|
65
|
+
value: string,
|
|
66
|
+
error: string,
|
|
67
|
+
invalid: boolean,
|
|
68
|
+
options: Array<OptionOfCountryOfAddressOfBookingFlowViewState>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface AddressLineOfAddressOfBookingFlowViewState {
|
|
72
|
+
shown: boolean,
|
|
73
|
+
required: boolean,
|
|
74
|
+
order: number,
|
|
75
|
+
label: string,
|
|
76
|
+
value: string,
|
|
77
|
+
error: string,
|
|
78
|
+
invalid: boolean,
|
|
79
|
+
maxLength: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface AddressLine2OfAddressOfBookingFlowViewState {
|
|
83
|
+
shown: boolean,
|
|
84
|
+
required: boolean,
|
|
85
|
+
order: number,
|
|
86
|
+
label: string,
|
|
87
|
+
value: string,
|
|
88
|
+
error: string,
|
|
89
|
+
invalid: boolean,
|
|
90
|
+
maxLength: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface StreetNameOfAddressOfBookingFlowViewState {
|
|
94
|
+
shown: boolean,
|
|
95
|
+
required: boolean,
|
|
96
|
+
order: number,
|
|
97
|
+
label: string,
|
|
98
|
+
value: string,
|
|
99
|
+
error: string,
|
|
100
|
+
invalid: boolean,
|
|
101
|
+
maxLength: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface StreetNumberOfAddressOfBookingFlowViewState {
|
|
105
|
+
shown: boolean,
|
|
106
|
+
required: boolean,
|
|
107
|
+
order: number,
|
|
108
|
+
label: string,
|
|
109
|
+
value: string,
|
|
110
|
+
error: string,
|
|
111
|
+
invalid: boolean,
|
|
112
|
+
maxLength: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface CityOfAddressOfBookingFlowViewState {
|
|
116
|
+
shown: boolean,
|
|
117
|
+
required: boolean,
|
|
118
|
+
order: number,
|
|
119
|
+
label: string,
|
|
120
|
+
value: string,
|
|
121
|
+
error: string,
|
|
122
|
+
invalid: boolean,
|
|
123
|
+
maxLength: number
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface OptionOfSubdivisionOfAddressOfBookingFlowViewState {
|
|
127
|
+
value: string,
|
|
128
|
+
label: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface SubdivisionOfAddressOfBookingFlowViewState {
|
|
132
|
+
shown: boolean,
|
|
133
|
+
listed: boolean,
|
|
134
|
+
required: boolean,
|
|
135
|
+
order: number,
|
|
136
|
+
label: string,
|
|
137
|
+
value: string,
|
|
138
|
+
error: string,
|
|
139
|
+
invalid: boolean,
|
|
140
|
+
options: Array<OptionOfSubdivisionOfAddressOfBookingFlowViewState>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface PostalCodeOfAddressOfBookingFlowViewState {
|
|
144
|
+
shown: boolean,
|
|
145
|
+
required: boolean,
|
|
146
|
+
order: number,
|
|
147
|
+
label: string,
|
|
148
|
+
value: string,
|
|
149
|
+
error: string,
|
|
150
|
+
invalid: boolean,
|
|
151
|
+
maxLength: number
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface AddressOfBookingFlowViewState {
|
|
155
|
+
present: boolean,
|
|
156
|
+
label: string,
|
|
157
|
+
required: boolean,
|
|
158
|
+
error: string,
|
|
159
|
+
invalid: boolean,
|
|
160
|
+
country: CountryOfAddressOfBookingFlowViewState,
|
|
161
|
+
addressLine: AddressLineOfAddressOfBookingFlowViewState,
|
|
162
|
+
addressLine2: AddressLine2OfAddressOfBookingFlowViewState,
|
|
163
|
+
streetName: StreetNameOfAddressOfBookingFlowViewState,
|
|
164
|
+
streetNumber: StreetNumberOfAddressOfBookingFlowViewState,
|
|
165
|
+
city: CityOfAddressOfBookingFlowViewState,
|
|
166
|
+
subdivision: SubdivisionOfAddressOfBookingFlowViewState,
|
|
167
|
+
postalCode: PostalCodeOfAddressOfBookingFlowViewState
|
|
168
|
+
}
|
|
169
|
+
|
|
56
170
|
declare enum BookingState {
|
|
57
171
|
IDLE,
|
|
58
172
|
BOOKING,
|
|
@@ -67,7 +181,8 @@ declare enum BookingFailure {
|
|
|
67
181
|
CHECKOUT_PERMISSION,
|
|
68
182
|
CHECKOUT_REDIRECT_REJECTED,
|
|
69
183
|
SITE_NOT_PUBLISHED,
|
|
70
|
-
UNKNOWN
|
|
184
|
+
UNKNOWN,
|
|
185
|
+
FORM_UNSUPPORTED
|
|
71
186
|
}
|
|
72
187
|
|
|
73
188
|
interface BookingFlowViewState {
|
|
@@ -86,6 +201,7 @@ interface BookingFlowViewState {
|
|
|
86
201
|
slotsMessage: string,
|
|
87
202
|
slotsFailure: SlotsFailure,
|
|
88
203
|
formFields: Array<FormFieldOfBookingFlowViewState>,
|
|
204
|
+
address: AddressOfBookingFlowViewState,
|
|
89
205
|
formLoading: boolean,
|
|
90
206
|
isBooking: boolean,
|
|
91
207
|
bookingStatus: string,
|
|
@@ -100,12 +216,14 @@ type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | '
|
|
|
100
216
|
services: Array<BookingFlowViewState['services'][number]>;
|
|
101
217
|
slots: Array<BookingFlowViewState['slots'][number]>;
|
|
102
218
|
formFields: Array<BookingFlowViewState['formFields'][number]>;
|
|
219
|
+
address: BookingFlowViewState['address'];
|
|
103
220
|
};
|
|
104
221
|
|
|
105
222
|
type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
|
|
106
223
|
services: Array<BookingFlowViewState['services'][number]>;
|
|
107
224
|
slots: Array<BookingFlowViewState['slots'][number]>;
|
|
108
225
|
formFields: Array<BookingFlowViewState['formFields'][number]>;
|
|
226
|
+
address: BookingFlowViewState['address'];
|
|
109
227
|
};
|
|
110
228
|
|
|
111
229
|
|
|
@@ -120,6 +238,33 @@ interface BookingFlowRefs {
|
|
|
120
238
|
},
|
|
121
239
|
formFields: {
|
|
122
240
|
formInputs: HTMLElementCollectionProxy<FormFieldOfBookingFlowViewState, HTMLInputElement>
|
|
241
|
+
},
|
|
242
|
+
address: {
|
|
243
|
+
country: {
|
|
244
|
+
input: HTMLElementProxy<CountryOfAddressOfBookingFlowViewState, HTMLSelectElement>
|
|
245
|
+
},
|
|
246
|
+
addressLine: {
|
|
247
|
+
input: HTMLElementProxy<AddressLineOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
248
|
+
},
|
|
249
|
+
addressLine2: {
|
|
250
|
+
input: HTMLElementProxy<AddressLine2OfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
251
|
+
},
|
|
252
|
+
streetName: {
|
|
253
|
+
input: HTMLElementProxy<StreetNameOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
254
|
+
},
|
|
255
|
+
streetNumber: {
|
|
256
|
+
input: HTMLElementProxy<StreetNumberOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
257
|
+
},
|
|
258
|
+
city: {
|
|
259
|
+
input: HTMLElementProxy<CityOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
260
|
+
},
|
|
261
|
+
subdivision: {
|
|
262
|
+
input: HTMLElementProxy<SubdivisionOfAddressOfBookingFlowViewState, HTMLSelectElement>,
|
|
263
|
+
text: HTMLElementProxy<SubdivisionOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
264
|
+
},
|
|
265
|
+
postalCode: {
|
|
266
|
+
input: HTMLElementProxy<PostalCodeOfAddressOfBookingFlowViewState, HTMLInputElement>
|
|
267
|
+
}
|
|
123
268
|
}
|
|
124
269
|
}
|
|
125
270
|
|
|
@@ -142,11 +287,33 @@ interface BookingSlotView {
|
|
|
142
287
|
eventId?: string;
|
|
143
288
|
serviceType: BookingServiceType;
|
|
144
289
|
}
|
|
145
|
-
|
|
290
|
+
/** A participant field bookings can render (DL #51 §3): its type plus Get Form's view data. */
|
|
291
|
+
type BookingFormFieldView = {
|
|
146
292
|
target: string;
|
|
147
293
|
label: string;
|
|
148
|
-
type: 'STRING' | 'EMAIL' | 'PHONE' | '
|
|
294
|
+
type: 'STRING' | 'EMAIL' | 'PHONE' | 'URL' | 'BOOLEAN' | 'ADDRESS';
|
|
149
295
|
required: boolean;
|
|
296
|
+
/** PHONE fields: the rules `checkPhone` uses to judge and normalize the value (DL #58). */
|
|
297
|
+
phone?: PhoneRules;
|
|
298
|
+
/** A long-text (`TEXT_AREA`) field, validated as a textarea. */
|
|
299
|
+
longText: boolean;
|
|
300
|
+
} & FieldViewData;
|
|
301
|
+
/** A participant value: a string, a boolean for a single checkbox, or an address (DL #52). */
|
|
302
|
+
type ParticipantFormValue = string | boolean | AddressValue;
|
|
303
|
+
/** The `createBooking` action input. */
|
|
304
|
+
interface CreateBookingInput {
|
|
305
|
+
serviceId: string;
|
|
306
|
+
serviceType: BookingServiceType;
|
|
307
|
+
slot: {
|
|
308
|
+
localStartDate: string;
|
|
309
|
+
localEndDate: string;
|
|
310
|
+
scheduleId?: string;
|
|
311
|
+
eventId?: string;
|
|
312
|
+
};
|
|
313
|
+
formValues: Record<string, ParticipantFormValue>;
|
|
314
|
+
timezone: string;
|
|
315
|
+
siteOrigin: string;
|
|
316
|
+
paymentPreference?: 'ONLINE' | 'OFFLINE';
|
|
150
317
|
}
|
|
151
318
|
type CreateBookingOutcome =
|
|
152
319
|
/** Booked with nothing to pay: `orderId` is the placed order (Wix's thank-you page is /thank-you-page/<orderId>). */
|
|
@@ -156,6 +323,26 @@ type CreateBookingOutcome =
|
|
|
156
323
|
} | {
|
|
157
324
|
outcome: 'redirect';
|
|
158
325
|
redirectUrl: string;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Server validation failed (DL #51 §4): key = field target, or `<target>/<part>` for an address
|
|
329
|
+
* part (DL #52); value = the message; ≥1 entry.
|
|
330
|
+
*/
|
|
331
|
+
| {
|
|
332
|
+
outcome: 'invalid';
|
|
333
|
+
fieldErrors: Record<string, string>;
|
|
334
|
+
/** `<target>/subdivision` → the codes Wix accepts, learned from this 400 (DL #52 Q6). */
|
|
335
|
+
fieldOptions?: Record<string, FormFieldOptionView[]>;
|
|
336
|
+
/** target → parts Wix required that the layout hid (DL #52 Q17). */
|
|
337
|
+
revealedParts?: Record<string, LayoutPart[]>;
|
|
338
|
+
/** target → the submitted country the learned facts belong to. */
|
|
339
|
+
factsCountry?: Record<string, string>;
|
|
340
|
+
}
|
|
341
|
+
/** The participant form cannot be booked: never retry FORM_UNSUPPORTED (DL #51 §4). */
|
|
342
|
+
| {
|
|
343
|
+
outcome: 'formUnavailable';
|
|
344
|
+
failure: 'FORM_UNSUPPORTED' | 'FORM_UNAVAILABLE';
|
|
345
|
+
message: string;
|
|
159
346
|
};
|
|
160
347
|
|
|
161
348
|
interface WixBookingsService {
|
|
@@ -166,20 +353,16 @@ interface WixBookingsService {
|
|
|
166
353
|
timezone?: string;
|
|
167
354
|
windowDays?: number;
|
|
168
355
|
}): Promise<BookingSlotView[]>;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
timezone: string;
|
|
180
|
-
siteOrigin: string;
|
|
181
|
-
paymentPreference?: 'ONLINE' | 'OFFLINE';
|
|
182
|
-
}): Promise<CreateBookingOutcome>;
|
|
356
|
+
/**
|
|
357
|
+
* The service's participant form from Get Form (DL #51 §3), in layout order, with the fields
|
|
358
|
+
* bookings cannot show. Throws for a missing service or form, an invalid form id, or a Wix failure.
|
|
359
|
+
*/
|
|
360
|
+
getParticipantForm(serviceId: string, forms: WixFormsService): Promise<ProjectedForm<BookingFormFieldView>>;
|
|
361
|
+
/**
|
|
362
|
+
* Re-validates the participant values against Get Form (DL #51 §4), then books and checks
|
|
363
|
+
* out. Form problems are returned as `invalid` / `formUnavailable`, never thrown.
|
|
364
|
+
*/
|
|
365
|
+
createBooking(input: CreateBookingInput, forms: WixFormsService): Promise<CreateBookingOutcome>;
|
|
183
366
|
}
|
|
184
367
|
declare const WIX_BOOKINGS_SERVICE: _jay_framework_fullstack_component.ServiceMarker<WixBookingsService>;
|
|
185
368
|
|
|
@@ -210,33 +393,16 @@ declare const listSlots: _jay_framework_fullstack_component.JayAction<{
|
|
|
210
393
|
}, {
|
|
211
394
|
slots: BookingSlotView[];
|
|
212
395
|
}, [WixBookingsService]>;
|
|
213
|
-
|
|
396
|
+
/**
|
|
397
|
+
* The service's participant form from Get Form (DL #51 §3). The form id comes only from the
|
|
398
|
+
* service, so a page cannot point it at another form; the result is what Wix's own form shows.
|
|
399
|
+
*/
|
|
400
|
+
declare const getParticipantForm: _jay_framework_fullstack_component.JayAction<{
|
|
214
401
|
serviceId: string;
|
|
215
|
-
|
|
216
|
-
slot: {
|
|
217
|
-
localStartDate: string;
|
|
218
|
-
localEndDate: string;
|
|
219
|
-
scheduleId?: string;
|
|
220
|
-
eventId?: string;
|
|
221
|
-
};
|
|
222
|
-
formValues: Record<string, string>;
|
|
223
|
-
timezone: string;
|
|
224
|
-
siteOrigin: string;
|
|
225
|
-
paymentPreference?: "ONLINE" | "OFFLINE";
|
|
226
|
-
}, CreateBookingOutcome> & _jay_framework_fullstack_component.JayActionDefinition<{
|
|
402
|
+
}, _jay_framework_wix_forms.ProjectedForm<BookingFormFieldView>> & _jay_framework_fullstack_component.JayActionDefinition<{
|
|
227
403
|
serviceId: string;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
localStartDate: string;
|
|
231
|
-
localEndDate: string;
|
|
232
|
-
scheduleId?: string;
|
|
233
|
-
eventId?: string;
|
|
234
|
-
};
|
|
235
|
-
formValues: Record<string, string>;
|
|
236
|
-
timezone: string;
|
|
237
|
-
siteOrigin: string;
|
|
238
|
-
paymentPreference?: "ONLINE" | "OFFLINE";
|
|
239
|
-
}, CreateBookingOutcome, [WixBookingsService]>;
|
|
404
|
+
}, _jay_framework_wix_forms.ProjectedForm<BookingFormFieldView>, [WixBookingsService, _jay_framework_wix_forms.WixFormsService]>;
|
|
405
|
+
declare const createBooking: _jay_framework_fullstack_component.JayAction<CreateBookingInput, CreateBookingOutcome> & _jay_framework_fullstack_component.JayActionDefinition<CreateBookingInput, CreateBookingOutcome, [WixBookingsService, _jay_framework_wix_forms.WixFormsService]>;
|
|
240
406
|
|
|
241
407
|
interface ServiceForm {
|
|
242
408
|
id?: string;
|
|
@@ -344,8 +510,12 @@ interface WixBookingsContext {
|
|
|
344
510
|
serviceById(id: string): Promise<RawBookingService | undefined>;
|
|
345
511
|
/** Class sessions (and appointment openings) in a local date range, as Wix's calendar queries them. */
|
|
346
512
|
timeSlots(query: TimeSlotsQuery): Promise<TimeSlot[]>;
|
|
347
|
-
/**
|
|
348
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Create the booking and continue to checkout (or confirm a free booking), as the server action does,
|
|
515
|
+
* but without its participant-form checks (DL #51 §4): there is no server, and the visitor's own client
|
|
516
|
+
* can call Wix directly anyway. Validate the form on the page.
|
|
517
|
+
*/
|
|
518
|
+
createBooking(input: CreateBookingInput): Promise<CreateBookingOutcome>;
|
|
349
519
|
/**
|
|
350
520
|
* A placed order (a confirmed booking's `orderId`) as its buyer reads it, with the texts Wix's thank-you page
|
|
351
521
|
* shows; undefined for anyone else.
|
|
@@ -411,4 +581,4 @@ interface BookingOrder {
|
|
|
411
581
|
declare const WIX_BOOKINGS_CONTEXT: _jay_framework_runtime.ContextMarker<WixBookingsContext>;
|
|
412
582
|
declare function createWixBookingsContext(wixClient: WixClient, config: WixBookingsConfig): WixBookingsContext;
|
|
413
583
|
|
|
414
|
-
export { type BookingServiceView as B, type
|
|
584
|
+
export { type BookingServiceView as B, type CreateBookingInput as C, type ParticipantFormValue as P, 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, getParticipantForm as g, type BookingFormFieldView as h, init as i, type CreateBookingOutcome as j, WIX_BOOKINGS_CONTEXT as k, listServices as l, canBookOnline as m, createWixBookingsContext as n, type BookingFeatures as o, type BookingStep as p, type TimeSlotsQuery as q, type WixBookingsContext as r, type BookingOrder as s };
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { o as BookingFeatures, h as BookingFormFieldView, s as BookingOrder, B as BookingServiceView, f as BookingSlotView, p as BookingStep, C as CreateBookingInput, j as CreateBookingOutcome, P as ParticipantFormValue, T as TimeSlot, q as TimeSlotsQuery, k as WIX_BOOKINGS_CONTEXT, r as WixBookingsContext, b as bookingFlow, m as canBookOnline, d as createBooking, n as createWixBookingsContext, g as getParticipantForm, i as init, l as listServices, c as listSlots } from './index.client-BzhFjOWZ.js';
|
|
2
2
|
import '@jay-framework/fullstack-component';
|
|
3
3
|
import '@jay-framework/component';
|
|
4
4
|
import '@jay-framework/runtime';
|
|
5
|
+
import '@jay-framework/wix-forms';
|
|
5
6
|
import '@wix/sdk';
|