@skilder-ai/smoobu 0.1.0 → 0.2.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.
- package/README.md +20 -3
- package/dist/index.d.ts +976 -5
- package/dist/index.js +472 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,7 +47,13 @@ function signRequest(input) {
|
|
|
47
47
|
// src/wire.ts
|
|
48
48
|
var wire_exports = {};
|
|
49
49
|
__export(wire_exports, {
|
|
50
|
+
smoobuApartmentListSchema: () => smoobuApartmentListSchema,
|
|
51
|
+
smoobuApartmentSchema: () => smoobuApartmentSchema,
|
|
52
|
+
smoobuBookingSchema: () => smoobuBookingSchema,
|
|
53
|
+
smoobuBookingsPageSchema: () => smoobuBookingsPageSchema,
|
|
50
54
|
smoobuErrorSchema: () => smoobuErrorSchema,
|
|
55
|
+
smoobuGuestSchema: () => smoobuGuestSchema,
|
|
56
|
+
smoobuGuestsPageSchema: () => smoobuGuestsPageSchema,
|
|
51
57
|
smoobuMessageSchema: () => smoobuMessageSchema,
|
|
52
58
|
smoobuMessagesPageSchema: () => smoobuMessagesPageSchema,
|
|
53
59
|
smoobuNewMessageDataSchema: () => smoobuNewMessageDataSchema,
|
|
@@ -119,8 +125,119 @@ var smoobuNewMessageDataSchema = z.looseObject({
|
|
|
119
125
|
sender: z.string().nullish(),
|
|
120
126
|
booking: z.looseObject({ id: z.number() })
|
|
121
127
|
});
|
|
128
|
+
var numeric = z.union([z.number(), z.string()]).nullish();
|
|
129
|
+
var smoobuApartmentListSchema = z.looseObject({
|
|
130
|
+
apartments: z.array(z.looseObject({ id: z.number(), name: z.string().nullish() }))
|
|
131
|
+
});
|
|
132
|
+
var smoobuApartmentSchema = z.looseObject({
|
|
133
|
+
// Not in the docs, but present in real responses.
|
|
134
|
+
id: z.number().nullish(),
|
|
135
|
+
name: z.string().nullish(),
|
|
136
|
+
location: z.looseObject({
|
|
137
|
+
street: z.string().nullish(),
|
|
138
|
+
zip: z.string().nullish(),
|
|
139
|
+
city: z.string().nullish(),
|
|
140
|
+
state: z.string().nullish(),
|
|
141
|
+
country: z.string().nullish(),
|
|
142
|
+
// Documented as strings, observed as numbers.
|
|
143
|
+
latitude: numeric,
|
|
144
|
+
longitude: numeric
|
|
145
|
+
}).nullish(),
|
|
146
|
+
timeZone: z.string().nullish(),
|
|
147
|
+
rooms: z.record(z.string(), z.number().nullable()).nullish(),
|
|
148
|
+
// The field table says `amenities` (observed), the docs' example says `equipments`.
|
|
149
|
+
amenities: z.array(z.string()).nullish(),
|
|
150
|
+
equipments: z.array(z.string()).nullish(),
|
|
151
|
+
currency: z.string().nullish(),
|
|
152
|
+
price: z.looseObject({ minimal: numeric, maximal: numeric }).nullish(),
|
|
153
|
+
type: z.looseObject({ id: z.number().nullish(), name: z.string().nullish() }).nullish()
|
|
154
|
+
});
|
|
155
|
+
var smoobuBookingSchema = z.looseObject({
|
|
156
|
+
id: z.number(),
|
|
157
|
+
"reference-id": z.string().nullish(),
|
|
158
|
+
/** "reservation" | "modification of booking" | "cancellation". */
|
|
159
|
+
type: z.string().nullish(),
|
|
160
|
+
/** YYYY-MM-DD */
|
|
161
|
+
arrival: z.string(),
|
|
162
|
+
departure: z.string(),
|
|
163
|
+
/** "YYYY-MM-DD HH:MM" */
|
|
164
|
+
"created-at": z.string().nullish(),
|
|
165
|
+
/** "YYYY-MM-DD HH:MM:SS" */
|
|
166
|
+
modifiedAt: z.string().nullish(),
|
|
167
|
+
apartment: z.looseObject({ id: z.number().nullish(), name: z.string().nullish() }).nullish(),
|
|
168
|
+
channel: z.looseObject({
|
|
169
|
+
/** The account's channel instance id. */
|
|
170
|
+
id: z.number().nullish(),
|
|
171
|
+
/** The channel type id (14 = Booking.com, 74 = Airbnb…). */
|
|
172
|
+
channel_id: z.number().nullish(),
|
|
173
|
+
name: z.string().nullish()
|
|
174
|
+
}).nullish(),
|
|
175
|
+
"guest-name": z.string().nullish(),
|
|
176
|
+
firstname: z.string().nullish(),
|
|
177
|
+
lastname: z.string().nullish(),
|
|
178
|
+
email: z.string().nullish(),
|
|
179
|
+
phone: z.string().nullish(),
|
|
180
|
+
adults: z.number().nullish(),
|
|
181
|
+
children: z.number().nullish(),
|
|
182
|
+
/** "HH:MM" */
|
|
183
|
+
"check-in": z.string().nullish(),
|
|
184
|
+
"check-out": z.string().nullish(),
|
|
185
|
+
notice: z.string().nullish(),
|
|
186
|
+
"assistant-notice": z.string().nullish(),
|
|
187
|
+
price: numeric,
|
|
188
|
+
"price-details": z.string().nullish(),
|
|
189
|
+
"city-tax": numeric,
|
|
190
|
+
/** "Yes" | "No" */
|
|
191
|
+
"price-paid": z.string().nullish(),
|
|
192
|
+
"commission-included": numeric,
|
|
193
|
+
prepayment: numeric,
|
|
194
|
+
"prepayment-paid": z.string().nullish(),
|
|
195
|
+
deposit: numeric,
|
|
196
|
+
"deposit-paid": z.string().nullish(),
|
|
197
|
+
language: z.string().nullish(),
|
|
198
|
+
"guest-app-url": z.string().nullish(),
|
|
199
|
+
"is-blocked-booking": z.boolean().nullish(),
|
|
200
|
+
guestId: z.number().nullish(),
|
|
201
|
+
related: z.array(z.looseObject({ id: z.number().nullish() })).nullish()
|
|
202
|
+
});
|
|
203
|
+
var smoobuBookingsPageSchema = z.looseObject({
|
|
204
|
+
page_count: z.number(),
|
|
205
|
+
page_size: z.number(),
|
|
206
|
+
total_items: z.number(),
|
|
207
|
+
page: z.number(),
|
|
208
|
+
bookings: z.array(smoobuBookingSchema)
|
|
209
|
+
});
|
|
210
|
+
var contactList = z.array(z.unknown()).nullish();
|
|
211
|
+
var smoobuGuestSchema = z.looseObject({
|
|
212
|
+
id: z.number(),
|
|
213
|
+
firstName: z.string().nullish(),
|
|
214
|
+
lastName: z.string().nullish(),
|
|
215
|
+
companyName: z.string().nullish(),
|
|
216
|
+
emails: contactList,
|
|
217
|
+
telephoneNumbers: contactList,
|
|
218
|
+
address: z.looseObject({
|
|
219
|
+
street: z.string().nullish(),
|
|
220
|
+
postalCode: z.string().nullish(),
|
|
221
|
+
city: z.string().nullish(),
|
|
222
|
+
country: z.string().nullish()
|
|
223
|
+
}).nullish(),
|
|
224
|
+
notes: z.string().nullish(),
|
|
225
|
+
bookings: z.array(smoobuBookingSchema).nullish()
|
|
226
|
+
});
|
|
227
|
+
var smoobuGuestsPageSchema = z.looseObject({
|
|
228
|
+
pageCount: z.number(),
|
|
229
|
+
pageSize: z.number(),
|
|
230
|
+
totalItems: z.number(),
|
|
231
|
+
page: z.number(),
|
|
232
|
+
guests: z.array(smoobuGuestSchema)
|
|
233
|
+
});
|
|
122
234
|
|
|
123
235
|
// src/client.ts
|
|
236
|
+
function assertPageSize(pageSize) {
|
|
237
|
+
if (pageSize !== void 0 && (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100)) {
|
|
238
|
+
throw new RangeError("pageSize must be an integer between 1 and 100");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
124
241
|
function errorCode(status) {
|
|
125
242
|
if (status === 0) return "network";
|
|
126
243
|
if (status === 401) return "unauthorized";
|
|
@@ -196,6 +313,40 @@ var SmoobuClient = class {
|
|
|
196
313
|
schema: smoobuMessagesPageSchema
|
|
197
314
|
});
|
|
198
315
|
}
|
|
316
|
+
/** GET /api/apartments: ids and names only (no pagination). */
|
|
317
|
+
listApartments() {
|
|
318
|
+
return this.request("GET", "/api/apartments", { schema: smoobuApartmentListSchema });
|
|
319
|
+
}
|
|
320
|
+
/** GET /api/apartments/{id}: location, rooms, amenities, currency, price range. */
|
|
321
|
+
getApartment(apartmentId) {
|
|
322
|
+
return this.request("GET", `/api/apartments/${apartmentId}`, { schema: smoobuApartmentSchema });
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* GET /api/reservations. Dates are `YYYY-MM-DD`; `from`/`to` select stays overlapping the range.
|
|
326
|
+
* Smoobu silently falls back to 25 for a `pageSize` above 100, so that is rejected here.
|
|
327
|
+
*/
|
|
328
|
+
listReservations(params = {}) {
|
|
329
|
+
assertPageSize(params.pageSize);
|
|
330
|
+
return this.request("GET", "/api/reservations", {
|
|
331
|
+
query: { ...params },
|
|
332
|
+
schema: smoobuBookingsPageSchema
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
/** GET /api/reservations/{id} (adds firstname, lastname, assistant-notice, price-details…). */
|
|
336
|
+
getReservation(reservationId) {
|
|
337
|
+
return this.request("GET", `/api/reservations/${reservationId}`, {
|
|
338
|
+
schema: smoobuBookingSchema
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/** GET /api/guests. Needs the "Guest Data (PII)" key permission (403 otherwise). */
|
|
342
|
+
listGuests(params = {}) {
|
|
343
|
+
assertPageSize(params.pageSize);
|
|
344
|
+
return this.request("GET", "/api/guests", { query: params, schema: smoobuGuestsPageSchema });
|
|
345
|
+
}
|
|
346
|
+
/** GET /api/guests/{id}. Needs the "Guest Data (PII)" key permission (403 otherwise). */
|
|
347
|
+
getGuest(guestId) {
|
|
348
|
+
return this.request("GET", `/api/guests/${guestId}`, { schema: smoobuGuestSchema });
|
|
349
|
+
}
|
|
199
350
|
/** POST /api/reservations/{id}/messages/send-message-to-guest (no message id is returned). */
|
|
200
351
|
sendMessageToGuest(reservationId, body) {
|
|
201
352
|
return this.request(
|
|
@@ -305,8 +456,8 @@ function htmlToText(html) {
|
|
|
305
456
|
// src/mappers.ts
|
|
306
457
|
function toLocalDateTime(value) {
|
|
307
458
|
if (!value) return null;
|
|
308
|
-
const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})
|
|
309
|
-
return m ? `${m[1]}T${m[2]}` : null;
|
|
459
|
+
const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})(:\d{2})?$/.exec(value.trim());
|
|
460
|
+
return m ? `${m[1]}T${m[2]}${m[3] ?? ":00"}` : null;
|
|
310
461
|
}
|
|
311
462
|
var emptyToNull = (v) => v ? v : null;
|
|
312
463
|
function toMessage(reservationId, m) {
|
|
@@ -337,8 +488,145 @@ function toConversationSummary(t) {
|
|
|
337
488
|
} : null
|
|
338
489
|
};
|
|
339
490
|
}
|
|
491
|
+
var toNumber = (v) => {
|
|
492
|
+
if (v === null || v === void 0 || v === "") return null;
|
|
493
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
494
|
+
return Number.isFinite(n) ? n : null;
|
|
495
|
+
};
|
|
496
|
+
var yesNo = (v) => v === "Yes" ? true : v === "No" ? false : null;
|
|
497
|
+
var isoDate = (v) => v && /^\d{4}-\d{2}-\d{2}$/.test(v) ? v : null;
|
|
498
|
+
var timeOfDay = (v) => v && /^\d{2}:\d{2}$/.test(v) ? v : null;
|
|
499
|
+
function nightsBetween(arrival, departure) {
|
|
500
|
+
const ms = Date.parse(`${departure}T00:00:00Z`) - Date.parse(`${arrival}T00:00:00Z`);
|
|
501
|
+
return Number.isFinite(ms) ? Math.round(ms / 864e5) : null;
|
|
502
|
+
}
|
|
503
|
+
function toProperty(a, fallback) {
|
|
504
|
+
const rooms = a.rooms ?? {};
|
|
505
|
+
const int = (k) => toNumber(rooms[k]);
|
|
506
|
+
return {
|
|
507
|
+
id: a.id ?? fallback.id,
|
|
508
|
+
name: emptyToNull(a.name ?? fallback.name),
|
|
509
|
+
type: emptyToNull(a.type?.name),
|
|
510
|
+
location: {
|
|
511
|
+
street: emptyToNull(a.location?.street),
|
|
512
|
+
zip: emptyToNull(a.location?.zip),
|
|
513
|
+
city: emptyToNull(a.location?.city),
|
|
514
|
+
state: emptyToNull(a.location?.state),
|
|
515
|
+
country: emptyToNull(a.location?.country),
|
|
516
|
+
latitude: toNumber(a.location?.latitude),
|
|
517
|
+
longitude: toNumber(a.location?.longitude)
|
|
518
|
+
},
|
|
519
|
+
timeZone: emptyToNull(a.timeZone),
|
|
520
|
+
capacity: {
|
|
521
|
+
maxGuests: int("maxOccupancy"),
|
|
522
|
+
bedrooms: int("bedrooms"),
|
|
523
|
+
bathrooms: int("bathrooms"),
|
|
524
|
+
beds: {
|
|
525
|
+
double: int("doubleBeds"),
|
|
526
|
+
single: int("singleBeds"),
|
|
527
|
+
queen: int("queenSizeBeds"),
|
|
528
|
+
king: int("kingSizeBeds"),
|
|
529
|
+
sofa: int("sofaBeds"),
|
|
530
|
+
couch: int("couches"),
|
|
531
|
+
child: int("childBeds")
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
amenities: (a.amenities ?? a.equipments ?? []).filter(Boolean),
|
|
535
|
+
currency: emptyToNull(a.currency),
|
|
536
|
+
priceRange: { min: toNumber(a.price?.minimal), max: toNumber(a.price?.maximal) }
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function toStatus(b) {
|
|
540
|
+
if (b["is-blocked-booking"]) return "blocked";
|
|
541
|
+
if (b.type === "cancellation") return "cancelled";
|
|
542
|
+
if (b.type === "modification of booking") return "modified";
|
|
543
|
+
return "confirmed";
|
|
544
|
+
}
|
|
545
|
+
function toReservation(b) {
|
|
546
|
+
const arrival = isoDate(b.arrival) ?? b.arrival;
|
|
547
|
+
const departure = isoDate(b.departure) ?? b.departure;
|
|
548
|
+
return {
|
|
549
|
+
id: b.id,
|
|
550
|
+
reference: emptyToNull(b["reference-id"]),
|
|
551
|
+
status: toStatus(b),
|
|
552
|
+
property: b.apartment?.id != null ? { id: b.apartment.id, name: emptyToNull(b.apartment.name) } : null,
|
|
553
|
+
channel: b.channel ? { typeId: b.channel.channel_id ?? null, name: emptyToNull(b.channel.name) } : null,
|
|
554
|
+
stay: {
|
|
555
|
+
arrival,
|
|
556
|
+
departure,
|
|
557
|
+
nights: nightsBetween(arrival, departure),
|
|
558
|
+
checkInTime: timeOfDay(b["check-in"]),
|
|
559
|
+
checkOutTime: timeOfDay(b["check-out"]),
|
|
560
|
+
adults: b.adults ?? null,
|
|
561
|
+
children: b.children ?? null
|
|
562
|
+
},
|
|
563
|
+
guest: {
|
|
564
|
+
id: b.guestId ?? null,
|
|
565
|
+
name: emptyToNull(b["guest-name"]?.trim()),
|
|
566
|
+
firstName: emptyToNull(b.firstname),
|
|
567
|
+
lastName: emptyToNull(b.lastname),
|
|
568
|
+
email: emptyToNull(b.email),
|
|
569
|
+
phone: emptyToNull(b.phone),
|
|
570
|
+
language: emptyToNull(b.language)
|
|
571
|
+
},
|
|
572
|
+
notes: { guest: emptyToNull(b.notice), assistant: emptyToNull(b["assistant-notice"]) },
|
|
573
|
+
payment: {
|
|
574
|
+
total: toNumber(b.price),
|
|
575
|
+
paid: yesNo(b["price-paid"]),
|
|
576
|
+
prepayment: toNumber(b.prepayment),
|
|
577
|
+
prepaymentPaid: yesNo(b["prepayment-paid"]),
|
|
578
|
+
deposit: toNumber(b.deposit),
|
|
579
|
+
depositPaid: yesNo(b["deposit-paid"]),
|
|
580
|
+
cityTax: toNumber(b["city-tax"]),
|
|
581
|
+
channelCommission: toNumber(b["commission-included"]),
|
|
582
|
+
details: emptyToNull(b["price-details"])
|
|
583
|
+
},
|
|
584
|
+
guestAppUrl: emptyToNull(b["guest-app-url"]),
|
|
585
|
+
relatedPropertyIds: (b.related ?? []).flatMap((r) => r.id != null ? [r.id] : []),
|
|
586
|
+
createdAt: toLocalDateTime(b["created-at"]),
|
|
587
|
+
modifiedAt: toLocalDateTime(b.modifiedAt)
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function contactValues(list) {
|
|
591
|
+
return (list ?? []).flatMap((e) => {
|
|
592
|
+
if (typeof e === "string") return e ? [e] : [];
|
|
593
|
+
if (e && typeof e === "object") {
|
|
594
|
+
const o = e;
|
|
595
|
+
const v = o.email ?? o.number ?? o.telephoneNumber ?? o.value;
|
|
596
|
+
return typeof v === "string" && v ? [v] : [];
|
|
597
|
+
}
|
|
598
|
+
return [];
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
function toGuest(g) {
|
|
602
|
+
const addr = g.address;
|
|
603
|
+
const address = addr && (addr.street || addr.postalCode || addr.city || addr.country) ? {
|
|
604
|
+
street: emptyToNull(addr.street),
|
|
605
|
+
postalCode: emptyToNull(addr.postalCode),
|
|
606
|
+
city: emptyToNull(addr.city),
|
|
607
|
+
country: emptyToNull(addr.country)
|
|
608
|
+
} : null;
|
|
609
|
+
return {
|
|
610
|
+
id: g.id,
|
|
611
|
+
firstName: emptyToNull(g.firstName),
|
|
612
|
+
lastName: emptyToNull(g.lastName),
|
|
613
|
+
companyName: emptyToNull(g.companyName),
|
|
614
|
+
emails: contactValues(g.emails),
|
|
615
|
+
phones: contactValues(g.telephoneNumbers),
|
|
616
|
+
address,
|
|
617
|
+
notes: emptyToNull(g.notes),
|
|
618
|
+
reservations: (g.bookings ?? []).map(toReservation)
|
|
619
|
+
};
|
|
620
|
+
}
|
|
340
621
|
|
|
341
622
|
// src/smoobu.ts
|
|
623
|
+
async function* paginate(fetchPage) {
|
|
624
|
+
for (let page = 1; ; page++) {
|
|
625
|
+
const res = await fetchPage(page);
|
|
626
|
+
yield* res.items;
|
|
627
|
+
if (page >= res.pageCount || res.items.length === 0) return;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
342
630
|
var Smoobu = class {
|
|
343
631
|
client;
|
|
344
632
|
constructor(options) {
|
|
@@ -354,6 +642,62 @@ var Smoobu = class {
|
|
|
354
642
|
email: me.email ?? null
|
|
355
643
|
};
|
|
356
644
|
}
|
|
645
|
+
properties = {
|
|
646
|
+
/** All properties (ids and names). Smoobu calls them apartments. */
|
|
647
|
+
list: async () => {
|
|
648
|
+
const res = await this.client.listApartments();
|
|
649
|
+
return res.apartments.map((a) => ({ id: a.id, name: a.name || null }));
|
|
650
|
+
},
|
|
651
|
+
/** One property's details: location, time zone, capacity, amenities, currency. */
|
|
652
|
+
get: async (propertyId) => toProperty(await this.client.getApartment(propertyId), { id: propertyId })
|
|
653
|
+
};
|
|
654
|
+
reservations = {
|
|
655
|
+
/** Reservations matching the filter, in Smoobu's order. Dates are `YYYY-MM-DD`. */
|
|
656
|
+
list: async (filter = {}) => {
|
|
657
|
+
const res = await this.client.listReservations({
|
|
658
|
+
page: filter.page,
|
|
659
|
+
pageSize: filter.pageSize,
|
|
660
|
+
apartmentId: filter.propertyId,
|
|
661
|
+
includeRelated: filter.includeRelated,
|
|
662
|
+
from: filter.stayFrom,
|
|
663
|
+
to: filter.stayTo,
|
|
664
|
+
arrivalFrom: filter.arrivalFrom,
|
|
665
|
+
arrivalTo: filter.arrivalTo,
|
|
666
|
+
departureFrom: filter.departureFrom,
|
|
667
|
+
departureTo: filter.departureTo,
|
|
668
|
+
created_from: filter.createdFrom,
|
|
669
|
+
created_to: filter.createdTo,
|
|
670
|
+
modifiedFrom: filter.modifiedFrom,
|
|
671
|
+
modifiedTo: filter.modifiedTo,
|
|
672
|
+
showCancellation: filter.includeCancelled,
|
|
673
|
+
excludeBlocked: filter.includeBlocked === false ? true : void 0
|
|
674
|
+
});
|
|
675
|
+
return {
|
|
676
|
+
items: res.bookings.map(toReservation),
|
|
677
|
+
page: res.page,
|
|
678
|
+
pageSize: res.page_size,
|
|
679
|
+
pageCount: res.page_count,
|
|
680
|
+
total: res.total_items
|
|
681
|
+
};
|
|
682
|
+
},
|
|
683
|
+
/** One reservation, with the fields only the single-booking endpoint returns. */
|
|
684
|
+
get: async (reservationId) => toReservation(await this.client.getReservation(reservationId))
|
|
685
|
+
};
|
|
686
|
+
/** Smoobu's guest CRM. Requires the API key's "Guest Data (PII)" permission (403 otherwise). */
|
|
687
|
+
guests = {
|
|
688
|
+
get: async (guestId) => toGuest(await this.client.getGuest(guestId)),
|
|
689
|
+
/** Searches guests by a free-text query (name, email…). */
|
|
690
|
+
search: async (params = {}) => {
|
|
691
|
+
const res = await this.client.listGuests(params);
|
|
692
|
+
return {
|
|
693
|
+
items: res.guests.map(toGuest),
|
|
694
|
+
page: res.page,
|
|
695
|
+
pageSize: res.pageSize,
|
|
696
|
+
pageCount: res.pageCount,
|
|
697
|
+
total: res.totalItems
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
};
|
|
357
701
|
messages = {
|
|
358
702
|
/** Conversations, most recent first, with the latest message of each (GET /api/threads). */
|
|
359
703
|
listConversations: async (params = {}) => {
|
|
@@ -437,6 +781,121 @@ var conversationPageSchema = pageSchema(conversationSummarySchema).extend({
|
|
|
437
781
|
});
|
|
438
782
|
var messagePageSchema = pageSchema(messageSchema);
|
|
439
783
|
var messageAudienceSchema = z2.enum(["guest", "internal"]);
|
|
784
|
+
var isoDate2 = z2.iso.date();
|
|
785
|
+
var timeOfDay2 = z2.string().regex(/^\d{2}:\d{2}$/);
|
|
786
|
+
var propertySummarySchema = z2.object({
|
|
787
|
+
id: z2.number().int(),
|
|
788
|
+
name: z2.string().nullable()
|
|
789
|
+
});
|
|
790
|
+
var propertySchema = propertySummarySchema.extend({
|
|
791
|
+
/** e.g. "Holiday rental". */
|
|
792
|
+
type: z2.string().nullable(),
|
|
793
|
+
location: z2.object({
|
|
794
|
+
street: z2.string().nullable(),
|
|
795
|
+
zip: z2.string().nullable(),
|
|
796
|
+
city: z2.string().nullable(),
|
|
797
|
+
state: z2.string().nullable(),
|
|
798
|
+
country: z2.string().nullable(),
|
|
799
|
+
latitude: z2.number().nullable(),
|
|
800
|
+
longitude: z2.number().nullable()
|
|
801
|
+
}),
|
|
802
|
+
/** IANA zone, e.g. "Europe/Zurich". */
|
|
803
|
+
timeZone: z2.string().nullable(),
|
|
804
|
+
capacity: z2.object({
|
|
805
|
+
maxGuests: z2.number().int().nullable(),
|
|
806
|
+
bedrooms: z2.number().int().nullable(),
|
|
807
|
+
bathrooms: z2.number().nullable(),
|
|
808
|
+
beds: z2.object({
|
|
809
|
+
double: z2.number().int().nullable(),
|
|
810
|
+
single: z2.number().int().nullable(),
|
|
811
|
+
queen: z2.number().int().nullable(),
|
|
812
|
+
king: z2.number().int().nullable(),
|
|
813
|
+
sofa: z2.number().int().nullable(),
|
|
814
|
+
couch: z2.number().int().nullable(),
|
|
815
|
+
child: z2.number().int().nullable()
|
|
816
|
+
})
|
|
817
|
+
}),
|
|
818
|
+
amenities: z2.array(z2.string()),
|
|
819
|
+
currency: z2.string().nullable(),
|
|
820
|
+
/** Nightly price range configured in Smoobu. */
|
|
821
|
+
priceRange: z2.object({ min: z2.number().nullable(), max: z2.number().nullable() })
|
|
822
|
+
});
|
|
823
|
+
var reservationStatusSchema = z2.enum(["confirmed", "modified", "cancelled", "blocked"]);
|
|
824
|
+
var reservationSchema = z2.object({
|
|
825
|
+
id: z2.number().int(),
|
|
826
|
+
/** The booking channel's own reference (e.g. the Airbnb confirmation code). */
|
|
827
|
+
reference: z2.string().nullable(),
|
|
828
|
+
status: reservationStatusSchema,
|
|
829
|
+
property: propertySummarySchema.nullable(),
|
|
830
|
+
channel: z2.object({
|
|
831
|
+
/** Channel type: 14 = Booking.com, 74 = Airbnb, 13 = direct booking… */
|
|
832
|
+
typeId: z2.number().int().nullable(),
|
|
833
|
+
name: z2.string().nullable()
|
|
834
|
+
}).nullable(),
|
|
835
|
+
stay: z2.object({
|
|
836
|
+
arrival: isoDate2,
|
|
837
|
+
departure: isoDate2,
|
|
838
|
+
nights: z2.number().int().nullable(),
|
|
839
|
+
checkInTime: timeOfDay2.nullable(),
|
|
840
|
+
checkOutTime: timeOfDay2.nullable(),
|
|
841
|
+
adults: z2.number().int().nullable(),
|
|
842
|
+
children: z2.number().int().nullable()
|
|
843
|
+
}),
|
|
844
|
+
/** Empty (nulls) unless the API key has the "Guest Data (PII)" permission. */
|
|
845
|
+
guest: z2.object({
|
|
846
|
+
id: z2.number().int().nullable(),
|
|
847
|
+
name: z2.string().nullable(),
|
|
848
|
+
firstName: z2.string().nullable(),
|
|
849
|
+
lastName: z2.string().nullable(),
|
|
850
|
+
email: z2.string().nullable(),
|
|
851
|
+
phone: z2.string().nullable(),
|
|
852
|
+
/** Locale code such as "en" or "fr". */
|
|
853
|
+
language: z2.string().nullable()
|
|
854
|
+
}),
|
|
855
|
+
notes: z2.object({
|
|
856
|
+
/** Note entered with the booking (often the guest's own message). */
|
|
857
|
+
guest: z2.string().nullable(),
|
|
858
|
+
/** Host/assistant note. Only returned when fetching one reservation. */
|
|
859
|
+
assistant: z2.string().nullable()
|
|
860
|
+
}),
|
|
861
|
+
/** Amounts are in the property's currency. */
|
|
862
|
+
payment: z2.object({
|
|
863
|
+
total: z2.number().nullable(),
|
|
864
|
+
paid: z2.boolean().nullable(),
|
|
865
|
+
prepayment: z2.number().nullable(),
|
|
866
|
+
prepaymentPaid: z2.boolean().nullable(),
|
|
867
|
+
deposit: z2.number().nullable(),
|
|
868
|
+
depositPaid: z2.boolean().nullable(),
|
|
869
|
+
cityTax: z2.number().nullable(),
|
|
870
|
+
channelCommission: z2.number().nullable(),
|
|
871
|
+
/** One "name - currency amount" line per price element. */
|
|
872
|
+
details: z2.string().nullable()
|
|
873
|
+
}),
|
|
874
|
+
guestAppUrl: z2.string().nullable(),
|
|
875
|
+
/** Other properties this booking also blocks (grouped units). */
|
|
876
|
+
relatedPropertyIds: z2.array(z2.number().int()),
|
|
877
|
+
createdAt: localDateTime.nullable(),
|
|
878
|
+
modifiedAt: localDateTime.nullable()
|
|
879
|
+
});
|
|
880
|
+
var reservationPageSchema = pageSchema(reservationSchema);
|
|
881
|
+
var guestSchema = z2.object({
|
|
882
|
+
id: z2.number().int(),
|
|
883
|
+
firstName: z2.string().nullable(),
|
|
884
|
+
lastName: z2.string().nullable(),
|
|
885
|
+
companyName: z2.string().nullable(),
|
|
886
|
+
emails: z2.array(z2.string()),
|
|
887
|
+
phones: z2.array(z2.string()),
|
|
888
|
+
address: z2.object({
|
|
889
|
+
street: z2.string().nullable(),
|
|
890
|
+
postalCode: z2.string().nullable(),
|
|
891
|
+
city: z2.string().nullable(),
|
|
892
|
+
country: z2.string().nullable()
|
|
893
|
+
}).nullable(),
|
|
894
|
+
/** The host's CRM notes about this guest. */
|
|
895
|
+
notes: z2.string().nullable(),
|
|
896
|
+
reservations: z2.array(reservationSchema)
|
|
897
|
+
});
|
|
898
|
+
var guestPageSchema = pageSchema(guestSchema);
|
|
440
899
|
export {
|
|
441
900
|
Smoobu,
|
|
442
901
|
SmoobuApiError,
|
|
@@ -445,16 +904,27 @@ export {
|
|
|
445
904
|
canonicalQuery,
|
|
446
905
|
conversationPageSchema,
|
|
447
906
|
conversationSummarySchema,
|
|
907
|
+
guestPageSchema,
|
|
908
|
+
guestSchema,
|
|
448
909
|
htmlToText,
|
|
449
910
|
messageAudienceSchema,
|
|
450
911
|
messageDirectionSchema,
|
|
451
912
|
messagePageSchema,
|
|
452
913
|
messageSchema,
|
|
453
914
|
pageSchema,
|
|
915
|
+
paginate,
|
|
916
|
+
propertySchema,
|
|
917
|
+
propertySummarySchema,
|
|
918
|
+
reservationPageSchema,
|
|
919
|
+
reservationSchema,
|
|
920
|
+
reservationStatusSchema,
|
|
454
921
|
signRequest,
|
|
455
922
|
toConversationSummary,
|
|
923
|
+
toGuest,
|
|
456
924
|
toLocalDateTime,
|
|
457
925
|
toMessage,
|
|
926
|
+
toProperty,
|
|
927
|
+
toReservation,
|
|
458
928
|
wire_exports as wire
|
|
459
929
|
};
|
|
460
930
|
//# sourceMappingURL=index.js.map
|