@wix/headless-bookings 1.0.18 → 1.0.19

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.
@@ -9,6 +9,6 @@ export { ServiceListService, ServiceListServiceDefinition, type ServiceListServi
9
9
  export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, AvailabilityLocationType, type ServiceWithAvailabilityItem, type AvailabilityFilter, type Attribute, type AvailabilityLocation, } from '../api/query-services/index.js';
10
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
- export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type ServicePaymentOptions, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
12
+ export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type AppliedAdditionalFee, type PreviewPriceInfo, 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';
14
14
  export { StaffMemberListService, StaffMemberListServiceDefinition, loadStaffMemberListServiceInitialData, staffMemberListServiceBinding, type StaffMemberListServiceAPI, type StaffMemberListServiceConfig, type StaffMemberListActions, type StaffMemberData, type LoadStaffMemberListServiceResult, } from './staff-member-list/staff-member-list.js';
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { type PaymentServiceConfig, type PaymentServiceInternalConfig, type PricingServiceSelection } from './payment.def.js';
7
7
  import type { SelectedPaymentOption } from '../booking/book-action/types.js';
8
- export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
8
+ export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type AppliedAdditionalFee, type PreviewPriceInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
9
9
  export type { PaymentServiceAPI, PaymentServiceInternalConfig, } from './payment.def.js';
10
10
  export declare const PaymentService: import("@wix/services-definitions").ServiceFactory<string & {
11
11
  __api: import("./payment.def.js").PaymentServiceAPI;
@@ -5,6 +5,7 @@
5
5
  import type { Signal } from '@wix/services-definitions/core-services/signals';
6
6
  import type { CalculateTotalsResponse } from '@wix/auto_sdk_ecom_totals-calculator';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
+ import type { BookingLineItem, PriceInfo } from '@wix/auto_sdk_bookings_pricing';
8
9
  import type { SelectedPaymentOption } from '../booking/book-action/types.js';
9
10
  import type { ServiceSelectionTimeSlot } from '../booking/booking.js';
10
11
  /**
@@ -32,6 +33,31 @@ export interface ServicePaymentOptions {
32
33
  * Payment option for line items
33
34
  */
34
35
  export type PaymentOption = 'FULL_PAYMENT_ONLINE' | 'FULL_PAYMENT_OFFLINE' | 'DEPOSIT_ONLINE';
36
+ /**
37
+ * An additional fee pricing applied to a booking line, as served.
38
+ */
39
+ export interface AppliedAdditionalFee {
40
+ /** The service's additional fee ID. */
41
+ feeId?: string;
42
+ /** Units the fee was charged for (1 for a per-reservation fee). */
43
+ units?: number;
44
+ /** The fee amount for this line. */
45
+ amount?: number;
46
+ }
47
+ /**
48
+ * `PriceInfo` with the additional-fee fields `previewPrice` serves, which the
49
+ * public pricing SDK types don't declare (they are `@internal` there). Types
50
+ * only: the values are the response as served.
51
+ */
52
+ export interface PreviewPriceInfo extends PriceInfo {
53
+ bookingLineItems?: (BookingLineItem & {
54
+ additionalFees?: AppliedAdditionalFee[];
55
+ })[];
56
+ /** Sum of all lines' additional fees. */
57
+ totalAdditionalFees?: number | null;
58
+ /** `calculatedPrice` plus `totalAdditionalFees`. */
59
+ calculatedPriceWithFees?: number | null;
60
+ }
35
61
  /**
36
62
  * Additional computed info for a line item (not in SDK response)
37
63
  */
@@ -40,6 +66,14 @@ export interface LineItemAdditionalInfo {
40
66
  lineItemId: string;
41
67
  /** Custom price (for CUSTOM rate type services) */
42
68
  customPrice?: string;
69
+ /**
70
+ * The raw `previewPrice` response for this line, as served — for fields the
71
+ * payment service does not read. Not the amounts charged: those (including
72
+ * a capped deposit) come from `response`. Set only when the line was priced
73
+ * by `previewPrice` (duration-range services, or a deposit the server
74
+ * resolves).
75
+ */
76
+ priceInfo?: PreviewPriceInfo;
43
77
  }
44
78
  /**
45
79
  * Payment calculation result with SDK response and additional computed info
@@ -139,14 +139,9 @@ function getDurationRange(service) {
139
139
  async function getPreviewedPrice(bookingLineItems) {
140
140
  if (!bookingLineItems.length)
141
141
  return null;
142
- const result = await (0, auto_sdk_bookings_pricing_1.previewPrice)(bookingLineItems);
143
- const price = result.priceInfo?.calculatedPrice;
144
- if (price == null)
145
- return null;
146
- return {
147
- price,
148
- deposit: result.priceInfo?.deposit ?? null,
149
- };
142
+ const { priceInfo } = await (0, auto_sdk_bookings_pricing_1.previewPrice)(bookingLineItems);
143
+ const calculatedPrice = priceInfo?.calculatedPrice;
144
+ return calculatedPrice != null ? { ...priceInfo, calculatedPrice } : null;
150
145
  }
151
146
  async function buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected) {
152
147
  const slots = item.rangeTimeSlots && item.rangeTimeSlots.length > 0
@@ -175,10 +170,10 @@ async function buildLineItemWithPreview(item, totalParticipants, selectedPayment
175
170
  numberOfParticipants: totalParticipants,
176
171
  ...(item.timeZone ? { timeZone: item.timeZone } : {}),
177
172
  }));
178
- const previewedPrice = await getPreviewedPrice(bookingLineItems).catch(() => null);
179
- if (previewedPrice != null) {
173
+ const priceInfo = await getPreviewedPrice(bookingLineItems).catch(() => null);
174
+ if (priceInfo != null) {
180
175
  const depositValue = (0, servicePayment_js_1.getDepositValue)(item.service);
181
- const previewedDeposit = previewedPrice.deposit;
176
+ const previewedDeposit = priceInfo.deposit ?? null;
182
177
  const hasDeposit = (0, servicePayment_js_1.requiresDeposit)(item.service) &&
183
178
  (previewedDeposit != null
184
179
  ? previewedDeposit > 0
@@ -188,27 +183,39 @@ async function buildLineItemWithPreview(item, totalParticipants, selectedPayment
188
183
  ? previewedDeposit
189
184
  : Number(depositValue) * totalParticipants
190
185
  : undefined;
191
- return toLineItem({
192
- lineItemId: item.lineItemId,
193
- serviceId: item.service._id,
194
- price: previewedPrice.price,
195
- deposit,
196
- paymentOption: getPaymentOption(item.service, hasDeposit, selectedPaymentOption, depositSelected),
197
- });
186
+ return {
187
+ lineItem: toLineItem({
188
+ lineItemId: item.lineItemId,
189
+ serviceId: item.service._id,
190
+ price: priceInfo.calculatedPrice,
191
+ deposit,
192
+ paymentOption: getPaymentOption(item.service, hasDeposit, selectedPaymentOption, depositSelected),
193
+ }),
194
+ priceInfo,
195
+ };
198
196
  }
199
197
  }
200
- return buildLineItem(item.service, totalParticipants, item.lineItemId, selectedPaymentOption, depositSelected);
198
+ return {
199
+ lineItem: buildLineItem(item.service, totalParticipants, item.lineItemId, selectedPaymentOption, depositSelected),
200
+ };
201
201
  }
202
202
  async function calculatePaymentDetails(pricingServiceSelections, totalParticipants, selectedPaymentOption, depositSelected) {
203
203
  const data = pricingServiceSelections.map((selection) => ({
204
204
  ...selection,
205
205
  lineItemId: selection.lineItemId || (0, guid_js_1.generateLineItemId)(),
206
206
  }));
207
- const lineItems = await Promise.all(data.map((item) => buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected)));
207
+ const builtLineItems = await Promise.all(data.map(async (item) => {
208
+ const { lineItem, priceInfo } = await buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected);
209
+ const additionalInfo = {
210
+ ...getAdditionalInfo(item.service, item.lineItemId),
211
+ ...(priceInfo ? { priceInfo } : {}),
212
+ };
213
+ return { lineItem, additionalInfo };
214
+ }));
208
215
  const response = await (0, auto_sdk_ecom_totals_calculator_1.calculateTotals)({
209
- lineItems,
216
+ lineItems: builtLineItems.map(({ lineItem }) => lineItem),
210
217
  });
211
- const additionalInfoList = data.map((item) => getAdditionalInfo(item.service, item.lineItemId));
218
+ const additionalInfoList = builtLineItems.map(({ additionalInfo }) => additionalInfo);
212
219
  return {
213
220
  response,
214
221
  additionalInfo: {
@@ -9,6 +9,6 @@ export { ServiceListService, ServiceListServiceDefinition, type ServiceListServi
9
9
  export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, AvailabilityLocationType, type ServiceWithAvailabilityItem, type AvailabilityFilter, type Attribute, type AvailabilityLocation, } from '../api/query-services/index.js';
10
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
- export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type ServicePaymentOptions, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
12
+ export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type AppliedAdditionalFee, type PreviewPriceInfo, 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';
14
14
  export { StaffMemberListService, StaffMemberListServiceDefinition, loadStaffMemberListServiceInitialData, staffMemberListServiceBinding, type StaffMemberListServiceAPI, type StaffMemberListServiceConfig, type StaffMemberListActions, type StaffMemberData, type LoadStaffMemberListServiceResult, } from './staff-member-list/staff-member-list.js';
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { type PaymentServiceConfig, type PaymentServiceInternalConfig, type PricingServiceSelection } from './payment.def.js';
7
7
  import type { SelectedPaymentOption } from '../booking/book-action/types.js';
8
- export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
8
+ export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type AppliedAdditionalFee, type PreviewPriceInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
9
9
  export type { PaymentServiceAPI, PaymentServiceInternalConfig, } from './payment.def.js';
10
10
  export declare const PaymentService: import("@wix/services-definitions").ServiceFactory<string & {
11
11
  __api: import("./payment.def.js").PaymentServiceAPI;
@@ -5,6 +5,7 @@
5
5
  import type { Signal } from '@wix/services-definitions/core-services/signals';
6
6
  import type { CalculateTotalsResponse } from '@wix/auto_sdk_ecom_totals-calculator';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
+ import type { BookingLineItem, PriceInfo } from '@wix/auto_sdk_bookings_pricing';
8
9
  import type { SelectedPaymentOption } from '../booking/book-action/types.js';
9
10
  import type { ServiceSelectionTimeSlot } from '../booking/booking.js';
10
11
  /**
@@ -32,6 +33,31 @@ export interface ServicePaymentOptions {
32
33
  * Payment option for line items
33
34
  */
34
35
  export type PaymentOption = 'FULL_PAYMENT_ONLINE' | 'FULL_PAYMENT_OFFLINE' | 'DEPOSIT_ONLINE';
36
+ /**
37
+ * An additional fee pricing applied to a booking line, as served.
38
+ */
39
+ export interface AppliedAdditionalFee {
40
+ /** The service's additional fee ID. */
41
+ feeId?: string;
42
+ /** Units the fee was charged for (1 for a per-reservation fee). */
43
+ units?: number;
44
+ /** The fee amount for this line. */
45
+ amount?: number;
46
+ }
47
+ /**
48
+ * `PriceInfo` with the additional-fee fields `previewPrice` serves, which the
49
+ * public pricing SDK types don't declare (they are `@internal` there). Types
50
+ * only: the values are the response as served.
51
+ */
52
+ export interface PreviewPriceInfo extends PriceInfo {
53
+ bookingLineItems?: (BookingLineItem & {
54
+ additionalFees?: AppliedAdditionalFee[];
55
+ })[];
56
+ /** Sum of all lines' additional fees. */
57
+ totalAdditionalFees?: number | null;
58
+ /** `calculatedPrice` plus `totalAdditionalFees`. */
59
+ calculatedPriceWithFees?: number | null;
60
+ }
35
61
  /**
36
62
  * Additional computed info for a line item (not in SDK response)
37
63
  */
@@ -40,6 +66,14 @@ export interface LineItemAdditionalInfo {
40
66
  lineItemId: string;
41
67
  /** Custom price (for CUSTOM rate type services) */
42
68
  customPrice?: string;
69
+ /**
70
+ * The raw `previewPrice` response for this line, as served — for fields the
71
+ * payment service does not read. Not the amounts charged: those (including
72
+ * a capped deposit) come from `response`. Set only when the line was priced
73
+ * by `previewPrice` (duration-range services, or a deposit the server
74
+ * resolves).
75
+ */
76
+ priceInfo?: PreviewPriceInfo;
43
77
  }
44
78
  /**
45
79
  * Payment calculation result with SDK response and additional computed info
@@ -134,14 +134,9 @@ function getDurationRange(service) {
134
134
  async function getPreviewedPrice(bookingLineItems) {
135
135
  if (!bookingLineItems.length)
136
136
  return null;
137
- const result = await previewPrice(bookingLineItems);
138
- const price = result.priceInfo?.calculatedPrice;
139
- if (price == null)
140
- return null;
141
- return {
142
- price,
143
- deposit: result.priceInfo?.deposit ?? null,
144
- };
137
+ const { priceInfo } = await previewPrice(bookingLineItems);
138
+ const calculatedPrice = priceInfo?.calculatedPrice;
139
+ return calculatedPrice != null ? { ...priceInfo, calculatedPrice } : null;
145
140
  }
146
141
  async function buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected) {
147
142
  const slots = item.rangeTimeSlots && item.rangeTimeSlots.length > 0
@@ -170,10 +165,10 @@ async function buildLineItemWithPreview(item, totalParticipants, selectedPayment
170
165
  numberOfParticipants: totalParticipants,
171
166
  ...(item.timeZone ? { timeZone: item.timeZone } : {}),
172
167
  }));
173
- const previewedPrice = await getPreviewedPrice(bookingLineItems).catch(() => null);
174
- if (previewedPrice != null) {
168
+ const priceInfo = await getPreviewedPrice(bookingLineItems).catch(() => null);
169
+ if (priceInfo != null) {
175
170
  const depositValue = getDepositValue(item.service);
176
- const previewedDeposit = previewedPrice.deposit;
171
+ const previewedDeposit = priceInfo.deposit ?? null;
177
172
  const hasDeposit = requiresDeposit(item.service) &&
178
173
  (previewedDeposit != null
179
174
  ? previewedDeposit > 0
@@ -183,27 +178,39 @@ async function buildLineItemWithPreview(item, totalParticipants, selectedPayment
183
178
  ? previewedDeposit
184
179
  : Number(depositValue) * totalParticipants
185
180
  : undefined;
186
- return toLineItem({
187
- lineItemId: item.lineItemId,
188
- serviceId: item.service._id,
189
- price: previewedPrice.price,
190
- deposit,
191
- paymentOption: getPaymentOption(item.service, hasDeposit, selectedPaymentOption, depositSelected),
192
- });
181
+ return {
182
+ lineItem: toLineItem({
183
+ lineItemId: item.lineItemId,
184
+ serviceId: item.service._id,
185
+ price: priceInfo.calculatedPrice,
186
+ deposit,
187
+ paymentOption: getPaymentOption(item.service, hasDeposit, selectedPaymentOption, depositSelected),
188
+ }),
189
+ priceInfo,
190
+ };
193
191
  }
194
192
  }
195
- return buildLineItem(item.service, totalParticipants, item.lineItemId, selectedPaymentOption, depositSelected);
193
+ return {
194
+ lineItem: buildLineItem(item.service, totalParticipants, item.lineItemId, selectedPaymentOption, depositSelected),
195
+ };
196
196
  }
197
197
  async function calculatePaymentDetails(pricingServiceSelections, totalParticipants, selectedPaymentOption, depositSelected) {
198
198
  const data = pricingServiceSelections.map((selection) => ({
199
199
  ...selection,
200
200
  lineItemId: selection.lineItemId || generateLineItemId(),
201
201
  }));
202
- const lineItems = await Promise.all(data.map((item) => buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected)));
202
+ const builtLineItems = await Promise.all(data.map(async (item) => {
203
+ const { lineItem, priceInfo } = await buildLineItemWithPreview(item, totalParticipants, selectedPaymentOption, depositSelected);
204
+ const additionalInfo = {
205
+ ...getAdditionalInfo(item.service, item.lineItemId),
206
+ ...(priceInfo ? { priceInfo } : {}),
207
+ };
208
+ return { lineItem, additionalInfo };
209
+ }));
203
210
  const response = await calculateTotals({
204
- lineItems,
211
+ lineItems: builtLineItems.map(({ lineItem }) => lineItem),
205
212
  });
206
- const additionalInfoList = data.map((item) => getAdditionalInfo(item.service, item.lineItemId));
213
+ const additionalInfoList = builtLineItems.map(({ additionalInfo }) => additionalInfo);
207
214
  return {
208
215
  response,
209
216
  additionalInfo: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -78,7 +78,7 @@
78
78
  "vitest": "^3.1.4"
79
79
  },
80
80
  "peerDependencies": {
81
- "@wix/headless-components": "^0.0.0",
81
+ "@wix/headless-components": "~0.0.47",
82
82
  "react": ">=16.3.0"
83
83
  },
84
84
  "publishConfig": {
@@ -91,5 +91,5 @@
91
91
  "groupId": "com.wixpress.headless-components"
92
92
  }
93
93
  },
94
- "falconPackageHash": "d2d5fc131a53bbc4b56519d28eb9b64e4b51ba51424316274177040e"
94
+ "falconPackageHash": "025aaf3ecf64a7ef23fcc40e8cad3993079c8c4a92038520589a77a2"
95
95
  }