@wix/headless-bookings 1.0.3 → 1.0.5
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/api/create-booking/index.d.ts +4 -4
- package/cjs/dist/api/create-bulk-booking/index.d.ts +54 -0
- package/cjs/dist/api/create-bulk-booking/index.js +54 -0
- package/cjs/dist/api/create-multi-service-booking/index.d.ts +53 -0
- package/cjs/dist/api/create-multi-service-booking/index.js +47 -0
- package/cjs/dist/api/index.d.ts +4 -1
- package/cjs/dist/api/index.js +32 -13
- package/cjs/dist/services/booking/book-action/bookAction.js +39 -27
- package/cjs/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
- package/cjs/dist/services/booking/book-action/buildCartRequest.js +24 -13
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.js +70 -0
- package/cjs/dist/services/booking/book-action/canBook.d.ts +2 -1
- package/cjs/dist/services/booking/book-action/canBook.js +4 -2
- package/cjs/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
- package/cjs/dist/services/booking/book-action/createBookingsForCart.js +69 -0
- package/cjs/dist/services/booking/book-action/dayRange.d.ts +34 -0
- package/cjs/dist/services/booking/book-action/dayRange.js +43 -0
- package/cjs/dist/services/booking/book-action/index.d.ts +9 -6
- package/cjs/dist/services/booking/book-action/index.js +23 -13
- package/cjs/dist/services/booking/booking.d.ts +11 -1
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/index.js +6 -1
- package/cjs/dist/services/payment/payment.js +15 -4
- package/dist/api/create-booking/index.d.ts +4 -4
- package/dist/api/create-bulk-booking/index.d.ts +54 -0
- package/dist/api/create-bulk-booking/index.js +51 -0
- package/dist/api/create-multi-service-booking/index.d.ts +53 -0
- package/dist/api/create-multi-service-booking/index.js +44 -0
- package/dist/api/index.d.ts +4 -1
- package/dist/api/index.js +3 -0
- package/dist/services/booking/book-action/bookAction.js +34 -22
- package/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
- package/dist/services/booking/book-action/buildCartRequest.js +23 -13
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.js +67 -0
- package/dist/services/booking/book-action/canBook.d.ts +2 -1
- package/dist/services/booking/book-action/canBook.js +4 -2
- package/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
- package/dist/services/booking/book-action/createBookingsForCart.js +66 -0
- package/dist/services/booking/book-action/dayRange.d.ts +34 -0
- package/dist/services/booking/book-action/dayRange.js +39 -0
- package/dist/services/booking/book-action/index.d.ts +9 -6
- package/dist/services/booking/book-action/index.js +9 -6
- package/dist/services/booking/booking.d.ts +11 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/payment/payment.js +15 -4
- package/package.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the booking(s) needed for cart construction.
|
|
3
|
+
*
|
|
4
|
+
* Branches on the service selection:
|
|
5
|
+
* - DAY-range path with 1 picked slot -> `bulkCreateBooking`
|
|
6
|
+
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
7
|
+
* - default path -> `createBooking`
|
|
8
|
+
*
|
|
9
|
+
* All branches return the same shape so `executeBookAction` can stay
|
|
10
|
+
* branchless from cart-creation onwards. Cart construction reads each
|
|
11
|
+
* single-service booking ID — per SDK guidance, never the
|
|
12
|
+
* `multiServiceBooking._id`.
|
|
13
|
+
*/
|
|
14
|
+
import type { ContactDetails } from '@wix/auto_sdk_bookings_bookings';
|
|
15
|
+
import type { BookActionParams } from './types.js';
|
|
16
|
+
export interface CreatedBookings {
|
|
17
|
+
/** One ID per single-service booking. >=1 on success. */
|
|
18
|
+
bookingIds: string[];
|
|
19
|
+
/** Canonical contact details echoed by the server (read from the first booking). */
|
|
20
|
+
contactDetails?: ContactDetails;
|
|
21
|
+
}
|
|
22
|
+
export declare function createBookingsForCart(params: BookActionParams): Promise<CreatedBookings>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the booking(s) needed for cart construction.
|
|
4
|
+
*
|
|
5
|
+
* Branches on the service selection:
|
|
6
|
+
* - DAY-range path with 1 picked slot -> `bulkCreateBooking`
|
|
7
|
+
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
* - default path -> `createBooking`
|
|
9
|
+
*
|
|
10
|
+
* All branches return the same shape so `executeBookAction` can stay
|
|
11
|
+
* branchless from cart-creation onwards. Cart construction reads each
|
|
12
|
+
* single-service booking ID — per SDK guidance, never the
|
|
13
|
+
* `multiServiceBooking._id`.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createBookingsForCart = createBookingsForCart;
|
|
17
|
+
const index_js_1 = require("../../../api/create-booking/index.js");
|
|
18
|
+
const index_js_2 = require("../../../api/create-bulk-booking/index.js");
|
|
19
|
+
const index_js_3 = require("../../../api/create-multi-service-booking/index.js");
|
|
20
|
+
const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
21
|
+
const buildDayRangeBookingRequest_js_1 = require("./buildDayRangeBookingRequest.js");
|
|
22
|
+
const dayRange_js_1 = require("./dayRange.js");
|
|
23
|
+
async function createBookingsForCart(params) {
|
|
24
|
+
const firstSelection = params.serviceSelections[0];
|
|
25
|
+
if (!firstSelection) {
|
|
26
|
+
throw new Error('No service selection provided');
|
|
27
|
+
}
|
|
28
|
+
if ((0, dayRange_js_1.isDayRangeService)(firstSelection.service)) {
|
|
29
|
+
const req = (0, buildDayRangeBookingRequest_js_1.buildDayRangeBookingRequest)(params);
|
|
30
|
+
// TODO(createAsOneBooking): when the server flag lands, branch here:
|
|
31
|
+
// if (createAsOneBooking) -> createBooking({ ...wideRange, fullDay: true })
|
|
32
|
+
// collapsing all slots into one combined Booking. Until then, we always
|
|
33
|
+
// use one Booking per picked slot.
|
|
34
|
+
if (req.bookings.length === 1) {
|
|
35
|
+
const response = await (0, index_js_2.bulkCreateBooking)([{ booking: req.bookings[0] }], {
|
|
36
|
+
participantNotification: req.participantNotification,
|
|
37
|
+
sendSmsReminder: req.sendSmsReminder,
|
|
38
|
+
});
|
|
39
|
+
const results = response.results ?? [];
|
|
40
|
+
return {
|
|
41
|
+
bookingIds: results.map((r) => r.item?._id).filter(Boolean),
|
|
42
|
+
// All N daily bookings share the same customer; read from the first.
|
|
43
|
+
contactDetails: results[0]?.item?.contactDetails,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const response = await (0, index_js_3.createMultiServiceBooking)(req.bookings, {
|
|
47
|
+
participantNotification: req.participantNotification,
|
|
48
|
+
sendSmsReminder: req.sendSmsReminder,
|
|
49
|
+
});
|
|
50
|
+
const bookings = response.multiServiceBooking?.bookings ?? [];
|
|
51
|
+
return {
|
|
52
|
+
bookingIds: bookings
|
|
53
|
+
.map((b) => b.booking?._id)
|
|
54
|
+
.filter(Boolean),
|
|
55
|
+
contactDetails: bookings[0]?.booking?.contactDetails,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const createBookingRequest = (0, buildBookingRequest_js_1.buildBookingRequest)(params);
|
|
59
|
+
const bookingResponse = await (0, index_js_1.createBooking)(createBookingRequest.booking, {
|
|
60
|
+
participantNotification: createBookingRequest.participantNotification,
|
|
61
|
+
sendSmsReminder: createBookingRequest.sendSmsReminder,
|
|
62
|
+
formSubmission: createBookingRequest.formSubmission,
|
|
63
|
+
});
|
|
64
|
+
const bookingId = bookingResponse.booking?._id;
|
|
65
|
+
return {
|
|
66
|
+
bookingIds: bookingId ? [bookingId] : [],
|
|
67
|
+
contactDetails: bookingResponse.booking?.contactDetails,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAY-range service helpers.
|
|
3
|
+
*
|
|
4
|
+
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
5
|
+
* `unitType === DAY` route through the per-day slot path:
|
|
6
|
+
* - 1 picked slot -> `bulkCreateBooking`
|
|
7
|
+
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
*
|
|
9
|
+
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
10
|
+
* selections keep using the existing `createBooking` path.
|
|
11
|
+
*/
|
|
12
|
+
import { type Service } from '@wix/auto_sdk_bookings_services';
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when the given service is an APPOINTMENT whose duration is
|
|
15
|
+
* configured as a DAY range. Useful at the UI layer (e.g. routing) to know
|
|
16
|
+
* before a slot has been picked whether the selection will go through the
|
|
17
|
+
* DAY-range create path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDayRangeService(service: Service): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Bounds (in days) that a customer may pick for a DAY-range service.
|
|
22
|
+
* Both bounds are inclusive. The server enforces 1..8 per `DailyConfig` (SDK);
|
|
23
|
+
* this helper just exposes whatever the configured values are.
|
|
24
|
+
*/
|
|
25
|
+
export type DayRangeBounds = {
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Returns the configured min/max day bounds for a DAY-range service, or
|
|
31
|
+
* `null` if the service is not DAY-range. Falls back to `min = 1` / `max = min`
|
|
32
|
+
* when the service is missing `dayOptions` configuration values.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDayRangeBounds(service: Service): DayRangeBounds | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DAY-range service helpers.
|
|
4
|
+
*
|
|
5
|
+
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
6
|
+
* `unitType === DAY` route through the per-day slot path:
|
|
7
|
+
* - 1 picked slot -> `bulkCreateBooking`
|
|
8
|
+
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
9
|
+
*
|
|
10
|
+
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
11
|
+
* selections keep using the existing `createBooking` path.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.isDayRangeService = isDayRangeService;
|
|
15
|
+
exports.getDayRangeBounds = getDayRangeBounds;
|
|
16
|
+
const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
|
|
17
|
+
/**
|
|
18
|
+
* Returns true when the given service is an APPOINTMENT whose duration is
|
|
19
|
+
* configured as a DAY range. Useful at the UI layer (e.g. routing) to know
|
|
20
|
+
* before a slot has been picked whether the selection will go through the
|
|
21
|
+
* DAY-range create path.
|
|
22
|
+
*/
|
|
23
|
+
function isDayRangeService(service) {
|
|
24
|
+
const isAppointment = service.type === auto_sdk_bookings_services_1.ServiceType.APPOINTMENT;
|
|
25
|
+
const isDayRange = service.schedule?.availabilityConstraints?.durationRange?.unitType ===
|
|
26
|
+
auto_sdk_bookings_services_1.UnitType.DAY;
|
|
27
|
+
return isAppointment && isDayRange;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the configured min/max day bounds for a DAY-range service, or
|
|
31
|
+
* `null` if the service is not DAY-range. Falls back to `min = 1` / `max = min`
|
|
32
|
+
* when the service is missing `dayOptions` configuration values.
|
|
33
|
+
*/
|
|
34
|
+
function getDayRangeBounds(service) {
|
|
35
|
+
if (!isDayRangeService(service))
|
|
36
|
+
return null;
|
|
37
|
+
const dayOptions = service.schedule?.availabilityConstraints?.durationRange?.dayOptions;
|
|
38
|
+
const min = dayOptions?.minDurationInDays ?? 1;
|
|
39
|
+
const max = dayOptions?.maxDurationInDays ?? min;
|
|
40
|
+
if (max < min)
|
|
41
|
+
return null;
|
|
42
|
+
return { min, max };
|
|
43
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Book Action - Exports
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
4
|
+
export * from './bookAction.js';
|
|
5
|
+
export * from './canBook.js';
|
|
6
|
+
export * from './buildBookingRequest.js';
|
|
7
|
+
export * from './buildDayRangeBookingRequest.js';
|
|
8
|
+
export * from './buildCartRequest.js';
|
|
9
|
+
export * from './createBookingsForCart.js';
|
|
10
|
+
export * from './dayRange.js';
|
|
11
|
+
export * from './isCheckoutRequired.js';
|
|
12
|
+
export * from './types.js';
|
|
@@ -2,17 +2,27 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Book Action - Exports
|
|
4
4
|
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
5
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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; } });
|
|
20
|
+
__exportStar(require("./bookAction.js"), exports);
|
|
21
|
+
__exportStar(require("./canBook.js"), exports);
|
|
22
|
+
__exportStar(require("./buildBookingRequest.js"), exports);
|
|
23
|
+
__exportStar(require("./buildDayRangeBookingRequest.js"), exports);
|
|
24
|
+
__exportStar(require("./buildCartRequest.js"), exports);
|
|
25
|
+
__exportStar(require("./createBookingsForCart.js"), exports);
|
|
26
|
+
__exportStar(require("./dayRange.js"), exports);
|
|
27
|
+
__exportStar(require("./isCheckoutRequired.js"), exports);
|
|
28
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -40,8 +40,18 @@ export interface ServiceSelection {
|
|
|
40
40
|
service: Service;
|
|
41
41
|
/** Selected resources (staff members, rooms, etc.) with type information */
|
|
42
42
|
resources: ExtendedResource[];
|
|
43
|
-
/** Per-item time slot data */
|
|
43
|
+
/** Per-item time slot data (single-slot path; existing behavior). */
|
|
44
44
|
timeSlot?: ServiceSelectionTimeSlot;
|
|
45
|
+
/**
|
|
46
|
+
* Per-day slots for DAY-range services. Populated by the availability
|
|
47
|
+
* picker after the customer picks a start + end date: one entry per day
|
|
48
|
+
* in the picked range. When set, supersedes `timeSlot` for the DAY-range
|
|
49
|
+
* builder, which produces one Booking per entry and routes via length:
|
|
50
|
+
* - 1 -> bulkCreateBooking
|
|
51
|
+
* - 2-8 -> createMultiServiceBooking
|
|
52
|
+
* Optional & additive: existing single-slot callers stay on `timeSlot`.
|
|
53
|
+
*/
|
|
54
|
+
rangeTimeSlots?: ServiceSelectionTimeSlot[];
|
|
45
55
|
/** Number of participants for this service selection */
|
|
46
56
|
totalParticipants?: number;
|
|
47
57
|
}
|
|
@@ -7,7 +7,7 @@ export { BookingService, BookingServiceDefinition, type BookingServiceConfig, ty
|
|
|
7
7
|
export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type TimeSlotServiceAPI, type TimeSlotServiceConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
|
|
8
8
|
export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
|
|
9
9
|
export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
|
|
10
|
-
export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, } from './booking/book-action/index.js';
|
|
10
|
+
export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, buildDayRangeCartRequest, buildDayRangeBookingRequest, createBookingsForCart, isDayRangeService, getDayRangeBounds, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, type BuildDayRangeCartParams, type BuildDayRangeBookingRequest, type CreatedBookings, type DayRangeBounds, } from './booking/book-action/index.js';
|
|
11
11
|
export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, } from './booking-form/booking-form.js';
|
|
12
12
|
export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type ServicePaymentOptions, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
|
|
13
13
|
export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, type LocationListServiceAPI, type LocationListServiceConfig, type LocationListActions, type Location, type LoadLocationListServiceResult, getLocationById, } from './location-list/location-list.js';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Main export file for all service definitions and implementations
|
|
5
5
|
*/
|
|
6
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.buildCartRequest = 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;
|
|
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.getDayRangeBounds = exports.isDayRangeService = exports.createBookingsForCart = exports.buildDayRangeBookingRequest = exports.buildDayRangeCartRequest = exports.buildCartRequest = 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
8
|
var service_js_1 = require("./service/service.js");
|
|
9
9
|
Object.defineProperty(exports, "ServiceService", { enumerable: true, get: function () { return service_js_1.ServiceService; } });
|
|
10
10
|
Object.defineProperty(exports, "ServiceServiceDefinition", { enumerable: true, get: function () { return service_js_1.ServiceServiceDefinition; } });
|
|
@@ -31,6 +31,11 @@ Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: fun
|
|
|
31
31
|
Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return index_js_3.canBook; } });
|
|
32
32
|
Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return index_js_3.buildBookingRequest; } });
|
|
33
33
|
Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return index_js_3.buildCartRequest; } });
|
|
34
|
+
Object.defineProperty(exports, "buildDayRangeCartRequest", { enumerable: true, get: function () { return index_js_3.buildDayRangeCartRequest; } });
|
|
35
|
+
Object.defineProperty(exports, "buildDayRangeBookingRequest", { enumerable: true, get: function () { return index_js_3.buildDayRangeBookingRequest; } });
|
|
36
|
+
Object.defineProperty(exports, "createBookingsForCart", { enumerable: true, get: function () { return index_js_3.createBookingsForCart; } });
|
|
37
|
+
Object.defineProperty(exports, "isDayRangeService", { enumerable: true, get: function () { return index_js_3.isDayRangeService; } });
|
|
38
|
+
Object.defineProperty(exports, "getDayRangeBounds", { enumerable: true, get: function () { return index_js_3.getDayRangeBounds; } });
|
|
34
39
|
var booking_form_js_1 = require("./booking-form/booking-form.js");
|
|
35
40
|
Object.defineProperty(exports, "BookingFormService", { enumerable: true, get: function () { return booking_form_js_1.BookingFormService; } });
|
|
36
41
|
Object.defineProperty(exports, "BookingFormServiceDefinition", { enumerable: true, get: function () { return booking_form_js_1.BookingFormServiceDefinition; } });
|
|
@@ -109,7 +109,13 @@ async function getPreviewedPrice(service, localStartDate, localEndDate, timeZone
|
|
|
109
109
|
...(timeZone ? { timeZone } : {}),
|
|
110
110
|
};
|
|
111
111
|
const result = await (0, auto_sdk_bookings_pricing_1.previewPrice)([lineItemInput]);
|
|
112
|
-
|
|
112
|
+
const price = result.priceInfo?.calculatedPrice;
|
|
113
|
+
if (price == null)
|
|
114
|
+
return null;
|
|
115
|
+
return {
|
|
116
|
+
price,
|
|
117
|
+
deposit: result.priceInfo?.deposit ?? null,
|
|
118
|
+
};
|
|
113
119
|
}
|
|
114
120
|
async function buildLineItemWithPreview(item, totalParticipants) {
|
|
115
121
|
if (item.localStartDate &&
|
|
@@ -118,9 +124,14 @@ async function buildLineItemWithPreview(item, totalParticipants) {
|
|
|
118
124
|
const previewedPrice = await getPreviewedPrice(item.service, item.localStartDate, item.localEndDate, item.timeZone, totalParticipants).catch(() => null);
|
|
119
125
|
if (previewedPrice != null) {
|
|
120
126
|
const depositValue = item.service.payment?.fixed?.deposit?.value;
|
|
121
|
-
const
|
|
127
|
+
const previewedDeposit = previewedPrice.deposit;
|
|
128
|
+
const hasDeposit = previewedDeposit != null
|
|
129
|
+
? previewedDeposit > 0
|
|
130
|
+
: !!depositValue && Number(depositValue) > 0;
|
|
122
131
|
const deposit = hasDeposit
|
|
123
|
-
?
|
|
132
|
+
? previewedDeposit != null
|
|
133
|
+
? previewedDeposit
|
|
134
|
+
: Number(depositValue) * totalParticipants
|
|
124
135
|
: undefined;
|
|
125
136
|
return {
|
|
126
137
|
_id: item.lineItemId,
|
|
@@ -128,7 +139,7 @@ async function buildLineItemWithPreview(item, totalParticipants) {
|
|
|
128
139
|
catalogItemId: item.service._id || '',
|
|
129
140
|
appId: constants_js_1.BOOKING_APP_ID,
|
|
130
141
|
},
|
|
131
|
-
price: String(previewedPrice),
|
|
142
|
+
price: String(previewedPrice.price),
|
|
132
143
|
...(deposit ? { depositAmount: String(deposit) } : {}),
|
|
133
144
|
quantity: 1,
|
|
134
145
|
paymentOption: getPaymentOption(item.service, hasDeposit),
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
import { type Booking, type CreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
6
6
|
import type { FormValues } from '@wix/forms/components';
|
|
7
7
|
/**
|
|
8
|
-
* Options for creating a booking
|
|
8
|
+
* Options for creating a booking. `null` is accepted on optional fields so
|
|
9
|
+
* callers can forward the SDK's `T | null` shape without coercion.
|
|
9
10
|
*/
|
|
10
11
|
export interface CreateBookingOptions {
|
|
11
12
|
/** Notification settings for participants */
|
|
12
13
|
participantNotification?: ParticipantNotification;
|
|
13
14
|
/** Whether to send SMS reminder */
|
|
14
|
-
sendSmsReminder?: boolean;
|
|
15
|
+
sendSmsReminder?: boolean | null;
|
|
15
16
|
/** Form submission data */
|
|
16
|
-
formSubmission?: FormValues;
|
|
17
|
+
formSubmission?: FormValues | null;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Creates a booking with the specified booking data and options
|
|
@@ -39,4 +40,3 @@ export interface CreateBookingOptions {
|
|
|
39
40
|
* ```
|
|
40
41
|
*/
|
|
41
42
|
export declare function createBooking(booking: Booking, options?: CreateBookingOptions): Promise<CreateBookingResponse>;
|
|
42
|
-
export type { Booking, CreateBookingRequest, CreateBookingResponse, ParticipantNotification, ContactDetails, } from '@wix/auto_sdk_bookings_bookings';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulk Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings bulkCreateBooking SDK function.
|
|
4
|
+
*
|
|
5
|
+
* Used for the 1-day case of the DAY-range expansion: a single APPOINTMENT
|
|
6
|
+
* service whose duration is configured as a DAY range, with exactly one
|
|
7
|
+
* per-day availability slot picked. The 2-8 day case is routed to
|
|
8
|
+
* createMultiServiceBooking.
|
|
9
|
+
*/
|
|
10
|
+
import { type CreateBookingInfo, type BulkCreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
11
|
+
/**
|
|
12
|
+
* Options for creating bookings in bulk.
|
|
13
|
+
*
|
|
14
|
+
* `formSubmission` is intentionally absent: the SDK's
|
|
15
|
+
* `BulkCreateBookingOptions` does not accept it. Customer details flow
|
|
16
|
+
* through the cart layer instead. We always set `returnFullEntity: true` so
|
|
17
|
+
* the response includes per-booking entities (with `contactDetails`) for
|
|
18
|
+
* cart wiring.
|
|
19
|
+
*/
|
|
20
|
+
export interface BulkCreateBookingOptions {
|
|
21
|
+
/** Notification settings for participants. Applied to every entry. */
|
|
22
|
+
participantNotification?: ParticipantNotification;
|
|
23
|
+
/** Whether to send SMS reminder. Applied to every entry. */
|
|
24
|
+
sendSmsReminder?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates 1-8 bookings in a single bulk call.
|
|
28
|
+
*
|
|
29
|
+
* Per the SDK contract, `createBookingsInfo` accepts 1-8 bookings. When the
|
|
30
|
+
* DAY-range routing picks exactly one per-day slot, this wrapper is invoked
|
|
31
|
+
* with a single-element array. Validation of constraints is delegated to the
|
|
32
|
+
* SDK; this wrapper only forwards the request and pins
|
|
33
|
+
* `returnFullEntity: true` so the caller can read
|
|
34
|
+
* `results[].item.contactDetails` for downstream cart construction.
|
|
35
|
+
*
|
|
36
|
+
* @param createBookingsInfo - 1-8 single-service booking specifications
|
|
37
|
+
* @param options - Optional notification / SMS settings (applied to every entry)
|
|
38
|
+
* @returns Promise resolving to the bulk-create response
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const response = await bulkCreateBooking(
|
|
43
|
+
* [{ booking: bookingDay1 }],
|
|
44
|
+
* {
|
|
45
|
+
* participantNotification: { notifyParticipants: true },
|
|
46
|
+
* sendSmsReminder: true,
|
|
47
|
+
* }
|
|
48
|
+
* );
|
|
49
|
+
* const ids = response.results
|
|
50
|
+
* ?.map((r) => r.item?._id)
|
|
51
|
+
* .filter(Boolean);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function bulkCreateBooking(createBookingsInfo: CreateBookingInfo[], options?: BulkCreateBookingOptions): Promise<BulkCreateBookingResponse>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulk Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings bulkCreateBooking SDK function.
|
|
4
|
+
*
|
|
5
|
+
* Used for the 1-day case of the DAY-range expansion: a single APPOINTMENT
|
|
6
|
+
* service whose duration is configured as a DAY range, with exactly one
|
|
7
|
+
* per-day availability slot picked. The 2-8 day case is routed to
|
|
8
|
+
* createMultiServiceBooking.
|
|
9
|
+
*/
|
|
10
|
+
import { bulkCreateBooking as bulkCreateBookingSdk, } from '@wix/auto_sdk_bookings_bookings';
|
|
11
|
+
/**
|
|
12
|
+
* Creates 1-8 bookings in a single bulk call.
|
|
13
|
+
*
|
|
14
|
+
* Per the SDK contract, `createBookingsInfo` accepts 1-8 bookings. When the
|
|
15
|
+
* DAY-range routing picks exactly one per-day slot, this wrapper is invoked
|
|
16
|
+
* with a single-element array. Validation of constraints is delegated to the
|
|
17
|
+
* SDK; this wrapper only forwards the request and pins
|
|
18
|
+
* `returnFullEntity: true` so the caller can read
|
|
19
|
+
* `results[].item.contactDetails` for downstream cart construction.
|
|
20
|
+
*
|
|
21
|
+
* @param createBookingsInfo - 1-8 single-service booking specifications
|
|
22
|
+
* @param options - Optional notification / SMS settings (applied to every entry)
|
|
23
|
+
* @returns Promise resolving to the bulk-create response
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const response = await bulkCreateBooking(
|
|
28
|
+
* [{ booking: bookingDay1 }],
|
|
29
|
+
* {
|
|
30
|
+
* participantNotification: { notifyParticipants: true },
|
|
31
|
+
* sendSmsReminder: true,
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
* const ids = response.results
|
|
35
|
+
* ?.map((r) => r.item?._id)
|
|
36
|
+
* .filter(Boolean);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function bulkCreateBooking(createBookingsInfo, options) {
|
|
40
|
+
// Apply the shared participantNotification / sendSmsReminder onto each
|
|
41
|
+
// CreateBookingInfo entry. The SDK's per-call options object only carries
|
|
42
|
+
// `returnFullEntity`, so notification settings live on each entry.
|
|
43
|
+
const enriched = createBookingsInfo.map((info) => ({
|
|
44
|
+
...info,
|
|
45
|
+
participantNotification: info.participantNotification ?? options?.participantNotification,
|
|
46
|
+
sendSmsReminder: info.sendSmsReminder ?? options?.sendSmsReminder,
|
|
47
|
+
}));
|
|
48
|
+
return bulkCreateBookingSdk(enriched, {
|
|
49
|
+
returnFullEntity: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Multi-Service Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createMultiServiceBooking SDK function.
|
|
4
|
+
*
|
|
5
|
+
* Used for the 2-8 day case of the DAY-range expansion: a single
|
|
6
|
+
* APPOINTMENT service whose duration is configured as a DAY range, with
|
|
7
|
+
* 2-8 per-day availability slots picked. One Booking entry is sent per
|
|
8
|
+
* picked slot.
|
|
9
|
+
*/
|
|
10
|
+
import { type Booking, type CreateMultiServiceBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
11
|
+
/**
|
|
12
|
+
* Options for creating a multi-service booking.
|
|
13
|
+
*
|
|
14
|
+
* `formSubmission` is intentionally absent: the SDK's
|
|
15
|
+
* `CreateMultiServiceBookingOptions` does not accept it. Customer details
|
|
16
|
+
* flow through the cart layer instead. We always set `returnFullEntity: true`
|
|
17
|
+
* so the response includes per-booking entities (with `contactDetails`) for
|
|
18
|
+
* cart wiring.
|
|
19
|
+
*/
|
|
20
|
+
export interface CreateMultiServiceBookingOptions {
|
|
21
|
+
/** Notification settings for participants */
|
|
22
|
+
participantNotification?: ParticipantNotification;
|
|
23
|
+
/** Whether to send SMS reminder */
|
|
24
|
+
sendSmsReminder?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a multi-service booking from 2-8 single-service booking specs.
|
|
28
|
+
*
|
|
29
|
+
* Per the SDK contract, the bookings array must contain 2-8 APPOINTMENT
|
|
30
|
+
* bookings at the same location with sequential, gapless scheduling.
|
|
31
|
+
* Validation of those constraints is delegated to the SDK; this wrapper only
|
|
32
|
+
* forwards the request and pins `returnFullEntity: true` so the caller can
|
|
33
|
+
* read `bookings[].booking.contactDetails` for downstream cart construction.
|
|
34
|
+
*
|
|
35
|
+
* @param bookings - 2 to 8 single-service booking specifications
|
|
36
|
+
* @param options - Optional notification / SMS settings
|
|
37
|
+
* @returns Promise resolving to the created multi-service booking response
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const response = await createMultiServiceBooking(
|
|
42
|
+
* [bookingDay1, bookingDay2, bookingDay3],
|
|
43
|
+
* {
|
|
44
|
+
* participantNotification: { notifyParticipants: true },
|
|
45
|
+
* sendSmsReminder: true,
|
|
46
|
+
* }
|
|
47
|
+
* );
|
|
48
|
+
* const ids = response.multiServiceBooking?.bookings
|
|
49
|
+
* ?.map((b) => b.bookingId)
|
|
50
|
+
* .filter(Boolean);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createMultiServiceBooking(bookings: Booking[], options?: CreateMultiServiceBookingOptions): Promise<CreateMultiServiceBookingResponse>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Multi-Service Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createMultiServiceBooking SDK function.
|
|
4
|
+
*
|
|
5
|
+
* Used for the 2-8 day case of the DAY-range expansion: a single
|
|
6
|
+
* APPOINTMENT service whose duration is configured as a DAY range, with
|
|
7
|
+
* 2-8 per-day availability slots picked. One Booking entry is sent per
|
|
8
|
+
* picked slot.
|
|
9
|
+
*/
|
|
10
|
+
import { createMultiServiceBooking as createMultiServiceBookingSdk, } from '@wix/auto_sdk_bookings_bookings';
|
|
11
|
+
/**
|
|
12
|
+
* Creates a multi-service booking from 2-8 single-service booking specs.
|
|
13
|
+
*
|
|
14
|
+
* Per the SDK contract, the bookings array must contain 2-8 APPOINTMENT
|
|
15
|
+
* bookings at the same location with sequential, gapless scheduling.
|
|
16
|
+
* Validation of those constraints is delegated to the SDK; this wrapper only
|
|
17
|
+
* forwards the request and pins `returnFullEntity: true` so the caller can
|
|
18
|
+
* read `bookings[].booking.contactDetails` for downstream cart construction.
|
|
19
|
+
*
|
|
20
|
+
* @param bookings - 2 to 8 single-service booking specifications
|
|
21
|
+
* @param options - Optional notification / SMS settings
|
|
22
|
+
* @returns Promise resolving to the created multi-service booking response
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const response = await createMultiServiceBooking(
|
|
27
|
+
* [bookingDay1, bookingDay2, bookingDay3],
|
|
28
|
+
* {
|
|
29
|
+
* participantNotification: { notifyParticipants: true },
|
|
30
|
+
* sendSmsReminder: true,
|
|
31
|
+
* }
|
|
32
|
+
* );
|
|
33
|
+
* const ids = response.multiServiceBooking?.bookings
|
|
34
|
+
* ?.map((b) => b.bookingId)
|
|
35
|
+
* .filter(Boolean);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function createMultiServiceBooking(bookings, options) {
|
|
39
|
+
return createMultiServiceBookingSdk(bookings, {
|
|
40
|
+
participantNotification: options?.participantNotification,
|
|
41
|
+
sendSmsReminder: options?.sendSmsReminder,
|
|
42
|
+
returnFullEntity: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, type PagingMetadata, type QueryServicesRequest, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
-
export
|
|
9
|
+
export * from '@wix/auto_sdk_bookings_bookings';
|
|
10
|
+
export { createBooking, type CreateBookingOptions, } from './create-booking/index.js';
|
|
11
|
+
export { bulkCreateBooking, type BulkCreateBookingOptions, } from './create-bulk-booking/index.js';
|
|
12
|
+
export { createMultiServiceBooking, type CreateMultiServiceBookingOptions, } from './create-multi-service-booking/index.js';
|
|
10
13
|
export { createCart, ChannelType, type CreateCartOptions, type Cart, } from './create-cart/index.js';
|
|
11
14
|
export { calculateCart, type CalculateCartResponse, type CartSummary, } from './calculate-cart/index.js';
|
|
12
15
|
export { placeOrder, type PlaceOrderOptions, type PlaceOrderResponse, } from './place-order/index.js';
|
package/dist/api/index.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
+
export * from '@wix/auto_sdk_bookings_bookings';
|
|
9
10
|
export { createBooking, } from './create-booking/index.js';
|
|
11
|
+
export { bulkCreateBooking, } from './create-bulk-booking/index.js';
|
|
12
|
+
export { createMultiServiceBooking, } from './create-multi-service-booking/index.js';
|
|
10
13
|
export { createCart, ChannelType, } from './create-cart/index.js';
|
|
11
14
|
export { calculateCart, } from './calculate-cart/index.js';
|
|
12
15
|
export { placeOrder, } from './place-order/index.js';
|