@wix/headless-bookings 0.0.104 → 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.
- package/cjs/dist/__mocks__/booking/booking-client-service.js +25 -20
- package/cjs/dist/__mocks__/booking/booking-mocks.js +28 -20
- package/cjs/dist/__mocks__/payment/payment-mocks.js +6 -3
- package/cjs/dist/__mocks__/services/services-mocks.js +79 -74
- package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +39 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-core.js +43 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +18 -13
- package/cjs/dist/api/create-booking/index.js +6 -3
- package/cjs/dist/api/create-checkout/index.js +9 -4
- package/cjs/dist/api/create-order/index.js +6 -3
- package/cjs/dist/api/fetch-availability/index.js +18 -15
- package/cjs/dist/api/index.js +24 -7
- package/cjs/dist/api/query-categories/index.js +6 -3
- package/cjs/dist/api/query-locations/index.js +9 -5
- package/cjs/dist/api/query-services/index.js +24 -17
- package/cjs/dist/react/booking/Book.js +51 -12
- package/cjs/dist/react/booking/Booking.js +68 -26
- package/cjs/dist/react/booking/BookingItem.d.ts +2 -0
- package/cjs/dist/react/booking/BookingItem.js +57 -16
- package/cjs/dist/react/booking-form/BookingForm.js +63 -21
- package/cjs/dist/react/core/booking/Book.js +14 -11
- package/cjs/dist/react/core/booking/Booking.d.ts +3 -1
- package/cjs/dist/react/core/booking/Booking.js +38 -25
- package/cjs/dist/react/core/booking-form/BookingForm.js +63 -26
- package/cjs/dist/react/core/location/Location.js +60 -21
- package/cjs/dist/react/core/location-list/LocationList.js +15 -10
- package/cjs/dist/react/core/payment/Payment.js +41 -30
- package/cjs/dist/react/core/service/Service.js +28 -19
- package/cjs/dist/react/core/service/ServiceMediaCover.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaGallery.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaMain.js +7 -4
- package/cjs/dist/react/core/service-list/ServiceList.js +12 -8
- package/cjs/dist/react/core/service-list/ServiceListFilter.js +9 -6
- package/cjs/dist/react/core/staff-member/StaffMember.js +20 -14
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +19 -14
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +21 -15
- package/cjs/dist/react/index.js +49 -13
- package/cjs/dist/react/location/Location.js +76 -36
- package/cjs/dist/react/location/LocationList.js +70 -31
- package/cjs/dist/react/payment/Payment.js +87 -48
- package/cjs/dist/react/service/Service.js +197 -158
- package/cjs/dist/react/service/ServiceMedia.js +56 -17
- package/cjs/dist/react/service-list/ServiceList.js +71 -32
- package/cjs/dist/react/staff-member/StaffMember.js +61 -20
- package/cjs/dist/react/staff-member/StaffMemberList.js +68 -29
- package/cjs/dist/react/time-slot-list/TimeSlot.js +95 -56
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +87 -48
- package/cjs/dist/services/booking/book-action/bookAction.js +21 -18
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +18 -15
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +8 -5
- package/cjs/dist/services/booking/book-action/canBook.js +4 -1
- package/cjs/dist/services/booking/book-action/index.js +15 -6
- package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +4 -1
- package/cjs/dist/services/booking/book-action/types.js +5 -2
- package/cjs/dist/services/booking/booking.js +11 -8
- package/cjs/dist/services/booking-form/booking-form.js +26 -18
- package/cjs/dist/services/booking-form/utils.js +10 -4
- package/cjs/dist/services/constants.js +6 -3
- package/cjs/dist/services/index.js +48 -10
- package/cjs/dist/services/location-list/location-list.def.js +7 -5
- package/cjs/dist/services/location-list/location-list.js +31 -23
- package/cjs/dist/services/payment/payment.def.js +5 -2
- package/cjs/dist/services/payment/payment.js +22 -17
- package/cjs/dist/services/service/service.js +33 -29
- package/cjs/dist/services/service-list/service-list.js +22 -18
- package/cjs/dist/services/staff-member-list/staff-member-list.def.js +5 -2
- package/cjs/dist/services/staff-member-list/staff-member-list.js +16 -10
- package/cjs/dist/services/time-slot-list/index.js +12 -3
- package/cjs/dist/services/time-slot-list/time-slot-list.def.js +8 -5
- package/cjs/dist/services/time-slot-list/time-slot-list.js +24 -19
- package/cjs/dist/services/time-slot-list/time-slot.js +9 -6
- package/cjs/dist/utils/dateAndTime.js +7 -2
- package/cjs/dist/utils/guid.js +4 -1
- package/cjs/dist/utils/index.js +5 -1
- package/cjs/dist/utils/money.js +6 -2
- package/cjs/dist/utils/navigation.js +6 -3
- package/dist/react/booking/BookingItem.d.ts +2 -0
- package/dist/react/booking/BookingItem.js +2 -2
- package/dist/react/core/booking/Booking.d.ts +3 -1
- package/dist/react/core/booking/Booking.js +3 -2
- package/package.json +3 -3
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Builds the createBooking request from BookActionParams
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildBookingRequest = buildBookingRequest;
|
|
7
|
+
const auto_sdk_bookings_availability_time_slots_1 = require("@wix/auto_sdk_bookings_availability-time-slots");
|
|
8
|
+
const auto_sdk_bookings_bookings_1 = require("@wix/auto_sdk_bookings_bookings");
|
|
9
|
+
const constants_js_1 = require("../../constants.js");
|
|
7
10
|
/**
|
|
8
11
|
* Derives the selected payment option from service payment settings.
|
|
9
12
|
* Maps service.payment.options to booking API's selectedPaymentOption.
|
|
@@ -40,7 +43,7 @@ function deriveSelectedPaymentOption(service) {
|
|
|
40
43
|
* @param params - The booking action parameters
|
|
41
44
|
* @returns CreateBookingRequest ready to be sent to the API
|
|
42
45
|
*/
|
|
43
|
-
|
|
46
|
+
function buildBookingRequest(params) {
|
|
44
47
|
const { serviceSelections, location, formSubmission } = params;
|
|
45
48
|
const item = serviceSelections[0]; // Single booking focus
|
|
46
49
|
if (!item) {
|
|
@@ -74,8 +77,8 @@ export function buildBookingRequest(params) {
|
|
|
74
77
|
...(!resource && {
|
|
75
78
|
resourceSelections: [
|
|
76
79
|
{
|
|
77
|
-
resourceTypeId: STAFF_MEMBER_RESOURCE_TYPE_ID,
|
|
78
|
-
selectionMethod: SelectionMethod.ANY_RESOURCE,
|
|
80
|
+
resourceTypeId: constants_js_1.STAFF_MEMBER_RESOURCE_TYPE_ID,
|
|
81
|
+
selectionMethod: auto_sdk_bookings_bookings_1.SelectionMethod.ANY_RESOURCE,
|
|
79
82
|
},
|
|
80
83
|
],
|
|
81
84
|
}),
|
|
@@ -99,15 +102,15 @@ export function buildBookingRequest(params) {
|
|
|
99
102
|
}
|
|
100
103
|
function mapTimeSlotLocationTypeToBookingLocationType(slotLocationType) {
|
|
101
104
|
switch (slotLocationType) {
|
|
102
|
-
case
|
|
103
|
-
return
|
|
104
|
-
case
|
|
105
|
-
return
|
|
106
|
-
case
|
|
107
|
-
return
|
|
108
|
-
case
|
|
109
|
-
return
|
|
105
|
+
case auto_sdk_bookings_availability_time_slots_1.LocationType.BUSINESS:
|
|
106
|
+
return auto_sdk_bookings_bookings_1.LocationType.OWNER_BUSINESS;
|
|
107
|
+
case auto_sdk_bookings_availability_time_slots_1.LocationType.CUSTOMER:
|
|
108
|
+
return auto_sdk_bookings_bookings_1.LocationType.CUSTOM;
|
|
109
|
+
case auto_sdk_bookings_availability_time_slots_1.LocationType.CUSTOM:
|
|
110
|
+
return auto_sdk_bookings_bookings_1.LocationType.OWNER_CUSTOM;
|
|
111
|
+
case auto_sdk_bookings_availability_time_slots_1.LocationType.UNKNOWN_LOCATION_TYPE:
|
|
112
|
+
return auto_sdk_bookings_bookings_1.LocationType.UNDEFINED;
|
|
110
113
|
default:
|
|
111
|
-
return
|
|
114
|
+
return auto_sdk_bookings_bookings_1.LocationType.OWNER_BUSINESS;
|
|
112
115
|
}
|
|
113
116
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Builds the createCheckout request
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildCheckoutRequest = buildCheckoutRequest;
|
|
7
|
+
const index_js_1 = require("../../../api/create-checkout/index.js");
|
|
8
|
+
const constants_js_1 = require("../../constants.js");
|
|
6
9
|
/**
|
|
7
10
|
* Builds a checkout request from the booking ID and contact details
|
|
8
11
|
*
|
|
@@ -15,7 +18,7 @@ import { BOOKING_APP_ID } from '../../constants.js';
|
|
|
15
18
|
* @param params - The checkout parameters
|
|
16
19
|
* @returns CreateCheckoutRequest ready to be sent to the API
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
function buildCheckoutRequest(params) {
|
|
19
22
|
const { bookingId, contactDetails, businessLocationId } = params;
|
|
20
23
|
// Build checkoutInfo incrementally for readability
|
|
21
24
|
const checkoutInfo = {};
|
|
@@ -47,13 +50,13 @@ export function buildCheckoutRequest(params) {
|
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
return {
|
|
50
|
-
channelType: ChannelType.WEB,
|
|
53
|
+
channelType: index_js_1.ChannelType.WEB,
|
|
51
54
|
lineItems: [
|
|
52
55
|
{
|
|
53
56
|
quantity: 1,
|
|
54
57
|
catalogReference: {
|
|
55
58
|
catalogItemId: bookingId,
|
|
56
|
-
appId: BOOKING_APP_ID,
|
|
59
|
+
appId: constants_js_1.BOOKING_APP_ID,
|
|
57
60
|
},
|
|
58
61
|
},
|
|
59
62
|
],
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Validation logic for the Book action
|
|
3
4
|
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.canBook = canBook;
|
|
4
7
|
/**
|
|
5
8
|
* Validates if booking can be executed
|
|
6
9
|
* Checks that all required data is present:
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
* @param params - The booking data to validate
|
|
12
15
|
* @returns true if booking can proceed, false otherwise
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
function canBook(params) {
|
|
15
18
|
const { serviceSelections, formSubmission } = params;
|
|
16
19
|
return (serviceSelections.length > 0 &&
|
|
17
20
|
serviceSelections.every((item) => item.timeSlot !== undefined) &&
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Book Action - Exports
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BookResultType = exports.isCheckoutRequired = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = void 0;
|
|
7
|
+
var bookAction_js_1 = require("./bookAction.js");
|
|
8
|
+
Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return bookAction_js_1.executeBookAction; } });
|
|
9
|
+
var canBook_js_1 = require("./canBook.js");
|
|
10
|
+
Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return canBook_js_1.canBook; } });
|
|
11
|
+
var buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
12
|
+
Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return buildBookingRequest_js_1.buildBookingRequest; } });
|
|
13
|
+
var buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
|
|
14
|
+
Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return buildCheckoutRequest_js_1.buildCheckoutRequest; } });
|
|
15
|
+
var isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
|
|
16
|
+
Object.defineProperty(exports, "isCheckoutRequired", { enumerable: true, get: function () { return isCheckoutRequired_js_1.isCheckoutRequired; } });
|
|
17
|
+
var types_js_1 = require("./types.js");
|
|
18
|
+
Object.defineProperty(exports, "BookResultType", { enumerable: true, get: function () { return types_js_1.BookResultType; } });
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Determines if checkout page is required based on payment amounts
|
|
3
4
|
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isCheckoutRequired = isCheckoutRequired;
|
|
4
7
|
/**
|
|
5
8
|
* Determines if checkout page is required based on payment amounts.
|
|
6
9
|
*
|
|
@@ -15,7 +18,7 @@
|
|
|
15
18
|
* @param service - The service being booked
|
|
16
19
|
* @returns true if checkout page is required, false if can skip to order
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
function isCheckoutRequired(checkout, service) {
|
|
19
22
|
// Force checkout for cancellation fee policy
|
|
20
23
|
const hasCancellationFee = service.bookingPolicy?.cancellationFeePolicy?.enabled;
|
|
21
24
|
if (hasCancellationFee) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Types for the Book action
|
|
3
4
|
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BookResultType = void 0;
|
|
4
7
|
/**
|
|
5
8
|
* Enum for book result types
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
var BookResultType;
|
|
8
11
|
(function (BookResultType) {
|
|
9
12
|
BookResultType["CheckoutRequired"] = "checkout_required";
|
|
10
13
|
BookResultType["CheckoutSkipped"] = "checkout_skipped";
|
|
11
|
-
})(BookResultType || (BookResultType = {}));
|
|
14
|
+
})(BookResultType || (exports.BookResultType = BookResultType = {}));
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Booking Service - Global booking store
|
|
3
4
|
* Manages booking flow state (selected services, time slot, location, form submission)
|
|
4
5
|
* Persists across page navigation in SPA until page refresh
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BookingService = exports.BookingServiceDefinition = void 0;
|
|
9
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
10
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
11
|
+
const bookAction_js_1 = require("./book-action/bookAction.js");
|
|
12
|
+
const constants_js_1 = require("../constants.js");
|
|
10
13
|
// ============================================================================
|
|
11
14
|
// Constants
|
|
12
15
|
// ============================================================================
|
|
@@ -30,7 +33,7 @@ function getClientTimezone() {
|
|
|
30
33
|
/**
|
|
31
34
|
* Service definition for Booking
|
|
32
35
|
*/
|
|
33
|
-
|
|
36
|
+
exports.BookingServiceDefinition = (0, services_definitions_1.defineService)(constants_js_1.ClientServiceIds.booking);
|
|
34
37
|
// ============================================================================
|
|
35
38
|
// Service Implementation
|
|
36
39
|
// ============================================================================
|
|
@@ -58,8 +61,8 @@ export const BookingServiceDefinition = defineService(ClientServiceIds.booking);
|
|
|
58
61
|
* </Booking.Data>
|
|
59
62
|
* ```
|
|
60
63
|
*/
|
|
61
|
-
|
|
62
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
64
|
+
exports.BookingService = services_definitions_1.implementService.withConfig()(exports.BookingServiceDefinition, ({ getService, config }) => {
|
|
65
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
63
66
|
// Initialize signals with config values
|
|
64
67
|
// Ensure all initial service selections have instanceIds
|
|
65
68
|
const initialItemsWithIds = (config.serviceSelections || []).map((item) => ({
|
|
@@ -178,7 +181,7 @@ export const BookingService = implementService.withConfig()(BookingServiceDefini
|
|
|
178
181
|
const location = locationSignal.get();
|
|
179
182
|
const timezone = timezoneSignal.get();
|
|
180
183
|
// Validation happens inside executeBookAction
|
|
181
|
-
return executeBookAction({
|
|
184
|
+
return (0, bookAction_js_1.executeBookAction)({
|
|
182
185
|
serviceSelections,
|
|
183
186
|
formSubmission,
|
|
184
187
|
location,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* BookingForm Service - Manages form submission state for booking flows
|
|
3
4
|
*
|
|
@@ -7,10 +8,12 @@
|
|
|
7
8
|
*
|
|
8
9
|
* When using a pre-loaded form, it must belong to the bookings namespace.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BookingFormService = exports.BookingFormServiceDefinition = exports.extractFormIdFromConfig = exports.extractFormIdFromForm = exports.hasForm = exports.hasFormId = exports.BookingFormConfigurationError = exports.BOOKING_FORM_NAMESPACE = void 0;
|
|
13
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
14
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
15
|
+
const booking_js_1 = require("../booking/booking.js");
|
|
16
|
+
const utils_js_1 = require("./utils.js");
|
|
14
17
|
// ============================================================================
|
|
15
18
|
// Constants
|
|
16
19
|
// ============================================================================
|
|
@@ -18,7 +21,7 @@ import { hasForm, extractFormIdFromConfig, hasFormId } from './utils.js';
|
|
|
18
21
|
* The required namespace for booking forms.
|
|
19
22
|
* All booking forms must belong to this namespace.
|
|
20
23
|
*/
|
|
21
|
-
|
|
24
|
+
exports.BOOKING_FORM_NAMESPACE = 'wix.bookings.v2.bookings';
|
|
22
25
|
const DEFAULT_FORM_ID = '00000000-0000-0000-0000-000000000000';
|
|
23
26
|
/**
|
|
24
27
|
* Error thrown when BookingFormService cannot be initialized due to missing configuration.
|
|
@@ -26,7 +29,7 @@ const DEFAULT_FORM_ID = '00000000-0000-0000-0000-000000000000';
|
|
|
26
29
|
* - No config (formId or form) was provided
|
|
27
30
|
* - AND the component is not wrapped with Booking.Root (no BookingService available)
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
class BookingFormConfigurationError extends Error {
|
|
30
33
|
constructor(message) {
|
|
31
34
|
super(message ||
|
|
32
35
|
'BookingFormService: Cannot initialize - no formId or form provided in config and no BookingService available. ' +
|
|
@@ -34,10 +37,15 @@ export class BookingFormConfigurationError extends Error {
|
|
|
34
37
|
this.name = 'BookingFormConfigurationError';
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
exports.BookingFormConfigurationError = BookingFormConfigurationError;
|
|
37
41
|
// ============================================================================
|
|
38
42
|
// Re-export utilities
|
|
39
43
|
// ============================================================================
|
|
40
|
-
|
|
44
|
+
var utils_js_2 = require("./utils.js");
|
|
45
|
+
Object.defineProperty(exports, "hasFormId", { enumerable: true, get: function () { return utils_js_2.hasFormId; } });
|
|
46
|
+
Object.defineProperty(exports, "hasForm", { enumerable: true, get: function () { return utils_js_2.hasForm; } });
|
|
47
|
+
Object.defineProperty(exports, "extractFormIdFromForm", { enumerable: true, get: function () { return utils_js_2.extractFormIdFromForm; } });
|
|
48
|
+
Object.defineProperty(exports, "extractFormIdFromConfig", { enumerable: true, get: function () { return utils_js_2.extractFormIdFromConfig; } });
|
|
41
49
|
// ============================================================================
|
|
42
50
|
// Service Definition
|
|
43
51
|
// ============================================================================
|
|
@@ -45,7 +53,7 @@ export { hasFormId, hasForm, extractFormIdFromForm, extractFormIdFromConfig, } f
|
|
|
45
53
|
* Service definition for BookingForm.
|
|
46
54
|
* Defines the contract that the BookingFormService must implement.
|
|
47
55
|
*/
|
|
48
|
-
|
|
56
|
+
exports.BookingFormServiceDefinition = (0, services_definitions_1.defineService)('bookingForm');
|
|
49
57
|
// ============================================================================
|
|
50
58
|
// Service Implementation
|
|
51
59
|
// ============================================================================
|
|
@@ -59,9 +67,9 @@ export const BookingFormServiceDefinition = defineService('bookingForm');
|
|
|
59
67
|
*/
|
|
60
68
|
function validateBookingFormNamespace(form) {
|
|
61
69
|
const formNamespace = form.namespace;
|
|
62
|
-
if (formNamespace && formNamespace !== BOOKING_FORM_NAMESPACE) {
|
|
70
|
+
if (formNamespace && formNamespace !== exports.BOOKING_FORM_NAMESPACE) {
|
|
63
71
|
throw new Error(`BookingFormService: Invalid form namespace. ` +
|
|
64
|
-
`Expected "${BOOKING_FORM_NAMESPACE}", but received "${formNamespace}". ` +
|
|
72
|
+
`Expected "${exports.BOOKING_FORM_NAMESPACE}", but received "${formNamespace}". ` +
|
|
65
73
|
`Ensure the form is a booking form.`);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
@@ -69,7 +77,7 @@ function validateBookingFormConfig({ config, services, }) {
|
|
|
69
77
|
if (!config) {
|
|
70
78
|
return;
|
|
71
79
|
}
|
|
72
|
-
if (hasForm(config)) {
|
|
80
|
+
if ((0, utils_js_1.hasForm)(config)) {
|
|
73
81
|
validateBookingFormNamespace(config.form);
|
|
74
82
|
const servicesFormId = services.length > 1 ? DEFAULT_FORM_ID : services?.[0]?.form?._id;
|
|
75
83
|
if (servicesFormId !== config.form._id) {
|
|
@@ -95,7 +103,7 @@ function validateBookingFormConfig({ config, services, }) {
|
|
|
95
103
|
*/
|
|
96
104
|
function extractFormId(config, services) {
|
|
97
105
|
// Try to extract from config first
|
|
98
|
-
let formId = extractFormIdFromConfig(config);
|
|
106
|
+
let formId = (0, utils_js_1.extractFormIdFromConfig)(config);
|
|
99
107
|
// Fallback to extracting from services
|
|
100
108
|
if (!formId) {
|
|
101
109
|
formId = services.length > 1 ? DEFAULT_FORM_ID : services?.[0]?.form?._id;
|
|
@@ -118,7 +126,7 @@ function extractFormId(config, services) {
|
|
|
118
126
|
* @returns Array of service IDs
|
|
119
127
|
*/
|
|
120
128
|
function getServiceIds(config, services) {
|
|
121
|
-
if (hasFormId(config) && config.serviceIds) {
|
|
129
|
+
if ((0, utils_js_1.hasFormId)(config) && config.serviceIds) {
|
|
122
130
|
return config.serviceIds;
|
|
123
131
|
}
|
|
124
132
|
return services.map((s) => s._id).filter(Boolean);
|
|
@@ -177,12 +185,12 @@ function getServiceIds(config, services) {
|
|
|
177
185
|
* }
|
|
178
186
|
* ```
|
|
179
187
|
*/
|
|
180
|
-
|
|
181
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
188
|
+
exports.BookingFormService = services_definitions_1.implementService.withConfig()(exports.BookingFormServiceDefinition, ({ getService, config }) => {
|
|
189
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
182
190
|
// BookingService is optional - may not be available if not wrapped with Booking.Root
|
|
183
191
|
let bookingService = null;
|
|
184
192
|
try {
|
|
185
|
-
bookingService = getService(BookingServiceDefinition);
|
|
193
|
+
bookingService = getService(booking_js_1.BookingServiceDefinition);
|
|
186
194
|
}
|
|
187
195
|
catch {
|
|
188
196
|
// BookingService not available - that's ok if formId was provided explicitly
|
|
@@ -224,11 +232,11 @@ export const BookingFormService = implementService.withConfig()(BookingFormServi
|
|
|
224
232
|
* - Creates config with formId, namespace, and metadata
|
|
225
233
|
* - Includes serviceIds in additionalMetadata for FormService
|
|
226
234
|
*/
|
|
227
|
-
const formServiceConfig = signalsService.signal(hasForm(config)
|
|
235
|
+
const formServiceConfig = signalsService.signal((0, utils_js_1.hasForm)(config)
|
|
228
236
|
? { form: config.form }
|
|
229
237
|
: {
|
|
230
238
|
formId: formIdValue,
|
|
231
|
-
namespace: BOOKING_FORM_NAMESPACE,
|
|
239
|
+
namespace: exports.BOOKING_FORM_NAMESPACE,
|
|
232
240
|
additionalMetadata: {
|
|
233
241
|
...config?.additionalMetadata,
|
|
234
242
|
serviceIds,
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Utility functions for BookingForm
|
|
3
4
|
*
|
|
4
5
|
* Note: This file should not import from booking-form.ts to avoid circular dependencies.
|
|
5
6
|
* Type guards use generic types that will be compatible with BookingFormServiceConfig.
|
|
6
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.hasFormId = hasFormId;
|
|
10
|
+
exports.hasForm = hasForm;
|
|
11
|
+
exports.extractFormIdFromForm = extractFormIdFromForm;
|
|
12
|
+
exports.extractFormIdFromConfig = extractFormIdFromConfig;
|
|
7
13
|
// ============================================================================
|
|
8
14
|
// Type Guards
|
|
9
15
|
// ============================================================================
|
|
10
16
|
/**
|
|
11
17
|
* Type guard to check if config has formId
|
|
12
18
|
*/
|
|
13
|
-
|
|
19
|
+
function hasFormId(config) {
|
|
14
20
|
return config != null && 'formId' in config;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* Type guard to check if config has pre-loaded form
|
|
18
24
|
*/
|
|
19
|
-
|
|
25
|
+
function hasForm(config) {
|
|
20
26
|
return config != null && 'form' in config;
|
|
21
27
|
}
|
|
22
28
|
// ============================================================================
|
|
@@ -27,7 +33,7 @@ export function hasForm(config) {
|
|
|
27
33
|
* @param form The form object to extract ID from
|
|
28
34
|
* @returns The form ID or undefined if not found
|
|
29
35
|
*/
|
|
30
|
-
|
|
36
|
+
function extractFormIdFromForm(form) {
|
|
31
37
|
return (form.id ||
|
|
32
38
|
form._id);
|
|
33
39
|
}
|
|
@@ -36,7 +42,7 @@ export function extractFormIdFromForm(form) {
|
|
|
36
42
|
* @param config The config object containing either formId or form
|
|
37
43
|
* @returns The form ID or undefined if not found/extractable
|
|
38
44
|
*/
|
|
39
|
-
|
|
45
|
+
function extractFormIdFromConfig(config) {
|
|
40
46
|
if (hasFormId(config)) {
|
|
41
47
|
return config.formId;
|
|
42
48
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Shared constants for bookings services
|
|
3
4
|
*
|
|
4
5
|
* @module Services/Constants
|
|
5
6
|
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ClientServiceIds = exports.STAFF_MEMBER_RESOURCE_TYPE_ID = exports.BOOKING_APP_ID = void 0;
|
|
6
9
|
/** Booking app definition ID */
|
|
7
|
-
|
|
10
|
+
exports.BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
8
11
|
/** Resource type ID for staff members */
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
exports.STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
13
|
+
exports.ClientServiceIds = {
|
|
11
14
|
booking: 'booking',
|
|
12
15
|
bookingForm: 'bookingForm',
|
|
13
16
|
timeSlot: 'time-slot',
|
|
@@ -1,14 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Bookings Services
|
|
3
4
|
* Main export file for all service definitions and implementations
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.staffMemberListServiceBinding = exports.loadStaffMemberListServiceInitialData = exports.StaffMemberListServiceDefinition = exports.StaffMemberListService = exports.getLocationById = exports.locationListServiceBinding = exports.loadLocationListServiceInitialData = exports.LocationType = exports.LocationListServiceDefinition = exports.LocationListService = exports.loadPaymentConfig = exports.PaymentServiceDefinition = exports.PaymentService = exports.BookingFormServiceDefinition = exports.BookingFormService = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.loadServiceListServiceInitialData = exports.ServiceListServiceDefinition = exports.ServiceListService = exports.loadTimeSlotListConfig = exports.ViewMode = exports.TimeSlotServiceDefinition = exports.TimeSlotService = exports.TimeSlotListServiceDefinition = exports.TimeSlotListService = exports.BookingServiceDefinition = exports.BookingService = exports.loadServiceServiceInitialData = exports.ServiceServiceDefinition = exports.ServiceService = void 0;
|
|
8
|
+
var service_js_1 = require("./service/service.js");
|
|
9
|
+
Object.defineProperty(exports, "ServiceService", { enumerable: true, get: function () { return service_js_1.ServiceService; } });
|
|
10
|
+
Object.defineProperty(exports, "ServiceServiceDefinition", { enumerable: true, get: function () { return service_js_1.ServiceServiceDefinition; } });
|
|
11
|
+
Object.defineProperty(exports, "loadServiceServiceInitialData", { enumerable: true, get: function () { return service_js_1.loadServiceServiceInitialData; } });
|
|
12
|
+
var booking_js_1 = require("./booking/booking.js");
|
|
13
|
+
Object.defineProperty(exports, "BookingService", { enumerable: true, get: function () { return booking_js_1.BookingService; } });
|
|
14
|
+
Object.defineProperty(exports, "BookingServiceDefinition", { enumerable: true, get: function () { return booking_js_1.BookingServiceDefinition; } });
|
|
15
|
+
var index_js_1 = require("./time-slot-list/index.js");
|
|
16
|
+
Object.defineProperty(exports, "TimeSlotListService", { enumerable: true, get: function () { return index_js_1.TimeSlotListService; } });
|
|
17
|
+
Object.defineProperty(exports, "TimeSlotListServiceDefinition", { enumerable: true, get: function () { return index_js_1.TimeSlotListServiceDefinition; } });
|
|
18
|
+
Object.defineProperty(exports, "TimeSlotService", { enumerable: true, get: function () { return index_js_1.TimeSlotService; } });
|
|
19
|
+
Object.defineProperty(exports, "TimeSlotServiceDefinition", { enumerable: true, get: function () { return index_js_1.TimeSlotServiceDefinition; } });
|
|
20
|
+
Object.defineProperty(exports, "ViewMode", { enumerable: true, get: function () { return index_js_1.ViewMode; } });
|
|
21
|
+
Object.defineProperty(exports, "loadTimeSlotListConfig", { enumerable: true, get: function () { return index_js_1.loadTimeSlotListConfig; } });
|
|
22
|
+
var service_list_js_1 = require("./service-list/service-list.js");
|
|
23
|
+
Object.defineProperty(exports, "ServiceListService", { enumerable: true, get: function () { return service_list_js_1.ServiceListService; } });
|
|
24
|
+
Object.defineProperty(exports, "ServiceListServiceDefinition", { enumerable: true, get: function () { return service_list_js_1.ServiceListServiceDefinition; } });
|
|
25
|
+
Object.defineProperty(exports, "loadServiceListServiceInitialData", { enumerable: true, get: function () { return service_list_js_1.loadServiceListServiceInitialData; } });
|
|
26
|
+
var index_js_2 = require("../api/query-services/index.js");
|
|
27
|
+
Object.defineProperty(exports, "SYNTHETIC_CUSTOM_ID", { enumerable: true, get: function () { return index_js_2.SYNTHETIC_CUSTOM_ID; } });
|
|
28
|
+
Object.defineProperty(exports, "SYNTHETIC_CUSTOMER_ID", { enumerable: true, get: function () { return index_js_2.SYNTHETIC_CUSTOMER_ID; } });
|
|
29
|
+
var index_js_3 = require("./booking/book-action/index.js");
|
|
30
|
+
Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return index_js_3.executeBookAction; } });
|
|
31
|
+
Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return index_js_3.canBook; } });
|
|
32
|
+
Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return index_js_3.buildBookingRequest; } });
|
|
33
|
+
Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return index_js_3.buildCheckoutRequest; } });
|
|
34
|
+
var booking_form_js_1 = require("./booking-form/booking-form.js");
|
|
35
|
+
Object.defineProperty(exports, "BookingFormService", { enumerable: true, get: function () { return booking_form_js_1.BookingFormService; } });
|
|
36
|
+
Object.defineProperty(exports, "BookingFormServiceDefinition", { enumerable: true, get: function () { return booking_form_js_1.BookingFormServiceDefinition; } });
|
|
37
|
+
var payment_js_1 = require("./payment/payment.js");
|
|
38
|
+
Object.defineProperty(exports, "PaymentService", { enumerable: true, get: function () { return payment_js_1.PaymentService; } });
|
|
39
|
+
Object.defineProperty(exports, "PaymentServiceDefinition", { enumerable: true, get: function () { return payment_js_1.PaymentServiceDefinition; } });
|
|
40
|
+
Object.defineProperty(exports, "loadPaymentConfig", { enumerable: true, get: function () { return payment_js_1.loadPaymentConfig; } });
|
|
41
|
+
var location_list_js_1 = require("./location-list/location-list.js");
|
|
42
|
+
Object.defineProperty(exports, "LocationListService", { enumerable: true, get: function () { return location_list_js_1.LocationListService; } });
|
|
43
|
+
Object.defineProperty(exports, "LocationListServiceDefinition", { enumerable: true, get: function () { return location_list_js_1.LocationListServiceDefinition; } });
|
|
44
|
+
Object.defineProperty(exports, "LocationType", { enumerable: true, get: function () { return location_list_js_1.LocationType; } });
|
|
45
|
+
Object.defineProperty(exports, "loadLocationListServiceInitialData", { enumerable: true, get: function () { return location_list_js_1.loadLocationListServiceInitialData; } });
|
|
46
|
+
Object.defineProperty(exports, "locationListServiceBinding", { enumerable: true, get: function () { return location_list_js_1.locationListServiceBinding; } });
|
|
47
|
+
Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return location_list_js_1.getLocationById; } });
|
|
48
|
+
var staff_member_list_js_1 = require("./staff-member-list/staff-member-list.js");
|
|
49
|
+
Object.defineProperty(exports, "StaffMemberListService", { enumerable: true, get: function () { return staff_member_list_js_1.StaffMemberListService; } });
|
|
50
|
+
Object.defineProperty(exports, "StaffMemberListServiceDefinition", { enumerable: true, get: function () { return staff_member_list_js_1.StaffMemberListServiceDefinition; } });
|
|
51
|
+
Object.defineProperty(exports, "loadStaffMemberListServiceInitialData", { enumerable: true, get: function () { return staff_member_list_js_1.loadStaffMemberListServiceInitialData; } });
|
|
52
|
+
Object.defineProperty(exports, "staffMemberListServiceBinding", { enumerable: true, get: function () { return staff_member_list_js_1.staffMemberListServiceBinding; } });
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Location List Service Definition
|
|
3
4
|
* Defines types and service interface for managing location lists
|
|
4
5
|
*
|
|
5
6
|
* @module Services/LocationList/Definition
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LocationType = exports.LocationListServiceDefinition = void 0;
|
|
10
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
11
|
+
const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
|
|
12
|
+
Object.defineProperty(exports, "LocationType", { enumerable: true, get: function () { return auto_sdk_bookings_services_1.LocationType; } });
|
|
9
13
|
// ============================================================================
|
|
10
14
|
// Service Definition
|
|
11
15
|
// ============================================================================
|
|
12
16
|
/**
|
|
13
17
|
* Service definition for LocationList
|
|
14
18
|
*/
|
|
15
|
-
|
|
16
|
-
// Re-export LocationType for consumers
|
|
17
|
-
export { LocationType };
|
|
19
|
+
exports.LocationListServiceDefinition = (0, services_definitions_1.defineService)('location-list');
|