@wix/bookings 1.0.1777 → 1.0.1779

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 (56) hide show
  1. package/build/cjs/context-booking-checkout.d.ts +243 -108
  2. package/build/cjs/context-booking-checkout.js +176 -182
  3. package/build/cjs/context-booking-checkout.js.map +1 -1
  4. package/build/cjs/context-categories.d.ts +16 -143
  5. package/build/cjs/context-categories.js +411 -411
  6. package/build/cjs/context-categories.js.map +1 -1
  7. package/build/cjs/context-locations.d.ts +16 -287
  8. package/build/cjs/context-locations.js +335 -335
  9. package/build/cjs/context-locations.js.map +1 -1
  10. package/build/cjs/context-service-addons.d.ts +2 -2
  11. package/build/cjs/context-service.d.ts +71 -33
  12. package/build/cjs/context-service.js +97 -95
  13. package/build/cjs/context-service.js.map +1 -1
  14. package/build/cjs/context-time-slots.d.ts +10 -0
  15. package/build/cjs/context-time-slots.js +1 -1
  16. package/build/cjs/context-time-slots.js.map +1 -1
  17. package/build/es/context-booking-checkout.d.mts +243 -108
  18. package/build/es/context-booking-checkout.mjs +176 -179
  19. package/build/es/context-booking-checkout.mjs.map +1 -1
  20. package/build/es/context-categories.d.mts +16 -143
  21. package/build/es/context-categories.mjs +411 -411
  22. package/build/es/context-categories.mjs.map +1 -1
  23. package/build/es/context-locations.d.mts +16 -287
  24. package/build/es/context-locations.mjs +335 -335
  25. package/build/es/context-locations.mjs.map +1 -1
  26. package/build/es/context-service-addons.d.mts +2 -2
  27. package/build/es/context-service.d.mts +71 -33
  28. package/build/es/context-service.mjs +97 -95
  29. package/build/es/context-service.mjs.map +1 -1
  30. package/build/es/context-time-slots.d.mts +10 -0
  31. package/build/es/context-time-slots.mjs +1 -1
  32. package/build/es/context-time-slots.mjs.map +1 -1
  33. package/build/internal/cjs/context-booking-checkout.d.ts +243 -108
  34. package/build/internal/cjs/context-categories.d.ts +16 -143
  35. package/build/internal/cjs/context-locations.d.ts +16 -287
  36. package/build/internal/cjs/context-service-addons.d.ts +2 -2
  37. package/build/internal/cjs/context-service.d.ts +71 -33
  38. package/build/internal/cjs/context-time-slots.d.ts +10 -0
  39. package/build/internal/es/context-booking-checkout.d.mts +243 -108
  40. package/build/internal/es/context-categories.d.mts +16 -143
  41. package/build/internal/es/context-locations.d.mts +16 -287
  42. package/build/internal/es/context-service-addons.d.mts +2 -2
  43. package/build/internal/es/context-service.d.mts +71 -33
  44. package/build/internal/es/context-time-slots.d.mts +10 -0
  45. package/context-runtime/context-booking-checkout/runtime.d.ts +243 -108
  46. package/context-runtime/context-booking-checkout/runtime.js +3 -3
  47. package/context-runtime/context-categories/runtime.d.ts +16 -143
  48. package/context-runtime/context-categories/runtime.js +2 -2
  49. package/context-runtime/context-locations/runtime.d.ts +16 -287
  50. package/context-runtime/context-locations/runtime.js +2 -2
  51. package/context-runtime/context-service/runtime.d.ts +71 -33
  52. package/context-runtime/context-service/runtime.js +3 -3
  53. package/context-runtime/context-service-addons/runtime.d.ts +2 -2
  54. package/context-runtime/context-time-slots/runtime.d.ts +10 -0
  55. package/context-runtime/context-time-slots/runtime.js +2 -2
  56. package/package.json +7 -7
@@ -1,246 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
2
 
3
- //#region ../../node_modules/type-fest/source/observable-like.d.ts
4
- declare global {
5
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
6
- interface SymbolConstructor {
7
- readonly observable: symbol;
8
- }
9
- }
10
- /**
11
- @remarks
12
- The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
13
- As well, some guidance on making an `Observable` to not include `closed` property.
14
- @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
15
- @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
16
- @see https://github.com/benlesh/symbol-observable#making-an-object-observable
17
-
18
- @category Observable
19
- */
20
- //#endregion
21
- //#region ../../node_modules/@wix/sdk-types/internal/build/index.d.ts
22
- declare global {
23
- interface ContextualClient {}
24
- }
25
- /**
26
- * Creates concrete types from SDK descriptors when a contextual client is
27
- * available.
28
- *
29
- * For a REST descriptor the built (bound) API is intersected with the original
30
- * descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a
31
- * value callable as the bound API and still usable as a descriptor. Keeping the
32
- * descriptor half lets contextual modules be passed to descriptor-constrained
33
- * helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092).
34
- *
35
- * The `& T` is scoped to REST descriptors — the only shape codegen wraps in
36
- * `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left
37
- * unchanged and stays bound-only. The fix lives here rather than in `elevate`,
38
- * which is kept strict on purpose (see #941) so it still rejects bound-only
39
- * functions that are unsafe through `createRESTModule`.
40
- */
41
- declare global {
42
- /**
43
- * A global interface to set the exposure toggle for the SDK.
44
- * @example
45
- * ```ts
46
- * declare global {
47
- * interface SDKExposureToggle {
48
- * alpha: true;
49
- * }
50
- * }
51
- */
52
- interface SDKExposureToggle {}
53
- }
54
- declare global {
55
- /**
56
- * A global interface to set the type mode for the SDK.
57
- * @example
58
- * ```ts
59
- * declare global {
60
- * interface SDKTypeMode {
61
- * strict: true;
62
- * }
63
- * }
64
- */
65
- interface SDKTypeMode {}
66
- }
67
- //#endregion
68
- //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-p5eQUd5f.d.mts
69
- interface V2Location extends V2LocationOptionsOneOf {
70
- /** Information about business locations. Required when `type` is `BUSINESS`. */
71
- business?: BusinessLocationOptions;
72
- /** Information about custom locations. Required when `type` is `CUSTOM`. */
73
- custom?: CustomLocationOptions;
74
- /**
75
- * Location ID.
76
- * @format GUID
77
- * @readonly
78
- */
79
- _id?: string;
80
- /**
81
- * Location type.
82
- *
83
- * Default: `CUSTOM`
84
- */
85
- type?: LocationTypeEnumLocationTypeWithLiterals;
86
- /**
87
- * Location address. Empty for `{"type": "CUSTOMER"}`.
88
- * @readonly
89
- */
90
- calculatedAddress?: CommonAddress;
91
- }
92
- /** @oneof */
93
- interface V2LocationOptionsOneOf {
94
- /** Information about business locations. Required when `type` is `BUSINESS`. */
95
- business?: BusinessLocationOptions;
96
- /** Information about custom locations. Required when `type` is `CUSTOM`. */
97
- custom?: CustomLocationOptions;
98
- }
99
- declare enum LocationTypeEnumLocationType {
100
- /** Location set by the business that is not a standard business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction). */
101
- CUSTOM = "CUSTOM",
102
- /** Business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction). */
103
- BUSINESS = "BUSINESS",
104
- /**
105
- * The customer specifies any address when booking. Available only for
106
- * appointment-based services.
107
- */
108
- CUSTOMER = "CUSTOMER"
109
- }
110
- /** @enumType */
111
- type LocationTypeEnumLocationTypeWithLiterals = LocationTypeEnumLocationType | 'CUSTOM' | 'BUSINESS' | 'CUSTOMER';
112
- interface CommonAddress extends CommonAddressStreetOneOf {
113
- /** Street name and number. */
114
- streetAddress?: CommonStreetAddress;
115
- /** @maxLength 255 */
116
- addressLine1?: string | null;
117
- /**
118
- * 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.
119
- * @format COUNTRY
120
- */
121
- country?: string | null;
122
- /**
123
- * Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format.
124
- * @maxLength 255
125
- */
126
- subdivision?: string | null;
127
- /**
128
- * City name.
129
- * @maxLength 255
130
- */
131
- city?: string | null;
132
- /**
133
- * Postal or zip code.
134
- * @maxLength 255
135
- */
136
- postalCode?: string | null;
137
- /**
138
- * Full address of the location.
139
- * @maxLength 512
140
- */
141
- formatted?: string | null;
142
- }
143
- /** @oneof */
144
- interface CommonAddressStreetOneOf {
145
- /** Street name and number. */
146
- streetAddress?: CommonStreetAddress;
147
- /** @maxLength 255 */
148
- addressLine?: string | null;
149
- }
150
- /** Street address. Includes street name, number, and apartment number in separate fields. */
151
- interface CommonStreetAddress {
152
- /**
153
- * Street number.
154
- * @maxLength 255
155
- */
156
- number?: string;
157
- /**
158
- * Street name.
159
- * @maxLength 255
160
- */
161
- name?: string;
162
- /**
163
- * Apartment number.
164
- * @maxLength 255
165
- */
166
- apt?: string;
167
- }
168
- interface BusinessLocationOptions {
169
- /**
170
- * ID of the business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction).
171
- * When setting a business location, specify only the location ID. Other location details are overwritten.
172
- * @format GUID
173
- */
174
- _id?: string;
175
- /**
176
- * Business location name.
177
- * @readonly
178
- * @maxLength 150
179
- */
180
- name?: string;
181
- /**
182
- * Whether this is the default location. There can only be a single default location per site.
183
- * @readonly
184
- */
185
- default?: boolean | null;
186
- /**
187
- * Business location address.
188
- * @readonly
189
- */
190
- address?: CommonAddress;
191
- /**
192
- * Business location email.
193
- * @format EMAIL
194
- * @readonly
195
- */
196
- email?: string | null;
197
- /**
198
- * Business location phone.
199
- * @format PHONE
200
- * @readonly
201
- */
202
- phone?: string | null;
203
- }
204
- interface CustomLocationOptions {
205
- /**
206
- * ID of the custom location.
207
- * @format GUID
208
- * @readonly
209
- */
210
- _id?: string;
211
- /** Address of the custom location. */
212
- address?: CommonAddress;
213
- }
214
- /**
215
- * `BookingPolicy` is the main entity of `BookingPolicyService` and specifies a set of rules for booking a service
216
- * by visitors and members.
217
- *
218
- * Each `BookingPolicy` consists of a number of sub-policies. When the Bookings App is provisioned to a meta site then a
219
- * default `BookingPolicy` will be created with defaults for each of these sub-policies. This also applies when a request
220
- * is received to create a new `BookingPolicy` and one or more of these sub-policies are not provided.
221
- *
222
- * Sub-policies are defined in separate objects as specified below.
223
- *
224
- * - The `LimitEarlyBookingPolicy` object defines the policy for limiting early bookings.
225
- * - The `LimitLateBookingPolicy` object defines the policy for limiting late bookings.
226
- * - The `BookAfterStartPolicy` object defines the policy for booking after the start of the schedule.
227
- * - The `CancellationPolicy` object defines the policy for canceling a booked entity.
228
- * - The `ReschedulePolicy` object defines the policy for rescheduling booked entity.
229
- * - The `WaitlistPolicy` object defines the policy for a waitlist.
230
- * - The `ParticipantsPolicy` object defines the policy regarding the participants per booking.
231
- * - The `ResourcesPolicy` object defines the policy regarding the resources per booking.
232
- * - The `CancellationFeePolicy` object defines the policy regarding cancellation fees.
233
- * - The `SaveCreditCardPolicy` object defines the policy for saving credit card details.
234
- *
235
- * By default each sub-policy is disabled. A more detailed specification of the default settings of each sub-policy
236
- * can be found in the description of the corresponding object.
237
- *
238
- * Partial updates are supported on the main entity level, however in order to update a sub-policy the client needs to provide the whole sub-policy object.
239
- */
240
- //#endregion
241
- //#region src/api/adapters/location/location.d.ts
242
- type BusinessLocation = V2Location;
243
- //#endregion
244
3
  //#region src/extensions/contexts/locations-context/locations-context.d.ts
245
4
  /** A business location as shown in a location list, with its selected state. */
246
5
  interface LocationItem {
@@ -270,18 +29,8 @@ interface LocationItem {
270
29
  interface LocationsContextValue {
271
30
  /**
272
31
  * Business locations where the site's visible Wix Bookings services take place, sorted by name.
273
- *
274
- * Each item is a service location object from the
275
- * [Services V2
276
- * API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction).
277
- * Its `business` field holds the location's ID and name. To render a list of the locations, use
278
- * `locationItems`, which holds the same locations in the same order.
279
- *
280
- * Empty while `isLoading` is `true`, and when the locations fail to load.
281
- */
282
- locations: BusinessLocation[];
283
- /**
284
- * Locations to list, an item for each location in `locations`, in the same order.
32
+ * Each item holds the location's ID, name, and whether it's selected. Use them to render a list
33
+ * of locations that site visitors select from.
285
34
  *
286
35
  * Empty while `isLoading` is `true`, and when the locations fail to load.
287
36
  */
@@ -289,35 +38,18 @@ interface LocationsContextValue {
289
38
  /**
290
39
  * ID of the selected location, from the `location` query parameter in the page URL.
291
40
  *
292
- * When the page opens with the parameter, it's set right away, even while `isLoading` is
293
- * `true`. It changes after each call to `selectLocation()`. It isn't checked against
294
- * `locations`, so it can be an ID that matches no location. It's `'OTHER_LOCATIONS'` when the
41
+ * Use it to mark the selected option in a location filter. It's `'OTHER_LOCATIONS'` when the
295
42
  * services at custom addresses or at customers' locations are selected, as `hasOtherLocations`
296
- * describes.
43
+ * describes. That option has no item in `locationItems`.
44
+ *
45
+ * When the page opens with the parameter, it's set right away, even while `isLoading` is
46
+ * `true`. It changes after each call to `selectLocation()`. When the parameter holds an ID the
47
+ * business doesn't have, such as from an outdated link, the context removes it from the URL
48
+ * after the locations load.
297
49
  *
298
50
  * `null` when no location is selected.
299
51
  */
300
52
  selectedLocationId: string | null;
301
- /**
302
- * Index in `locations` of the selected location.
303
- *
304
- * `-1` when no location in `locations` is selected. For example, when no location is selected,
305
- * when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
306
- */
307
- selectedLocationIndex: number;
308
- /**
309
- * Item in `locations` whose ID is `selectedLocationId`.
310
- *
311
- * `null` when no location in `locations` is selected. For example, when no location is
312
- * selected, when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
313
- */
314
- selectedLocation: BusinessLocation | null;
315
- /**
316
- * Name of the selected location.
317
- *
318
- * `null` when `selectedLocation` is `null`, or when the location has no name.
319
- */
320
- selectedLocationName: string | null;
321
53
  /**
322
54
  * Whether any of the site's visible Wix Bookings services takes place at a custom address or at
323
55
  * the customer's location.
@@ -331,7 +63,7 @@ interface LocationsContextValue {
331
63
  /**
332
64
  * Whether site visitors have more than 1 location to choose from.
333
65
  *
334
- * `true` when there are at least 2 choices: each location in `locations` that has an ID, plus
66
+ * `true` when there are at least 2 choices: each item in `locationItems` that has an ID, plus
335
67
  * 1 more when `hasOtherLocations` is `true`. Use it to hide a location filter that has
336
68
  * nothing to filter.
337
69
  *
@@ -342,15 +74,15 @@ interface LocationsContextValue {
342
74
  * Whether the locations are loading.
343
75
  *
344
76
  * `true` while the locations load when the page opens, and while `refetch()` loads them again.
345
- * Meanwhile, `locations` and `locationItems` are empty, the values that depend on them are
346
- * `null`, `false`, or `-1`, and `selectLocation()` does nothing. `selectedLocationId` already
77
+ * Meanwhile, `locationItems` is empty, `hasOtherLocations` and `hasMultipleLocations` are
78
+ * `false`, and `selectLocation()` does nothing. `selectedLocationId` already
347
79
  * holds the location from the page URL.
348
80
  */
349
81
  isLoading: boolean;
350
82
  /**
351
83
  * Whether the locations failed to load.
352
84
  *
353
- * When it's `true`, `isLoading` is `false`, `locations` and `locationItems` are empty, and
85
+ * When it's `true`, `isLoading` is `false`, `locationItems` is empty, and
354
86
  * `hasOtherLocations` and `hasMultipleLocations` are `false`. To try again, call `refetch()`.
355
87
  *
356
88
  * It's also `true`, with the same empty values, after a component under the context fails to
@@ -361,7 +93,7 @@ interface LocationsContextValue {
361
93
  /**
362
94
  * Loads the locations again.
363
95
  *
364
- * While they load, `isLoading` is `true`, `locations` and `locationItems` are empty, and
96
+ * While they load, `isLoading` is `true`, `locationItems` is empty, and
365
97
  * `selectLocation()` does nothing. The selected location stays the same, because it's kept in
366
98
  * the page URL.
367
99
  *
@@ -395,14 +127,14 @@ interface LocationsContextValue {
395
127
  * It sets the `location` query parameter in the page URL and keeps the URL's other parameters,
396
128
  * except `page`, which it removes so a paged list starts again from its first page. It adds an
397
129
  * entry to the browser history and doesn't scroll to the top of the page. `selectedLocationId`
398
- * and the other selection values then update. A Services context on the same page reads the
130
+ * and each item's `isSelected` then update. A Services context on the same page reads the
399
131
  * same parameter, so it lists the services at the new selection.
400
132
  *
401
133
  * Does nothing while `isLoading` is `true`, or after a component under the context fails to
402
134
  * render.
403
135
  *
404
136
  * @param locationId - ID of the location to select, such as an item's `locationId` from
405
- * `locationItems`. It isn't checked against `locations`.
137
+ * `locationItems`. It isn't checked against `locationItems`.
406
138
  *
407
139
  * To select the services at a custom address or at the customer's location, pass
408
140
  * `'OTHER_LOCATIONS'`. Offer that option only when `hasOtherLocations` is `true`.
@@ -442,8 +174,6 @@ interface LocationsContextValue {
442
174
  }
443
175
  /** Props accepted by {@link LocationsContextProvider}. */
444
176
  interface LocationsContextProviderProps {
445
- /** Selected on load when the page URL names no location. */
446
- initialLocationId?: string;
447
177
  children: ReactNode;
448
178
  }
449
179
  declare const locationsContext: React.Context<LocationsContextValue | null>;
@@ -459,7 +189,6 @@ declare const LOCATIONS_CONTEXT_MISSING_PROVIDER_ERROR = "useLocationsContext mu
459
189
  declare function useLocationsContext(): LocationsContextValue;
460
190
  /** Loads the business locations that host bookable services, checks for services at other locations, and tracks the selected location in the page URL. */
461
191
  declare function LocationsContextProvider({
462
- initialLocationId,
463
192
  children
464
193
  }: LocationsContextProviderProps): React.JSX.Element;
465
194