@wix/headless-bookings 0.0.105 → 0.0.106

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 (76) hide show
  1. package/cjs/dist/__mocks__/booking/booking-client-service.js +25 -20
  2. package/cjs/dist/__mocks__/booking/booking-mocks.js +28 -20
  3. package/cjs/dist/__mocks__/payment/payment-mocks.js +6 -3
  4. package/cjs/dist/__mocks__/services/services-mocks.js +79 -74
  5. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +39 -33
  6. package/cjs/dist/__mocks__/time-slots/time-slots-core.js +43 -33
  7. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +18 -13
  8. package/cjs/dist/api/create-booking/index.js +6 -3
  9. package/cjs/dist/api/create-checkout/index.js +9 -4
  10. package/cjs/dist/api/create-order/index.js +6 -3
  11. package/cjs/dist/api/fetch-availability/index.js +18 -15
  12. package/cjs/dist/api/index.js +24 -7
  13. package/cjs/dist/api/query-categories/index.js +6 -3
  14. package/cjs/dist/api/query-locations/index.js +9 -5
  15. package/cjs/dist/api/query-services/index.js +24 -17
  16. package/cjs/dist/react/booking/Book.js +51 -12
  17. package/cjs/dist/react/booking/Booking.js +68 -26
  18. package/cjs/dist/react/booking/BookingItem.js +56 -15
  19. package/cjs/dist/react/booking-form/BookingForm.js +63 -21
  20. package/cjs/dist/react/core/booking/Book.js +14 -11
  21. package/cjs/dist/react/core/booking/Booking.js +35 -23
  22. package/cjs/dist/react/core/booking-form/BookingForm.js +63 -26
  23. package/cjs/dist/react/core/location/Location.js +60 -21
  24. package/cjs/dist/react/core/location-list/LocationList.js +15 -10
  25. package/cjs/dist/react/core/payment/Payment.js +41 -30
  26. package/cjs/dist/react/core/service/Service.js +28 -19
  27. package/cjs/dist/react/core/service/ServiceMediaCover.js +7 -4
  28. package/cjs/dist/react/core/service/ServiceMediaGallery.js +7 -4
  29. package/cjs/dist/react/core/service/ServiceMediaMain.js +7 -4
  30. package/cjs/dist/react/core/service-list/ServiceList.js +12 -8
  31. package/cjs/dist/react/core/service-list/ServiceListFilter.js +9 -6
  32. package/cjs/dist/react/core/staff-member/StaffMember.js +20 -14
  33. package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +19 -14
  34. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
  35. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +21 -15
  36. package/cjs/dist/react/index.js +49 -13
  37. package/cjs/dist/react/location/Location.js +76 -36
  38. package/cjs/dist/react/location/LocationList.js +70 -31
  39. package/cjs/dist/react/payment/Payment.js +87 -48
  40. package/cjs/dist/react/service/Service.js +197 -158
  41. package/cjs/dist/react/service/ServiceMedia.js +56 -17
  42. package/cjs/dist/react/service-list/ServiceList.js +71 -32
  43. package/cjs/dist/react/staff-member/StaffMember.js +61 -20
  44. package/cjs/dist/react/staff-member/StaffMemberList.js +68 -29
  45. package/cjs/dist/react/time-slot-list/TimeSlot.js +95 -56
  46. package/cjs/dist/react/time-slot-list/TimeSlotList.js +87 -48
  47. package/cjs/dist/services/booking/book-action/bookAction.js +21 -18
  48. package/cjs/dist/services/booking/book-action/buildBookingRequest.js +18 -15
  49. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +8 -5
  50. package/cjs/dist/services/booking/book-action/canBook.js +4 -1
  51. package/cjs/dist/services/booking/book-action/index.js +15 -6
  52. package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +4 -1
  53. package/cjs/dist/services/booking/book-action/types.js +5 -2
  54. package/cjs/dist/services/booking/booking.js +11 -8
  55. package/cjs/dist/services/booking-form/booking-form.js +26 -18
  56. package/cjs/dist/services/booking-form/utils.js +10 -4
  57. package/cjs/dist/services/constants.js +6 -3
  58. package/cjs/dist/services/index.js +48 -10
  59. package/cjs/dist/services/location-list/location-list.def.js +7 -5
  60. package/cjs/dist/services/location-list/location-list.js +31 -23
  61. package/cjs/dist/services/payment/payment.def.js +5 -2
  62. package/cjs/dist/services/payment/payment.js +22 -17
  63. package/cjs/dist/services/service/service.js +33 -29
  64. package/cjs/dist/services/service-list/service-list.js +22 -18
  65. package/cjs/dist/services/staff-member-list/staff-member-list.def.js +5 -2
  66. package/cjs/dist/services/staff-member-list/staff-member-list.js +16 -10
  67. package/cjs/dist/services/time-slot-list/index.js +12 -3
  68. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +8 -5
  69. package/cjs/dist/services/time-slot-list/time-slot-list.js +24 -19
  70. package/cjs/dist/services/time-slot-list/time-slot.js +9 -6
  71. package/cjs/dist/utils/dateAndTime.js +7 -2
  72. package/cjs/dist/utils/guid.js +4 -1
  73. package/cjs/dist/utils/index.js +5 -1
  74. package/cjs/dist/utils/money.js +6 -2
  75. package/cjs/dist/utils/navigation.js +6 -3
  76. package/package.json +3 -3
@@ -1,36 +1,42 @@
1
- import { vi } from 'vitest';
2
- import { mockSignal, createMockBookingService, createMockSignalsService, } from '../booking/booking-client-service.js';
3
- import { mockTimeSlot as defaultTimeSlot, mockTimeSlots as defaultTimeSlots, createTimeSlotListConfig, } from './time-slots-mocks.js';
4
- import { ClientServiceIds } from '../../services/constants.js';
5
- import { TimeSlotListService } from '../../services/time-slot-list/time-slot-list.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMockTimeSlotListService = createMockTimeSlotListService;
4
+ exports.createTimeSlotListService = createTimeSlotListService;
5
+ exports.setupTimeSlotClientServiceMocks = setupTimeSlotClientServiceMocks;
6
+ exports.setupTimeSlotListClientServiceMocks = setupTimeSlotListClientServiceMocks;
7
+ const vitest_1 = require("vitest");
8
+ const booking_client_service_js_1 = require("../booking/booking-client-service.js");
9
+ const time_slots_mocks_js_1 = require("./time-slots-mocks.js");
10
+ const constants_js_1 = require("../../services/constants.js");
11
+ const time_slot_list_js_1 = require("../../services/time-slot-list/time-slot-list.js");
6
12
  /**
7
13
  * Creates a mock TimeSlotListService
8
14
  */
9
- export function createMockTimeSlotListService(options = {}) {
10
- const { timeSlots = defaultTimeSlots, hasMore = false, isLoading = false, error = null, dateRange = {
15
+ function createMockTimeSlotListService(options = {}) {
16
+ const { timeSlots = time_slots_mocks_js_1.mockTimeSlots, hasMore = false, isLoading = false, error = null, dateRange = {
11
17
  start: new Date('2024-01-15'),
12
18
  end: new Date('2024-01-22'),
13
19
  }, } = options;
14
20
  const actions = {
15
- loadMore: vi.fn(),
16
- setDateRange: vi.fn(),
17
- selectSlot: vi.fn(),
18
- selectStaffMember: vi.fn(),
19
- clearStaffSelection: vi.fn(),
21
+ loadMore: vitest_1.vi.fn(),
22
+ setDateRange: vitest_1.vi.fn(),
23
+ selectSlot: vitest_1.vi.fn(),
24
+ selectStaffMember: vitest_1.vi.fn(),
25
+ clearStaffSelection: vitest_1.vi.fn(),
20
26
  };
21
27
  return {
22
- timeSlots: mockSignal(timeSlots),
23
- hasMore: mockSignal(hasMore),
24
- isLoading: mockSignal(isLoading),
25
- error: mockSignal(error),
26
- dateRange: mockSignal(dateRange),
28
+ timeSlots: (0, booking_client_service_js_1.mockSignal)(timeSlots),
29
+ hasMore: (0, booking_client_service_js_1.mockSignal)(hasMore),
30
+ isLoading: (0, booking_client_service_js_1.mockSignal)(isLoading),
31
+ error: (0, booking_client_service_js_1.mockSignal)(error),
32
+ dateRange: (0, booking_client_service_js_1.mockSignal)(dateRange),
27
33
  actions,
28
34
  };
29
35
  }
30
- export function createTimeSlotListService(overrides = {}) {
31
- const config = createTimeSlotListConfig(overrides);
32
- const mockBookingService = createMockBookingService();
33
- const mockSignalsService = createMockSignalsService();
36
+ function createTimeSlotListService(overrides = {}) {
37
+ const config = (0, time_slots_mocks_js_1.createTimeSlotListConfig)(overrides);
38
+ const mockBookingService = (0, booking_client_service_js_1.createMockBookingService)();
39
+ const mockSignalsService = (0, booking_client_service_js_1.createMockSignalsService)();
34
40
  const getService = (definition) => {
35
41
  const def = definition;
36
42
  if (def.name === 'signals') {
@@ -41,7 +47,7 @@ export function createTimeSlotListService(overrides = {}) {
41
47
  }
42
48
  throw new Error(`Unknown service: ${def.name}`);
43
49
  };
44
- const service = TimeSlotListService({
50
+ const service = (0, time_slot_list_js_1.TimeSlotListService)({
45
51
  getService,
46
52
  config,
47
53
  });
@@ -54,18 +60,18 @@ export function createTimeSlotListService(overrides = {}) {
54
60
  * Setup client service mocks for TimeSlot core component tests
55
61
  * @param options - Optional configuration (timeSlot state + booking state)
56
62
  */
57
- export function setupTimeSlotClientServiceMocks(options = {}, mockUseService) {
58
- const { timeSlot = defaultTimeSlot, ...bookingOptions } = options;
59
- const timeSlotService = { timeSlotSignal: mockSignal(timeSlot) };
63
+ function setupTimeSlotClientServiceMocks(options = {}, mockUseService) {
64
+ const { timeSlot = time_slots_mocks_js_1.mockTimeSlot, ...bookingOptions } = options;
65
+ const timeSlotService = { timeSlotSignal: (0, booking_client_service_js_1.mockSignal)(timeSlot) };
60
66
  const timeSlotListService = createMockTimeSlotListService();
61
- const bookingService = createMockBookingService(bookingOptions);
67
+ const bookingService = (0, booking_client_service_js_1.createMockBookingService)(bookingOptions);
62
68
  mockUseService.mockImplementation((def) => {
63
69
  switch (def.id) {
64
- case ClientServiceIds.timeSlot:
70
+ case constants_js_1.ClientServiceIds.timeSlot:
65
71
  return timeSlotService;
66
- case ClientServiceIds.timeSlotList:
72
+ case constants_js_1.ClientServiceIds.timeSlotList:
67
73
  return timeSlotListService;
68
- case ClientServiceIds.booking:
74
+ case constants_js_1.ClientServiceIds.booking:
69
75
  return bookingService;
70
76
  default:
71
77
  return {};
@@ -84,7 +90,7 @@ export function setupTimeSlotClientServiceMocks(options = {}, mockUseService) {
84
90
  * Setup client service mocks for TimeSlotList core component tests
85
91
  * @param options - Optional configuration for the mock state (TimeSlotList + Booking)
86
92
  */
87
- export function setupTimeSlotListClientServiceMocks(options = {}, mockUseService) {
93
+ function setupTimeSlotListClientServiceMocks(options = {}, mockUseService) {
88
94
  const {
89
95
  // TimeSlotList state
90
96
  timeSlots, hasMore, isLoading, error, dateRange,
@@ -97,7 +103,7 @@ export function setupTimeSlotListClientServiceMocks(options = {}, mockUseService
97
103
  error,
98
104
  dateRange,
99
105
  });
100
- const bookingService = createMockBookingService({
106
+ const bookingService = (0, booking_client_service_js_1.createMockBookingService)({
101
107
  serviceSelections,
102
108
  location,
103
109
  timezone,
@@ -105,9 +111,9 @@ export function setupTimeSlotListClientServiceMocks(options = {}, mockUseService
105
111
  });
106
112
  mockUseService.mockImplementation((def) => {
107
113
  switch (def.id) {
108
- case ClientServiceIds.timeSlotList:
114
+ case constants_js_1.ClientServiceIds.timeSlotList:
109
115
  return timeSlotListService;
110
- case ClientServiceIds.booking:
116
+ case constants_js_1.ClientServiceIds.booking:
111
117
  return bookingService;
112
118
  default:
113
119
  return {};
@@ -1,15 +1,25 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { vi } from 'vitest';
3
- import React from 'react';
4
- import { mockTimeSlot, mockTimeSlots } from './time-slots-mocks.js';
5
- export function createCoreTimeSlotMock(config) {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GenericListContext = void 0;
7
+ exports.createCoreTimeSlotMock = createCoreTimeSlotMock;
8
+ exports.createCoreTimeSlotListMock = createCoreTimeSlotListMock;
9
+ exports.createCoreTimeSlotInfoMock = createCoreTimeSlotInfoMock;
10
+ exports.createGenericListMock = createGenericListMock;
11
+ const jsx_runtime_1 = require("react/jsx-runtime");
12
+ const vitest_1 = require("vitest");
13
+ const react_1 = __importDefault(require("react"));
14
+ const time_slots_mocks_js_1 = require("./time-slots-mocks.js");
15
+ function createCoreTimeSlotMock(config) {
6
16
  const { timeSlot, staffMembers, selectTimeSlot, clearStaffSelection, selectStaffMember, } = config;
7
17
  const startDate = new Date(timeSlot.localStartDate);
8
18
  const endDate = new Date(timeSlot.localEndDate);
9
19
  const durationInMinutes = Math.round((endDate.getTime() - startDate.getTime()) / (1000 * 60));
10
20
  return {
11
- Root: vi.fn(({ children, config: cfg }) => (_jsx("div", { "data-timeslot-id": cfg.timeSlot.scheduleId, children: children }))),
12
- Info: vi.fn(({ children }) => children({
21
+ Root: vitest_1.vi.fn(({ children, config: cfg }) => ((0, jsx_runtime_1.jsx)("div", { "data-timeslot-id": cfg.timeSlot.scheduleId, children: children }))),
22
+ Info: vitest_1.vi.fn(({ children }) => children({
13
23
  startDate,
14
24
  endDate,
15
25
  durationInMinutes,
@@ -18,51 +28,51 @@ export function createCoreTimeSlotMock(config) {
18
28
  isSelected: false,
19
29
  timeSlot,
20
30
  })),
21
- Actions: vi.fn(({ children }) => children({
31
+ Actions: vitest_1.vi.fn(({ children }) => children({
22
32
  selectTimeSlot,
23
33
  clearStaffSelection,
24
34
  timeSlot,
25
35
  bookable: timeSlot.bookable ?? false,
26
36
  isSelected: false,
27
37
  })),
28
- StaffMembers: vi.fn(({ children }) => children({ staffMembers, selectStaffMember: vi.fn() })),
29
- StaffMemberProvider: vi.fn(({ children, staffMember }) => (_jsx("div", { "data-staff-id": staffMember.id, children: children }))),
30
- StaffMemberInfo: vi.fn(({ children }) => children({
38
+ StaffMembers: vitest_1.vi.fn(({ children }) => children({ staffMembers, selectStaffMember: vitest_1.vi.fn() })),
39
+ StaffMemberProvider: vitest_1.vi.fn(({ children, staffMember }) => ((0, jsx_runtime_1.jsx)("div", { "data-staff-id": staffMember.id, children: children }))),
40
+ StaffMemberInfo: vitest_1.vi.fn(({ children }) => children({
31
41
  name: staffMembers[0]?.name ?? '',
32
42
  isSelected: false,
33
43
  staffMember: staffMembers[0],
34
44
  })),
35
- StaffMemberActions: vi.fn(({ children }) => children({
45
+ StaffMemberActions: vitest_1.vi.fn(({ children }) => children({
36
46
  selectStaffMember,
37
47
  isSelected: false,
38
48
  staffMember: staffMembers[0],
39
49
  })),
40
50
  };
41
51
  }
42
- export function createCoreTimeSlotListMock(config = { timeSlots: mockTimeSlots }) {
52
+ function createCoreTimeSlotListMock(config = { timeSlots: time_slots_mocks_js_1.mockTimeSlots }) {
43
53
  const { timeSlots, timezone = 'America/New_York', displayName = 'Eastern Standard Time', startDate = new Date('2024-01-15'), endDate = new Date('2024-01-22'), } = config;
44
54
  return {
45
- Root: vi.fn(({ children }) => _jsx(_Fragment, { children: children })),
46
- Timezone: vi.fn(({ children }) => children({ timezone, displayName })),
47
- ListData: vi.fn(({ children }) => children({
55
+ Root: vitest_1.vi.fn(({ children }) => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })),
56
+ Timezone: vitest_1.vi.fn(({ children }) => children({ timezone, displayName })),
57
+ ListData: vitest_1.vi.fn(({ children }) => children({
48
58
  timeSlots,
49
59
  hasMore: false,
50
60
  isLoading: false,
51
61
  error: null,
52
- loadMore: vi.fn(),
62
+ loadMore: vitest_1.vi.fn(),
53
63
  hasSelectedTimeSlot: false,
54
64
  })),
55
- DateRange: vi.fn(({ children }) => children({
65
+ DateRange: vitest_1.vi.fn(({ children }) => children({
56
66
  startDate,
57
67
  endDate,
58
- setDateRange: vi.fn(),
68
+ setDateRange: vitest_1.vi.fn(),
59
69
  })),
60
70
  };
61
71
  }
62
- export function createCoreTimeSlotInfoMock(timeSlot = mockTimeSlot) {
72
+ function createCoreTimeSlotInfoMock(timeSlot = time_slots_mocks_js_1.mockTimeSlot) {
63
73
  return {
64
- Root: vi.fn(({ children, config: cfg }) => (_jsx("div", { "data-timeslot-id": cfg.timeSlot.scheduleId, children: children }))),
65
- Info: vi.fn(({ children }) => children({
74
+ Root: vitest_1.vi.fn(({ children, config: cfg }) => ((0, jsx_runtime_1.jsx)("div", { "data-timeslot-id": cfg.timeSlot.scheduleId, children: children }))),
75
+ Info: vitest_1.vi.fn(({ children }) => children({
66
76
  startDate: new Date(timeSlot.localStartDate),
67
77
  endDate: new Date(timeSlot.localEndDate),
68
78
  durationInMinutes: 60,
@@ -73,25 +83,25 @@ export function createCoreTimeSlotInfoMock(timeSlot = mockTimeSlot) {
73
83
  })),
74
84
  };
75
85
  }
76
- const GenericListContext = React.createContext(null);
77
- export function createGenericListMock() {
86
+ const GenericListContext = react_1.default.createContext(null);
87
+ exports.GenericListContext = GenericListContext;
88
+ function createGenericListMock() {
78
89
  return {
79
90
  GenericList: {
80
- Root: vi.fn(({ children, items, className, ...props }) => (_jsx(GenericListContext.Provider, { value: { items }, children: _jsx("div", { className: className, ...props, children: children }) }))),
81
- Items: vi.fn(({ children, emptyState }) => {
82
- const ctx = React.useContext(GenericListContext);
83
- return ctx?.items?.length ? _jsx("div", { children: children }) : emptyState || null;
91
+ Root: vitest_1.vi.fn(({ children, items, className, ...props }) => ((0, jsx_runtime_1.jsx)(GenericListContext.Provider, { value: { items }, children: (0, jsx_runtime_1.jsx)("div", { className: className, ...props, children: children }) }))),
92
+ Items: vitest_1.vi.fn(({ children, emptyState }) => {
93
+ const ctx = react_1.default.useContext(GenericListContext);
94
+ return ctx?.items?.length ? (0, jsx_runtime_1.jsx)("div", { children: children }) : emptyState || null;
84
95
  }),
85
- Repeater: vi.fn(({ itemWrapper, children }) => {
86
- const ctx = React.useContext(GenericListContext);
96
+ Repeater: vitest_1.vi.fn(({ itemWrapper, children }) => {
97
+ const ctx = react_1.default.useContext(GenericListContext);
87
98
  if (!ctx?.items?.length)
88
99
  return null;
89
- return (_jsx(_Fragment, { children: ctx.items.map((item, i) => itemWrapper({ item, index: i, children })) }));
100
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ctx.items.map((item, i) => itemWrapper({ item, index: i, children })) }));
90
101
  }),
91
102
  Actions: {
92
- LoadMore: vi.fn(({ children, ...props }) => (_jsx("button", { ...props, children: children }))),
103
+ LoadMore: vitest_1.vi.fn(({ children, ...props }) => ((0, jsx_runtime_1.jsx)("button", { ...props, children: children }))),
93
104
  },
94
105
  },
95
106
  };
96
107
  }
97
- export { GenericListContext };
@@ -1,4 +1,9 @@
1
- export function createTimeSlot(overrides = {}) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockCursorPagingMetadataNoMore = exports.mockTimezone = exports.mockEndDate = exports.mockStartDate = exports.mockTimeSlots = exports.mockTimeSlotNotBookable = exports.mockTimeSlotMultipleStaff = exports.mockTimeSlot = void 0;
4
+ exports.createTimeSlot = createTimeSlot;
5
+ exports.createTimeSlotListConfig = createTimeSlotListConfig;
6
+ function createTimeSlot(overrides = {}) {
2
7
  return {
3
8
  localStartDate: '2024-01-15T10:00:00',
4
9
  localEndDate: '2024-01-15T11:00:00',
@@ -11,7 +16,7 @@ export function createTimeSlot(overrides = {}) {
11
16
  ...overrides,
12
17
  };
13
18
  }
14
- export function createTimeSlotListConfig(overrides = {}) {
19
+ function createTimeSlotListConfig(overrides = {}) {
15
20
  const { startDate = new Date('2024-01-15T00:00:00'), endDate = new Date('2024-01-22T00:00:00'), timezone = 'America/New_York', timeSlots, ...rest } = overrides;
16
21
  return {
17
22
  startDate,
@@ -21,8 +26,8 @@ export function createTimeSlotListConfig(overrides = {}) {
21
26
  ...(timeSlots !== undefined ? { timeSlots } : {}),
22
27
  };
23
28
  }
24
- export const mockTimeSlot = createTimeSlot();
25
- export const mockTimeSlotMultipleStaff = createTimeSlot({
29
+ exports.mockTimeSlot = createTimeSlot();
30
+ exports.mockTimeSlotMultipleStaff = createTimeSlot({
26
31
  availableResources: [
27
32
  {
28
33
  resources: [
@@ -32,19 +37,19 @@ export const mockTimeSlotMultipleStaff = createTimeSlot({
32
37
  },
33
38
  ],
34
39
  });
35
- export const mockTimeSlotNotBookable = createTimeSlot({
40
+ exports.mockTimeSlotNotBookable = createTimeSlot({
36
41
  localStartDate: '2024-01-15T14:00:00',
37
42
  localEndDate: '2024-01-15T15:00:00',
38
43
  bookable: false,
39
44
  remainingCapacity: 0,
40
45
  location: { _id: 'loc-2', name: 'Downtown Branch' },
41
46
  });
42
- export const mockTimeSlots = [
43
- mockTimeSlot,
44
- mockTimeSlotMultipleStaff,
45
- mockTimeSlotNotBookable,
47
+ exports.mockTimeSlots = [
48
+ exports.mockTimeSlot,
49
+ exports.mockTimeSlotMultipleStaff,
50
+ exports.mockTimeSlotNotBookable,
46
51
  ];
47
- export const mockStartDate = new Date('2024-01-15T00:00:00');
48
- export const mockEndDate = new Date('2024-01-22T00:00:00');
49
- export const mockTimezone = 'America/New_York';
50
- export const mockCursorPagingMetadataNoMore = { cursors: {} };
52
+ exports.mockStartDate = new Date('2024-01-15T00:00:00');
53
+ exports.mockEndDate = new Date('2024-01-22T00:00:00');
54
+ exports.mockTimezone = 'America/New_York';
55
+ exports.mockCursorPagingMetadataNoMore = { cursors: {} };
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * Create Booking API
3
4
  * Wrapper for the Wix Bookings createBooking SDK function
4
5
  */
5
- import { createBooking as createBookingSdk, } from '@wix/auto_sdk_bookings_bookings';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createBooking = createBooking;
8
+ const auto_sdk_bookings_bookings_1 = require("@wix/auto_sdk_bookings_bookings");
6
9
  /**
7
10
  * Creates a booking with the specified booking data and options
8
11
  *
@@ -26,8 +29,8 @@ import { createBooking as createBookingSdk, } from '@wix/auto_sdk_bookings_booki
26
29
  * );
27
30
  * ```
28
31
  */
29
- export async function createBooking(booking, options) {
30
- return createBookingSdk(booking, {
32
+ async function createBooking(booking, options) {
33
+ return (0, auto_sdk_bookings_bookings_1.createBooking)(booking, {
31
34
  participantNotification: options?.participantNotification,
32
35
  sendSmsReminder: options?.sendSmsReminder,
33
36
  formSubmission: options?.formSubmission,
@@ -1,8 +1,12 @@
1
+ "use strict";
1
2
  /**
2
3
  * Create Checkout API
3
4
  * Wrapper for the Wix eCommerce createCheckout SDK function
4
5
  */
5
- import { createCheckout as createCheckoutSdk, } from '@wix/auto_sdk_ecom_checkout';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ChannelType = void 0;
8
+ exports.createCheckout = createCheckout;
9
+ const auto_sdk_ecom_checkout_1 = require("@wix/auto_sdk_ecom_checkout");
6
10
  /**
7
11
  * Creates a checkout session with the specified request data
8
12
  *
@@ -29,9 +33,10 @@ import { createCheckout as createCheckoutSdk, } from '@wix/auto_sdk_ecom_checkou
29
33
  * });
30
34
  * ```
31
35
  */
32
- export async function createCheckout(request) {
33
- const checkout = await createCheckoutSdk(request);
36
+ async function createCheckout(request) {
37
+ const checkout = await (0, auto_sdk_ecom_checkout_1.createCheckout)(request);
34
38
  return { checkout };
35
39
  }
36
40
  // Re-export types and constants that consumers may need
37
- export { ChannelType, } from '@wix/auto_sdk_ecom_checkout';
41
+ var auto_sdk_ecom_checkout_2 = require("@wix/auto_sdk_ecom_checkout");
42
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return auto_sdk_ecom_checkout_2.ChannelType; } });
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * Create Order API
3
4
  * Wrapper for the Wix eCommerce createOrder SDK function
4
5
  */
5
- import { createOrder as createOrderSdk, } from '@wix/auto_sdk_ecom_checkout';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createOrder = createOrder;
8
+ const auto_sdk_ecom_checkout_1 = require("@wix/auto_sdk_ecom_checkout");
6
9
  /**
7
10
  * Creates an order from a checkout session
8
11
  *
@@ -16,6 +19,6 @@ import { createOrder as createOrderSdk, } from '@wix/auto_sdk_ecom_checkout';
16
19
  * const orderId = response.orderId;
17
20
  * ```
18
21
  */
19
- export async function createOrder(checkoutId, options) {
20
- return createOrderSdk(checkoutId, options);
22
+ async function createOrder(checkoutId, options) {
23
+ return (0, auto_sdk_ecom_checkout_1.createOrder)(checkoutId, options);
21
24
  }
@@ -1,13 +1,16 @@
1
+ "use strict";
1
2
  /**
2
3
  * Time Slot List API
3
4
  * Fetches available time slots for booking services from Wix Bookings
4
5
  */
5
- import { listAvailabilityTimeSlots, } from '@wix/auto_sdk_bookings_availability-time-slots';
6
- import { listEventTimeSlots } from '@wix/auto_sdk_bookings_event-time-slots';
7
- import { ServiceType } from '@wix/auto_sdk_bookings_services';
8
- import { format } from 'date-fns';
9
- import { ViewMode, } from '../../services/time-slot-list/time-slot-list.def.js';
10
- import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../services/constants.js';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.fetchAvailability = fetchAvailability;
8
+ const auto_sdk_bookings_availability_time_slots_1 = require("@wix/auto_sdk_bookings_availability-time-slots");
9
+ const auto_sdk_bookings_event_time_slots_1 = require("@wix/auto_sdk_bookings_event-time-slots");
10
+ const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
11
+ const date_fns_1 = require("date-fns");
12
+ const time_slot_list_def_js_1 = require("../../services/time-slot-list/time-slot-list.def.js");
13
+ const constants_js_1 = require("../../services/constants.js");
11
14
  // ============================================================================
12
15
  // Internal Types
13
16
  // ============================================================================
@@ -25,7 +28,7 @@ var FlowType;
25
28
  */
26
29
  function toLocalDateString(date) {
27
30
  const pattern = "yyyy-MM-dd'T'HH:mm:ss";
28
- return format(date, pattern);
31
+ return (0, date_fns_1.format)(date, pattern);
29
32
  }
30
33
  // ============================================================================
31
34
  // Internal Flow Detection
@@ -35,13 +38,13 @@ function toLocalDateString(date) {
35
38
  */
36
39
  function detectFlow(bookingServices, viewMode) {
37
40
  if (bookingServices.length === 0) {
38
- if (viewMode === ViewMode.AGENDA) {
41
+ if (viewMode === time_slot_list_def_js_1.ViewMode.AGENDA) {
39
42
  return FlowType.CLASS; // AGENDA can fetch all classes without specifying services
40
43
  }
41
44
  throw new Error('Services required for classic view mode');
42
45
  }
43
- const allAppointments = bookingServices.every((s) => s.type === ServiceType.APPOINTMENT);
44
- const allClasses = bookingServices.every((s) => s.type === ServiceType.CLASS);
46
+ const allAppointments = bookingServices.every((s) => s.type === auto_sdk_bookings_services_1.ServiceType.APPOINTMENT);
47
+ const allClasses = bookingServices.every((s) => s.type === auto_sdk_bookings_services_1.ServiceType.CLASS);
45
48
  if (!allAppointments && !allClasses) {
46
49
  throw new Error('All services must be either appointments or classes');
47
50
  }
@@ -70,7 +73,7 @@ function detectFlow(bookingServices, viewMode) {
70
73
  * // response.timeSlots are grouped by time
71
74
  * ```
72
75
  */
73
- export async function fetchAvailability({ services: selectedServices, viewMode = ViewMode.CLASSIC, fromLocalDate, toLocalDate, timeZone, location, staffMemberIds, cursor, slotsPerPage, bookable, bookingPolicyViolations, timeSlotsPerDay, }) {
76
+ async function fetchAvailability({ services: selectedServices, viewMode = time_slot_list_def_js_1.ViewMode.CLASSIC, fromLocalDate, toLocalDate, timeZone, location, staffMemberIds, cursor, slotsPerPage, bookable, bookingPolicyViolations, timeSlotsPerDay, }) {
74
77
  const flow = detectFlow(selectedServices, viewMode);
75
78
  const serviceIds = selectedServices.map((s) => s._id);
76
79
  // Convert Date objects to local ISO strings
@@ -87,18 +90,18 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
87
90
  const resourceTypes = staffMemberIds?.length
88
91
  ? [
89
92
  {
90
- resourceTypeId: STAFF_MEMBER_RESOURCE_TYPE_ID,
93
+ resourceTypeId: constants_js_1.STAFF_MEMBER_RESOURCE_TYPE_ID,
91
94
  resourceIds: staffMemberIds,
92
95
  },
93
96
  ]
94
97
  : undefined;
95
98
  const includeResourceTypeIds = isFetchAvailabileDays
96
99
  ? undefined
97
- : [STAFF_MEMBER_RESOURCE_TYPE_ID];
100
+ : [constants_js_1.STAFF_MEMBER_RESOURCE_TYPE_ID];
98
101
  const locations = location
99
102
  ? [{ _id: location.id, locationType: location.locationType }]
100
103
  : undefined;
101
- const response = await listAvailabilityTimeSlots({
104
+ const response = await (0, auto_sdk_bookings_availability_time_slots_1.listAvailabilityTimeSlots)({
102
105
  serviceId: serviceIds[0],
103
106
  fromLocalDate: fromLocalDateStr,
104
107
  toLocalDate: toLocalDateStr,
@@ -130,7 +133,7 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
130
133
  if (staffMemberIds?.length) {
131
134
  eventFilter['resources.id'] = { $hasSome: staffMemberIds };
132
135
  }
133
- const response = await listEventTimeSlots({
136
+ const response = await (0, auto_sdk_bookings_event_time_slots_1.listEventTimeSlots)({
134
137
  fromLocalDate: fromLocalDateStr,
135
138
  toLocalDate: toLocalDateStr,
136
139
  timeZone,
@@ -1,16 +1,33 @@
1
+ "use strict";
1
2
  /**
2
3
  * API Layer
3
4
  * Exports all Wix Bookings API functions
4
5
  *
5
6
  * @module API
6
7
  */
7
- export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
- export { fetchAvailability } from './fetch-availability/index.js';
9
- export { createBooking, } from './create-booking/index.js';
10
- export { createCheckout, ChannelType, } from './create-checkout/index.js';
11
- export { createOrder, } from './create-order/index.js';
12
- export { queryLocations, getLocationById, } from './query-locations/index.js';
13
- export { queryCategories, } from './query-categories/index.js';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.createOrder = exports.ChannelType = exports.createCheckout = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
10
+ var index_js_1 = require("./query-services/index.js");
11
+ Object.defineProperty(exports, "getServiceById", { enumerable: true, get: function () { return index_js_1.getServiceById; } });
12
+ Object.defineProperty(exports, "getServiceBySlug", { enumerable: true, get: function () { return index_js_1.getServiceBySlug; } });
13
+ Object.defineProperty(exports, "queryServices", { enumerable: true, get: function () { return index_js_1.queryServices; } });
14
+ Object.defineProperty(exports, "convertPlatformFilterToApiFilter", { enumerable: true, get: function () { return index_js_1.convertPlatformFilterToApiFilter; } });
15
+ Object.defineProperty(exports, "SYNTHETIC_CUSTOM_ID", { enumerable: true, get: function () { return index_js_1.SYNTHETIC_CUSTOM_ID; } });
16
+ Object.defineProperty(exports, "SYNTHETIC_CUSTOMER_ID", { enumerable: true, get: function () { return index_js_1.SYNTHETIC_CUSTOMER_ID; } });
17
+ var index_js_2 = require("./fetch-availability/index.js");
18
+ Object.defineProperty(exports, "fetchAvailability", { enumerable: true, get: function () { return index_js_2.fetchAvailability; } });
19
+ var index_js_3 = require("./create-booking/index.js");
20
+ Object.defineProperty(exports, "createBooking", { enumerable: true, get: function () { return index_js_3.createBooking; } });
21
+ var index_js_4 = require("./create-checkout/index.js");
22
+ Object.defineProperty(exports, "createCheckout", { enumerable: true, get: function () { return index_js_4.createCheckout; } });
23
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return index_js_4.ChannelType; } });
24
+ var index_js_5 = require("./create-order/index.js");
25
+ Object.defineProperty(exports, "createOrder", { enumerable: true, get: function () { return index_js_5.createOrder; } });
26
+ var index_js_6 = require("./query-locations/index.js");
27
+ Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_6.queryLocations; } });
28
+ Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_6.getLocationById; } });
29
+ var index_js_7 = require("./query-categories/index.js");
30
+ Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_7.queryCategories; } });
14
31
  /**
15
32
  * PagingMetadata includes:
16
33
  * - limit: Number of items per page
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  /**
2
3
  * Query Categories API
3
4
  * Fetches booking service categories from Wix Bookings
4
5
  *
5
6
  * @module API/QueryCategories
6
7
  */
7
- import { categoriesV2 } from '@wix/bookings';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.queryCategories = queryCategories;
10
+ const bookings_1 = require("@wix/bookings");
8
11
  /**
9
12
  * Query all booking service categories.
10
13
  * Returns an array of categories sorted by creation date (ascending).
@@ -20,8 +23,8 @@ import { categoriesV2 } from '@wix/bookings';
20
23
  * });
21
24
  * ```
22
25
  */
23
- export async function queryCategories() {
24
- const result = await categoriesV2.queryCategories().find();
26
+ async function queryCategories() {
27
+ const result = await bookings_1.categoriesV2.queryCategories().find();
25
28
  return {
26
29
  categories: result.items || [],
27
30
  };
@@ -1,10 +1,14 @@
1
+ "use strict";
1
2
  /**
2
3
  * Query Locations API
3
4
  * Fetches business locations from Wix Bookings Services
4
5
  *
5
6
  * @module API/QueryLocations
6
7
  */
7
- import { queryLocations as queryLocationsApi, } from '@wix/auto_sdk_bookings_services';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.queryLocations = queryLocations;
10
+ exports.getLocationById = getLocationById;
11
+ const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
8
12
  /**
9
13
  * Query all locations connected to services.
10
14
  * Returns business locations array and existence flags for custom/customer locations.
@@ -20,8 +24,8 @@ import { queryLocations as queryLocationsApi, } from '@wix/auto_sdk_bookings_ser
20
24
  * // hasCustomerLocations indicates if any service is at customer's place
21
25
  * ```
22
26
  */
23
- export async function queryLocations() {
24
- const response = await queryLocationsApi();
27
+ async function queryLocations() {
28
+ const response = await (0, auto_sdk_bookings_services_1.queryLocations)();
25
29
  return {
26
30
  locations: (response.businessLocations?.locations || []),
27
31
  hasCustomLocations: response.customLocations?.exists || false,
@@ -41,9 +45,9 @@ export async function queryLocations() {
41
45
  * }
42
46
  * ```
43
47
  */
44
- export async function getLocationById(locationId) {
48
+ async function getLocationById(locationId) {
45
49
  try {
46
- const response = await queryLocationsApi({
50
+ const response = await (0, auto_sdk_bookings_services_1.queryLocations)({
47
51
  filter: {
48
52
  businessLocationIds: [locationId],
49
53
  },