@jay-framework/wix-bookings 0.26.4 → 0.26.6
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
package/dist/tools.js
CHANGED
|
@@ -2,15 +2,17 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import yaml from "js-yaml";
|
|
4
4
|
import { getService, hasService } from "@jay-framework/stack-server-runtime";
|
|
5
|
+
import { WIX_FORMS_SERVICE, canonicalFormId } from "@jay-framework/wix-forms";
|
|
5
6
|
import { WIX_CLIENT_SERVICE, serverClientSetupBlocker } from "@jay-framework/wix-server-client";
|
|
6
|
-
import {
|
|
7
|
+
import { p as participantFormId, d as loadWixBookingsConfig, q as queryBookingServices } from "./query-services-XDLgzwiL.js";
|
|
7
8
|
import { wixFetch } from "@jay-framework/wix-server-client/client";
|
|
8
|
-
import {
|
|
9
|
-
|
|
9
|
+
import { walkElements } from "@jay-framework/compiler-shared";
|
|
10
|
+
import { checkAddressBindings } from "@jay-framework/wix-forms/tools";
|
|
11
|
+
const DESCRIPTION = "Wix Bookings services for agent discovery. Use serviceId with dashboard path bookings/services/form/<serviceId>. participantFormHasAddress: the participant form has an address, so a booking-flow page must bind the address parts.";
|
|
10
12
|
function serviceId(service) {
|
|
11
13
|
return service._id ?? service.id ?? "";
|
|
12
14
|
}
|
|
13
|
-
function buildServicesReference(services) {
|
|
15
|
+
function buildServicesReference(services, addressFlags = /* @__PURE__ */ new Map()) {
|
|
14
16
|
const visible = services.filter((s) => !s.hidden);
|
|
15
17
|
return {
|
|
16
18
|
_description: DESCRIPTION,
|
|
@@ -24,6 +26,7 @@ function buildServicesReference(services) {
|
|
|
24
26
|
type: service.type ?? "",
|
|
25
27
|
formId: participantFormId(service.form),
|
|
26
28
|
dashboardPath: id ? `bookings/services/form/${id}` : "",
|
|
29
|
+
...addressFlags.has(id) ? { participantFormHasAddress: addressFlags.get(id) } : {},
|
|
27
30
|
payment: {
|
|
28
31
|
online: service.payment?.options?.online ?? false,
|
|
29
32
|
inPerson: service.payment?.options?.inPerson ?? false,
|
|
@@ -84,7 +87,11 @@ async function generateWixBookingsAgentKit(ctx) {
|
|
|
84
87
|
queryStaffMembers(client),
|
|
85
88
|
discoverStaffResourceTypeId(client)
|
|
86
89
|
]);
|
|
87
|
-
const
|
|
90
|
+
const forms = hasService(WIX_FORMS_SERVICE) ? getService(WIX_FORMS_SERVICE) : void 0;
|
|
91
|
+
const servicesRef = buildServicesReference(
|
|
92
|
+
services,
|
|
93
|
+
await participantAddressFlags(services, forms)
|
|
94
|
+
);
|
|
88
95
|
const siteRef = buildSiteReference({
|
|
89
96
|
staffResourceTypeId: config.staffResourceTypeId || discoveredStaffResourceTypeId || "",
|
|
90
97
|
staffMembers
|
|
@@ -121,6 +128,27 @@ async function generateWixBookingsAgentKit(ctx) {
|
|
|
121
128
|
message: `${servicesRef.visibleServices} services indexed${siteNote}`
|
|
122
129
|
};
|
|
123
130
|
}
|
|
131
|
+
async function participantAddressFlags(services, forms) {
|
|
132
|
+
const flags = /* @__PURE__ */ new Map();
|
|
133
|
+
if (!forms) return flags;
|
|
134
|
+
for (const service of services.filter((entry) => !entry.hidden)) {
|
|
135
|
+
const id = serviceId(service);
|
|
136
|
+
const formId = canonicalFormId(participantFormId(service.form));
|
|
137
|
+
if (!id || !formId) continue;
|
|
138
|
+
try {
|
|
139
|
+
const rawForm = await forms.getRawForm(formId);
|
|
140
|
+
flags.set(id, hasVisibleAddress(rawForm.formFields ?? []));
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.warn(
|
|
143
|
+
`[wix-bookings] agent-kit: could not read the participant form of service "${service.name ?? id}"; participantFormHasAddress is left out (${error instanceof Error ? error.message : String(error)}).`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return flags;
|
|
148
|
+
}
|
|
149
|
+
function hasVisibleAddress(fields) {
|
|
150
|
+
return fields.some((field) => !field.hidden && field.inputOptions?.inputType === "ADDRESS");
|
|
151
|
+
}
|
|
124
152
|
const CONFIG_FILE = ".wix-bookings.yaml";
|
|
125
153
|
const CONFIG_TEMPLATE = `# Wix Bookings Configuration
|
|
126
154
|
#
|
|
@@ -185,8 +213,74 @@ ${line}
|
|
|
185
213
|
fs.writeFileSync(configPath, updated, "utf-8");
|
|
186
214
|
}
|
|
187
215
|
const setup = setupWixBookings;
|
|
216
|
+
const BOOKING_FLOW_CONTRACT = "booking-flow";
|
|
217
|
+
const PLUGIN_KEY = "wix-bookings";
|
|
218
|
+
const SUPPRESSION_KEY = "allow-unbound-address";
|
|
219
|
+
const UNBOUND_ADDRESS_CODE = "BOOKINGS-ADDRESS-UNBOUND";
|
|
220
|
+
const SERVICES_REFERENCE = path.join("agent-kit", "references", "wix-bookings", "services.yaml");
|
|
221
|
+
const SUPPRESSION_HINT = `A page that only offers address-free services can add <script type="application/jay-validations">${PLUGIN_KEY}: { ${SUPPRESSION_KEY}: true }<\/script>.`;
|
|
222
|
+
const validateBookingFlowBindings = (ctx) => {
|
|
223
|
+
const keys = ctx.headlessImports.filter((imp) => imp.key && imp.contractName === BOOKING_FLOW_CONTRACT).map((imp) => imp.key);
|
|
224
|
+
if (!keys.length) return [];
|
|
225
|
+
const refs = collectRefs(ctx);
|
|
226
|
+
const findings = [];
|
|
227
|
+
for (const key of keys) {
|
|
228
|
+
const prefix = `${key}.address`;
|
|
229
|
+
if (refs.some((ref) => ref.startsWith(`${prefix}.`))) {
|
|
230
|
+
findings.push(...checkAddressBindings(refs, prefix));
|
|
231
|
+
} else if (!isSuppressed(ctx)) {
|
|
232
|
+
findings.push(...unboundAddressFindings(ctx.projectRoot, key));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return findings;
|
|
236
|
+
};
|
|
237
|
+
function isSuppressed(ctx) {
|
|
238
|
+
return ctx.validationOverrides?.[PLUGIN_KEY]?.[SUPPRESSION_KEY] === true;
|
|
239
|
+
}
|
|
240
|
+
function unboundAddressFindings(projectRoot, key) {
|
|
241
|
+
const services = readServices(projectRoot);
|
|
242
|
+
const withAddress = services?.filter((service) => service.participantFormHasAddress === true) ?? [];
|
|
243
|
+
if (withAddress.length) {
|
|
244
|
+
const names = withAddress.map((service) => service.name || "(unnamed)").join(", ");
|
|
245
|
+
return [
|
|
246
|
+
{
|
|
247
|
+
severity: "error",
|
|
248
|
+
message: `${UNBOUND_ADDRESS_CODE}: Service ${names} asks for an address, but this booking-flow page binds no address inputs. Add the address markup (wix-bookings-setup.md → Address).`,
|
|
249
|
+
suggestion: `Bind ref="${key}.address.<part>.input" for every part (see the ✅ example in wix-bookings-setup.md). ${SUPPRESSION_HINT}`,
|
|
250
|
+
attribute: "ref"
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
const isKnown = services !== void 0 && services.every((service) => typeof service.participantFormHasAddress === "boolean");
|
|
255
|
+
if (isKnown) return [];
|
|
256
|
+
return [
|
|
257
|
+
{
|
|
258
|
+
severity: "warning",
|
|
259
|
+
message: `${UNBOUND_ADDRESS_CODE}: Cannot tell whether any service asks for an address; run \`jay-stack agent-kit\` to refresh services.yaml.`,
|
|
260
|
+
suggestion: `If a service asks for one, bind the address parts under "${key}.address". ${SUPPRESSION_HINT}`
|
|
261
|
+
}
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
function readServices(projectRoot) {
|
|
265
|
+
try {
|
|
266
|
+
const file = path.join(projectRoot, SERVICES_REFERENCE);
|
|
267
|
+
const parsed = yaml.load(fs.readFileSync(file, "utf8"));
|
|
268
|
+
return Array.isArray(parsed?.services) ? parsed.services : void 0;
|
|
269
|
+
} catch {
|
|
270
|
+
return void 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function collectRefs(ctx) {
|
|
274
|
+
const refs = [];
|
|
275
|
+
walkElements(ctx.body, ctx, (el) => {
|
|
276
|
+
const ref = el?.getAttribute?.("ref");
|
|
277
|
+
if (ref) refs.push(ref);
|
|
278
|
+
});
|
|
279
|
+
return refs;
|
|
280
|
+
}
|
|
188
281
|
export {
|
|
189
282
|
generateWixBookingsAgentKit,
|
|
190
283
|
setup,
|
|
191
|
-
setupWixBookings
|
|
284
|
+
setupWixBookings,
|
|
285
|
+
validateBookingFlowBindings
|
|
192
286
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/wix-bookings",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wix Bookings package for Jay Framework — browse services, pick slots, submit participant details, complete checkout",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./booking-flow.jay-contract": "./dist/contracts/booking-flow.jay-contract",
|
|
28
28
|
"./list-services.jay-action": "./dist/actions/list-services.jay-action",
|
|
29
29
|
"./list-slots.jay-action": "./dist/actions/list-slots.jay-action",
|
|
30
|
+
"./get-participant-form.jay-action": "./dist/actions/get-participant-form.jay-action",
|
|
30
31
|
"./create-booking.jay-action": "./dist/actions/create-booking.jay-action"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
@@ -43,15 +44,16 @@
|
|
|
43
44
|
"test": "vitest run"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@jay-framework/
|
|
47
|
-
"@jay-framework/
|
|
48
|
-
"@jay-framework/
|
|
49
|
-
"@jay-framework/
|
|
50
|
-
"@jay-framework/
|
|
51
|
-
"@jay-framework/
|
|
52
|
-
"@jay-framework/stack-
|
|
53
|
-
"@jay-framework/
|
|
54
|
-
"@jay-framework/wix-
|
|
47
|
+
"@jay-framework/compiler-shared": "^0.26.6",
|
|
48
|
+
"@jay-framework/component": "^0.26.6",
|
|
49
|
+
"@jay-framework/fullstack-component": "^0.26.6",
|
|
50
|
+
"@jay-framework/reactive": "^0.26.6",
|
|
51
|
+
"@jay-framework/runtime": "^0.26.6",
|
|
52
|
+
"@jay-framework/secure": "^0.26.6",
|
|
53
|
+
"@jay-framework/stack-client-runtime": "^0.26.6",
|
|
54
|
+
"@jay-framework/stack-server-runtime": "^0.26.6",
|
|
55
|
+
"@jay-framework/wix-forms": "^0.26.6",
|
|
56
|
+
"@jay-framework/wix-server-client": "^0.26.6",
|
|
55
57
|
"@wix/sdk": "^1.21.5",
|
|
56
58
|
"js-yaml": "^4.1.0"
|
|
57
59
|
},
|
|
@@ -59,10 +61,10 @@
|
|
|
59
61
|
"@babel/core": "^7.23.7",
|
|
60
62
|
"@babel/preset-env": "^7.23.8",
|
|
61
63
|
"@babel/preset-typescript": "^7.23.3",
|
|
62
|
-
"@jay-framework/compiler-jay-stack": "^0.26.
|
|
63
|
-
"@jay-framework/jay-cli": "^0.26.
|
|
64
|
-
"@jay-framework/jay-stack-cli": "^0.26.
|
|
65
|
-
"@jay-framework/vite-plugin": "^0.26.
|
|
64
|
+
"@jay-framework/compiler-jay-stack": "^0.26.6",
|
|
65
|
+
"@jay-framework/jay-cli": "^0.26.6",
|
|
66
|
+
"@jay-framework/jay-stack-cli": "^0.26.6",
|
|
67
|
+
"@jay-framework/vite-plugin": "^0.26.6",
|
|
66
68
|
"@jay-framework/wix-dev-environment": "^0.6.12",
|
|
67
69
|
"nodemon": "^3.0.3",
|
|
68
70
|
"rimraf": "^5.0.5",
|
package/plugin.yaml
CHANGED
|
@@ -18,9 +18,16 @@ actions:
|
|
|
18
18
|
action: list-services.jay-action
|
|
19
19
|
- name: listSlots
|
|
20
20
|
action: list-slots.jay-action
|
|
21
|
+
- name: getParticipantForm
|
|
22
|
+
action: get-participant-form.jay-action
|
|
21
23
|
- name: createBooking
|
|
22
24
|
action: create-booking.jay-action
|
|
23
25
|
|
|
26
|
+
validators:
|
|
27
|
+
- name: wix-bookings-address-bindings
|
|
28
|
+
handler: validateBookingFlowBindings
|
|
29
|
+
description: Errors on a booking-flow page whose address binds an unknown part or leaves a part input unbound, and on a page with no address inputs when a service's participant form asks for an address (BOOKINGS-ADDRESS-UNBOUND; a warning when services.yaml cannot tell; suppress with wix-bookings allow-unbound-address)
|
|
30
|
+
|
|
24
31
|
setup: setupWixBookings
|
|
25
32
|
agentkit: generateWixBookingsAgentKit
|
|
26
33
|
description: Bookings setup and agent-kit service index for dashboard links
|