@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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WixBookingsConfig, a as WixBookingsService } from './index.client-DHSnbb5_.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-DHSnbb5_.js';
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 rawMessage = error instanceof Error ? error.message : "Could not load booking services.";
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.25.5",
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.25.5",
47
- "@jay-framework/fullstack-component": "^0.25.5",
48
- "@jay-framework/reactive": "^0.25.5",
49
- "@jay-framework/runtime": "^0.25.5",
50
- "@jay-framework/secure": "^0.25.5",
51
- "@jay-framework/stack-client-runtime": "^0.25.5",
52
- "@jay-framework/stack-server-runtime": "^0.25.5",
53
- "@jay-framework/wix-forms": "^0.25.5",
54
- "@jay-framework/wix-server-client": "^0.25.5",
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.25.5",
63
- "@jay-framework/jay-cli": "^0.25.5",
64
- "@jay-framework/jay-stack-cli": "^0.25.5",
65
- "@jay-framework/vite-plugin": "^0.25.5",
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": "^5.0.11",
73
- "vitest": "^1.2.0"
72
+ "vite": "^6.4.4",
73
+ "vitest": "^4.1.11"
74
74
  }
75
75
  }
package/plugin.yaml CHANGED
@@ -6,6 +6,7 @@ contracts:
6
6
  contract: booking-flow.jay-contract
7
7
  component: bookingFlow
8
8
  description: Full booking flow (service list, slot picker, form, checkout)
9
+ editingGuide: ./agent-kit/designer/wix-bookings-dashboard-content.md
9
10
 
10
11
  services:
11
12
  - name: wix-bookings