@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.
- package/agent-kit/designer/wix-bookings-dashboard-content.md +67 -0
- package/agent-kit/plugin/wix-bookings-setup.md +25 -0
- package/dist/contracts/booking-flow.jay-contract +27 -0
- package/dist/contracts/booking-flow.jay-contract.d.ts +35 -3
- package/dist/{index.client-DHSnbb5_.d.ts → index.client-gTd3Cezm.d.ts} +36 -3
- package/dist/index.client.d.ts +1 -1
- package/dist/index.client.js +620 -116
- package/dist/index.d.ts +2 -2
- package/dist/index.js +59 -9
- package/package.json +16 -16
- package/plugin.yaml +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WixBookingsConfig, a as WixBookingsService } from './index.client-
|
|
2
|
-
export { m as BookingFeatures, g as BookingFormFieldView, B as BookingServiceView, f as BookingSlotView, n as BookingStep, C as CreateBookingOutcome, T as TimeSlot, o as TimeSlotsQuery, h as WIX_BOOKINGS_CONTEXT, e as WIX_BOOKINGS_SERVICE, 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-
|
|
1
|
+
import { W as WixBookingsConfig, a as WixBookingsService } from './index.client-gTd3Cezm.js';
|
|
2
|
+
export { m as BookingFeatures, g as BookingFormFieldView, B as BookingServiceView, f as BookingSlotView, n as BookingStep, C as CreateBookingOutcome, T as TimeSlot, o as TimeSlotsQuery, h as WIX_BOOKINGS_CONTEXT, e as WIX_BOOKINGS_SERVICE, 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';
|
|
3
3
|
import { WixClient } from '@wix/sdk';
|
|
4
4
|
import '@jay-framework/fullstack-component';
|
|
5
5
|
import '@jay-framework/component';
|
package/dist/index.js
CHANGED
|
@@ -372,15 +372,62 @@ const init = makeJayInit().withServer(async () => {
|
|
|
372
372
|
console.log("[wix-bookings] Server initialization complete");
|
|
373
373
|
return { config };
|
|
374
374
|
});
|
|
375
|
+
var ServicesFailure = /* @__PURE__ */ ((ServicesFailure2) => {
|
|
376
|
+
ServicesFailure2[ServicesFailure2["NONE"] = 0] = "NONE";
|
|
377
|
+
ServicesFailure2[ServicesFailure2["PERMISSION"] = 1] = "PERMISSION";
|
|
378
|
+
ServicesFailure2[ServicesFailure2["UNKNOWN"] = 2] = "UNKNOWN";
|
|
379
|
+
return ServicesFailure2;
|
|
380
|
+
})(ServicesFailure || {});
|
|
381
|
+
var SlotsFailure = /* @__PURE__ */ ((SlotsFailure2) => {
|
|
382
|
+
SlotsFailure2[SlotsFailure2["NONE"] = 0] = "NONE";
|
|
383
|
+
SlotsFailure2[SlotsFailure2["UNKNOWN"] = 1] = "UNKNOWN";
|
|
384
|
+
return SlotsFailure2;
|
|
385
|
+
})(SlotsFailure || {});
|
|
386
|
+
var BookingState = /* @__PURE__ */ ((BookingState2) => {
|
|
387
|
+
BookingState2[BookingState2["IDLE"] = 0] = "IDLE";
|
|
388
|
+
BookingState2[BookingState2["BOOKING"] = 1] = "BOOKING";
|
|
389
|
+
BookingState2[BookingState2["CONFIRMED"] = 2] = "CONFIRMED";
|
|
390
|
+
BookingState2[BookingState2["FAILED"] = 3] = "FAILED";
|
|
391
|
+
return BookingState2;
|
|
392
|
+
})(BookingState || {});
|
|
393
|
+
var BookingFailure = /* @__PURE__ */ ((BookingFailure2) => {
|
|
394
|
+
BookingFailure2[BookingFailure2["NONE"] = 0] = "NONE";
|
|
395
|
+
BookingFailure2[BookingFailure2["VALIDATION"] = 1] = "VALIDATION";
|
|
396
|
+
BookingFailure2[BookingFailure2["FORM_UNAVAILABLE"] = 2] = "FORM_UNAVAILABLE";
|
|
397
|
+
BookingFailure2[BookingFailure2["CHECKOUT_PERMISSION"] = 3] = "CHECKOUT_PERMISSION";
|
|
398
|
+
BookingFailure2[BookingFailure2["CHECKOUT_REDIRECT_REJECTED"] = 4] = "CHECKOUT_REDIRECT_REJECTED";
|
|
399
|
+
BookingFailure2[BookingFailure2["SITE_NOT_PUBLISHED"] = 5] = "SITE_NOT_PUBLISHED";
|
|
400
|
+
BookingFailure2[BookingFailure2["UNKNOWN"] = 6] = "UNKNOWN";
|
|
401
|
+
return BookingFailure2;
|
|
402
|
+
})(BookingFailure || {});
|
|
403
|
+
const SLOW_RENDER_TTL = 600;
|
|
404
|
+
const SLOW_RENDER_GRACE = 3600;
|
|
405
|
+
const SLOW_RENDER_ERROR_TTL = 30;
|
|
406
|
+
function describeServicesError(error) {
|
|
407
|
+
const rawMessage = error instanceof Error ? error.message : "";
|
|
408
|
+
if (rawMessage.includes("403")) {
|
|
409
|
+
return {
|
|
410
|
+
failure: ServicesFailure.PERMISSION,
|
|
411
|
+
message: "Bookings API access denied. Add Wix Bookings permission to your API key in the Wix dashboard."
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
failure: ServicesFailure.UNKNOWN,
|
|
416
|
+
message: rawMessage || "Could not load booking services."
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function bookingStateOf(state) {
|
|
420
|
+
if (state.failure !== BookingFailure.NONE) return BookingState.FAILED;
|
|
421
|
+
return BookingState.IDLE;
|
|
422
|
+
}
|
|
375
423
|
async function renderSlowlyChanging(_props, bookings) {
|
|
376
424
|
try {
|
|
377
425
|
const services = await bookings.listServices();
|
|
378
|
-
return phaseOutput({ services }, { services });
|
|
426
|
+
return phaseOutput({ services }, { services }, { ttl: SLOW_RENDER_TTL, grace: SLOW_RENDER_GRACE });
|
|
379
427
|
} catch (error) {
|
|
380
|
-
const
|
|
381
|
-
const message = rawMessage.includes("403") ? "Bookings API access denied. Add Wix Bookings permission to your API key in the Wix dashboard." : rawMessage || "Could not load booking services.";
|
|
428
|
+
const { failure, message } = describeServicesError(error);
|
|
382
429
|
console.error("[booking-flow] listServices failed:", error);
|
|
383
|
-
return phaseOutput({ services: [] }, { services: [], servicesError: message });
|
|
430
|
+
return phaseOutput({ services: [] }, { services: [], servicesError: message, servicesFailure: failure }, { ttl: SLOW_RENDER_ERROR_TTL });
|
|
384
431
|
}
|
|
385
432
|
}
|
|
386
433
|
async function renderFastChanging(_props, carryForward) {
|
|
@@ -390,6 +437,7 @@ async function renderFastChanging(_props, carryForward) {
|
|
|
390
437
|
services: carryForward.services,
|
|
391
438
|
servicesLoading: false,
|
|
392
439
|
servicesError: carryForward.servicesError ?? "",
|
|
440
|
+
servicesFailure: carryForward.servicesFailure ?? ServicesFailure.NONE,
|
|
393
441
|
showNoServices: carryForward.services.length === 0 && !carryForward.servicesError,
|
|
394
442
|
hasSlots: false,
|
|
395
443
|
showServices: true,
|
|
@@ -399,16 +447,18 @@ async function renderFastChanging(_props, carryForward) {
|
|
|
399
447
|
slots: [],
|
|
400
448
|
slotsLoading: false,
|
|
401
449
|
slotsMessage: "",
|
|
450
|
+
slotsFailure: SlotsFailure.NONE,
|
|
402
451
|
formFields: [],
|
|
403
452
|
formLoading: false,
|
|
404
453
|
isBooking: false,
|
|
405
454
|
bookingStatus: "",
|
|
406
|
-
bookingError: ""
|
|
455
|
+
bookingError: "",
|
|
456
|
+
bookingState: bookingStateOf({
|
|
457
|
+
failure: BookingFailure.NONE
|
|
458
|
+
}),
|
|
459
|
+
bookingFailure: BookingFailure.NONE
|
|
407
460
|
},
|
|
408
|
-
carryForward
|
|
409
|
-
services: carryForward.services,
|
|
410
|
-
servicesError: carryForward.servicesError
|
|
411
|
-
}
|
|
461
|
+
carryForward
|
|
412
462
|
}));
|
|
413
463
|
}
|
|
414
464
|
const bookingFlow = makeJayStackComponent().withProps().withServices(WIX_BOOKINGS_SERVICE).withSlowlyRender(renderSlowlyChanging).withFastRender(renderFastChanging).withInteractiveMark();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/wix-bookings",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
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",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"test": "vitest run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@jay-framework/component": "^0.
|
|
47
|
-
"@jay-framework/fullstack-component": "^0.
|
|
48
|
-
"@jay-framework/reactive": "^0.
|
|
49
|
-
"@jay-framework/runtime": "^0.
|
|
50
|
-
"@jay-framework/secure": "^0.
|
|
51
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
52
|
-
"@jay-framework/stack-server-runtime": "^0.
|
|
53
|
-
"@jay-framework/wix-forms": "^0.
|
|
54
|
-
"@jay-framework/wix-server-client": "^0.
|
|
46
|
+
"@jay-framework/component": "^0.26.0",
|
|
47
|
+
"@jay-framework/fullstack-component": "^0.26.0",
|
|
48
|
+
"@jay-framework/reactive": "^0.26.0",
|
|
49
|
+
"@jay-framework/runtime": "^0.26.0",
|
|
50
|
+
"@jay-framework/secure": "^0.26.0",
|
|
51
|
+
"@jay-framework/stack-client-runtime": "^0.26.0",
|
|
52
|
+
"@jay-framework/stack-server-runtime": "^0.26.0",
|
|
53
|
+
"@jay-framework/wix-forms": "^0.26.0",
|
|
54
|
+
"@jay-framework/wix-server-client": "^0.26.0",
|
|
55
55
|
"@wix/sdk": "^1.21.5",
|
|
56
56
|
"js-yaml": "^4.1.0"
|
|
57
57
|
},
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
"@babel/core": "^7.23.7",
|
|
60
60
|
"@babel/preset-env": "^7.23.8",
|
|
61
61
|
"@babel/preset-typescript": "^7.23.3",
|
|
62
|
-
"@jay-framework/compiler-jay-stack": "^0.
|
|
63
|
-
"@jay-framework/jay-cli": "^0.
|
|
64
|
-
"@jay-framework/jay-stack-cli": "^0.
|
|
65
|
-
"@jay-framework/vite-plugin": "^0.
|
|
62
|
+
"@jay-framework/compiler-jay-stack": "^0.26.0",
|
|
63
|
+
"@jay-framework/jay-cli": "^0.26.0",
|
|
64
|
+
"@jay-framework/jay-stack-cli": "^0.26.0",
|
|
65
|
+
"@jay-framework/vite-plugin": "^0.26.0",
|
|
66
66
|
"@jay-framework/wix-dev-environment": "^0.6.12",
|
|
67
67
|
"nodemon": "^3.0.3",
|
|
68
68
|
"rimraf": "^5.0.5",
|
|
69
69
|
"tslib": "^2.6.2",
|
|
70
70
|
"tsup": "^8.5.1",
|
|
71
71
|
"typescript": "^5.3.3",
|
|
72
|
-
"vite": "^
|
|
73
|
-
"vitest": "^1.
|
|
72
|
+
"vite": "^6.4.4",
|
|
73
|
+
"vitest": "^4.1.11"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/plugin.yaml
CHANGED