@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/dist/index.d.ts CHANGED
@@ -1,17 +1,10 @@
1
- import { W as WixBookingsService } from './index.client-CBlxQDjy.js';
2
- export { f as BookingFormFieldView, B as BookingServiceView, e as BookingSlotView, C as CreateBookingOutcome, d as WIX_BOOKINGS_SERVICE, b as bookingFlow, c as createBooking, i as init, l as listServices, a as listSlots } from './index.client-CBlxQDjy.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';
6
6
  import '@jay-framework/runtime';
7
7
 
8
- interface WixBookingsConfig {
9
- bookingAppId: string;
10
- staffResourceTypeId: string;
11
- slotWindowDays: number;
12
- postCheckoutUrl: string;
13
- }
14
-
15
8
  declare function provideWixBookingsService(wixClient: WixClient, config: WixBookingsConfig): WixBookingsService;
16
9
 
17
10
  export { WixBookingsService, provideWixBookingsService };
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { createJayService, makeJayInit, makeJayStackComponent, phaseOutput, RenderPipeline, makeJayQuery, makeJayAction } from "@jay-framework/fullstack-component";
2
2
  import { registerService, getService } from "@jay-framework/stack-server-runtime";
3
- import { wixFetch, WixApiError, WIX_CLIENT_SERVICE } from "@jay-framework/wix-server-client";
4
- import { l as loadWixBookingsConfig } from "./config-loader-C7I2yXpp.js";
3
+ import { WIX_CLIENT_SERVICE } from "@jay-framework/wix-server-client";
4
+ import { l as loadWixBookingsConfig } from "./config-loader-sfgwfXPV.js";
5
+ import { wixFetch, WixApiError } from "@jay-framework/wix-server-client/client";
6
+ import { createJayContext } from "@jay-framework/runtime";
7
+ const WIX_BOOKINGS_SERVICE = createJayService("WixBookingsService");
5
8
  const MAX_SLOTS_PER_QUERY = 200;
6
9
  const SERVICES_PAGE_SIZE = 100;
7
- const WIX_BOOKINGS_SERVICE = createJayService("WixBookingsService");
8
10
  function formatPrice(service) {
9
11
  const price = service.payment?.fixed?.price;
10
12
  if (!price?.value) {
@@ -118,7 +120,12 @@ async function calculateBookingCart(client, cartId) {
118
120
  return wixFetch(client, `/ecom/v2/carts/${cartId}/calculate`, { method: "POST", body: {} });
119
121
  }
120
122
  async function placeBookingOrder(client, cartId) {
121
- await wixFetch(client, `/ecom/v2/carts/${cartId}/place-order`, { method: "POST", body: {} });
123
+ const res = await wixFetch(
124
+ client,
125
+ `/ecom/v2/carts/${cartId}/place-order`,
126
+ { method: "POST", body: {} }
127
+ );
128
+ return { orderId: res?.orderId };
122
129
  }
123
130
  async function createBookingRedirectSession(client, cartId, postFlowUrl) {
124
131
  return wixFetch(client, "/headless/v1/redirect-session", {
@@ -258,8 +265,8 @@ async function resolvePaidCheckoutRedirectUrl(wixClient, cartId, postFlowUrl) {
258
265
  }
259
266
  return checkoutUrl;
260
267
  }
261
- function provideWixBookingsService(wixClient, config) {
262
- const service = {
268
+ function createWixBookingsService(wixClient, config) {
269
+ return {
263
270
  async listServices() {
264
271
  const items = await queryBookingServices(wixClient, config.bookingAppId);
265
272
  return items.filter((item) => !item.hidden).map((item) => mapService(item));
@@ -308,12 +315,16 @@ function provideWixBookingsService(wixClient, config) {
308
315
  endDate: input.slot.localEndDate,
309
316
  timezone: input.timezone,
310
317
  location: { locationType: "OWNER_BUSINESS" },
311
- resourceSelections: [
312
- {
313
- resourceTypeId: config.staffResourceTypeId,
314
- selectionMethod: "ANY_RESOURCE"
315
- }
316
- ]
318
+ // Any staff member of the configured staff resource type; without one, the slot's own (a class
319
+ // session names its staff; Wix rejects an empty resource type id).
320
+ ...config.staffResourceTypeId ? {
321
+ resourceSelections: [
322
+ {
323
+ resourceTypeId: config.staffResourceTypeId,
324
+ selectionMethod: "ANY_RESOURCE"
325
+ }
326
+ ]
327
+ } : {}
317
328
  };
318
329
  if (input.serviceType === "APPOINTMENT") {
319
330
  slotData.scheduleId = input.slot.scheduleId;
@@ -342,10 +353,13 @@ function provideWixBookingsService(wixClient, config) {
342
353
  );
343
354
  return { outcome: "redirect", redirectUrl };
344
355
  }
345
- await placeBookingOrder(wixClient, cartId);
346
- return { outcome: "confirmed" };
356
+ const { orderId } = await placeBookingOrder(wixClient, cartId);
357
+ return { outcome: "confirmed", ...orderId ? { orderId } : {} };
347
358
  }
348
359
  };
360
+ }
361
+ function provideWixBookingsService(wixClient, config) {
362
+ const service = createWixBookingsService(wixClient, config);
349
363
  registerService(WIX_BOOKINGS_SERVICE, service);
350
364
  return service;
351
365
  }
@@ -356,17 +370,64 @@ const init = makeJayInit().withServer(async () => {
356
370
  provideWixBookingsService(wixClient, config);
357
371
  console.log(`[wix-bookings] Booking app ID: ${config.bookingAppId}`);
358
372
  console.log("[wix-bookings] Server initialization complete");
359
- return {};
373
+ return { config };
360
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
+ }
361
423
  async function renderSlowlyChanging(_props, bookings) {
362
424
  try {
363
425
  const services = await bookings.listServices();
364
- return phaseOutput({ services }, { services });
426
+ return phaseOutput({ services }, { services }, { ttl: SLOW_RENDER_TTL, grace: SLOW_RENDER_GRACE });
365
427
  } catch (error) {
366
- const rawMessage = error instanceof Error ? error.message : "Could not load booking services.";
367
- 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);
368
429
  console.error("[booking-flow] listServices failed:", error);
369
- return phaseOutput({ services: [] }, { services: [], servicesError: message });
430
+ return phaseOutput({ services: [] }, { services: [], servicesError: message, servicesFailure: failure }, { ttl: SLOW_RENDER_ERROR_TTL });
370
431
  }
371
432
  }
372
433
  async function renderFastChanging(_props, carryForward) {
@@ -376,6 +437,7 @@ async function renderFastChanging(_props, carryForward) {
376
437
  services: carryForward.services,
377
438
  servicesLoading: false,
378
439
  servicesError: carryForward.servicesError ?? "",
440
+ servicesFailure: carryForward.servicesFailure ?? ServicesFailure.NONE,
379
441
  showNoServices: carryForward.services.length === 0 && !carryForward.servicesError,
380
442
  hasSlots: false,
381
443
  showServices: true,
@@ -385,16 +447,18 @@ async function renderFastChanging(_props, carryForward) {
385
447
  slots: [],
386
448
  slotsLoading: false,
387
449
  slotsMessage: "",
450
+ slotsFailure: SlotsFailure.NONE,
388
451
  formFields: [],
389
452
  formLoading: false,
390
453
  isBooking: false,
391
454
  bookingStatus: "",
392
- bookingError: ""
455
+ bookingError: "",
456
+ bookingState: bookingStateOf({
457
+ failure: BookingFailure.NONE
458
+ }),
459
+ bookingFailure: BookingFailure.NONE
393
460
  },
394
- carryForward: {
395
- services: carryForward.services,
396
- servicesError: carryForward.servicesError
397
- }
461
+ carryForward
398
462
  }));
399
463
  }
400
464
  const bookingFlow = makeJayStackComponent().withProps().withServices(WIX_BOOKINGS_SERVICE).withSlowlyRender(renderSlowlyChanging).withFastRender(renderFastChanging).withInteractiveMark();
@@ -411,10 +475,119 @@ const listSlots = makeJayQuery("wixBookings.listSlots").withServices(WIX_BOOKING
411
475
  const createBooking = makeJayAction("wixBookings.createBooking").withServices(WIX_BOOKINGS_SERVICE).withHandler(
412
476
  async (input, bookings) => bookings.createBooking(input)
413
477
  );
478
+ function canBookOnline(features, type, step) {
479
+ if (type === "COURSE") return step !== "form" || features.courses;
480
+ return type === "CLASS" ? features.groups : features.appointments;
481
+ }
482
+ const WIX_BOOKINGS_CONTEXT = createJayContext("wix:bookings");
483
+ function createWixBookingsContext(wixClient, config) {
484
+ let settings;
485
+ const readSettings = () => {
486
+ if (!settings) {
487
+ settings = wixFetch(
488
+ wixClient,
489
+ "/_api/bookings-settings/v2/settings?fields=FEATURES&fields=SITE_PROPERTIES"
490
+ ).then((res) => res.bookingsSettings).catch(() => {
491
+ settings = void 0;
492
+ return void 0;
493
+ });
494
+ }
495
+ return settings;
496
+ };
497
+ const service = createWixBookingsService(wixClient, config);
498
+ const ownBookings = async (filter) => {
499
+ const res = await wixFetch(wixClient, "/_api/bookings-reader/v2/extended-bookings/query", {
500
+ method: "POST",
501
+ body: {
502
+ query: { filter, cursorPaging: { limit: 100 } },
503
+ withBookingAllowedActions: false
504
+ }
505
+ }).catch(() => ({ extendedBookings: [] }));
506
+ return (res.extendedBookings ?? []).map((e) => e.booking ?? {});
507
+ };
508
+ return {
509
+ async features() {
510
+ const f = (await readSettings())?.features ?? {};
511
+ return {
512
+ groups: Boolean(f.bookingsGroups?.enabled),
513
+ appointments: Boolean(f.bookingsAppointments?.enabled),
514
+ courses: Boolean(f.bookingsCourses?.enabled),
515
+ payments: Boolean(f.bookingsPayments?.enabled)
516
+ };
517
+ },
518
+ async timeZone() {
519
+ return (await readSettings())?.siteProperties?.timeZone ?? "UTC";
520
+ },
521
+ async serviceBySlug(slug) {
522
+ const res = await wixFetch(
523
+ wixClient,
524
+ "/bookings/v2/services/query",
525
+ {
526
+ method: "POST",
527
+ body: {
528
+ query: {
529
+ filter: { "supportedSlugs.name": slug, hidden: false },
530
+ paging: { limit: 1 }
531
+ }
532
+ }
533
+ }
534
+ );
535
+ return res.services?.[0];
536
+ },
537
+ serviceById(id) {
538
+ return getBookingServiceById(wixClient, id);
539
+ },
540
+ async timeSlots(query) {
541
+ const res = await wixFetch(
542
+ wixClient,
543
+ "/_api/service-availability/v2/time-slots/event",
544
+ {
545
+ method: "POST",
546
+ body: {
547
+ serviceIds: query.serviceIds,
548
+ timeZone: query.timeZone,
549
+ fromLocalDate: query.fromLocalDate,
550
+ toLocalDate: query.toLocalDate,
551
+ includeNonBookable: query.includeNonBookable ?? true,
552
+ ...query.maxSlotsPerDay ? { maxSlotsPerDay: query.maxSlotsPerDay } : {},
553
+ eventFilter: {},
554
+ cursorPaging: { limit: query.limit ?? 1e3 }
555
+ }
556
+ }
557
+ );
558
+ return res.timeSlots ?? [];
559
+ },
560
+ createBooking: service.createBooking,
561
+ async serviceBookings(serviceId) {
562
+ return (await ownBookings({
563
+ "bookedEntity.slot.serviceId": serviceId,
564
+ status: { $in: ["CONFIRMED", "PENDING"] }
565
+ })).filter((b) => b.id || b.startDate);
566
+ },
567
+ async bookingById(bookingId) {
568
+ return (await ownBookings({ id: bookingId }))[0];
569
+ },
570
+ async orderById(orderId) {
571
+ try {
572
+ const res = await wixFetch(
573
+ wixClient,
574
+ `/ecom/v1/orders/${encodeURIComponent(orderId)}`
575
+ );
576
+ return res.order;
577
+ } catch (error) {
578
+ if (error instanceof WixApiError) return void 0;
579
+ throw error;
580
+ }
581
+ }
582
+ };
583
+ }
414
584
  export {
585
+ WIX_BOOKINGS_CONTEXT,
415
586
  WIX_BOOKINGS_SERVICE,
416
587
  bookingFlow,
588
+ canBookOnline,
417
589
  createBooking,
590
+ createWixBookingsContext,
418
591
  init,
419
592
  listServices,
420
593
  listSlots,
package/dist/tools.js CHANGED
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { hasService } from "@jay-framework/stack-server-runtime";
4
4
  import { WIX_FORMS_SERVICE } from "@jay-framework/wix-forms";
5
- import { l as loadWixBookingsConfig } from "./config-loader-C7I2yXpp.js";
5
+ import { l as loadWixBookingsConfig } from "./config-loader-sfgwfXPV.js";
6
6
  const CONFIG_FILE = ".wix-bookings.yaml";
7
7
  const CONFIG_TEMPLATE = `# Wix Bookings Configuration
8
8
  #
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-bookings",
3
- "version": "0.25.4",
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",
@@ -19,7 +19,10 @@
19
19
  "types": "./dist/index.client.d.ts",
20
20
  "default": "./dist/index.client.js"
21
21
  },
22
- "./tools": "./dist/tools.js",
22
+ "./tools": {
23
+ "types": "./dist/tools.d.ts",
24
+ "default": "./dist/tools.js"
25
+ },
23
26
  "./plugin.yaml": "./plugin.yaml",
24
27
  "./booking-flow.jay-contract": "./dist/contracts/booking-flow.jay-contract",
25
28
  "./list-services.jay-action": "./dist/actions/list-services.jay-action",
@@ -40,15 +43,15 @@
40
43
  "test": "vitest run"
41
44
  },
42
45
  "dependencies": {
43
- "@jay-framework/component": "^0.25.4",
44
- "@jay-framework/fullstack-component": "^0.25.4",
45
- "@jay-framework/reactive": "^0.25.4",
46
- "@jay-framework/runtime": "^0.25.4",
47
- "@jay-framework/secure": "^0.25.4",
48
- "@jay-framework/stack-client-runtime": "^0.25.4",
49
- "@jay-framework/stack-server-runtime": "^0.25.4",
50
- "@jay-framework/wix-forms": "^0.25.4",
51
- "@jay-framework/wix-server-client": "^0.25.4",
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",
52
55
  "@wix/sdk": "^1.21.5",
53
56
  "js-yaml": "^4.1.0"
54
57
  },
@@ -56,17 +59,17 @@
56
59
  "@babel/core": "^7.23.7",
57
60
  "@babel/preset-env": "^7.23.8",
58
61
  "@babel/preset-typescript": "^7.23.3",
59
- "@jay-framework/compiler-jay-stack": "^0.25.4",
60
- "@jay-framework/jay-cli": "^0.25.4",
61
- "@jay-framework/jay-stack-cli": "^0.25.4",
62
- "@jay-framework/vite-plugin": "^0.25.4",
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",
63
66
  "@jay-framework/wix-dev-environment": "^0.6.12",
64
67
  "nodemon": "^3.0.3",
65
68
  "rimraf": "^5.0.5",
66
69
  "tslib": "^2.6.2",
67
70
  "tsup": "^8.5.1",
68
71
  "typescript": "^5.3.3",
69
- "vite": "^5.0.11",
70
- "vitest": "^1.2.0"
72
+ "vite": "^6.4.4",
73
+ "vitest": "^4.1.11"
71
74
  }
72
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
@@ -1,194 +0,0 @@
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 { HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
5
-
6
- declare const init: _jay_framework_fullstack_component.JayInit<{}>;
7
-
8
- interface ServiceOfBookingFlowViewState {
9
- id: string,
10
- name: string,
11
- description: string,
12
- type: string,
13
- durationLabel: string,
14
- priceLabel: string,
15
- formId: string
16
- }
17
-
18
- interface SlotOfBookingFlowViewState {
19
- id: string,
20
- label: string,
21
- localStartDate: string,
22
- localEndDate: string,
23
- scheduleId: string,
24
- eventId: string
25
- }
26
-
27
- interface FormFieldOfBookingFlowViewState {
28
- target: string,
29
- label: string,
30
- type: string,
31
- required: boolean
32
- }
33
-
34
- interface BookingFlowViewState {
35
- services: Array<ServiceOfBookingFlowViewState>,
36
- servicesLoading: boolean,
37
- showNoServices: boolean,
38
- hasSlots: boolean,
39
- servicesError: string,
40
- showServices: boolean,
41
- showSlots: boolean,
42
- showForm: boolean,
43
- selectedServiceName: string,
44
- slots: Array<SlotOfBookingFlowViewState>,
45
- slotsLoading: boolean,
46
- slotsMessage: string,
47
- formFields: Array<FormFieldOfBookingFlowViewState>,
48
- formLoading: boolean,
49
- isBooking: boolean,
50
- bookingStatus: string,
51
- bookingError: string
52
- }
53
-
54
- type BookingFlowSlowViewState = {};
55
-
56
- type BookingFlowFastViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
57
- services: Array<BookingFlowViewState['services'][number]>;
58
- slots: Array<BookingFlowViewState['slots'][number]>;
59
- formFields: Array<BookingFlowViewState['formFields'][number]>;
60
- };
61
-
62
- type BookingFlowInteractiveViewState = Pick<BookingFlowViewState, 'servicesLoading' | 'showNoServices' | 'hasSlots' | 'servicesError' | 'showServices' | 'showSlots' | 'showForm' | 'selectedServiceName' | 'slotsLoading' | 'slotsMessage' | 'formLoading' | 'isBooking' | 'bookingStatus' | 'bookingError'> & {
63
- services: Array<BookingFlowViewState['services'][number]>;
64
- slots: Array<BookingFlowViewState['slots'][number]>;
65
- formFields: Array<BookingFlowViewState['formFields'][number]>;
66
- };
67
-
68
-
69
- interface BookingFlowRefs {
70
- bookButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
71
- backButton: HTMLElementProxy<BookingFlowViewState, HTMLButtonElement>,
72
- services: {
73
- serviceButtons: HTMLElementCollectionProxy<ServiceOfBookingFlowViewState, HTMLButtonElement>
74
- },
75
- slots: {
76
- slotButtons: HTMLElementCollectionProxy<SlotOfBookingFlowViewState, HTMLButtonElement>
77
- },
78
- formFields: {
79
- formInputs: HTMLElementCollectionProxy<FormFieldOfBookingFlowViewState, HTMLInputElement>
80
- }
81
- }
82
-
83
- type BookingServiceType = 'APPOINTMENT' | 'CLASS';
84
- interface BookingServiceView {
85
- id: string;
86
- name: string;
87
- type: BookingServiceType;
88
- description: string;
89
- priceLabel: string;
90
- durationLabel: string;
91
- formId: string;
92
- }
93
- interface BookingSlotView {
94
- id: string;
95
- localStartDate: string;
96
- localEndDate: string;
97
- label: string;
98
- scheduleId?: string;
99
- eventId?: string;
100
- serviceType: BookingServiceType;
101
- }
102
- interface BookingFormFieldView {
103
- target: string;
104
- label: string;
105
- type: 'STRING' | 'EMAIL' | 'PHONE' | 'NUMBER' | 'URL';
106
- required: boolean;
107
- }
108
- type CreateBookingOutcome = {
109
- outcome: 'confirmed';
110
- } | {
111
- outcome: 'redirect';
112
- redirectUrl: string;
113
- };
114
-
115
- interface WixBookingsService {
116
- listServices(): Promise<BookingServiceView[]>;
117
- listSlots(input: {
118
- serviceId: string;
119
- serviceType: BookingServiceType;
120
- timezone?: string;
121
- windowDays?: number;
122
- }): Promise<BookingSlotView[]>;
123
- createBooking(input: {
124
- serviceId: string;
125
- serviceType: BookingServiceType;
126
- slot: {
127
- localStartDate: string;
128
- localEndDate: string;
129
- scheduleId?: string;
130
- eventId?: string;
131
- };
132
- formValues: Record<string, string>;
133
- timezone: string;
134
- siteOrigin: string;
135
- paymentPreference?: 'ONLINE' | 'OFFLINE';
136
- }): Promise<CreateBookingOutcome>;
137
- }
138
- declare const WIX_BOOKINGS_SERVICE: _jay_framework_fullstack_component.ServiceMarker<WixBookingsService>;
139
-
140
- interface BookingFlowCarryForward {
141
- services: BookingServiceView[];
142
- servicesError?: string;
143
- }
144
- declare const bookingFlow: _jay_framework_fullstack_component.JayStackComponentDefinition<BookingFlowRefs, BookingFlowSlowViewState, BookingFlowFastViewState, BookingFlowInteractiveViewState, [BookingFlowCarryForward, WixBookingsService], [Signals<BookingFlowFastViewState>, BookingFlowCarryForward], object, {}, _jay_framework_component.JayComponentCore<object, BookingFlowInteractiveViewState>>;
145
-
146
- declare const listServices: _jay_framework_fullstack_component.JayAction<Record<string, never>, {
147
- services: BookingServiceView[];
148
- }> & _jay_framework_fullstack_component.JayActionDefinition<Record<string, never>, {
149
- services: BookingServiceView[];
150
- }, [WixBookingsService]>;
151
- declare const listSlots: _jay_framework_fullstack_component.JayAction<{
152
- serviceId: string;
153
- serviceType: "APPOINTMENT" | "CLASS";
154
- timezone?: string;
155
- windowDays?: number;
156
- }, {
157
- slots: BookingSlotView[];
158
- }> & _jay_framework_fullstack_component.JayActionDefinition<{
159
- serviceId: string;
160
- serviceType: "APPOINTMENT" | "CLASS";
161
- timezone?: string;
162
- windowDays?: number;
163
- }, {
164
- slots: BookingSlotView[];
165
- }, [WixBookingsService]>;
166
- declare const createBooking: _jay_framework_fullstack_component.JayAction<{
167
- serviceId: string;
168
- serviceType: "APPOINTMENT" | "CLASS";
169
- slot: {
170
- localStartDate: string;
171
- localEndDate: string;
172
- scheduleId?: string;
173
- eventId?: string;
174
- };
175
- formValues: Record<string, string>;
176
- timezone: string;
177
- siteOrigin: string;
178
- paymentPreference?: "ONLINE" | "OFFLINE";
179
- }, CreateBookingOutcome> & _jay_framework_fullstack_component.JayActionDefinition<{
180
- serviceId: string;
181
- serviceType: "APPOINTMENT" | "CLASS";
182
- slot: {
183
- localStartDate: string;
184
- localEndDate: string;
185
- scheduleId?: string;
186
- eventId?: string;
187
- };
188
- formValues: Record<string, string>;
189
- timezone: string;
190
- siteOrigin: string;
191
- paymentPreference?: "ONLINE" | "OFFLINE";
192
- }, CreateBookingOutcome, [WixBookingsService]>;
193
-
194
- export { type BookingServiceView as B, type CreateBookingOutcome as C, type WixBookingsService as W, listSlots as a, bookingFlow as b, createBooking as c, WIX_BOOKINGS_SERVICE as d, type BookingSlotView as e, type BookingFormFieldView as f, init as i, listServices as l };