@wix/headless-bookings 0.0.26 → 0.0.27
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 +42 -0
- package/cjs/dist/api/create-booking/index.js +35 -0
- package/cjs/dist/api/create-checkout/index.d.ts +40 -0
- package/cjs/dist/api/create-checkout/index.js +37 -0
- package/cjs/dist/api/index.d.ts +2 -0
- package/cjs/dist/api/index.js +2 -0
- package/cjs/dist/services/booking/book-action/bookAction.d.ts +2 -2
- package/cjs/dist/services/booking/book-action/bookAction.js +7 -7
- package/cjs/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +2 -2
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +1 -1
- package/dist/api/create-booking/index.d.ts +42 -0
- package/dist/api/create-booking/index.js +35 -0
- package/dist/api/create-checkout/index.d.ts +40 -0
- package/dist/api/create-checkout/index.js +37 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/services/booking/book-action/bookAction.d.ts +2 -2
- package/dist/services/booking/book-action/bookAction.js +7 -7
- package/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +2 -2
- package/dist/services/booking/book-action/buildCheckoutRequest.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createBooking SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { type Booking, type CreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
6
|
+
import type { FormValues } from '@wix/form-public';
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a booking
|
|
9
|
+
*/
|
|
10
|
+
export interface CreateBookingOptions {
|
|
11
|
+
/** Notification settings for participants */
|
|
12
|
+
participantNotification?: ParticipantNotification;
|
|
13
|
+
/** Whether to send SMS reminder */
|
|
14
|
+
sendSmsReminder?: boolean;
|
|
15
|
+
/** Form submission data */
|
|
16
|
+
formSubmission?: FormValues;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a booking with the specified booking data and options
|
|
20
|
+
*
|
|
21
|
+
* @param booking - The booking data
|
|
22
|
+
* @param options - Optional settings for notifications and form submission
|
|
23
|
+
* @returns Promise resolving to the created booking response
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const response = await createBooking(
|
|
28
|
+
* {
|
|
29
|
+
* selectedPaymentOption: 'ONLINE',
|
|
30
|
+
* totalParticipants: 1,
|
|
31
|
+
* bookedEntity: { slot: { ... } }
|
|
32
|
+
* },
|
|
33
|
+
* {
|
|
34
|
+
* participantNotification: { notifyParticipants: true },
|
|
35
|
+
* sendSmsReminder: true,
|
|
36
|
+
* formSubmission: formValues
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createBooking SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { createBooking as createBookingSdk, } from '@wix/auto_sdk_bookings_bookings';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a booking with the specified booking data and options
|
|
8
|
+
*
|
|
9
|
+
* @param booking - The booking data
|
|
10
|
+
* @param options - Optional settings for notifications and form submission
|
|
11
|
+
* @returns Promise resolving to the created booking response
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const response = await createBooking(
|
|
16
|
+
* {
|
|
17
|
+
* selectedPaymentOption: 'ONLINE',
|
|
18
|
+
* totalParticipants: 1,
|
|
19
|
+
* bookedEntity: { slot: { ... } }
|
|
20
|
+
* },
|
|
21
|
+
* {
|
|
22
|
+
* participantNotification: { notifyParticipants: true },
|
|
23
|
+
* sendSmsReminder: true,
|
|
24
|
+
* formSubmission: formValues
|
|
25
|
+
* }
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export async function createBooking(booking, options) {
|
|
30
|
+
return createBookingSdk(booking, {
|
|
31
|
+
participantNotification: options?.participantNotification,
|
|
32
|
+
sendSmsReminder: options?.sendSmsReminder,
|
|
33
|
+
formSubmission: options?.formSubmission,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Checkout API
|
|
3
|
+
* Wrapper for the Wix eCommerce createCheckout SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { type CreateCheckoutRequest, type Checkout } from '@wix/auto_sdk_ecom_checkout';
|
|
6
|
+
/**
|
|
7
|
+
* Response from createCheckout API
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateCheckoutResponse {
|
|
10
|
+
/** The created checkout */
|
|
11
|
+
checkout?: Checkout;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a checkout session with the specified request data
|
|
15
|
+
*
|
|
16
|
+
* @param request - The checkout request data including line items and checkout info
|
|
17
|
+
* @returns Promise resolving to the created checkout response
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const response = await createCheckout({
|
|
22
|
+
* channelType: ChannelType.WEB,
|
|
23
|
+
* lineItems: [
|
|
24
|
+
* {
|
|
25
|
+
* quantity: 1,
|
|
26
|
+
* catalogReference: {
|
|
27
|
+
* catalogItemId: bookingId,
|
|
28
|
+
* appId: BOOKINGS_APP_DEF_ID,
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* ],
|
|
32
|
+
* checkoutInfo: {
|
|
33
|
+
* businessLocationId,
|
|
34
|
+
* billingInfo: { ... },
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function createCheckout(request: CreateCheckoutRequest): Promise<CreateCheckoutResponse>;
|
|
40
|
+
export { ChannelType, type CreateCheckoutRequest, } from '@wix/auto_sdk_ecom_checkout';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Checkout API
|
|
3
|
+
* Wrapper for the Wix eCommerce createCheckout SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { createCheckout as createCheckoutSdk, } from '@wix/auto_sdk_ecom_checkout';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a checkout session with the specified request data
|
|
8
|
+
*
|
|
9
|
+
* @param request - The checkout request data including line items and checkout info
|
|
10
|
+
* @returns Promise resolving to the created checkout response
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const response = await createCheckout({
|
|
15
|
+
* channelType: ChannelType.WEB,
|
|
16
|
+
* lineItems: [
|
|
17
|
+
* {
|
|
18
|
+
* quantity: 1,
|
|
19
|
+
* catalogReference: {
|
|
20
|
+
* catalogItemId: bookingId,
|
|
21
|
+
* appId: BOOKINGS_APP_DEF_ID,
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* ],
|
|
25
|
+
* checkoutInfo: {
|
|
26
|
+
* businessLocationId,
|
|
27
|
+
* billingInfo: { ... },
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export async function createCheckout(request) {
|
|
33
|
+
const checkout = await createCheckoutSdk(request);
|
|
34
|
+
return { checkout };
|
|
35
|
+
}
|
|
36
|
+
// Re-export types and constants that consumers may need
|
|
37
|
+
export { ChannelType, } from '@wix/auto_sdk_ecom_checkout';
|
package/cjs/dist/api/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, type ServiceListFilters, type QueryServicesRequest, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
+
export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
|
|
10
|
+
export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
|
|
9
11
|
/**
|
|
10
12
|
* PagingMetadata includes:
|
|
11
13
|
* - limit: Number of items per page
|
package/cjs/dist/api/index.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
+
export { createBooking, } from './create-booking/index.js';
|
|
10
|
+
export { createCheckout, ChannelType, } from './create-checkout/index.js';
|
|
9
11
|
/**
|
|
10
12
|
* PagingMetadata includes:
|
|
11
13
|
* - limit: Number of items per page
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Book Action - Orchestrates the booking flow
|
|
3
3
|
*
|
|
4
4
|
* 1. Validates booking data with canBook()
|
|
5
|
-
* 2. Creates a booking via createBooking() from
|
|
6
|
-
* 3. Creates a checkout via createCheckout() from
|
|
5
|
+
* 2. Creates a booking via createBooking() from API layer
|
|
6
|
+
* 3. Creates a checkout via createCheckout() from API layer
|
|
7
7
|
* 4. Returns the checkoutId for navigation
|
|
8
8
|
*/
|
|
9
9
|
import type { BookActionParams, BookResult } from './types.js';
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Book Action - Orchestrates the booking flow
|
|
3
3
|
*
|
|
4
4
|
* 1. Validates booking data with canBook()
|
|
5
|
-
* 2. Creates a booking via createBooking() from
|
|
6
|
-
* 3. Creates a checkout via createCheckout() from
|
|
5
|
+
* 2. Creates a booking via createBooking() from API layer
|
|
6
|
+
* 3. Creates a checkout via createCheckout() from API layer
|
|
7
7
|
* 4. Returns the checkoutId for navigation
|
|
8
8
|
*/
|
|
9
|
-
import { createBooking } from '
|
|
10
|
-
import { createCheckout } from '
|
|
9
|
+
import { createBooking } from '../../../api/create-booking/index.js';
|
|
10
|
+
import { createCheckout } from '../../../api/create-checkout/index.js';
|
|
11
11
|
import { buildBookingRequest } from './buildBookingRequest.js';
|
|
12
12
|
import { buildCheckoutRequest } from './buildCheckoutRequest.js';
|
|
13
13
|
import { canBook } from './canBook.js';
|
|
@@ -34,8 +34,8 @@ export async function executeBookAction(params) {
|
|
|
34
34
|
const createBookingRequest = buildBookingRequest(params);
|
|
35
35
|
const bookingResponse = await createBooking(createBookingRequest.booking, {
|
|
36
36
|
participantNotification: createBookingRequest.participantNotification,
|
|
37
|
-
sendSmsReminder: createBookingRequest.sendSmsReminder,
|
|
38
|
-
formSubmission: createBookingRequest.formSubmission,
|
|
37
|
+
sendSmsReminder: createBookingRequest.sendSmsReminder ?? undefined,
|
|
38
|
+
formSubmission: createBookingRequest.formSubmission ?? undefined,
|
|
39
39
|
});
|
|
40
40
|
const bookingId = bookingResponse.booking?._id;
|
|
41
41
|
const contactDetails = bookingResponse.booking?.contactDetails;
|
|
@@ -51,7 +51,7 @@ export async function executeBookAction(params) {
|
|
|
51
51
|
businessLocationId,
|
|
52
52
|
});
|
|
53
53
|
const checkoutResponse = await createCheckout(checkoutRequest);
|
|
54
|
-
const checkoutId = checkoutResponse._id;
|
|
54
|
+
const checkoutId = checkoutResponse.checkout?._id;
|
|
55
55
|
if (!checkoutId) {
|
|
56
56
|
throw new Error('Failed to create checkout');
|
|
57
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createBooking request from BookActionParams
|
|
3
3
|
*/
|
|
4
|
-
import type { CreateBookingRequest } from '
|
|
4
|
+
import type { CreateBookingRequest } from '../../../api/create-booking/index.js';
|
|
5
5
|
import type { BookActionParams } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Builds a CreateBookingRequest from the booking action parameters
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createCheckout request
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
5
|
-
import type { ContactDetails } from '
|
|
4
|
+
import { type CreateCheckoutRequest } from '../../../api/create-checkout/index.js';
|
|
5
|
+
import type { ContactDetails } from '../../../api/create-booking/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Parameters for building checkout request
|
|
8
8
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createCheckout request
|
|
3
3
|
*/
|
|
4
|
-
import { ChannelType } from '
|
|
4
|
+
import { ChannelType, } from '../../../api/create-checkout/index.js';
|
|
5
5
|
const BOOKINGS_APP_DEF_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
6
6
|
/**
|
|
7
7
|
* Builds a checkout request from the booking ID and contact details
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createBooking SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { type Booking, type CreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
|
|
6
|
+
import type { FormValues } from '@wix/form-public';
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a booking
|
|
9
|
+
*/
|
|
10
|
+
export interface CreateBookingOptions {
|
|
11
|
+
/** Notification settings for participants */
|
|
12
|
+
participantNotification?: ParticipantNotification;
|
|
13
|
+
/** Whether to send SMS reminder */
|
|
14
|
+
sendSmsReminder?: boolean;
|
|
15
|
+
/** Form submission data */
|
|
16
|
+
formSubmission?: FormValues;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a booking with the specified booking data and options
|
|
20
|
+
*
|
|
21
|
+
* @param booking - The booking data
|
|
22
|
+
* @param options - Optional settings for notifications and form submission
|
|
23
|
+
* @returns Promise resolving to the created booking response
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const response = await createBooking(
|
|
28
|
+
* {
|
|
29
|
+
* selectedPaymentOption: 'ONLINE',
|
|
30
|
+
* totalParticipants: 1,
|
|
31
|
+
* bookedEntity: { slot: { ... } }
|
|
32
|
+
* },
|
|
33
|
+
* {
|
|
34
|
+
* participantNotification: { notifyParticipants: true },
|
|
35
|
+
* sendSmsReminder: true,
|
|
36
|
+
* formSubmission: formValues
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Booking API
|
|
3
|
+
* Wrapper for the Wix Bookings createBooking SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { createBooking as createBookingSdk, } from '@wix/auto_sdk_bookings_bookings';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a booking with the specified booking data and options
|
|
8
|
+
*
|
|
9
|
+
* @param booking - The booking data
|
|
10
|
+
* @param options - Optional settings for notifications and form submission
|
|
11
|
+
* @returns Promise resolving to the created booking response
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const response = await createBooking(
|
|
16
|
+
* {
|
|
17
|
+
* selectedPaymentOption: 'ONLINE',
|
|
18
|
+
* totalParticipants: 1,
|
|
19
|
+
* bookedEntity: { slot: { ... } }
|
|
20
|
+
* },
|
|
21
|
+
* {
|
|
22
|
+
* participantNotification: { notifyParticipants: true },
|
|
23
|
+
* sendSmsReminder: true,
|
|
24
|
+
* formSubmission: formValues
|
|
25
|
+
* }
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export async function createBooking(booking, options) {
|
|
30
|
+
return createBookingSdk(booking, {
|
|
31
|
+
participantNotification: options?.participantNotification,
|
|
32
|
+
sendSmsReminder: options?.sendSmsReminder,
|
|
33
|
+
formSubmission: options?.formSubmission,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Checkout API
|
|
3
|
+
* Wrapper for the Wix eCommerce createCheckout SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { type CreateCheckoutRequest, type Checkout } from '@wix/auto_sdk_ecom_checkout';
|
|
6
|
+
/**
|
|
7
|
+
* Response from createCheckout API
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateCheckoutResponse {
|
|
10
|
+
/** The created checkout */
|
|
11
|
+
checkout?: Checkout;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a checkout session with the specified request data
|
|
15
|
+
*
|
|
16
|
+
* @param request - The checkout request data including line items and checkout info
|
|
17
|
+
* @returns Promise resolving to the created checkout response
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const response = await createCheckout({
|
|
22
|
+
* channelType: ChannelType.WEB,
|
|
23
|
+
* lineItems: [
|
|
24
|
+
* {
|
|
25
|
+
* quantity: 1,
|
|
26
|
+
* catalogReference: {
|
|
27
|
+
* catalogItemId: bookingId,
|
|
28
|
+
* appId: BOOKINGS_APP_DEF_ID,
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* ],
|
|
32
|
+
* checkoutInfo: {
|
|
33
|
+
* businessLocationId,
|
|
34
|
+
* billingInfo: { ... },
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function createCheckout(request: CreateCheckoutRequest): Promise<CreateCheckoutResponse>;
|
|
40
|
+
export { ChannelType, type CreateCheckoutRequest, } from '@wix/auto_sdk_ecom_checkout';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Checkout API
|
|
3
|
+
* Wrapper for the Wix eCommerce createCheckout SDK function
|
|
4
|
+
*/
|
|
5
|
+
import { createCheckout as createCheckoutSdk, } from '@wix/auto_sdk_ecom_checkout';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a checkout session with the specified request data
|
|
8
|
+
*
|
|
9
|
+
* @param request - The checkout request data including line items and checkout info
|
|
10
|
+
* @returns Promise resolving to the created checkout response
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const response = await createCheckout({
|
|
15
|
+
* channelType: ChannelType.WEB,
|
|
16
|
+
* lineItems: [
|
|
17
|
+
* {
|
|
18
|
+
* quantity: 1,
|
|
19
|
+
* catalogReference: {
|
|
20
|
+
* catalogItemId: bookingId,
|
|
21
|
+
* appId: BOOKINGS_APP_DEF_ID,
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* ],
|
|
25
|
+
* checkoutInfo: {
|
|
26
|
+
* businessLocationId,
|
|
27
|
+
* billingInfo: { ... },
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export async function createCheckout(request) {
|
|
33
|
+
const checkout = await createCheckoutSdk(request);
|
|
34
|
+
return { checkout };
|
|
35
|
+
}
|
|
36
|
+
// Re-export types and constants that consumers may need
|
|
37
|
+
export { ChannelType, } from '@wix/auto_sdk_ecom_checkout';
|
package/dist/api/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, type ServiceListFilters, type QueryServicesRequest, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
+
export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
|
|
10
|
+
export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
|
|
9
11
|
/**
|
|
10
12
|
* PagingMetadata includes:
|
|
11
13
|
* - limit: Number of items per page
|
package/dist/api/index.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, } from './query-services/index.js';
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
|
+
export { createBooking, } from './create-booking/index.js';
|
|
10
|
+
export { createCheckout, ChannelType, } from './create-checkout/index.js';
|
|
9
11
|
/**
|
|
10
12
|
* PagingMetadata includes:
|
|
11
13
|
* - limit: Number of items per page
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Book Action - Orchestrates the booking flow
|
|
3
3
|
*
|
|
4
4
|
* 1. Validates booking data with canBook()
|
|
5
|
-
* 2. Creates a booking via createBooking() from
|
|
6
|
-
* 3. Creates a checkout via createCheckout() from
|
|
5
|
+
* 2. Creates a booking via createBooking() from API layer
|
|
6
|
+
* 3. Creates a checkout via createCheckout() from API layer
|
|
7
7
|
* 4. Returns the checkoutId for navigation
|
|
8
8
|
*/
|
|
9
9
|
import type { BookActionParams, BookResult } from './types.js';
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Book Action - Orchestrates the booking flow
|
|
3
3
|
*
|
|
4
4
|
* 1. Validates booking data with canBook()
|
|
5
|
-
* 2. Creates a booking via createBooking() from
|
|
6
|
-
* 3. Creates a checkout via createCheckout() from
|
|
5
|
+
* 2. Creates a booking via createBooking() from API layer
|
|
6
|
+
* 3. Creates a checkout via createCheckout() from API layer
|
|
7
7
|
* 4. Returns the checkoutId for navigation
|
|
8
8
|
*/
|
|
9
|
-
import { createBooking } from '
|
|
10
|
-
import { createCheckout } from '
|
|
9
|
+
import { createBooking } from '../../../api/create-booking/index.js';
|
|
10
|
+
import { createCheckout } from '../../../api/create-checkout/index.js';
|
|
11
11
|
import { buildBookingRequest } from './buildBookingRequest.js';
|
|
12
12
|
import { buildCheckoutRequest } from './buildCheckoutRequest.js';
|
|
13
13
|
import { canBook } from './canBook.js';
|
|
@@ -34,8 +34,8 @@ export async function executeBookAction(params) {
|
|
|
34
34
|
const createBookingRequest = buildBookingRequest(params);
|
|
35
35
|
const bookingResponse = await createBooking(createBookingRequest.booking, {
|
|
36
36
|
participantNotification: createBookingRequest.participantNotification,
|
|
37
|
-
sendSmsReminder: createBookingRequest.sendSmsReminder,
|
|
38
|
-
formSubmission: createBookingRequest.formSubmission,
|
|
37
|
+
sendSmsReminder: createBookingRequest.sendSmsReminder ?? undefined,
|
|
38
|
+
formSubmission: createBookingRequest.formSubmission ?? undefined,
|
|
39
39
|
});
|
|
40
40
|
const bookingId = bookingResponse.booking?._id;
|
|
41
41
|
const contactDetails = bookingResponse.booking?.contactDetails;
|
|
@@ -51,7 +51,7 @@ export async function executeBookAction(params) {
|
|
|
51
51
|
businessLocationId,
|
|
52
52
|
});
|
|
53
53
|
const checkoutResponse = await createCheckout(checkoutRequest);
|
|
54
|
-
const checkoutId = checkoutResponse._id;
|
|
54
|
+
const checkoutId = checkoutResponse.checkout?._id;
|
|
55
55
|
if (!checkoutId) {
|
|
56
56
|
throw new Error('Failed to create checkout');
|
|
57
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createBooking request from BookActionParams
|
|
3
3
|
*/
|
|
4
|
-
import type { CreateBookingRequest } from '
|
|
4
|
+
import type { CreateBookingRequest } from '../../../api/create-booking/index.js';
|
|
5
5
|
import type { BookActionParams } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Builds a CreateBookingRequest from the booking action parameters
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createCheckout request
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
5
|
-
import type { ContactDetails } from '
|
|
4
|
+
import { type CreateCheckoutRequest } from '../../../api/create-checkout/index.js';
|
|
5
|
+
import type { ContactDetails } from '../../../api/create-booking/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Parameters for building checkout request
|
|
8
8
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the createCheckout request
|
|
3
3
|
*/
|
|
4
|
-
import { ChannelType } from '
|
|
4
|
+
import { ChannelType, } from '../../../api/create-checkout/index.js';
|
|
5
5
|
const BOOKINGS_APP_DEF_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
6
6
|
/**
|
|
7
7
|
* Builds a checkout request from the booking ID and contact details
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/headless-bookings",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"groupId": "com.wixpress.headless-components"
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
"falconPackageHash": "
|
|
75
|
+
"falconPackageHash": "fcc6fed76998cb4042fc59d2b43ef150e4446496a06668af64c20b9b"
|
|
76
76
|
}
|