@wix/headless-bookings 0.0.24 → 0.0.26

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.
Files changed (67) hide show
  1. package/cjs/dist/__mocks__/services.d.ts +75 -0
  2. package/cjs/dist/__mocks__/services.js +308 -0
  3. package/cjs/dist/api/fetch-availability/index.d.ts +5 -5
  4. package/cjs/dist/api/fetch-availability/index.js +9 -6
  5. package/cjs/dist/react/booking/Book.d.ts +49 -0
  6. package/cjs/dist/react/booking/Book.js +46 -0
  7. package/cjs/dist/react/booking/Booking.d.ts +18 -0
  8. package/cjs/dist/react/booking/Booking.js +19 -0
  9. package/cjs/dist/react/core/booking/Book.d.ts +41 -0
  10. package/cjs/dist/react/core/booking/Book.js +59 -0
  11. package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +4 -4
  12. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +3 -10
  13. package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +3 -3
  14. package/cjs/dist/react/time-slot-list/TimeSlot.js +3 -3
  15. package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +5 -3
  16. package/cjs/dist/services/booking/book-action/bookAction.d.ts +21 -0
  17. package/cjs/dist/services/booking/book-action/bookAction.js +59 -0
  18. package/cjs/dist/services/booking/book-action/buildBookingRequest.d.ts +22 -0
  19. package/cjs/dist/services/booking/book-action/buildBookingRequest.js +81 -0
  20. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +26 -0
  21. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +62 -0
  22. package/cjs/dist/services/booking/book-action/canBook.d.ts +23 -0
  23. package/cjs/dist/services/booking/book-action/canBook.js +19 -0
  24. package/cjs/dist/services/booking/book-action/index.d.ts +8 -0
  25. package/cjs/dist/services/booking/book-action/index.js +7 -0
  26. package/cjs/dist/services/booking/book-action/types.d.ts +50 -0
  27. package/cjs/dist/services/booking/book-action/types.js +4 -0
  28. package/cjs/dist/services/booking/booking.d.ts +2 -0
  29. package/cjs/dist/services/booking/booking.js +16 -0
  30. package/cjs/dist/services/index.d.ts +1 -0
  31. package/cjs/dist/services/index.js +1 -0
  32. package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +10 -2
  33. package/cjs/dist/services/time-slot-list/time-slot-list.js +9 -29
  34. package/dist/__mocks__/services.d.ts +75 -0
  35. package/dist/__mocks__/services.js +308 -0
  36. package/dist/api/fetch-availability/index.d.ts +5 -5
  37. package/dist/api/fetch-availability/index.js +9 -6
  38. package/dist/react/booking/Book.d.ts +49 -0
  39. package/dist/react/booking/Book.js +46 -0
  40. package/dist/react/booking/Booking.d.ts +18 -0
  41. package/dist/react/booking/Booking.js +19 -0
  42. package/dist/react/core/booking/Book.d.ts +41 -0
  43. package/dist/react/core/booking/Book.js +59 -0
  44. package/dist/react/core/time-slot-list/TimeSlot.d.ts +4 -4
  45. package/dist/react/core/time-slot-list/TimeSlot.js +3 -10
  46. package/dist/react/time-slot-list/TimeSlot.d.ts +3 -3
  47. package/dist/react/time-slot-list/TimeSlot.js +3 -3
  48. package/dist/react/time-slot-list/TimeSlotList.d.ts +5 -3
  49. package/dist/services/booking/book-action/bookAction.d.ts +21 -0
  50. package/dist/services/booking/book-action/bookAction.js +59 -0
  51. package/dist/services/booking/book-action/buildBookingRequest.d.ts +22 -0
  52. package/dist/services/booking/book-action/buildBookingRequest.js +81 -0
  53. package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +26 -0
  54. package/dist/services/booking/book-action/buildCheckoutRequest.js +62 -0
  55. package/dist/services/booking/book-action/canBook.d.ts +23 -0
  56. package/dist/services/booking/book-action/canBook.js +19 -0
  57. package/dist/services/booking/book-action/index.d.ts +8 -0
  58. package/dist/services/booking/book-action/index.js +7 -0
  59. package/dist/services/booking/book-action/types.d.ts +50 -0
  60. package/dist/services/booking/book-action/types.js +4 -0
  61. package/dist/services/booking/booking.d.ts +2 -0
  62. package/dist/services/booking/booking.js +16 -0
  63. package/dist/services/index.d.ts +1 -0
  64. package/dist/services/index.js +1 -0
  65. package/dist/services/time-slot-list/time-slot-list.def.d.ts +10 -2
  66. package/dist/services/time-slot-list/time-slot-list.js +9 -29
  67. package/package.json +4 -3
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { defineService, implementService } from '@wix/services-definitions';
7
7
  import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
8
+ import { executeBookAction } from './book-action/bookAction.js';
8
9
  // ============================================================================
9
10
  // Constants
10
11
  // ============================================================================
@@ -174,6 +175,21 @@ export const BookingService = implementService.withConfig()(BookingServiceDefini
174
175
  locationSignal.set(null);
175
176
  formSubmissionSignal.set(null);
176
177
  },
178
+ // Book action - collects data from signals and delegates to executeBookAction
179
+ // Loading/error state management is handled in Book.tsx component
180
+ async book() {
181
+ const serviceSelections = serviceSelectionsSignal.get();
182
+ const formSubmission = formSubmissionSignal.get();
183
+ const location = locationSignal.get();
184
+ const timezone = timezoneSignal.get();
185
+ // Validation happens inside executeBookAction
186
+ return executeBookAction({
187
+ serviceSelections,
188
+ formSubmission,
189
+ location,
190
+ timezone,
191
+ });
192
+ },
177
193
  };
178
194
  return {
179
195
  serviceSelections: serviceSelectionsSignal,
@@ -6,4 +6,5 @@ export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type
6
6
  export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type Location, type BookingServiceActions, type ServiceSelection, type ServiceSelectionTimeSlot, } from './booking/booking.js';
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type SlotSelection, type TimeSlot, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListFilters, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
9
+ export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
9
10
  export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, type BookingFormServiceInternalAPI, type ValidationResult, } from './booking-form/booking-form.js';
@@ -6,4 +6,5 @@ export { ServiceService, ServiceServiceDefinition, loadServiceServiceInitialData
6
6
  export { BookingService, BookingServiceDefinition, } from './booking/booking.js';
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeSlotListConfig, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, loadServiceListServiceInitialData, } from './service-list/service-list.js';
9
+ export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, } from './booking/book-action/index.js';
9
10
  export { BookingFormService, BookingFormServiceDefinition, } from './booking-form/booking-form.js';
@@ -3,8 +3,16 @@
3
3
  * Defines interfaces and service contract for time slot management
4
4
  */
5
5
  import type { Signal } from '@wix/services-definitions/core-services/signals';
6
- import type { TimeSlot as ApiTimeSlot, Location } from '@wix/auto_sdk_bookings_availability-time-slots';
6
+ import type { TimeSlot as ApiTimeSlot, LocationTypeWithLiterals } from '@wix/auto_sdk_bookings_availability-time-slots';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
+ /**
9
+ * Location filter input for availability calls.
10
+ * Require a stable `id` + `locationType` pair (no optional fields).
11
+ */
12
+ export interface Location {
13
+ id: string;
14
+ locationType: LocationTypeWithLiterals;
15
+ }
8
16
  export declare enum ViewMode {
9
17
  CLASSIC = "classic",
10
18
  AGENDA = "agenda"
@@ -48,7 +56,7 @@ export interface SlotSelection {
48
56
  */
49
57
  export interface TimeSlotsFilters {
50
58
  /** Filter by specific locations */
51
- locations?: Location[];
59
+ location?: Location;
52
60
  /** Filter by specific staff member IDs */
53
61
  staffMemberIds?: string[];
54
62
  /** Filter by bookable status. If undefined, returns both bookable and non-bookable */
@@ -65,31 +65,13 @@ export const TimeSlotListService = implementService.withConfig()(TimeSlotListSer
65
65
  * Helper: Get services from config or BookingService
66
66
  */
67
67
  const getServices = () => {
68
- if (config.services?.length)
69
- return config.services;
70
- return bookingService.serviceSelections.get().map((s) => s.service);
71
- };
72
- /**
73
- * Helper: Get filters from config or BookingService
74
- */
75
- const getFilters = () => {
76
- // Get BookingService selections (these take priority)
77
- const location = bookingService.location.get();
78
- const serviceSelections = bookingService.serviceSelections.get();
79
- const selectedStaffMemberIds = serviceSelections
80
- .map((serviceSelection) => serviceSelection.resources.map((r) => r._id))
81
- .flat();
82
- const selectedLocation = location ? { _id: location.id } : null;
83
- // Merge config filters with BookingService selections (selections win)
84
- return {
85
- ...config.filters,
86
- locations: selectedLocation
87
- ? [selectedLocation]
88
- : config.filters?.locations,
89
- staffMemberIds: selectedStaffMemberIds.length
90
- ? selectedStaffMemberIds
91
- : config.filters?.staffMemberIds,
92
- };
68
+ const selectedServices = bookingService.serviceSelections
69
+ .get()
70
+ .map((s) => s.service);
71
+ if (selectedServices.length) {
72
+ return selectedServices;
73
+ }
74
+ return config.services ?? [];
93
75
  };
94
76
  /**
95
77
  * Fetch time slots from API
@@ -97,7 +79,6 @@ export const TimeSlotListService = implementService.withConfig()(TimeSlotListSer
97
79
  */
98
80
  const fetchTimeSlots = async () => {
99
81
  const selectedServices = getServices();
100
- const filters = getFilters();
101
82
  isLoadingSignal.set(true);
102
83
  errorSignal.set(null);
103
84
  cursorSignal.set(undefined);
@@ -110,7 +91,7 @@ export const TimeSlotListService = implementService.withConfig()(TimeSlotListSer
110
91
  timeZone: bookingService.timezone.get(),
111
92
  viewMode: viewModeSignal.get(),
112
93
  cursor: cursorSignal.get(),
113
- ...filters,
94
+ ...config.filters,
114
95
  });
115
96
  timeSlotsSignal.set(response.timeSlots);
116
97
  const nextCursor = response.cursorPagingMetadata?.cursors?.next ?? undefined;
@@ -303,7 +284,6 @@ export const TimeSlotListService = implementService.withConfig()(TimeSlotListSer
303
284
  if (!cursor || isLoadingSignal.get())
304
285
  return;
305
286
  const selectedServices = getServices();
306
- const filters = getFilters();
307
287
  isLoadingSignal.set(true);
308
288
  try {
309
289
  const response = await fetchAvailability({
@@ -313,7 +293,7 @@ export const TimeSlotListService = implementService.withConfig()(TimeSlotListSer
313
293
  timeZone: bookingService.timezone.get(),
314
294
  cursor,
315
295
  viewMode: viewModeSignal.get(),
316
- ...filters,
296
+ ...config.filters,
317
297
  });
318
298
  // API returns grouped slots, merge with existing
319
299
  const existing = timeSlotsSignal.get();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -33,8 +33,9 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
+ "@wix/auto_sdk_bookings_bookings": "^1.0.103",
36
37
  "@wix/auto_sdk_bookings_event-time-slots": "^1.0.64",
37
- "@wix/bookings": "^1.0.122",
38
+ "@wix/auto_sdk_ecom_checkout": "^1.0.104",
38
39
  "@wix/form-public": "^0.64.0",
39
40
  "@wix/headless-forms": "0.0.20",
40
41
  "@wix/headless-media": "0.0.18",
@@ -71,5 +72,5 @@
71
72
  "groupId": "com.wixpress.headless-components"
72
73
  }
73
74
  },
74
- "falconPackageHash": "54198290a5192d2c6af4f5640d150d453c2d0c586edd1b238a1164d0"
75
+ "falconPackageHash": "75acc1ea692508f639c9e8416715d9db8c2f40cc6a4bf7bfc7839a0e"
75
76
  }