@jay-framework/wix-bookings 0.25.5 → 0.26.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.
@@ -0,0 +1,67 @@
1
+ # wix-bookings — dashboard-managed content
2
+
3
+ **Plugin** `@jay-framework/wix-bookings` · **contract** `booking-flow`.
4
+
5
+ Service data (name, tagline, description, price, duration, staff, images) is managed in the **Wix dashboard**. When asked to change it: **do not edit code.** Identify the service with the steps below. **Never write without a service id from these steps** — a wrong id changes, or sends the site owner to, the wrong service. When a step doesn't give a clear answer, use a [fallback](#fallbacks): it gives the services-list link and never writes.
6
+
7
+ **Mixed requests** (e.g. "rename this service and make the card bigger"): edit the jay-html part normally, and handle the service data part with the steps below.
8
+
9
+ ## Agent behavior
10
+
11
+ ### Reply style
12
+
13
+ Keep replies to the site owner **short and simple** (about 1–3 sentences). They are often non-technical — use everyday words and a visual or business angle. Say **what** changed or **where** they can change the service in Wix. Do **not** put file paths, code, binding syntax, or service ids in the thread reply (use ids only in tools and in the steps below).
14
+
15
+ ### Update data or send a link
16
+
17
+ - **Try to update** the service when you are **confident** you have the right service id (step 1), the request is **unambiguous**, and you have a **Wix API or tool** that can apply the change. After a successful update, confirm in plain language and include the dashboard link from step 3 so they can review.
18
+ - If you are **not** confident, the request is **ambiguous**, or you **lack** a working update tool → **do not write**. Build the dashboard link when you can and tell them where to edit the service in Wix.
19
+ - If an update **fails** → say so briefly and give the dashboard link.
20
+
21
+ Do not hard-code service fields into jay-html.
22
+
23
+ ### Ambiguity and area markers
24
+
25
+ A screenshot may show **several services** inside one **area marker**, but inspect returns **one** `Target source` (one element, at most **one** service id from step 1).
26
+
27
+ When you are unsure — several services visible, the comment does not name which one, “change these” without naming each, or the resolved id may not match what they meant — **do not write**. Explain briefly what you see, which service (if any) the mark resolved to, and **ask them to clarify** (name the service, say “both”, or mark one service at a time). Use the [services list](#fallbacks) when several services might be in scope; use a single-service link only when step 1 gave one clear id. Do not look up a service id by name alone (step 2).
28
+
29
+ ## What you get
30
+
31
+ When the user clicks an element in the editor, you get the **source-editing inspector result**: `file` (the page jay-html), `node` (the clicked element: `lines`, `tag`, `html` — its open tag, attributes and own text) and `stack` — enclosing frames, **innermost → outermost**:
32
+
33
+ - `{ kind: 'forEach', lines, itemId }` — a repeated item; `itemId` is the value of its `trackBy`.
34
+ - `{ kind: 'region', lines, name, props? }` — a `<jay:NAME …>` instance.
35
+
36
+ All `lines` are 1-based ranges in `file`. The contract is added as a page script — `<script type="application/jay-headless" plugin="@jay-framework/wix-bookings" contract="booking-flow" key="K">` — or as a `<jay:booking-flow>` instance (a `region` frame named `booking-flow`; its lists then appear without the `K.` prefix).
37
+
38
+ No inspector result → fallback.
39
+
40
+ ## Steps
41
+
42
+ 1. **Find the service id.** Go through the `forEach` frames in `stack`, innermost first; read the element in `file` at the frame's `lines`:
43
+
44
+ | `forEach` attribute | `trackBy` | `itemId` is |
45
+ |---------------------|-----------|-------------|
46
+ | `K.services` (or `services` inside a `booking-flow` region) | `id` | service id |
47
+
48
+ Use the first match. `slots` and `formFields` frames are **not** services — skip them and keep going outward.
49
+ 2. **No match** — the click is on the slot picker, the booking form, or the selected service's name (`{K.selectedServiceName}`): there is **no service id** in the inspector result. Don't look one up by name. Use the services-list link and name the service from the visible text.
50
+ 3. **Build the link** with `wix-server-client/getDashboardUrl`: service → `{ "path": "bookings/services/form/<serviceId>" }`. Run from the project root: `npx jay-stack-cli action wix-server-client/getDashboardUrl --input '{"path":"bookings/services/form/<serviceId>"}'`; the output's `url` is the link. Never read `config/.wix.yaml` or other credential files to build it.
51
+ 4. **Reply** (see [Agent behavior](#agent-behavior)): plain language only — e.g. “This service is set up in your Wix Bookings dashboard; you can change the name here: <url>” or “I updated the service name to …; you can review it here: <url>”.
52
+
53
+ ## Fallbacks
54
+
55
+ Give the services-list link — path `bookings/services` — and say you couldn't identify the specific service. Also use it for "add a service".
56
+
57
+ Fall back when: there is no inspector result; no `services` frame matches; or its `trackBy` isn't `id`.
58
+
59
+ If `wix-server-client/getDashboardUrl` itself fails, give no link: say services are managed in the Wix dashboard (Booking Services) and that you couldn't build the link.
60
+
61
+ ## Not editable content
62
+
63
+ Time slots, the selected slot and the participant form state are **live booking-flow state**, not site content. Edit no code and no data. Reply in plain language that this is live availability, not something you can edit on the page — suggest changing hours or staff in Bookings, or the page design in the template if they meant how it looks. Add the service link if step 1 found an id, otherwise the services-list link.
64
+
65
+ ## Not dashboard content
66
+
67
+ Layout, CSS and markup live in jay-html — edit those normally.
@@ -74,6 +74,31 @@ The Wix site must be **published** — hosted checkout uses the published site.
74
74
  </jay:booking-flow>
75
75
  ```
76
76
 
77
+ ## Outcomes — write your own copy
78
+
79
+ The plugin reports **what happened** through enum variants; the string tags are English **defaults**. For your own wording or another language, branch on the variant and write the text in jay-html. Never detect an outcome by testing or matching a string.
80
+
81
+ | Variant | Members | Default text in |
82
+ | ------- | ------- | --------------- |
83
+ | `servicesFailure` | `NONE`, `PERMISSION` (Bookings API 403), `UNKNOWN` | `servicesError` |
84
+ | `slotsFailure` | `NONE`, `UNKNOWN` (loading availability failed) | `slotsMessage` |
85
+ | `bookingState` | `IDLE`, `BOOKING`, `CONFIRMED`, `FAILED` | `bookingStatus` (on `CONFIRMED`) |
86
+ | `bookingFailure` | `NONE`, `VALIDATION`, `FORM_UNAVAILABLE`, `CHECKOUT_PERMISSION`, `CHECKOUT_REDIRECT_REJECTED`, `SITE_NOT_PUBLISHED`, `UNKNOWN` | `bookingError` |
87
+
88
+ - **No available times** is not a failure: `!hasSlots` with `slotsFailure === NONE` (and `!slotsLoading`).
89
+ - `VALIDATION`: the participant form failed a check; `bookingError` names the field (English template, Wix label).
90
+ - `CHECKOUT_PERMISSION`, `CHECKOUT_REDIRECT_REJECTED`, `SITE_NOT_PUBLISHED` are **setup** problems (see the troubleshooting guide). Show visitors a neutral line; the default text is a hint for the site owner.
91
+
92
+ ```html
93
+ <p if="servicesFailure === PERMISSION">Les réservations sont momentanément indisponibles.</p>
94
+ <p if="!slotsLoading && !hasSlots && slotsFailure === NONE">Aucun créneau dans les 14 prochains jours.</p>
95
+ <p if="bookingState === CONFIRMED">Réservation confirmée !</p>
96
+ <p if="bookingFailure === VALIDATION">Vérifiez vos informations.</p>
97
+ <p if="bookingFailure === UNKNOWN">La réservation a échoué. Réessayez.</p>
98
+ ```
99
+
100
+ With a page-script import (`key="booking"`), prefix the tags: `booking.bookingState`.
101
+
77
102
  ## Server flow
78
103
 
79
104
  ```
@@ -37,6 +37,13 @@ tags:
37
37
  type: data
38
38
  dataType: string
39
39
  phase: fast+interactive
40
+ description: English default text; branch on servicesFailure for your own copy
41
+
42
+ - tag: servicesFailure
43
+ type: variant
44
+ dataType: enum (NONE | PERMISSION | UNKNOWN)
45
+ phase: fast+interactive
46
+ description: Why listing services failed (NONE when it did not)
40
47
 
41
48
  - tag: showServices
42
49
  type: variant
@@ -81,6 +88,13 @@ tags:
81
88
  type: data
82
89
  dataType: string
83
90
  phase: fast+interactive
91
+ description: English default text (a load error, or no available times)
92
+
93
+ - tag: slotsFailure
94
+ type: variant
95
+ dataType: enum (NONE | UNKNOWN)
96
+ phase: fast+interactive
97
+ description: Whether loading availability failed; no times with NONE means none are available
84
98
 
85
99
  - tag: formFields
86
100
  type: sub-contract
@@ -108,11 +122,24 @@ tags:
108
122
  type: data
109
123
  dataType: string
110
124
  phase: fast+interactive
125
+ description: English default text on confirmation; branch on bookingState for your own copy
111
126
 
112
127
  - tag: bookingError
113
128
  type: data
114
129
  dataType: string
115
130
  phase: fast+interactive
131
+ description: English default text on failure; branch on bookingFailure for your own copy
132
+
133
+ - tag: bookingState
134
+ type: variant
135
+ dataType: enum (IDLE | BOOKING | CONFIRMED | FAILED)
136
+ phase: fast+interactive
137
+
138
+ - tag: bookingFailure
139
+ type: variant
140
+ dataType: enum (NONE | VALIDATION | FORM_UNAVAILABLE | CHECKOUT_PERMISSION | CHECKOUT_REDIRECT_REJECTED | SITE_NOT_PUBLISHED | UNKNOWN)
141
+ phase: fast+interactive
142
+ description: Why the participant form or the booking failed (NONE when it did not)
116
143
 
117
144
  - tag: bookButton
118
145
  type: interactive
@@ -11,6 +11,12 @@ export interface ServiceOfBookingFlowViewState {
11
11
  formId: string
12
12
  }
13
13
 
14
+ export enum ServicesFailure {
15
+ NONE,
16
+ PERMISSION,
17
+ UNKNOWN
18
+ }
19
+
14
20
  export interface SlotOfBookingFlowViewState {
15
21
  id: string,
16
22
  label: string,
@@ -20,6 +26,11 @@ export interface SlotOfBookingFlowViewState {
20
26
  eventId: string
21
27
  }
22
28
 
29
+ export enum SlotsFailure {
30
+ NONE,
31
+ UNKNOWN
32
+ }
33
+
23
34
  export interface FormFieldOfBookingFlowViewState {
24
35
  target: string,
25
36
  label: string,
@@ -27,12 +38,30 @@ export interface FormFieldOfBookingFlowViewState {
27
38
  required: boolean
28
39
  }
29
40
 
41
+ export enum BookingState {
42
+ IDLE,
43
+ BOOKING,
44
+ CONFIRMED,
45
+ FAILED
46
+ }
47
+
48
+ export enum BookingFailure {
49
+ NONE,
50
+ VALIDATION,
51
+ FORM_UNAVAILABLE,
52
+ CHECKOUT_PERMISSION,
53
+ CHECKOUT_REDIRECT_REJECTED,
54
+ SITE_NOT_PUBLISHED,
55
+ UNKNOWN
56
+ }
57
+
30
58
  export interface BookingFlowViewState {
31
59
  services: Array<ServiceOfBookingFlowViewState>,
32
60
  servicesLoading: boolean,
33
61
  showNoServices: boolean,
34
62
  hasSlots: boolean,
35
63
  servicesError: string,
64
+ servicesFailure: ServicesFailure,
36
65
  showServices: boolean,
37
66
  showSlots: boolean,
38
67
  showForm: boolean,
@@ -40,22 +69,25 @@ export interface BookingFlowViewState {
40
69
  slots: Array<SlotOfBookingFlowViewState>,
41
70
  slotsLoading: boolean,
42
71
  slotsMessage: string,
72
+ slotsFailure: SlotsFailure,
43
73
  formFields: Array<FormFieldOfBookingFlowViewState>,
44
74
  formLoading: boolean,
45
75
  isBooking: boolean,
46
76
  bookingStatus: string,
47
- bookingError: string
77
+ bookingError: string,
78
+ bookingState: BookingState,
79
+ bookingFailure: BookingFailure
48
80
  }
49
81
 
50
82
  export type BookingFlowSlowViewState = {};
51
83
 
52
- export type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
84
+ export type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
53
85
  services: Array<BookingFlowViewState['services'][number]>;
54
86
  slots: Array<BookingFlowViewState['slots'][number]>;
55
87
  formFields: Array<BookingFlowViewState['formFields'][number]>;
56
88
  };
57
89
 
58
- export type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
90
+ export type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
59
91
  services: Array<BookingFlowViewState['services'][number]>;
60
92
  slots: Array<BookingFlowViewState['slots'][number]>;
61
93
  formFields: Array<BookingFlowViewState['formFields'][number]>;
@@ -26,6 +26,12 @@ interface ServiceOfBookingFlowViewState {
26
26
  formId: string
27
27
  }
28
28
 
29
+ declare enum ServicesFailure {
30
+ NONE,
31
+ PERMISSION,
32
+ UNKNOWN
33
+ }
34
+
29
35
  interface SlotOfBookingFlowViewState {
30
36
  id: string,
31
37
  label: string,
@@ -35,6 +41,11 @@ interface SlotOfBookingFlowViewState {
35
41
  eventId: string
36
42
  }
37
43
 
44
+ declare enum SlotsFailure {
45
+ NONE,
46
+ UNKNOWN
47
+ }
48
+
38
49
  interface FormFieldOfBookingFlowViewState {
39
50
  target: string,
40
51
  label: string,
@@ -42,12 +53,30 @@ interface FormFieldOfBookingFlowViewState {
42
53
  required: boolean
43
54
  }
44
55
 
56
+ declare enum BookingState {
57
+ IDLE,
58
+ BOOKING,
59
+ CONFIRMED,
60
+ FAILED
61
+ }
62
+
63
+ declare enum BookingFailure {
64
+ NONE,
65
+ VALIDATION,
66
+ FORM_UNAVAILABLE,
67
+ CHECKOUT_PERMISSION,
68
+ CHECKOUT_REDIRECT_REJECTED,
69
+ SITE_NOT_PUBLISHED,
70
+ UNKNOWN
71
+ }
72
+
45
73
  interface BookingFlowViewState {
46
74
  services: Array<ServiceOfBookingFlowViewState>,
47
75
  servicesLoading: boolean,
48
76
  showNoServices: boolean,
49
77
  hasSlots: boolean,
50
78
  servicesError: string,
79
+ servicesFailure: ServicesFailure,
51
80
  showServices: boolean,
52
81
  showSlots: boolean,
53
82
  showForm: boolean,
@@ -55,22 +84,25 @@ interface BookingFlowViewState {
55
84
  slots: Array<SlotOfBookingFlowViewState>,
56
85
  slotsLoading: boolean,
57
86
  slotsMessage: string,
87
+ slotsFailure: SlotsFailure,
58
88
  formFields: Array<FormFieldOfBookingFlowViewState>,
59
89
  formLoading: boolean,
60
90
  isBooking: boolean,
61
91
  bookingStatus: string,
62
- bookingError: string
92
+ bookingError: string,
93
+ bookingState: BookingState,
94
+ bookingFailure: BookingFailure
63
95
  }
64
96
 
65
97
  type BookingFlowSlowViewState = {};
66
98
 
67
- type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
99
+ type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
68
100
  services: Array<BookingFlowViewState['services'][number]>;
69
101
  slots: Array<BookingFlowViewState['slots'][number]>;
70
102
  formFields: Array<BookingFlowViewState['formFields'][number]>;
71
103
  };
72
104
 
73
- type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
105
+ type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
74
106
  services: Array<BookingFlowViewState['services'][number]>;
75
107
  slots: Array<BookingFlowViewState['slots'][number]>;
76
108
  formFields: Array<BookingFlowViewState['formFields'][number]>;
@@ -154,6 +186,7 @@ declare const WIX_BOOKINGS_SERVICE: _jay_framework_fullstack_component.ServiceMa
154
186
  interface BookingFlowCarryForward {
155
187
  services: BookingServiceView[];
156
188
  servicesError?: string;
189
+ servicesFailure?: ServicesFailure;
157
190
  }
158
191
  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
192
 
@@ -1,4 +1,4 @@
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';
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-gTd3Cezm.js';
2
2
  import '@jay-framework/fullstack-component';
3
3
  import '@jay-framework/component';
4
4
  import '@jay-framework/runtime';