@wix/headless-bookings 1.0.8 → 1.0.10
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__/services/services-mocks.d.ts +17 -1
- package/cjs/dist/__mocks__/services/services-mocks.js +35 -1
- package/cjs/dist/api/index.d.ts +1 -1
- package/cjs/dist/api/index.js +2 -1
- package/cjs/dist/api/query-services/index.d.ts +60 -15
- package/cjs/dist/api/query-services/index.js +86 -10
- package/cjs/dist/react/core/service-list/ServiceList.d.ts +2 -3
- package/cjs/dist/react/service-list/ServiceList.d.ts +3 -3
- package/cjs/dist/react/service-list/ServiceList.js +1 -1
- package/cjs/dist/react/service-list/ServiceList.stories.d.ts +29 -0
- package/cjs/dist/react/service-list/ServiceList.stories.js +125 -0
- package/cjs/dist/services/booking/book-action/bookAction.js +9 -18
- package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +7 -18
- package/cjs/dist/services/booking/book-action/buildCartRequest.js +0 -7
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +7 -4
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.js +4 -5
- package/cjs/dist/services/booking/book-action/createBookingsForCart.d.ts +2 -2
- package/cjs/dist/services/booking/book-action/createBookingsForCart.js +5 -21
- package/cjs/dist/services/booking/book-action/dayRange.d.ts +2 -1
- package/cjs/dist/services/booking/book-action/dayRange.js +2 -1
- package/cjs/dist/services/booking/book-action/types.d.ts +2 -3
- package/cjs/dist/services/booking/booking.d.ts +4 -4
- package/cjs/dist/services/constants.d.ts +2 -0
- package/cjs/dist/services/constants.js +3 -1
- package/cjs/dist/services/index.d.ts +3 -3
- package/cjs/dist/services/index.js +2 -2
- package/cjs/dist/services/service-list/service-list.d.ts +45 -36
- package/cjs/dist/services/service-list/service-list.js +90 -112
- package/dist/__mocks__/services/services-mocks.d.ts +17 -1
- package/dist/__mocks__/services/services-mocks.js +34 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/query-services/index.d.ts +60 -15
- package/dist/api/query-services/index.js +89 -10
- package/dist/react/core/service-list/ServiceList.d.ts +2 -3
- package/dist/react/service-list/ServiceList.d.ts +3 -3
- package/dist/react/service-list/ServiceList.js +1 -1
- package/dist/react/service-list/ServiceList.stories.d.ts +29 -0
- package/dist/react/service-list/ServiceList.stories.js +89 -0
- package/dist/services/booking/book-action/bookAction.js +10 -19
- package/dist/services/booking/book-action/buildCartRequest.d.ts +7 -18
- package/dist/services/booking/book-action/buildCartRequest.js +0 -6
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +7 -4
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.js +4 -5
- package/dist/services/booking/book-action/createBookingsForCart.d.ts +2 -2
- package/dist/services/booking/book-action/createBookingsForCart.js +3 -19
- package/dist/services/booking/book-action/dayRange.d.ts +2 -1
- package/dist/services/booking/book-action/dayRange.js +2 -1
- package/dist/services/booking/book-action/types.d.ts +2 -3
- package/dist/services/booking/booking.d.ts +4 -4
- package/dist/services/constants.d.ts +2 -0
- package/dist/services/constants.js +2 -0
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +2 -2
- package/dist/services/service-list/service-list.d.ts +45 -36
- package/dist/services/service-list/service-list.js +90 -112
- package/package.json +17 -2
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { type CreateCartOptions } from '../../../api/create-cart/index.js';
|
|
2
2
|
import type { ContactDetails } from '@wix/auto_sdk_bookings_bookings';
|
|
3
3
|
export interface BuildCartParams {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export declare function buildCartRequest(params: BuildCartParams): CreateCartOptions;
|
|
12
|
-
/**
|
|
13
|
-
* DAY-range variant of `buildCartRequest`. Takes the N booking IDs returned
|
|
14
|
-
* by `bulkCreateBooking` (1 slot) or `createMultiServiceBooking` (2-8 slots)
|
|
15
|
-
* and emits one catalog item per ID. Per SDK guidance, never use
|
|
16
|
-
* `multiServiceBooking._id` here; always feed the per-day single-service
|
|
17
|
-
* booking IDs into the cart.
|
|
18
|
-
*/
|
|
19
|
-
export interface BuildDayRangeCartParams {
|
|
20
|
-
/** One catalog item per booking id. Bulk / multi-service responses produce N>=1 ids. */
|
|
4
|
+
/**
|
|
5
|
+
* One catalog item is emitted per booking id. Single-service and allDay
|
|
6
|
+
* bookings produce one id; DAY-range expansion produces one per day. Per SDK
|
|
7
|
+
* guidance, never use `multiServiceBooking._id` here; always feed the
|
|
8
|
+
* per-day single-service booking IDs into the cart.
|
|
9
|
+
*/
|
|
21
10
|
bookingIds: string[];
|
|
22
11
|
contactDetails?: ContactDetails;
|
|
23
12
|
/** `null` accepted so callers can forward SDK fields typed `string | null`. */
|
|
@@ -25,4 +14,4 @@ export interface BuildDayRangeCartParams {
|
|
|
25
14
|
/** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
|
|
26
15
|
appId?: string;
|
|
27
16
|
}
|
|
28
|
-
export declare function
|
|
17
|
+
export declare function buildCartRequest(params: BuildCartParams): CreateCartOptions;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildCartRequest = buildCartRequest;
|
|
4
|
-
exports.buildDayRangeCartRequest = buildDayRangeCartRequest;
|
|
5
4
|
const index_js_1 = require("../../../api/create-cart/index.js");
|
|
6
5
|
const constants_js_1 = require("../../constants.js");
|
|
7
6
|
function buildCartRequest(params) {
|
|
8
|
-
return {
|
|
9
|
-
catalogItems: [buildCatalogItem(params.bookingId, params.appId)],
|
|
10
|
-
cart: buildCartShape(params),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function buildDayRangeCartRequest(params) {
|
|
14
7
|
return {
|
|
15
8
|
catalogItems: params.bookingIds.map((id) => buildCatalogItem(id, params.appId)),
|
|
16
9
|
cart: buildCartShape(params),
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
* and the picker emits one slot per day in `rangeTimeSlots`. The client just
|
|
7
7
|
* packages them as one Booking each. Routing is decided by `bookings.length`
|
|
8
8
|
* in `createBookingsForCart`:
|
|
9
|
-
* - length 1 -> `
|
|
9
|
+
* - length 1 -> `createBooking`
|
|
10
10
|
* - length 2-8 -> `createMultiServiceBooking`
|
|
11
11
|
*
|
|
12
|
+
* With `allDay`, the picked slots collapse into one Booking spanning the full
|
|
13
|
+
* range, so that case routes through `createBooking`.
|
|
14
|
+
*
|
|
12
15
|
* The 8-day cap is enforced server-side; the builder does not gate on it.
|
|
13
16
|
*/
|
|
14
17
|
import type { Booking, ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
@@ -17,9 +20,9 @@ import type { BookActionParams } from './types.js';
|
|
|
17
20
|
export interface BuildDayRangeBookingRequest {
|
|
18
21
|
/**
|
|
19
22
|
* The Bookings to create. With `allDay`, this is a single Booking spanning
|
|
20
|
-
* the whole range
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* the whole range. Otherwise it is one Booking per picked per-day slot:
|
|
24
|
+
* length 1 routes to createBooking, length >=2 routes to
|
|
25
|
+
* createMultiServiceBooking.
|
|
23
26
|
*/
|
|
24
27
|
bookings: Booking[];
|
|
25
28
|
/** Notification settings forwarded to the server. */
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
* and the picker emits one slot per day in `rangeTimeSlots`. The client just
|
|
8
8
|
* packages them as one Booking each. Routing is decided by `bookings.length`
|
|
9
9
|
* in `createBookingsForCart`:
|
|
10
|
-
* - length 1 -> `
|
|
10
|
+
* - length 1 -> `createBooking`
|
|
11
11
|
* - length 2-8 -> `createMultiServiceBooking`
|
|
12
12
|
*
|
|
13
|
+
* With `allDay`, the picked slots collapse into one Booking spanning the full
|
|
14
|
+
* range, so that case routes through `createBooking`.
|
|
15
|
+
*
|
|
13
16
|
* The 8-day cap is enforced server-side; the builder does not gate on it.
|
|
14
17
|
*/
|
|
15
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -59,10 +62,6 @@ function buildDayRangeBookingRequest(params) {
|
|
|
59
62
|
},
|
|
60
63
|
},
|
|
61
64
|
});
|
|
62
|
-
// `allDay`: collapse every picked slot into one Booking spanning the whole
|
|
63
|
-
// range (`slots[0].startDate -> slots[N-1].endDate`). `createBookingsForCart`
|
|
64
|
-
// then routes this single Booking through plain `createBooking` instead of
|
|
65
|
-
// bulk / multi-service. Otherwise, emit one Booking per picked slot.
|
|
66
65
|
const bookings = params.allDay
|
|
67
66
|
? [buildBooking(slots[0].startDate, slots[slots.length - 1].endDate)]
|
|
68
67
|
: slots.map((slot) => buildBooking(slot.startDate, slot.endDate));
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Creates the booking(s) needed for cart construction.
|
|
3
3
|
*
|
|
4
4
|
* Branches on the service selection:
|
|
5
|
+
* - DAY-range path with 1 picked day -> `createBooking`
|
|
5
6
|
* - DAY-range path with `allDay` -> `createBooking` (one combined Booking)
|
|
6
|
-
* - DAY-range path with
|
|
7
|
-
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
7
|
+
* - DAY-range path with 2..8 picked days -> `createMultiServiceBooking`
|
|
8
8
|
* - default path -> `createBooking`
|
|
9
9
|
*
|
|
10
10
|
* All branches return the same shape so `executeBookAction` can stay
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Creates the booking(s) needed for cart construction.
|
|
4
4
|
*
|
|
5
5
|
* Branches on the service selection:
|
|
6
|
+
* - DAY-range path with 1 picked day -> `createBooking`
|
|
6
7
|
* - DAY-range path with `allDay` -> `createBooking` (one combined Booking)
|
|
7
|
-
* - DAY-range path with
|
|
8
|
-
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
* - DAY-range path with 2..8 picked days -> `createMultiServiceBooking`
|
|
9
9
|
* - default path -> `createBooking`
|
|
10
10
|
*
|
|
11
11
|
* All branches return the same shape so `executeBookAction` can stay
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.createBookingsForCart = createBookingsForCart;
|
|
18
18
|
const index_js_1 = require("../../../api/create-booking/index.js");
|
|
19
|
-
const index_js_2 = require("../../../api/create-
|
|
20
|
-
const index_js_3 = require("../../../api/create-multi-service-booking/index.js");
|
|
19
|
+
const index_js_2 = require("../../../api/create-multi-service-booking/index.js");
|
|
21
20
|
const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
22
21
|
const buildDayRangeBookingRequest_js_1 = require("./buildDayRangeBookingRequest.js");
|
|
23
22
|
const dayRange_js_1 = require("./dayRange.js");
|
|
@@ -28,9 +27,7 @@ async function createBookingsForCart(params) {
|
|
|
28
27
|
}
|
|
29
28
|
if ((0, dayRange_js_1.isDayRangeService)(firstSelection.service)) {
|
|
30
29
|
const req = (0, buildDayRangeBookingRequest_js_1.buildDayRangeBookingRequest)(params);
|
|
31
|
-
|
|
32
|
-
// Booking. Create it with plain `createBooking` (not bulk / multi-service).
|
|
33
|
-
if (params.allDay) {
|
|
30
|
+
if (req.bookings.length === 1) {
|
|
34
31
|
const bookingResponse = await (0, index_js_1.createBooking)(req.bookings[0], {
|
|
35
32
|
participantNotification: req.participantNotification,
|
|
36
33
|
sendSmsReminder: req.sendSmsReminder,
|
|
@@ -42,20 +39,7 @@ async function createBookingsForCart(params) {
|
|
|
42
39
|
contactDetails: bookingResponse.booking?.contactDetails,
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
const response = await (0, index_js_2.bulkCreateBooking)([{ booking: req.bookings[0] }], {
|
|
47
|
-
participantNotification: req.participantNotification,
|
|
48
|
-
sendSmsReminder: req.sendSmsReminder,
|
|
49
|
-
formSubmission: req.formSubmission,
|
|
50
|
-
});
|
|
51
|
-
const results = response.results ?? [];
|
|
52
|
-
return {
|
|
53
|
-
bookingIds: results.map((r) => r.item?._id).filter(Boolean),
|
|
54
|
-
// All N daily bookings share the same customer; read from the first.
|
|
55
|
-
contactDetails: results[0]?.item?.contactDetails,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const response = await (0, index_js_3.createMultiServiceBooking)(req.bookings, {
|
|
42
|
+
const response = await (0, index_js_2.createMultiServiceBooking)(req.bookings, {
|
|
59
43
|
participantNotification: req.participantNotification,
|
|
60
44
|
sendSmsReminder: req.sendSmsReminder,
|
|
61
45
|
formSubmission: req.formSubmission,
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
5
5
|
* `unitType === DAY` route through the per-day slot path:
|
|
6
|
-
* - 1 picked slot -> `
|
|
6
|
+
* - 1 picked slot -> `createBooking`
|
|
7
7
|
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
* - 2..8 picked slots with `allDay` -> `createBooking`
|
|
8
9
|
*
|
|
9
10
|
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
10
11
|
* selections keep using the existing `createBooking` path.
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
6
6
|
* `unitType === DAY` route through the per-day slot path:
|
|
7
|
-
* - 1 picked slot -> `
|
|
7
|
+
* - 1 picked slot -> `createBooking`
|
|
8
8
|
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
9
|
+
* - 2..8 picked slots with `allDay` -> `createBooking`
|
|
9
10
|
*
|
|
10
11
|
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
11
12
|
* selections keep using the existing `createBooking` path.
|
|
@@ -56,9 +56,8 @@ export interface BookActionParams {
|
|
|
56
56
|
/**
|
|
57
57
|
* DAY-range only. When `true`, the picked per-day slots are collapsed into a
|
|
58
58
|
* single Booking spanning the whole range (`firstSlot.startDate ->
|
|
59
|
-
* lastSlot.endDate`) and created via plain `createBooking
|
|
60
|
-
*
|
|
61
|
-
* `createMultiServiceBooking` (2-8 slots). Ignored for non-DAY-range services.
|
|
59
|
+
* lastSlot.endDate`) and created via plain `createBooking`. Ignored for
|
|
60
|
+
* non-DAY-range services.
|
|
62
61
|
*/
|
|
63
62
|
allDay?: boolean;
|
|
64
63
|
}
|
|
@@ -48,8 +48,9 @@ export interface ServiceSelection {
|
|
|
48
48
|
* picker after the customer picks a start + end date: one entry per day
|
|
49
49
|
* in the picked range. When set, supersedes `timeSlot` for the DAY-range
|
|
50
50
|
* builder, which produces one Booking per entry and routes via length:
|
|
51
|
-
* - 1 ->
|
|
51
|
+
* - 1 -> createBooking
|
|
52
52
|
* - 2-8 -> createMultiServiceBooking
|
|
53
|
+
* - 2-8 with allDay -> createBooking
|
|
53
54
|
* Optional & additive: existing single-slot callers stay on `timeSlot`.
|
|
54
55
|
*/
|
|
55
56
|
rangeTimeSlots?: ServiceSelectionTimeSlot[];
|
|
@@ -90,9 +91,8 @@ export interface BookingServiceActions {
|
|
|
90
91
|
setSelectedPaymentOption(value: SelectedPaymentOption | null): void;
|
|
91
92
|
/**
|
|
92
93
|
* Toggle the DAY-range `allDay` flag. When `true`, `book()` collapses the
|
|
93
|
-
* picked per-day slots
|
|
94
|
-
*
|
|
95
|
-
* Ignored for non-DAY-range services.
|
|
94
|
+
* picked per-day slots into one range-spanning Booking created via
|
|
95
|
+
* `createBooking`. Ignored for non-DAY-range services.
|
|
96
96
|
*/
|
|
97
97
|
setAllDay(value: boolean): void;
|
|
98
98
|
clearAll(): void;
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/** Booking app definition ID */
|
|
7
7
|
export declare const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
8
|
+
/** Default page size for service queries (offset and cursor/availability modes) */
|
|
9
|
+
export declare const DEFAULT_QUERY_LIMIT = 100;
|
|
8
10
|
/** Resource type ID for staff members */
|
|
9
11
|
export declare const STAFF_MEMBER_RESOURCE_TYPE_ID = "1cd44cf8-756f-41c3-bd90-3e2ffcaf1155";
|
|
10
12
|
export declare const ClientServiceIds: {
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* @module Services/Constants
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ClientServiceIds = exports.STAFF_MEMBER_RESOURCE_TYPE_ID = exports.BOOKING_APP_ID = void 0;
|
|
8
|
+
exports.ClientServiceIds = exports.STAFF_MEMBER_RESOURCE_TYPE_ID = exports.DEFAULT_QUERY_LIMIT = exports.BOOKING_APP_ID = void 0;
|
|
9
9
|
/** Booking app definition ID */
|
|
10
10
|
exports.BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
11
|
+
/** Default page size for service queries (offset and cursor/availability modes) */
|
|
12
|
+
exports.DEFAULT_QUERY_LIMIT = 100;
|
|
11
13
|
/** Resource type ID for staff members */
|
|
12
14
|
exports.STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
13
15
|
exports.ClientServiceIds = {
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type ServiceServiceConfig, type ServiceActions, type ServicePaymentData, loadServiceServiceInitialData, type SuccessServiceServiceConfigResult, type NotFoundServiceServiceConfigResult, } from './service/service.js';
|
|
6
6
|
export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type BookingServiceActions, type ServiceSelection, type ServiceSelectionTimeSlot, } from './booking/booking.js';
|
|
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
|
-
export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
|
|
9
|
-
export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
|
|
10
|
-
export { executeBookAction, canBook, buildBookingRequest, buildCartRequest,
|
|
8
|
+
export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type LoadServiceListServiceOptions, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
|
|
9
|
+
export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, AvailabilityLocationType, type ServiceWithAvailabilityItem, type AvailabilityFilter, type Attribute, type AvailabilityLocation, } from '../api/query-services/index.js';
|
|
10
|
+
export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, buildDayRangeBookingRequest, createBookingsForCart, isDayRangeService, getDayRangeBounds, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, 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.getDayRangeBounds = exports.isDayRangeService = exports.createBookingsForCart = exports.buildDayRangeBookingRequest = exports.
|
|
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.buildCartRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.AvailabilityLocationType = 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; } });
|
|
@@ -26,12 +26,12 @@ Object.defineProperty(exports, "loadServiceListServiceInitialData", { enumerable
|
|
|
26
26
|
var index_js_2 = require("../api/query-services/index.js");
|
|
27
27
|
Object.defineProperty(exports, "SYNTHETIC_CUSTOM_ID", { enumerable: true, get: function () { return index_js_2.SYNTHETIC_CUSTOM_ID; } });
|
|
28
28
|
Object.defineProperty(exports, "SYNTHETIC_CUSTOMER_ID", { enumerable: true, get: function () { return index_js_2.SYNTHETIC_CUSTOMER_ID; } });
|
|
29
|
+
Object.defineProperty(exports, "AvailabilityLocationType", { enumerable: true, get: function () { return index_js_2.AvailabilityLocationType; } });
|
|
29
30
|
var index_js_3 = require("./booking/book-action/index.js");
|
|
30
31
|
Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return index_js_3.executeBookAction; } });
|
|
31
32
|
Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return index_js_3.canBook; } });
|
|
32
33
|
Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return index_js_3.buildBookingRequest; } });
|
|
33
34
|
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
35
|
Object.defineProperty(exports, "buildDayRangeBookingRequest", { enumerable: true, get: function () { return index_js_3.buildDayRangeBookingRequest; } });
|
|
36
36
|
Object.defineProperty(exports, "createBookingsForCart", { enumerable: true, get: function () { return index_js_3.createBookingsForCart; } });
|
|
37
37
|
Object.defineProperty(exports, "isDayRangeService", { enumerable: true, get: function () { return index_js_3.isDayRangeService; } });
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ServiceList Service - Reactive service list data management
|
|
3
|
-
* Handles querying and pagination of services list (NO selection management)
|
|
3
|
+
* Handles querying and pagination of services list (NO selection management).
|
|
4
|
+
*
|
|
5
|
+
* Availability is just part of the query: when the query options carry an
|
|
6
|
+
* `availabilityFilter`, the API layer queries services by real bookable
|
|
7
|
+
* availability (and each service gets an `available` flag); otherwise it runs the
|
|
8
|
+
* plain offset query. The service does not know or care which endpoint is used —
|
|
9
|
+
* that decision lives in {@link queryServices}.
|
|
4
10
|
*/
|
|
5
11
|
import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
|
|
6
|
-
import type {
|
|
7
|
-
import type { QueryServicesRequest, PagingMetadata } from '../../api/query-services/index.js';
|
|
12
|
+
import type { Sorting } from '@wix/auto_sdk_bookings_services';
|
|
13
|
+
import type { QueryServicesRequest, PagingMetadata, ServiceWithAvailabilityItem, AvailabilityFilter } from '../../api/query-services/index.js';
|
|
8
14
|
import { type Category } from '../../api/query-categories/index.js';
|
|
9
15
|
import type { FilterOption, FilterValue as Filter } from '@wix/headless-components/react';
|
|
10
16
|
/**
|
|
11
|
-
* Query options without paging metadata (user-controlled request params)
|
|
12
|
-
*
|
|
17
|
+
* Query options without paging metadata (user-controlled request params).
|
|
18
|
+
* Includes `filter` (category/location) and `availabilityFilter`; the effect
|
|
19
|
+
* subscribes to changes in this signal to trigger re-fetches.
|
|
13
20
|
*/
|
|
14
21
|
export type QueryOptions = Omit<QueryServicesRequest, 'pagingMetadata'>;
|
|
15
22
|
/**
|
|
16
23
|
* Configuration for the ServiceList service
|
|
17
24
|
*/
|
|
18
25
|
export interface ServiceListServiceConfig {
|
|
19
|
-
services?:
|
|
26
|
+
services?: ServiceWithAvailabilityItem[];
|
|
20
27
|
categories?: Category[];
|
|
21
28
|
options?: QueryServicesRequest;
|
|
22
29
|
}
|
|
@@ -35,10 +42,10 @@ export interface ServiceListActions {
|
|
|
35
42
|
*/
|
|
36
43
|
export interface ServiceListServiceAPI {
|
|
37
44
|
/** Reactive signal containing the list of services */
|
|
38
|
-
servicesSignal: Signal<
|
|
39
|
-
/** Reactive signal containing current query options (appId, filter, sort) - changes trigger re-fetch */
|
|
45
|
+
servicesSignal: Signal<ServiceWithAvailabilityItem[]>;
|
|
46
|
+
/** Reactive signal containing current query options (appId, filter, availabilityFilter, sort) - changes trigger re-fetch */
|
|
40
47
|
queryOptionsSignal: Signal<QueryOptions>;
|
|
41
|
-
/** Reactive signal containing pagination metadata (limit, offset, count, hasNext) - updated after fetches */
|
|
48
|
+
/** Reactive signal containing pagination metadata (limit, offset/cursor, count, hasNext) - updated after fetches */
|
|
42
49
|
pagingMetadataSignal: Signal<PagingMetadata>;
|
|
43
50
|
/** Reactive signal indicating if services are currently being loaded */
|
|
44
51
|
isLoadingSignal: Signal<boolean>;
|
|
@@ -50,6 +57,8 @@ export interface ServiceListServiceAPI {
|
|
|
50
57
|
filterOptionsSignal: ReadOnlySignal<FilterOption[]>;
|
|
51
58
|
/** Computed signal indicating if any filters are active (from queryOptionsSignal.filter) */
|
|
52
59
|
isFilteredSignal: ReadOnlySignal<boolean>;
|
|
60
|
+
/** Computed signal indicating whether an availability filter is currently applied */
|
|
61
|
+
hasAvailabilityFilterSignal: ReadOnlySignal<boolean>;
|
|
53
62
|
/** Computed signal containing effective filter (queryOptions.filter + location from BookingService) */
|
|
54
63
|
effectiveFilterSignal: ReadOnlySignal<Filter | undefined>;
|
|
55
64
|
/** Actions object containing query actions */
|
|
@@ -91,7 +100,6 @@ export declare const ServiceListServiceDefinition: string & {
|
|
|
91
100
|
* const services = serviceListService.servicesSignal.get();
|
|
92
101
|
* const isLoading = serviceListService.isLoadingSignal.get();
|
|
93
102
|
* const error = serviceListService.errorSignal.get();
|
|
94
|
-
* const pagingMetadata = serviceListService.pagingMetadataSignal.get();
|
|
95
103
|
* const hasMore = serviceListService.hasMoreServicesSignal.get();
|
|
96
104
|
*
|
|
97
105
|
* if (isLoading) return <div>Loading services...</div>;
|
|
@@ -110,9 +118,6 @@ export declare const ServiceListServiceDefinition: string & {
|
|
|
110
118
|
* Load More
|
|
111
119
|
* </button>
|
|
112
120
|
* )}
|
|
113
|
-
* {pagingMetadata.hasNext && (
|
|
114
|
-
* <span>More services available</span>
|
|
115
|
-
* )}
|
|
116
121
|
* </div>
|
|
117
122
|
* );
|
|
118
123
|
* }
|
|
@@ -135,36 +140,40 @@ export type ErrorServiceListServiceConfigResult = {
|
|
|
135
140
|
error: Error;
|
|
136
141
|
};
|
|
137
142
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
* Options for {@link loadServiceListServiceInitialData}.
|
|
144
|
+
* Pass an `availabilityFilter` to load availability-aware services.
|
|
145
|
+
*/
|
|
146
|
+
export interface LoadServiceListServiceOptions {
|
|
147
|
+
appId?: string;
|
|
148
|
+
filter?: Filter;
|
|
149
|
+
pagingMetadata?: PagingMetadata;
|
|
150
|
+
sort?: Sorting[];
|
|
151
|
+
availabilityFilter?: AvailabilityFilter;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Loads service list configuration for SSR, pre-fetching services and categories.
|
|
155
|
+
* Pass an `availabilityFilter` to query availability-aware services.
|
|
142
156
|
*
|
|
143
|
-
* @param options - Query options
|
|
144
|
-
* @returns A
|
|
157
|
+
* @param options - Query options.
|
|
158
|
+
* @returns A success result with the config, or an error result.
|
|
145
159
|
*
|
|
146
160
|
* @example
|
|
147
161
|
* ```ts
|
|
148
|
-
* //
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* // Load with query options
|
|
152
|
-
* const serviceListResult = await loadServiceListServiceInitialData({
|
|
162
|
+
* // Plain offset query
|
|
163
|
+
* const result = await loadServiceListServiceInitialData({
|
|
153
164
|
* appId: '13d21c63-b5ec-5912-8397-c3a5ddb27a97',
|
|
154
165
|
* pagingMetadata: { limit: 20, offset: 0 },
|
|
155
166
|
* });
|
|
156
167
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* // More services can be loaded
|
|
167
|
-
* }
|
|
168
|
+
* // Availability-aware query (cursor paging + `available` flag)
|
|
169
|
+
* const availabilityResult = await loadServiceListServiceInitialData({
|
|
170
|
+
* availabilityFilter: {
|
|
171
|
+
* localStartDate: '2026-06-01T09:00:00',
|
|
172
|
+
* localEndDate: '2026-06-07T17:00:00',
|
|
173
|
+
* timeZone: 'America/New_York',
|
|
174
|
+
* },
|
|
175
|
+
* pagingMetadata: { limit: 20 },
|
|
176
|
+
* });
|
|
168
177
|
* ```
|
|
169
178
|
*/
|
|
170
|
-
export declare function loadServiceListServiceInitialData(options:
|
|
179
|
+
export declare function loadServiceListServiceInitialData(options: LoadServiceListServiceOptions): Promise<SuccessServiceListServiceConfigResult | ErrorServiceListServiceConfigResult>;
|