@wix/headless-bookings 0.0.118 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/cjs/dist/api/calculate-cart/index.d.ts +3 -0
  2. package/cjs/dist/api/calculate-cart/index.js +7 -0
  3. package/cjs/dist/api/create-cart/index.d.ts +3 -0
  4. package/cjs/dist/api/create-cart/index.js +10 -0
  5. package/cjs/dist/api/index.d.ts +3 -9
  6. package/cjs/dist/api/index.js +12 -17
  7. package/cjs/dist/api/place-order/index.d.ts +3 -0
  8. package/cjs/dist/api/place-order/index.js +7 -0
  9. package/cjs/dist/react/booking/Book.js +1 -1
  10. package/cjs/dist/react/core/booking/Book.d.ts +1 -1
  11. package/cjs/dist/react/core/booking/Book.js +1 -1
  12. package/cjs/dist/services/booking/book-action/bookAction.d.ts +0 -22
  13. package/cjs/dist/services/booking/book-action/bookAction.js +20 -39
  14. package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  15. package/cjs/dist/services/booking/book-action/buildCartRequest.js +37 -0
  16. package/cjs/dist/services/booking/book-action/index.d.ts +1 -1
  17. package/cjs/dist/services/booking/book-action/index.js +3 -3
  18. package/cjs/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  19. package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  20. package/cjs/dist/services/booking/book-action/types.d.ts +1 -1
  21. package/cjs/dist/services/index.d.ts +1 -1
  22. package/cjs/dist/services/index.js +2 -2
  23. package/cjs/dist/utils/navigation.d.ts +2 -2
  24. package/cjs/dist/utils/navigation.js +2 -2
  25. package/dist/api/calculate-cart/index.d.ts +3 -0
  26. package/dist/api/calculate-cart/index.js +4 -0
  27. package/dist/api/create-cart/index.d.ts +3 -0
  28. package/dist/api/create-cart/index.js +5 -0
  29. package/dist/api/index.d.ts +3 -9
  30. package/dist/api/index.js +3 -9
  31. package/dist/api/place-order/index.d.ts +3 -0
  32. package/dist/api/place-order/index.js +4 -0
  33. package/dist/react/booking/Book.js +1 -1
  34. package/dist/react/core/booking/Book.d.ts +1 -1
  35. package/dist/react/core/booking/Book.js +1 -1
  36. package/dist/services/booking/book-action/bookAction.d.ts +0 -22
  37. package/dist/services/booking/book-action/bookAction.js +20 -39
  38. package/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  39. package/dist/services/booking/book-action/buildCartRequest.js +34 -0
  40. package/dist/services/booking/book-action/index.d.ts +1 -1
  41. package/dist/services/booking/book-action/index.js +1 -1
  42. package/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  43. package/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  44. package/dist/services/booking/book-action/types.d.ts +1 -1
  45. package/dist/services/index.d.ts +1 -1
  46. package/dist/services/index.js +1 -1
  47. package/dist/utils/navigation.d.ts +2 -2
  48. package/dist/utils/navigation.js +2 -2
  49. package/package.json +3 -3
  50. package/cjs/dist/api/create-checkout/index.d.ts +0 -40
  51. package/cjs/dist/api/create-checkout/index.js +0 -42
  52. package/cjs/dist/api/create-order/index.d.ts +0 -20
  53. package/cjs/dist/api/create-order/index.js +0 -24
  54. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  55. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +0 -65
  56. package/dist/api/create-checkout/index.d.ts +0 -40
  57. package/dist/api/create-checkout/index.js +0 -37
  58. package/dist/api/create-order/index.d.ts +0 -20
  59. package/dist/api/create-order/index.js +0 -21
  60. package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  61. package/dist/services/booking/book-action/buildCheckoutRequest.js +0 -62
@@ -1,28 +0,0 @@
1
- /**
2
- * Builds the createCheckout request
3
- */
4
- import { type CreateCheckoutRequest } from '../../../api/create-checkout/index.js';
5
- import type { ContactDetails } from '../../../api/create-booking/index.js';
6
- /**
7
- * Parameters for building checkout request
8
- */
9
- export interface BuildCheckoutParams {
10
- bookingId: string;
11
- contactDetails?: ContactDetails;
12
- businessLocationId?: string;
13
- /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
14
- appId?: string;
15
- }
16
- /**
17
- * Builds a checkout request from the booking ID and contact details
18
- *
19
- * Contact details come from the booking response and are used to populate:
20
- * - billingInfo.contactDetails (firstName, lastName, phone)
21
- * - billingInfo.address (from fullAddress if available)
22
- * - shippingInfo.shippingDestination.contactDetails
23
- * - buyerInfo (email, contactId)
24
- *
25
- * @param params - The checkout parameters
26
- * @returns CreateCheckoutRequest ready to be sent to the API
27
- */
28
- export declare function buildCheckoutRequest(params: BuildCheckoutParams): CreateCheckoutRequest;
@@ -1,62 +0,0 @@
1
- /**
2
- * Builds the createCheckout request
3
- */
4
- import { ChannelType, } from '../../../api/create-checkout/index.js';
5
- import { BOOKING_APP_ID } from '../../constants.js';
6
- /**
7
- * Builds a checkout request from the booking ID and contact details
8
- *
9
- * Contact details come from the booking response and are used to populate:
10
- * - billingInfo.contactDetails (firstName, lastName, phone)
11
- * - billingInfo.address (from fullAddress if available)
12
- * - shippingInfo.shippingDestination.contactDetails
13
- * - buyerInfo (email, contactId)
14
- *
15
- * @param params - The checkout parameters
16
- * @returns CreateCheckoutRequest ready to be sent to the API
17
- */
18
- export function buildCheckoutRequest(params) {
19
- const { bookingId, contactDetails, businessLocationId, appId } = params;
20
- // Build checkoutInfo incrementally for readability
21
- const checkoutInfo = {};
22
- // businessLocationId for multi-location support
23
- if (businessLocationId) {
24
- checkoutInfo.businessLocationId = businessLocationId;
25
- }
26
- // Billing info and shipping info from contact details
27
- if (contactDetails) {
28
- checkoutInfo.billingInfo = {
29
- contactDetails,
30
- ...(contactDetails.fullAddress?.country
31
- ? { address: { ...contactDetails.fullAddress } }
32
- : {}),
33
- };
34
- checkoutInfo.shippingInfo = {
35
- shippingDestination: {
36
- contactDetails,
37
- },
38
- };
39
- }
40
- // Buyer info with email and contactId
41
- if (contactDetails?.email) {
42
- checkoutInfo.buyerInfo = {
43
- email: contactDetails.email,
44
- ...(contactDetails.contactId
45
- ? { contactId: contactDetails.contactId }
46
- : {}),
47
- };
48
- }
49
- return {
50
- channelType: ChannelType.WEB,
51
- lineItems: [
52
- {
53
- quantity: 1,
54
- catalogReference: {
55
- catalogItemId: bookingId,
56
- appId: appId ?? BOOKING_APP_ID,
57
- },
58
- },
59
- ],
60
- checkoutInfo,
61
- };
62
- }