@atzentis/booking-sdk 0.1.6 → 0.1.7
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/dist/index.cjs +286 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +579 -1
- package/dist/index.d.ts +579 -1
- package/dist/index.js +285 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
ConflictError: () => ConflictError,
|
|
39
39
|
DEFAULT_MODULES: () => DEFAULT_MODULES,
|
|
40
40
|
ForbiddenError: () => ForbiddenError,
|
|
41
|
+
GuestsService: () => GuestsService,
|
|
41
42
|
HttpClient: () => HttpClient,
|
|
42
43
|
NotFoundError: () => NotFoundError,
|
|
43
44
|
PROPERTY_MODULES: () => PROPERTY_MODULES,
|
|
@@ -1091,6 +1092,285 @@ var CategoriesService = class extends BaseService {
|
|
|
1091
1092
|
}
|
|
1092
1093
|
};
|
|
1093
1094
|
|
|
1095
|
+
// src/services/guests.ts
|
|
1096
|
+
var GuestsService = class extends BaseService {
|
|
1097
|
+
constructor() {
|
|
1098
|
+
super(...arguments);
|
|
1099
|
+
this.basePath = "/guest/v1/profiles";
|
|
1100
|
+
}
|
|
1101
|
+
// ---------------------------------------------------------------------------
|
|
1102
|
+
// CRUD
|
|
1103
|
+
// ---------------------------------------------------------------------------
|
|
1104
|
+
/**
|
|
1105
|
+
* Create a new guest profile.
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```typescript
|
|
1109
|
+
* const guest = await client.guests.create({
|
|
1110
|
+
* firstName: "Maria",
|
|
1111
|
+
* lastName: "Papadopoulou",
|
|
1112
|
+
* email: "maria@example.com",
|
|
1113
|
+
* phone: "+30 210 1234567",
|
|
1114
|
+
* nationality: "GR",
|
|
1115
|
+
* });
|
|
1116
|
+
* ```
|
|
1117
|
+
*/
|
|
1118
|
+
create(input) {
|
|
1119
|
+
return this._post(this.basePath, input);
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Get a single guest by ID.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const guest = await client.guests.get("guest_42");
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
get(guestId) {
|
|
1130
|
+
return this._get(this._buildPath(guestId));
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* List guests with optional filters and cursor-based pagination.
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* const page = await client.guests.list({
|
|
1138
|
+
* tags: ["vip", "returning"],
|
|
1139
|
+
* sort: { field: "lastName", direction: "asc" },
|
|
1140
|
+
* limit: 20,
|
|
1141
|
+
* });
|
|
1142
|
+
* ```
|
|
1143
|
+
*/
|
|
1144
|
+
list(params) {
|
|
1145
|
+
if (!params) {
|
|
1146
|
+
return this._get(this.basePath);
|
|
1147
|
+
}
|
|
1148
|
+
const query = {};
|
|
1149
|
+
if (params.tags !== void 0 && params.tags.length > 0) {
|
|
1150
|
+
query.tags = params.tags.join(",");
|
|
1151
|
+
}
|
|
1152
|
+
if (params.source !== void 0) query.source = params.source;
|
|
1153
|
+
if (params.createdFrom !== void 0) query.createdFrom = params.createdFrom;
|
|
1154
|
+
if (params.createdTo !== void 0) query.createdTo = params.createdTo;
|
|
1155
|
+
if (params.sort !== void 0) {
|
|
1156
|
+
query.sort = `${params.sort.field}:${params.sort.direction}`;
|
|
1157
|
+
}
|
|
1158
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1159
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1160
|
+
return this._get(this.basePath, query);
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Update an existing guest profile.
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```typescript
|
|
1167
|
+
* const updated = await client.guests.update("guest_42", {
|
|
1168
|
+
* email: "maria.new@example.com",
|
|
1169
|
+
* tags: ["vip"],
|
|
1170
|
+
* });
|
|
1171
|
+
* ```
|
|
1172
|
+
*/
|
|
1173
|
+
update(guestId, input) {
|
|
1174
|
+
return this._patch(this._buildPath(guestId), input);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Delete a guest profile (soft-delete).
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* ```typescript
|
|
1181
|
+
* await client.guests.delete("guest_42");
|
|
1182
|
+
* ```
|
|
1183
|
+
*/
|
|
1184
|
+
delete(guestId) {
|
|
1185
|
+
return this._delete(this._buildPath(guestId));
|
|
1186
|
+
}
|
|
1187
|
+
// ---------------------------------------------------------------------------
|
|
1188
|
+
// Search and Duplicate Detection
|
|
1189
|
+
// ---------------------------------------------------------------------------
|
|
1190
|
+
/**
|
|
1191
|
+
* Search guests by name, email, phone, or passport number.
|
|
1192
|
+
*
|
|
1193
|
+
* Returns results sorted by relevance score (highest first).
|
|
1194
|
+
*
|
|
1195
|
+
* @param query - Search query string
|
|
1196
|
+
* @param params - Optional search parameters (limit, fields)
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```typescript
|
|
1200
|
+
* // Search by name
|
|
1201
|
+
* const results = await client.guests.search("Papadopoulos");
|
|
1202
|
+
*
|
|
1203
|
+
* // Search by email with field filter
|
|
1204
|
+
* const results2 = await client.guests.search("maria@", {
|
|
1205
|
+
* fields: ["email"],
|
|
1206
|
+
* limit: 5,
|
|
1207
|
+
* });
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
search(query, params) {
|
|
1211
|
+
const searchQuery = {
|
|
1212
|
+
q: query
|
|
1213
|
+
};
|
|
1214
|
+
if (params?.limit !== void 0) searchQuery.limit = params.limit;
|
|
1215
|
+
if (params?.fields !== void 0 && params.fields.length > 0) {
|
|
1216
|
+
searchQuery.fields = params.fields.join(",");
|
|
1217
|
+
}
|
|
1218
|
+
return this._get(this._buildPath("search"), searchQuery);
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Find potential duplicate profiles for a guest.
|
|
1222
|
+
*
|
|
1223
|
+
* Returns candidates sorted by confidence score (highest first).
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1226
|
+
*
|
|
1227
|
+
* @example
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* const duplicates = await client.guests.findDuplicates("guest_42");
|
|
1230
|
+
* for (const dup of duplicates.data) {
|
|
1231
|
+
* console.log(`${dup.guest.firstName} — ${dup.confidence} (${dup.matchedFields})`);
|
|
1232
|
+
* }
|
|
1233
|
+
* ```
|
|
1234
|
+
*/
|
|
1235
|
+
findDuplicates(guestId) {
|
|
1236
|
+
return this._get(this._buildPath(guestId, "duplicates"));
|
|
1237
|
+
}
|
|
1238
|
+
// ---------------------------------------------------------------------------
|
|
1239
|
+
// Merge
|
|
1240
|
+
// ---------------------------------------------------------------------------
|
|
1241
|
+
/**
|
|
1242
|
+
* Merge duplicate guest profiles into a primary profile.
|
|
1243
|
+
*
|
|
1244
|
+
* **Warning: This operation is irreversible.** All history from duplicate
|
|
1245
|
+
* profiles is transferred to the primary. Duplicate profiles are soft-deleted.
|
|
1246
|
+
*
|
|
1247
|
+
* @throws {NotFoundError} 404 if primary or any duplicate is not found
|
|
1248
|
+
* @throws {ConflictError} 409 if attempting to merge a guest into itself
|
|
1249
|
+
* @throws {ValidationError} 400 if duplicateIds is empty
|
|
1250
|
+
*
|
|
1251
|
+
* @example
|
|
1252
|
+
* ```typescript
|
|
1253
|
+
* const merged = await client.guests.merge("guest_primary", {
|
|
1254
|
+
* duplicateIds: ["guest_dup1", "guest_dup2"],
|
|
1255
|
+
* });
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
merge(primaryId, input) {
|
|
1259
|
+
return this._post(this._buildPath(primaryId, "merge"), input);
|
|
1260
|
+
}
|
|
1261
|
+
// ---------------------------------------------------------------------------
|
|
1262
|
+
// Preferences
|
|
1263
|
+
// ---------------------------------------------------------------------------
|
|
1264
|
+
/**
|
|
1265
|
+
* Get guest preferences.
|
|
1266
|
+
*
|
|
1267
|
+
* Returns default/empty preferences if none have been set (does not throw 404).
|
|
1268
|
+
*
|
|
1269
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```typescript
|
|
1273
|
+
* const prefs = await client.guests.getPreferences("guest_42");
|
|
1274
|
+
* console.log(prefs.dietary, prefs.roomType);
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
getPreferences(guestId) {
|
|
1278
|
+
return this._get(this._buildPath(guestId, "preferences"));
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Update guest preferences (partial merge).
|
|
1282
|
+
*
|
|
1283
|
+
* Only provided fields are updated; unspecified fields retain their values.
|
|
1284
|
+
*
|
|
1285
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* ```typescript
|
|
1289
|
+
* const updated = await client.guests.updatePreferences("guest_42", {
|
|
1290
|
+
* dietary: ["vegetarian"],
|
|
1291
|
+
* roomType: "suite",
|
|
1292
|
+
* custom: { pillow: "firm" },
|
|
1293
|
+
* });
|
|
1294
|
+
* ```
|
|
1295
|
+
*/
|
|
1296
|
+
updatePreferences(guestId, input) {
|
|
1297
|
+
return this._patch(this._buildPath(guestId, "preferences"), input);
|
|
1298
|
+
}
|
|
1299
|
+
// ---------------------------------------------------------------------------
|
|
1300
|
+
// Cross-Domain History
|
|
1301
|
+
// ---------------------------------------------------------------------------
|
|
1302
|
+
/**
|
|
1303
|
+
* Get a guest's booking history.
|
|
1304
|
+
*
|
|
1305
|
+
* Returns lightweight booking summaries with pagination support.
|
|
1306
|
+
*
|
|
1307
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1308
|
+
*
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```typescript
|
|
1311
|
+
* const bookings = await client.guests.getBookings("guest_42", {
|
|
1312
|
+
* from: "2025-01-01",
|
|
1313
|
+
* to: "2025-12-31",
|
|
1314
|
+
* limit: 10,
|
|
1315
|
+
* });
|
|
1316
|
+
* ```
|
|
1317
|
+
*/
|
|
1318
|
+
getBookings(guestId, params) {
|
|
1319
|
+
return this._get(
|
|
1320
|
+
this._buildPath(guestId, "bookings"),
|
|
1321
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Get a guest's folio history.
|
|
1326
|
+
*
|
|
1327
|
+
* Returns lightweight folio summaries with pagination support.
|
|
1328
|
+
*
|
|
1329
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```typescript
|
|
1333
|
+
* const folios = await client.guests.getFolios("guest_42");
|
|
1334
|
+
* ```
|
|
1335
|
+
*/
|
|
1336
|
+
getFolios(guestId, params) {
|
|
1337
|
+
return this._get(
|
|
1338
|
+
this._buildPath(guestId, "folios"),
|
|
1339
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Get a guest's order history.
|
|
1344
|
+
*
|
|
1345
|
+
* Returns lightweight order summaries with pagination support.
|
|
1346
|
+
*
|
|
1347
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
* ```typescript
|
|
1351
|
+
* const orders = await client.guests.getOrders("guest_42", {
|
|
1352
|
+
* limit: 5,
|
|
1353
|
+
* cursor: "next_page",
|
|
1354
|
+
* });
|
|
1355
|
+
* ```
|
|
1356
|
+
*/
|
|
1357
|
+
getOrders(guestId, params) {
|
|
1358
|
+
return this._get(
|
|
1359
|
+
this._buildPath(guestId, "orders"),
|
|
1360
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
/** Build query params from GuestHistoryParams, omitting undefined values */
|
|
1364
|
+
_buildHistoryQuery(params) {
|
|
1365
|
+
const query = {};
|
|
1366
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1367
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1368
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1369
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1370
|
+
return query;
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1094
1374
|
// src/services/properties.ts
|
|
1095
1375
|
var PropertiesService = class extends BaseService {
|
|
1096
1376
|
constructor() {
|
|
@@ -1320,6 +1600,11 @@ var BookingClient = class {
|
|
|
1320
1600
|
this._bookings ?? (this._bookings = new BookingsService(this.httpClient));
|
|
1321
1601
|
return this._bookings;
|
|
1322
1602
|
}
|
|
1603
|
+
/** Guests service — lazy-initialized on first access */
|
|
1604
|
+
get guests() {
|
|
1605
|
+
this._guests ?? (this._guests = new GuestsService(this.httpClient));
|
|
1606
|
+
return this._guests;
|
|
1607
|
+
}
|
|
1323
1608
|
/** Properties service — lazy-initialized on first access */
|
|
1324
1609
|
get properties() {
|
|
1325
1610
|
this._properties ?? (this._properties = new PropertiesService(this.httpClient));
|
|
@@ -1454,6 +1739,7 @@ var VERSION = "0.1.0";
|
|
|
1454
1739
|
ConflictError,
|
|
1455
1740
|
DEFAULT_MODULES,
|
|
1456
1741
|
ForbiddenError,
|
|
1742
|
+
GuestsService,
|
|
1457
1743
|
HttpClient,
|
|
1458
1744
|
NotFoundError,
|
|
1459
1745
|
PROPERTY_MODULES,
|