@wix/bookings 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 (31) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +24 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/src/bookings-availability-v1-slot-availability.http.d.ts +51 -0
  5. package/build/cjs/src/bookings-availability-v1-slot-availability.http.js +160 -0
  6. package/build/cjs/src/bookings-availability-v1-slot-availability.http.js.map +1 -0
  7. package/build/cjs/src/bookings-availability-v1-slot-availability.public.d.ts +5 -0
  8. package/build/cjs/src/bookings-availability-v1-slot-availability.public.js +14 -0
  9. package/build/cjs/src/bookings-availability-v1-slot-availability.public.js.map +1 -0
  10. package/build/cjs/src/bookings-availability-v1-slot-availability.types.d.ts +260 -0
  11. package/build/cjs/src/bookings-availability-v1-slot-availability.types.js +16 -0
  12. package/build/cjs/src/bookings-availability-v1-slot-availability.types.js.map +1 -0
  13. package/build/cjs/src/bookings-availability-v1-slot-availability.universal.d.ts +341 -0
  14. package/build/cjs/src/bookings-availability-v1-slot-availability.universal.js +165 -0
  15. package/build/cjs/src/bookings-availability-v1-slot-availability.universal.js.map +1 -0
  16. package/build/es/index.d.ts +1 -0
  17. package/build/es/index.js +2 -0
  18. package/build/es/index.js.map +1 -0
  19. package/build/es/src/bookings-availability-v1-slot-availability.http.d.ts +51 -0
  20. package/build/es/src/bookings-availability-v1-slot-availability.http.js +156 -0
  21. package/build/es/src/bookings-availability-v1-slot-availability.http.js.map +1 -0
  22. package/build/es/src/bookings-availability-v1-slot-availability.public.d.ts +5 -0
  23. package/build/es/src/bookings-availability-v1-slot-availability.public.js +8 -0
  24. package/build/es/src/bookings-availability-v1-slot-availability.public.js.map +1 -0
  25. package/build/es/src/bookings-availability-v1-slot-availability.types.d.ts +260 -0
  26. package/build/es/src/bookings-availability-v1-slot-availability.types.js +13 -0
  27. package/build/es/src/bookings-availability-v1-slot-availability.types.js.map +1 -0
  28. package/build/es/src/bookings-availability-v1-slot-availability.universal.d.ts +341 -0
  29. package/build/es/src/bookings-availability-v1-slot-availability.universal.js +142 -0
  30. package/build/es/src/bookings-availability-v1-slot-availability.universal.js.map +1 -0
  31. package/package.json +37 -0
@@ -0,0 +1,341 @@
1
+ export declare const __debug: {
2
+ verboseLogging: {
3
+ on: () => boolean;
4
+ off: () => boolean;
5
+ };
6
+ };
7
+ export interface SlotAvailability {
8
+ /**
9
+ * The slot for the corresponding session, when the session is either a single session
10
+ * or a specific session generated from a recurring session.
11
+ */
12
+ slot?: Slot;
13
+ /**
14
+ * Whether the slot is bookable. Bookability is determined by checking a
15
+ * session's open slots and booking policies. Locks are not taken into
16
+ * account.
17
+ */
18
+ bookable?: boolean;
19
+ /**
20
+ * Total number of spots for this slot.
21
+ * For example, if a session has a total of 10 spots and 3 spots are booked,
22
+ * `spotsTotal` is 10 and `openSpots` is 7.
23
+ */
24
+ totalSpots?: number | null;
25
+ /** Number of open spots for this slot. */
26
+ openSpots?: number | null;
27
+ /** An object describing the slot's waitlist and its occupancy. */
28
+ waitingList?: WaitingList;
29
+ /** Booking policy violations for the slot. */
30
+ bookingPolicyViolations?: BookingPolicyViolations;
31
+ /**
32
+ * Indicates whether the slot is locked because a waitlist exists.
33
+ * When a slot frees up, the slot is offered to the next customer on the waitlist. Read-only.
34
+ */
35
+ locked?: boolean | null;
36
+ }
37
+ export interface Slot {
38
+ /**
39
+ * ID for the slot's corresponding session, when the session is either a single session
40
+ * or a specific session generated from a recurring session.
41
+ */
42
+ sessionId?: string | null;
43
+ /** Service ID. */
44
+ serviceId?: string;
45
+ /** Schedule ID. */
46
+ scheduleId?: string;
47
+ /**
48
+ * The start time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339)
49
+ * format.
50
+ *
51
+ * If `timezone` is specified,
52
+ * dates are based on the local date/time. This means that the timezone offset
53
+ * in the `start_date` is ignored.
54
+ */
55
+ startDate?: string | null;
56
+ /**
57
+ * The end time of this slot in
58
+ * [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format.
59
+ *
60
+ * If `timezone` is specified,
61
+ * dates are based on the local date/time. This means that the timezone offset
62
+ * in the `end_date` is ignored.
63
+ */
64
+ endDate?: string | null;
65
+ /**
66
+ * The timezone for which slot availability is to be calculated.
67
+ *
68
+ * Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones)
69
+ * when calculating availability.
70
+ */
71
+ timezone?: string | null;
72
+ /**
73
+ * The resource required for this slot. Currently, the only supported resource
74
+ * is the relevant staff member for the slot.
75
+ */
76
+ resource?: SlotResource;
77
+ /** Geographic location of the slot. */
78
+ location?: Location;
79
+ }
80
+ export interface SlotResource {
81
+ /**
82
+ * Resource ID.
83
+ * @readonly
84
+ */
85
+ _id?: string | null;
86
+ /** Resource name. Read only. */
87
+ name?: string | null;
88
+ }
89
+ export interface Location {
90
+ /**
91
+ * Business location ID. Available only for locations that are business locations,
92
+ * meaning the `location_type` is `"OWNER_BUSINESS"`.
93
+ */
94
+ _id?: string | null;
95
+ /** Location name. */
96
+ name?: string | null;
97
+ /** The full address of this location. */
98
+ formattedAddress?: string | null;
99
+ /**
100
+ * Location type.
101
+ *
102
+ * - `"OWNER_BUSINESS"`: The business address, as set in the site’s general settings.
103
+ * - `"OWNER_CUSTOM"`: The address as set when creating the service.
104
+ * - `"CUSTOM"`: The address as set for the individual session.
105
+ */
106
+ locationType?: LocationType;
107
+ }
108
+ export declare enum LocationType {
109
+ UNDEFINED = "UNDEFINED",
110
+ OWNER_BUSINESS = "OWNER_BUSINESS",
111
+ OWNER_CUSTOM = "OWNER_CUSTOM",
112
+ CUSTOM = "CUSTOM"
113
+ }
114
+ export interface WaitingList {
115
+ /**
116
+ * Total number of spots and open spots for this waitlist.
117
+ * For example, a Yoga class with 10 waitlist spots and 3 registered
118
+ * on the waitlist has 10 `total_spots` and 7 `open_spots`.
119
+ */
120
+ totalSpots?: number | null;
121
+ /** Number of open spots for this waitlist. */
122
+ openSpots?: number | null;
123
+ }
124
+ export interface BookingPolicyViolations {
125
+ /** Bookings policy violation. Too early to book this slot. */
126
+ tooEarlyToBook?: boolean | null;
127
+ /** Bookings policy violation. Too late to book this slot. */
128
+ tooLateToBook?: boolean | null;
129
+ /** Bookings policy violation. Online booking is disabled for this slot. */
130
+ bookOnlineDisabled?: boolean | null;
131
+ }
132
+ export interface QueryAvailabilityRequest {
133
+ /** Query options. */
134
+ query: QueryV2;
135
+ /**
136
+ * The timezone for which session availability is to be calculated. If specified,
137
+ * dates are based on the local date/time, meaning that the timezone offset
138
+ * in the date's format is ignored.
139
+ *
140
+ * Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones)
141
+ * when calculating availability.
142
+ */
143
+ timezone?: string | null;
144
+ /**
145
+ * Maximum number of slots to load for each date. For example, if `slots_per_day` is set to `3`,
146
+ * at most 3 available slots are returned for each day in the date range specified in the query's
147
+ * `filter`.
148
+ *
149
+ * When a day has both bookable and non-bookable slots, bookable slots are returned first.
150
+ * Non-bookable slots are returned according to the specified filters, after all
151
+ * bookable slots are already included.
152
+ */
153
+ slotsPerDay?: number | null;
154
+ }
155
+ export interface QueryV2 extends QueryV2PagingMethodOneOf {
156
+ /**
157
+ * Filter object. For a list of
158
+ * fields you can filter by, see [Calendar Availability: Supported Fields, Filters, and Sorting](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/supported-fields,-filters,-and-sorting).
159
+ * You must include the `startDate` and `endDate` in the filter. This avoids large results that can impact performance.
160
+ */
161
+ filter?: Record<string, any> | null;
162
+ /**
163
+ * Sort options.
164
+ * Currently, only sorting by `startDate` is supported. For details
165
+ * on sorting, see [Calendar Availability: Supported Fields, Filters and Sorting](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/supported-fields,-filters,-and-sorting).
166
+ */
167
+ sort?: Sorting[];
168
+ /** List of projected fields to return. All fields are supported. */
169
+ fields?: string[];
170
+ /** Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`. */
171
+ cursorPaging?: CursorPaging;
172
+ }
173
+ /** @oneof */
174
+ export interface QueryV2PagingMethodOneOf {
175
+ /** Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`. */
176
+ cursorPaging?: CursorPaging;
177
+ }
178
+ export interface Sorting {
179
+ /** Name of the field to sort by. */
180
+ fieldName?: string;
181
+ /** Sort order. */
182
+ order?: SortOrder;
183
+ }
184
+ export declare enum SortOrder {
185
+ ASC = "ASC",
186
+ DESC = "DESC"
187
+ }
188
+ export interface CursorPaging {
189
+ /** Number of items to load. */
190
+ limit?: number | null;
191
+ /**
192
+ * Pointer to the next or previous page in the list of results.
193
+ *
194
+ * You can get the relevant cursor token
195
+ * from the `pagingMetadata` object in the previous call's response.
196
+ * Not relevant for the first request.
197
+ */
198
+ cursor?: string | null;
199
+ }
200
+ export interface QueryAvailabilityResponse {
201
+ /** List of slots that potentially can be booked. */
202
+ availabilityEntries?: SlotAvailability[];
203
+ /** Details on the paged set of returned results. */
204
+ pagingMetadata?: PagingMetadataV2;
205
+ }
206
+ export interface PagingMetadataV2 {
207
+ /** Number of items returned in the response. */
208
+ count?: number | null;
209
+ /** Offset that was requested. */
210
+ offset?: number | null;
211
+ /** Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. */
212
+ total?: number | null;
213
+ /** Flag that indicates the server failed to calculate the `total` field. */
214
+ tooManyToCount?: boolean | null;
215
+ /** Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. */
216
+ cursors?: Cursors;
217
+ }
218
+ export interface Cursors {
219
+ /** Cursor pointing to next page in the list of results. */
220
+ next?: string | null;
221
+ /** Cursor pointing to previous page in the list of results. */
222
+ prev?: string | null;
223
+ }
224
+ export interface GetSlotAvailabilityRequest {
225
+ /** The slot for which the availability is checked. */
226
+ slot?: Slot;
227
+ /**
228
+ * The timezone for which slot availability is to be calculated. If specified,
229
+ * dates are based on the local date/time, meaning that the timezone offset
230
+ * in the date's format is ignored.
231
+ *
232
+ * Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones)
233
+ * when calculating availability.
234
+ */
235
+ timezone?: string | null;
236
+ }
237
+ export interface GetSlotAvailabilityResponse {
238
+ availability?: SlotAvailability;
239
+ bookingPolicySettings?: BookingPolicySettings;
240
+ }
241
+ export interface BookingPolicySettings {
242
+ /**
243
+ * The policy defining the maximum number of participants that can
244
+ * be booked for a slot or a schedule.
245
+ */
246
+ maxParticipantsPerBooking?: number | null;
247
+ }
248
+ export interface GetScheduleAvailabilityRequest {
249
+ /** The schedule ID for which availability is being checked. */
250
+ scheduleId?: string;
251
+ }
252
+ export interface GetScheduleAvailabilityResponse {
253
+ availability?: ScheduleAvailability;
254
+ bookingPolicySettings?: BookingPolicySettings;
255
+ }
256
+ export interface ScheduleAvailability {
257
+ /**
258
+ * The total number of spots defined for the schedule, including
259
+ * both open and non-available spots.
260
+ */
261
+ totalSpots?: number | null;
262
+ /** The number of open spots defined for the schedule. */
263
+ openSpots?: number | null;
264
+ /** Booking policy violations for the schedule. */
265
+ bookingPolicyViolations?: BookingPolicyViolations;
266
+ }
267
+ /**
268
+ * Retrieves the availability for sessions
269
+ * that match the provided query criteria (paging, filtering, and sorting).
270
+ *
271
+ *
272
+ * The Calendar Availability APIs calculate the availability of sessions for
273
+ * appointments and classes, but not
274
+ * for courses.
275
+ *
276
+ * The entire list of slots is returned in case you want to display both
277
+ * available and non-available slots in the calendar for your customers.
278
+ * Using the `bookable` property, you can limit the display to available
279
+ * slots only.
280
+ *
281
+ * When querying, you must enter a start date and an end date. This avoids very large
282
+ * results that can impact performance.
283
+ *
284
+ * #### Calculating availability
285
+ *
286
+ * The availability is determined
287
+ * by checking:
288
+ * + **The sessions' open slots**. A slot is considered open if the session's
289
+ * capacity is greater than number of participants.
290
+ * + **Booking policies**. Policies that affect whether a slot is considered
291
+ * available include `tooEarlyToBook`, `tooLateToBook`, and `bookOnlineDisabled`.
292
+ *
293
+ * Locked sessions do not impact session availability and `bookable` can
294
+ * be `true` even if `locked` is `true`. For example, if a session has a waitlist and a
295
+ * place frees up, the slot is offered to the customers on the waitlist, one by one. The
296
+ * sesssion remains locked because there is still a waitlist, but for a period of time
297
+ * there is availability, until a customer on the waitlist takes the slot. Locking
298
+ * prevents customers who are not yet on the waitlist from grabbing the slot.
299
+ *
300
+ * #### Handling Daylight Savings Time (DST) for local time zones
301
+ *
302
+ * Because of DST, there are cases where certain times either do not exist
303
+ * or exist twice for a local time zone.
304
+ * For example, the tine `00:05` on September 5th 2021 might not exist in Santiago, Chile,
305
+ * because at `00:00` the clock moved
306
+ * 1 hour forward to `01:00`.
307
+ *
308
+ * In this case, the Availability APIs take this
309
+ * into account and mediate the time gaps automatically. The non-existant local time is
310
+ * automtically moved forward 1 hour to match local DST. Local times that exist do not change.
311
+ * So if the `Query Availability` endpoint is called with a `startDate` of `2021-09-05T00:00:01.000`
312
+ * and an `endDate` of `2021-09-06T00:00:02.000`, `2021-09-05T01:00:01.000` is used in the query
313
+ * instead. The start time shifts one hour forward and the end time remains the same.
314
+ * @param query - Query options.
315
+ * @public
316
+ * @documentationMaturity preview
317
+ * @requiredField query
318
+ * @requiredField query.filter
319
+ */
320
+ export declare function queryAvailability(query: QueryV2, options?: QueryAvailabilityOptions): Promise<QueryAvailabilityResponse>;
321
+ export interface QueryAvailabilityOptions {
322
+ /**
323
+ * The timezone for which session availability is to be calculated. If specified,
324
+ * dates are based on the local date/time, meaning that the timezone offset
325
+ * in the date's format is ignored.
326
+ *
327
+ * Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones)
328
+ * when calculating availability.
329
+ */
330
+ timezone?: string | null;
331
+ /**
332
+ * Maximum number of slots to load for each date. For example, if `slots_per_day` is set to `3`,
333
+ * at most 3 available slots are returned for each day in the date range specified in the query's
334
+ * `filter`.
335
+ *
336
+ * When a day has both bookable and non-bookable slots, bookable slots are returned first.
337
+ * Non-bookable slots are returned according to the specified filters, after all
338
+ * bookable slots are already included.
339
+ */
340
+ slotsPerDay?: number | null;
341
+ }
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.queryAvailability = exports.SortOrder = exports.LocationType = exports.__debug = void 0;
32
+ const velo_1 = require("@wix/metro-runtime/velo");
33
+ const ambassadorWixBookingsAvailabilityV1SlotAvailability = __importStar(require("./bookings-availability-v1-slot-availability.http"));
34
+ let __verbose = false;
35
+ function __log(...args) {
36
+ __verbose && console.log(...args);
37
+ }
38
+ function __inspect(obj) {
39
+ return obj;
40
+ }
41
+ exports.__debug = {
42
+ verboseLogging: {
43
+ on: () => (__verbose = true),
44
+ off: () => (__verbose = false),
45
+ },
46
+ };
47
+ const _toVeloEntity = '$';
48
+ const _fromVeloEntity = '$';
49
+ var LocationType;
50
+ (function (LocationType) {
51
+ LocationType["UNDEFINED"] = "UNDEFINED";
52
+ LocationType["OWNER_BUSINESS"] = "OWNER_BUSINESS";
53
+ LocationType["OWNER_CUSTOM"] = "OWNER_CUSTOM";
54
+ LocationType["CUSTOM"] = "CUSTOM";
55
+ })(LocationType = exports.LocationType || (exports.LocationType = {}));
56
+ var SortOrder;
57
+ (function (SortOrder) {
58
+ SortOrder["ASC"] = "ASC";
59
+ SortOrder["DESC"] = "DESC";
60
+ })(SortOrder = exports.SortOrder || (exports.SortOrder = {}));
61
+ const _queryAvailabilityRequest = {};
62
+ const _queryAvailabilityResponse = {};
63
+ /**
64
+ * Retrieves the availability for sessions
65
+ * that match the provided query criteria (paging, filtering, and sorting).
66
+ *
67
+ *
68
+ * The Calendar Availability APIs calculate the availability of sessions for
69
+ * appointments and classes, but not
70
+ * for courses.
71
+ *
72
+ * The entire list of slots is returned in case you want to display both
73
+ * available and non-available slots in the calendar for your customers.
74
+ * Using the `bookable` property, you can limit the display to available
75
+ * slots only.
76
+ *
77
+ * When querying, you must enter a start date and an end date. This avoids very large
78
+ * results that can impact performance.
79
+ *
80
+ * #### Calculating availability
81
+ *
82
+ * The availability is determined
83
+ * by checking:
84
+ * + **The sessions' open slots**. A slot is considered open if the session's
85
+ * capacity is greater than number of participants.
86
+ * + **Booking policies**. Policies that affect whether a slot is considered
87
+ * available include `tooEarlyToBook`, `tooLateToBook`, and `bookOnlineDisabled`.
88
+ *
89
+ * Locked sessions do not impact session availability and `bookable` can
90
+ * be `true` even if `locked` is `true`. For example, if a session has a waitlist and a
91
+ * place frees up, the slot is offered to the customers on the waitlist, one by one. The
92
+ * sesssion remains locked because there is still a waitlist, but for a period of time
93
+ * there is availability, until a customer on the waitlist takes the slot. Locking
94
+ * prevents customers who are not yet on the waitlist from grabbing the slot.
95
+ *
96
+ * #### Handling Daylight Savings Time (DST) for local time zones
97
+ *
98
+ * Because of DST, there are cases where certain times either do not exist
99
+ * or exist twice for a local time zone.
100
+ * For example, the tine `00:05` on September 5th 2021 might not exist in Santiago, Chile,
101
+ * because at `00:00` the clock moved
102
+ * 1 hour forward to `01:00`.
103
+ *
104
+ * In this case, the Availability APIs take this
105
+ * into account and mediate the time gaps automatically. The non-existant local time is
106
+ * automtically moved forward 1 hour to match local DST. Local times that exist do not change.
107
+ * So if the `Query Availability` endpoint is called with a `startDate` of `2021-09-05T00:00:01.000`
108
+ * and an `endDate` of `2021-09-06T00:00:02.000`, `2021-09-05T01:00:01.000` is used in the query
109
+ * instead. The start time shifts one hour forward and the end time remains the same.
110
+ * @param query - Query options.
111
+ * @public
112
+ * @documentationMaturity preview
113
+ * @requiredField query
114
+ * @requiredField query.filter
115
+ */
116
+ function queryAvailability(query, options) {
117
+ var _a, _b, _c;
118
+ return __awaiter(this, arguments, void 0, function* () {
119
+ const requestTransformation = {
120
+ query: '$[0]',
121
+ timezone: '$[1].timezone',
122
+ slotsPerDay: '$[1].slotsPerDay',
123
+ };
124
+ const responseTransformation = '$';
125
+ // @ts-ignore
126
+ const { httpClient, sideEffects } = arguments[2];
127
+ const { toAmbassadorRequest } = velo_1.serializer({
128
+ rootSchema: _queryAvailabilityRequest,
129
+ depSchemas: {},
130
+ fqdnTransformation: {
131
+ paths: [],
132
+ transformation: _fromVeloEntity,
133
+ },
134
+ customTransformation: requestTransformation,
135
+ });
136
+ const { fromJSON } = velo_1.serializer({
137
+ rootSchema: _queryAvailabilityResponse,
138
+ depSchemas: {},
139
+ fqdnTransformation: {
140
+ paths: [...['Array#availabilityEntries']],
141
+ transformation: _toVeloEntity,
142
+ },
143
+ customTransformation: responseTransformation,
144
+ });
145
+ const payload = toAmbassadorRequest([query, options]);
146
+ const reqOpts = ambassadorWixBookingsAvailabilityV1SlotAvailability.queryAvailability(payload);
147
+ __log(`"QueryAvailability" sending request with: ${__inspect(reqOpts)}`);
148
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
149
+ try {
150
+ const result = yield httpClient.request(reqOpts);
151
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
152
+ return fromJSON(result.data);
153
+ }
154
+ catch (err) {
155
+ const transformedError = velo_1.transformError(err, requestTransformation, [
156
+ 'query',
157
+ 'options',
158
+ ]);
159
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
160
+ throw transformedError;
161
+ }
162
+ });
163
+ }
164
+ exports.queryAvailability = queryAvailability;
165
+ //# sourceMappingURL=bookings-availability-v1-slot-availability.universal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bookings-availability-v1-slot-availability.universal.js","sourceRoot":"","sources":["../../../src/bookings-availability-v1-slot-availability.universal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqE;AAErE,uIAAyH;AAEzH,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,SAAS,KAAK,CAAC,GAAG,IAAW;IAC3B,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC;AA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 +1,2 @@
1
+ export * as availabilityCalendar from './src/bookings-availability-v1-slot-availability.public';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,yDAAyD,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { RequestOptionsFactory } from '@wix/sdk-types';
2
+ import { QueryAvailabilityRequest, QueryAvailabilityResponse } from './bookings-availability-v1-slot-availability.types';
3
+ /**
4
+ * Retrieves the availability for sessions
5
+ * that match the provided query criteria (paging, filtering, and sorting).
6
+ *
7
+ *
8
+ * The Calendar Availability APIs calculate the availability of sessions for
9
+ * appointments and classes, but not
10
+ * for courses.
11
+ *
12
+ * The entire list of slots is returned in case you want to display both
13
+ * available and non-available slots in the calendar for your customers.
14
+ * Using the `bookable` property, you can limit the display to available
15
+ * slots only.
16
+ *
17
+ * When querying, you must enter a start date and an end date. This avoids very large
18
+ * results that can impact performance.
19
+ *
20
+ * #### Calculating availability
21
+ *
22
+ * The availability is determined
23
+ * by checking:
24
+ * + **The sessions' open slots**. A slot is considered open if the session's
25
+ * capacity is greater than number of participants.
26
+ * + **Booking policies**. Policies that affect whether a slot is considered
27
+ * available include `tooEarlyToBook`, `tooLateToBook`, and `bookOnlineDisabled`.
28
+ *
29
+ * Locked sessions do not impact session availability and `bookable` can
30
+ * be `true` even if `locked` is `true`. For example, if a session has a waitlist and a
31
+ * place frees up, the slot is offered to the customers on the waitlist, one by one. The
32
+ * sesssion remains locked because there is still a waitlist, but for a period of time
33
+ * there is availability, until a customer on the waitlist takes the slot. Locking
34
+ * prevents customers who are not yet on the waitlist from grabbing the slot.
35
+ *
36
+ * #### Handling Daylight Savings Time (DST) for local time zones
37
+ *
38
+ * Because of DST, there are cases where certain times either do not exist
39
+ * or exist twice for a local time zone.
40
+ * For example, the tine `00:05` on September 5th 2021 might not exist in Santiago, Chile,
41
+ * because at `00:00` the clock moved
42
+ * 1 hour forward to `01:00`.
43
+ *
44
+ * In this case, the Availability APIs take this
45
+ * into account and mediate the time gaps automatically. The non-existant local time is
46
+ * automtically moved forward 1 hour to match local DST. Local times that exist do not change.
47
+ * So if the `Query Availability` endpoint is called with a `startDate` of `2021-09-05T00:00:01.000`
48
+ * and an `endDate` of `2021-09-06T00:00:02.000`, `2021-09-05T01:00:01.000` is used in the query
49
+ * instead. The start time shifts one hour forward and the end time remains the same.
50
+ */
51
+ export declare function queryAvailability(payload: QueryAvailabilityRequest): RequestOptionsFactory<QueryAvailabilityResponse>;