@jay-framework/wix-bookings 0.25.4 → 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.
- package/agent-kit/designer/wix-bookings-dashboard-content.md +67 -0
- package/agent-kit/plugin/wix-bookings-setup.md +25 -0
- package/dist/{config-loader-C7I2yXpp.js → config-loader-sfgwfXPV.js} +3 -2
- package/dist/contracts/booking-flow.jay-contract +27 -0
- package/dist/contracts/booking-flow.jay-contract.d.ts +35 -3
- package/dist/index.client-gTd3Cezm.d.ts +411 -0
- package/dist/index.client.d.ts +2 -1
- package/dist/index.client.js +1092 -118
- package/dist/index.d.ts +2 -9
- package/dist/index.js +197 -24
- package/dist/tools.js +1 -1
- package/package.json +20 -17
- package/plugin.yaml +1 -0
- package/dist/index.client-CBlxQDjy.d.ts +0 -194
|
@@ -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
|
```
|
|
@@ -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
|
|
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
|
|
@@ -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]>;
|
|
@@ -0,0 +1,411 @@
|
|
|
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
|
+
declare enum ServicesFailure {
|
|
30
|
+
NONE,
|
|
31
|
+
PERMISSION,
|
|
32
|
+
UNKNOWN
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface SlotOfBookingFlowViewState {
|
|
36
|
+
id: string,
|
|
37
|
+
label: string,
|
|
38
|
+
localStartDate: string,
|
|
39
|
+
localEndDate: string,
|
|
40
|
+
scheduleId: string,
|
|
41
|
+
eventId: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare enum SlotsFailure {
|
|
45
|
+
NONE,
|
|
46
|
+
UNKNOWN
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface FormFieldOfBookingFlowViewState {
|
|
50
|
+
target: string,
|
|
51
|
+
label: string,
|
|
52
|
+
type: string,
|
|
53
|
+
required: boolean
|
|
54
|
+
}
|
|
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
|
+
|
|
73
|
+
interface BookingFlowViewState {
|
|
74
|
+
services: Array<ServiceOfBookingFlowViewState>,
|
|
75
|
+
servicesLoading: boolean,
|
|
76
|
+
showNoServices: boolean,
|
|
77
|
+
hasSlots: boolean,
|
|
78
|
+
servicesError: string,
|
|
79
|
+
servicesFailure: ServicesFailure,
|
|
80
|
+
showServices: boolean,
|
|
81
|
+
showSlots: boolean,
|
|
82
|
+
showForm: boolean,
|
|
83
|
+
selectedServiceName: string,
|
|
84
|
+
slots: Array<SlotOfBookingFlowViewState>,
|
|
85
|
+
slotsLoading: boolean,
|
|
86
|
+
slotsMessage: string,
|
|
87
|
+
slotsFailure: SlotsFailure,
|
|
88
|
+
formFields: Array<FormFieldOfBookingFlowViewState>,
|
|
89
|
+
formLoading: boolean,
|
|
90
|
+
isBooking: boolean,
|
|
91
|
+
bookingStatus: string,
|
|
92
|
+
bookingError: string,
|
|
93
|
+
bookingState: BookingState,
|
|
94
|
+
bookingFailure: BookingFailure
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type BookingFlowSlowViewState = {};
|
|
98
|
+
|
|
99
|
+
type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
|
|
100
|
+
services: Array<BookingFlowViewState['services'][number]>;
|
|
101
|
+
slots: Array<BookingFlowViewState['slots'][number]>;
|
|
102
|
+
formFields: Array<BookingFlowViewState['formFields'][number]>;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'servicesFailure' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'slotsFailure' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError' | 'bookingState' | 'bookingFailure'> & {
|
|
106
|
+
services: Array<BookingFlowViewState['services'][number]>;
|
|
107
|
+
slots: Array<BookingFlowViewState['slots'][number]>;
|
|
108
|
+
formFields: Array<BookingFlowViewState['formFields'][number]>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
interface BookingFlowRefs {
|
|
113
|
+
bookButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
|
|
114
|
+
backButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
|
|
115
|
+
services: {
|
|
116
|
+
serviceButtons: HTMLElementCollectionProxy<ServiceOfBookingFlowViewState, HTMLButtonElement>
|
|
117
|
+
},
|
|
118
|
+
slots: {
|
|
119
|
+
slotButtons: HTMLElementCollectionProxy<SlotOfBookingFlowViewState, HTMLButtonElement>
|
|
120
|
+
},
|
|
121
|
+
formFields: {
|
|
122
|
+
formInputs: HTMLElementCollectionProxy<FormFieldOfBookingFlowViewState, HTMLInputElement>
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type BookingServiceType = 'APPOINTMENT' | 'CLASS';
|
|
127
|
+
interface BookingServiceView {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
type: BookingServiceType;
|
|
131
|
+
description: string;
|
|
132
|
+
priceLabel: string;
|
|
133
|
+
durationLabel: string;
|
|
134
|
+
formId: string;
|
|
135
|
+
}
|
|
136
|
+
interface BookingSlotView {
|
|
137
|
+
id: string;
|
|
138
|
+
localStartDate: string;
|
|
139
|
+
localEndDate: string;
|
|
140
|
+
label: string;
|
|
141
|
+
scheduleId?: string;
|
|
142
|
+
eventId?: string;
|
|
143
|
+
serviceType: BookingServiceType;
|
|
144
|
+
}
|
|
145
|
+
interface BookingFormFieldView {
|
|
146
|
+
target: string;
|
|
147
|
+
label: string;
|
|
148
|
+
type: 'STRING' | 'EMAIL' | 'PHONE' | 'NUMBER' | 'URL';
|
|
149
|
+
required: boolean;
|
|
150
|
+
}
|
|
151
|
+
type CreateBookingOutcome =
|
|
152
|
+
/** Booked with nothing to pay: `orderId` is the placed order (Wix's thank-you page is /thank-you-page/<orderId>). */
|
|
153
|
+
{
|
|
154
|
+
outcome: 'confirmed';
|
|
155
|
+
orderId?: string;
|
|
156
|
+
} | {
|
|
157
|
+
outcome: 'redirect';
|
|
158
|
+
redirectUrl: string;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
interface WixBookingsService {
|
|
162
|
+
listServices(): Promise<BookingServiceView[]>;
|
|
163
|
+
listSlots(input: {
|
|
164
|
+
serviceId: string;
|
|
165
|
+
serviceType: BookingServiceType;
|
|
166
|
+
timezone?: string;
|
|
167
|
+
windowDays?: number;
|
|
168
|
+
}): Promise<BookingSlotView[]>;
|
|
169
|
+
createBooking(input: {
|
|
170
|
+
serviceId: string;
|
|
171
|
+
serviceType: BookingServiceType;
|
|
172
|
+
slot: {
|
|
173
|
+
localStartDate: string;
|
|
174
|
+
localEndDate: string;
|
|
175
|
+
scheduleId?: string;
|
|
176
|
+
eventId?: string;
|
|
177
|
+
};
|
|
178
|
+
formValues: Record<string, string>;
|
|
179
|
+
timezone: string;
|
|
180
|
+
siteOrigin: string;
|
|
181
|
+
paymentPreference?: 'ONLINE' | 'OFFLINE';
|
|
182
|
+
}): Promise<CreateBookingOutcome>;
|
|
183
|
+
}
|
|
184
|
+
declare const WIX_BOOKINGS_SERVICE: _jay_framework_fullstack_component.ServiceMarker<WixBookingsService>;
|
|
185
|
+
|
|
186
|
+
interface BookingFlowCarryForward {
|
|
187
|
+
services: BookingServiceView[];
|
|
188
|
+
servicesError?: string;
|
|
189
|
+
servicesFailure?: ServicesFailure;
|
|
190
|
+
}
|
|
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>>;
|
|
192
|
+
|
|
193
|
+
declare const listServices: _jay_framework_fullstack_component.JayAction<Record<string, never>, {
|
|
194
|
+
services: BookingServiceView[];
|
|
195
|
+
}> & _jay_framework_fullstack_component.JayActionDefinition<Record<string, never>, {
|
|
196
|
+
services: BookingServiceView[];
|
|
197
|
+
}, [WixBookingsService]>;
|
|
198
|
+
declare const listSlots: _jay_framework_fullstack_component.JayAction<{
|
|
199
|
+
serviceId: string;
|
|
200
|
+
serviceType: "APPOINTMENT" | "CLASS";
|
|
201
|
+
timezone?: string;
|
|
202
|
+
windowDays?: number;
|
|
203
|
+
}, {
|
|
204
|
+
slots: BookingSlotView[];
|
|
205
|
+
}> & _jay_framework_fullstack_component.JayActionDefinition<{
|
|
206
|
+
serviceId: string;
|
|
207
|
+
serviceType: "APPOINTMENT" | "CLASS";
|
|
208
|
+
timezone?: string;
|
|
209
|
+
windowDays?: number;
|
|
210
|
+
}, {
|
|
211
|
+
slots: BookingSlotView[];
|
|
212
|
+
}, [WixBookingsService]>;
|
|
213
|
+
declare const createBooking: _jay_framework_fullstack_component.JayAction<{
|
|
214
|
+
serviceId: string;
|
|
215
|
+
serviceType: "APPOINTMENT" | "CLASS";
|
|
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<{
|
|
227
|
+
serviceId: string;
|
|
228
|
+
serviceType: "APPOINTMENT" | "CLASS";
|
|
229
|
+
slot: {
|
|
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]>;
|
|
240
|
+
|
|
241
|
+
interface RawBookingService {
|
|
242
|
+
_id?: string;
|
|
243
|
+
id?: string;
|
|
244
|
+
name?: string;
|
|
245
|
+
type?: string;
|
|
246
|
+
description?: string;
|
|
247
|
+
hidden?: boolean;
|
|
248
|
+
payment?: {
|
|
249
|
+
fixed?: {
|
|
250
|
+
price?: {
|
|
251
|
+
currency?: string;
|
|
252
|
+
value?: string;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
options?: {
|
|
256
|
+
online?: boolean;
|
|
257
|
+
inPerson?: boolean;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
schedule?: {
|
|
261
|
+
availabilityConstraints?: {
|
|
262
|
+
sessionDurations?: number[];
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
form?: {
|
|
266
|
+
_id?: string;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Bookings in the browser, with the visitor's (or member's) own Wix client: for sites served without a Jay
|
|
272
|
+
* server (a static export), where the server actions cannot run. Visitor tokens may query services and
|
|
273
|
+
* availability and create bookings and checkouts, as Wix's own booking widgets do.
|
|
274
|
+
*/
|
|
275
|
+
/** Which booking features the site's plan includes (`bookings-settings` FEATURES). */
|
|
276
|
+
interface BookingFeatures {
|
|
277
|
+
/** CLASS services */
|
|
278
|
+
groups: boolean;
|
|
279
|
+
/** APPOINTMENT services */
|
|
280
|
+
appointments: boolean;
|
|
281
|
+
/** COURSE services */
|
|
282
|
+
courses: boolean;
|
|
283
|
+
payments: boolean;
|
|
284
|
+
}
|
|
285
|
+
type BookingStep = 'serviceList' | 'calendar' | 'form';
|
|
286
|
+
/**
|
|
287
|
+
* Whether Wix lets a visitor go on with a service at a booking step, as its widgets decide: a service type the
|
|
288
|
+
* site's plan does not include stops the visitor ("not yet available for online bookings"). The service list
|
|
289
|
+
* and service page let courses through (they start at the form); the form checks every type.
|
|
290
|
+
*/
|
|
291
|
+
declare function canBookOnline(features: BookingFeatures, type: BookingServiceType | 'COURSE', step: BookingStep): boolean;
|
|
292
|
+
/** One time slot as `service-availability` returns it (the fields Wix's calendar uses). */
|
|
293
|
+
interface TimeSlot {
|
|
294
|
+
serviceId?: string;
|
|
295
|
+
localStartDate?: string;
|
|
296
|
+
localEndDate?: string;
|
|
297
|
+
bookable?: boolean;
|
|
298
|
+
totalCapacity?: number;
|
|
299
|
+
remainingCapacity?: number;
|
|
300
|
+
bookableCapacity?: number;
|
|
301
|
+
eventInfo?: {
|
|
302
|
+
eventId?: string;
|
|
303
|
+
};
|
|
304
|
+
location?: {
|
|
305
|
+
id?: string;
|
|
306
|
+
name?: string;
|
|
307
|
+
formattedAddress?: string;
|
|
308
|
+
locationType?: string;
|
|
309
|
+
};
|
|
310
|
+
availableResources?: {
|
|
311
|
+
resourceTypeId?: string;
|
|
312
|
+
resources?: {
|
|
313
|
+
id?: string;
|
|
314
|
+
name?: string;
|
|
315
|
+
}[];
|
|
316
|
+
}[];
|
|
317
|
+
bookingPolicyViolations?: {
|
|
318
|
+
tooEarlyToBook?: boolean;
|
|
319
|
+
tooLateToBook?: boolean;
|
|
320
|
+
bookOnlineDisabled?: boolean;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
interface TimeSlotsQuery {
|
|
324
|
+
serviceIds: string[];
|
|
325
|
+
timeZone: string;
|
|
326
|
+
fromLocalDate: string;
|
|
327
|
+
toLocalDate: string;
|
|
328
|
+
/** Only the first slot of each day (the calendar's month view marks days that have one). */
|
|
329
|
+
maxSlotsPerDay?: number;
|
|
330
|
+
includeNonBookable?: boolean;
|
|
331
|
+
limit?: number;
|
|
332
|
+
}
|
|
333
|
+
interface WixBookingsContext {
|
|
334
|
+
/** The booking features of the site's plan (read once per page). */
|
|
335
|
+
features(): Promise<BookingFeatures>;
|
|
336
|
+
/** The business time zone, which Wix's calendar shows availability in by default. */
|
|
337
|
+
timeZone(): Promise<string>;
|
|
338
|
+
/** A bookable service by one of its URL slugs (`/booking-calendar/<slug>`, `/service-page/<slug>`). */
|
|
339
|
+
serviceBySlug(slug: string): Promise<RawBookingService | undefined>;
|
|
340
|
+
/** A service by its id (the booking form gets the id of the slot chosen on the calendar). */
|
|
341
|
+
serviceById(id: string): Promise<RawBookingService | undefined>;
|
|
342
|
+
/** Class sessions (and appointment openings) in a local date range, as Wix's calendar queries them. */
|
|
343
|
+
timeSlots(query: TimeSlotsQuery): Promise<TimeSlot[]>;
|
|
344
|
+
/** Create the booking and continue to checkout (or confirm a free booking), as the server action does. */
|
|
345
|
+
createBooking: WixBookingsService['createBooking'];
|
|
346
|
+
/**
|
|
347
|
+
* A placed order (a confirmed booking's `orderId`) as its buyer reads it, with the texts Wix's thank-you page
|
|
348
|
+
* shows; undefined for anyone else.
|
|
349
|
+
*/
|
|
350
|
+
orderById(orderId: string): Promise<BookingOrder | undefined>;
|
|
351
|
+
/**
|
|
352
|
+
* The visitor's or member's own confirmed and pending bookings of a service (Wix's booking form asks "Book this
|
|
353
|
+
* again?" when there is one).
|
|
354
|
+
*/
|
|
355
|
+
serviceBookings(serviceId: string): Promise<{
|
|
356
|
+
id?: string;
|
|
357
|
+
startDate?: string;
|
|
358
|
+
status?: string;
|
|
359
|
+
}[]>;
|
|
360
|
+
/** One of the visitor's or member's own bookings (an order's line item names it), with its start and end. */
|
|
361
|
+
bookingById(bookingId: string): Promise<{
|
|
362
|
+
id?: string;
|
|
363
|
+
startDate?: string;
|
|
364
|
+
endDate?: string;
|
|
365
|
+
status?: string;
|
|
366
|
+
} | undefined>;
|
|
367
|
+
}
|
|
368
|
+
/** The parts of an eCommerce order Wix's thank-you page shows. */
|
|
369
|
+
interface BookingOrder {
|
|
370
|
+
id: string;
|
|
371
|
+
number?: string;
|
|
372
|
+
billingInfo?: {
|
|
373
|
+
contactDetails?: {
|
|
374
|
+
firstName?: string;
|
|
375
|
+
lastName?: string;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
buyerInfo?: {
|
|
379
|
+
email?: string;
|
|
380
|
+
};
|
|
381
|
+
lineItems?: {
|
|
382
|
+
productName?: {
|
|
383
|
+
original?: string;
|
|
384
|
+
translated?: string;
|
|
385
|
+
};
|
|
386
|
+
/** For a booking: the booking's id. */
|
|
387
|
+
catalogReference?: {
|
|
388
|
+
catalogItemId?: string;
|
|
389
|
+
appId?: string;
|
|
390
|
+
};
|
|
391
|
+
descriptionLines?: {
|
|
392
|
+
plainText?: {
|
|
393
|
+
original?: string;
|
|
394
|
+
translated?: string;
|
|
395
|
+
};
|
|
396
|
+
}[];
|
|
397
|
+
image?: {
|
|
398
|
+
url?: string;
|
|
399
|
+
};
|
|
400
|
+
price?: {
|
|
401
|
+
formattedAmount?: string;
|
|
402
|
+
};
|
|
403
|
+
}[];
|
|
404
|
+
priceSummary?: Record<string, {
|
|
405
|
+
formattedAmount?: string;
|
|
406
|
+
} | undefined>;
|
|
407
|
+
}
|
|
408
|
+
declare const WIX_BOOKINGS_CONTEXT: _jay_framework_runtime.ContextMarker<WixBookingsContext>;
|
|
409
|
+
declare function createWixBookingsContext(wixClient: WixClient, config: WixBookingsConfig): WixBookingsContext;
|
|
410
|
+
|
|
411
|
+
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 };
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
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';
|
|
5
|
+
import '@wix/sdk';
|