@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.js CHANGED
@@ -1039,6 +1039,285 @@ var CategoriesService = class extends BaseService {
1039
1039
  }
1040
1040
  };
1041
1041
 
1042
+ // src/services/guests.ts
1043
+ var GuestsService = class extends BaseService {
1044
+ constructor() {
1045
+ super(...arguments);
1046
+ this.basePath = "/guest/v1/profiles";
1047
+ }
1048
+ // ---------------------------------------------------------------------------
1049
+ // CRUD
1050
+ // ---------------------------------------------------------------------------
1051
+ /**
1052
+ * Create a new guest profile.
1053
+ *
1054
+ * @example
1055
+ * ```typescript
1056
+ * const guest = await client.guests.create({
1057
+ * firstName: "Maria",
1058
+ * lastName: "Papadopoulou",
1059
+ * email: "maria@example.com",
1060
+ * phone: "+30 210 1234567",
1061
+ * nationality: "GR",
1062
+ * });
1063
+ * ```
1064
+ */
1065
+ create(input) {
1066
+ return this._post(this.basePath, input);
1067
+ }
1068
+ /**
1069
+ * Get a single guest by ID.
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * const guest = await client.guests.get("guest_42");
1074
+ * ```
1075
+ */
1076
+ get(guestId) {
1077
+ return this._get(this._buildPath(guestId));
1078
+ }
1079
+ /**
1080
+ * List guests with optional filters and cursor-based pagination.
1081
+ *
1082
+ * @example
1083
+ * ```typescript
1084
+ * const page = await client.guests.list({
1085
+ * tags: ["vip", "returning"],
1086
+ * sort: { field: "lastName", direction: "asc" },
1087
+ * limit: 20,
1088
+ * });
1089
+ * ```
1090
+ */
1091
+ list(params) {
1092
+ if (!params) {
1093
+ return this._get(this.basePath);
1094
+ }
1095
+ const query = {};
1096
+ if (params.tags !== void 0 && params.tags.length > 0) {
1097
+ query.tags = params.tags.join(",");
1098
+ }
1099
+ if (params.source !== void 0) query.source = params.source;
1100
+ if (params.createdFrom !== void 0) query.createdFrom = params.createdFrom;
1101
+ if (params.createdTo !== void 0) query.createdTo = params.createdTo;
1102
+ if (params.sort !== void 0) {
1103
+ query.sort = `${params.sort.field}:${params.sort.direction}`;
1104
+ }
1105
+ if (params.limit !== void 0) query.limit = params.limit;
1106
+ if (params.cursor !== void 0) query.cursor = params.cursor;
1107
+ return this._get(this.basePath, query);
1108
+ }
1109
+ /**
1110
+ * Update an existing guest profile.
1111
+ *
1112
+ * @example
1113
+ * ```typescript
1114
+ * const updated = await client.guests.update("guest_42", {
1115
+ * email: "maria.new@example.com",
1116
+ * tags: ["vip"],
1117
+ * });
1118
+ * ```
1119
+ */
1120
+ update(guestId, input) {
1121
+ return this._patch(this._buildPath(guestId), input);
1122
+ }
1123
+ /**
1124
+ * Delete a guest profile (soft-delete).
1125
+ *
1126
+ * @example
1127
+ * ```typescript
1128
+ * await client.guests.delete("guest_42");
1129
+ * ```
1130
+ */
1131
+ delete(guestId) {
1132
+ return this._delete(this._buildPath(guestId));
1133
+ }
1134
+ // ---------------------------------------------------------------------------
1135
+ // Search and Duplicate Detection
1136
+ // ---------------------------------------------------------------------------
1137
+ /**
1138
+ * Search guests by name, email, phone, or passport number.
1139
+ *
1140
+ * Returns results sorted by relevance score (highest first).
1141
+ *
1142
+ * @param query - Search query string
1143
+ * @param params - Optional search parameters (limit, fields)
1144
+ *
1145
+ * @example
1146
+ * ```typescript
1147
+ * // Search by name
1148
+ * const results = await client.guests.search("Papadopoulos");
1149
+ *
1150
+ * // Search by email with field filter
1151
+ * const results2 = await client.guests.search("maria@", {
1152
+ * fields: ["email"],
1153
+ * limit: 5,
1154
+ * });
1155
+ * ```
1156
+ */
1157
+ search(query, params) {
1158
+ const searchQuery = {
1159
+ q: query
1160
+ };
1161
+ if (params?.limit !== void 0) searchQuery.limit = params.limit;
1162
+ if (params?.fields !== void 0 && params.fields.length > 0) {
1163
+ searchQuery.fields = params.fields.join(",");
1164
+ }
1165
+ return this._get(this._buildPath("search"), searchQuery);
1166
+ }
1167
+ /**
1168
+ * Find potential duplicate profiles for a guest.
1169
+ *
1170
+ * Returns candidates sorted by confidence score (highest first).
1171
+ *
1172
+ * @throws {NotFoundError} 404 if the guest is not found
1173
+ *
1174
+ * @example
1175
+ * ```typescript
1176
+ * const duplicates = await client.guests.findDuplicates("guest_42");
1177
+ * for (const dup of duplicates.data) {
1178
+ * console.log(`${dup.guest.firstName} — ${dup.confidence} (${dup.matchedFields})`);
1179
+ * }
1180
+ * ```
1181
+ */
1182
+ findDuplicates(guestId) {
1183
+ return this._get(this._buildPath(guestId, "duplicates"));
1184
+ }
1185
+ // ---------------------------------------------------------------------------
1186
+ // Merge
1187
+ // ---------------------------------------------------------------------------
1188
+ /**
1189
+ * Merge duplicate guest profiles into a primary profile.
1190
+ *
1191
+ * **Warning: This operation is irreversible.** All history from duplicate
1192
+ * profiles is transferred to the primary. Duplicate profiles are soft-deleted.
1193
+ *
1194
+ * @throws {NotFoundError} 404 if primary or any duplicate is not found
1195
+ * @throws {ConflictError} 409 if attempting to merge a guest into itself
1196
+ * @throws {ValidationError} 400 if duplicateIds is empty
1197
+ *
1198
+ * @example
1199
+ * ```typescript
1200
+ * const merged = await client.guests.merge("guest_primary", {
1201
+ * duplicateIds: ["guest_dup1", "guest_dup2"],
1202
+ * });
1203
+ * ```
1204
+ */
1205
+ merge(primaryId, input) {
1206
+ return this._post(this._buildPath(primaryId, "merge"), input);
1207
+ }
1208
+ // ---------------------------------------------------------------------------
1209
+ // Preferences
1210
+ // ---------------------------------------------------------------------------
1211
+ /**
1212
+ * Get guest preferences.
1213
+ *
1214
+ * Returns default/empty preferences if none have been set (does not throw 404).
1215
+ *
1216
+ * @throws {NotFoundError} 404 if the guest is not found
1217
+ *
1218
+ * @example
1219
+ * ```typescript
1220
+ * const prefs = await client.guests.getPreferences("guest_42");
1221
+ * console.log(prefs.dietary, prefs.roomType);
1222
+ * ```
1223
+ */
1224
+ getPreferences(guestId) {
1225
+ return this._get(this._buildPath(guestId, "preferences"));
1226
+ }
1227
+ /**
1228
+ * Update guest preferences (partial merge).
1229
+ *
1230
+ * Only provided fields are updated; unspecified fields retain their values.
1231
+ *
1232
+ * @throws {NotFoundError} 404 if the guest is not found
1233
+ *
1234
+ * @example
1235
+ * ```typescript
1236
+ * const updated = await client.guests.updatePreferences("guest_42", {
1237
+ * dietary: ["vegetarian"],
1238
+ * roomType: "suite",
1239
+ * custom: { pillow: "firm" },
1240
+ * });
1241
+ * ```
1242
+ */
1243
+ updatePreferences(guestId, input) {
1244
+ return this._patch(this._buildPath(guestId, "preferences"), input);
1245
+ }
1246
+ // ---------------------------------------------------------------------------
1247
+ // Cross-Domain History
1248
+ // ---------------------------------------------------------------------------
1249
+ /**
1250
+ * Get a guest's booking history.
1251
+ *
1252
+ * Returns lightweight booking summaries with pagination support.
1253
+ *
1254
+ * @throws {NotFoundError} 404 if the guest is not found
1255
+ *
1256
+ * @example
1257
+ * ```typescript
1258
+ * const bookings = await client.guests.getBookings("guest_42", {
1259
+ * from: "2025-01-01",
1260
+ * to: "2025-12-31",
1261
+ * limit: 10,
1262
+ * });
1263
+ * ```
1264
+ */
1265
+ getBookings(guestId, params) {
1266
+ return this._get(
1267
+ this._buildPath(guestId, "bookings"),
1268
+ params ? this._buildHistoryQuery(params) : void 0
1269
+ );
1270
+ }
1271
+ /**
1272
+ * Get a guest's folio history.
1273
+ *
1274
+ * Returns lightweight folio summaries with pagination support.
1275
+ *
1276
+ * @throws {NotFoundError} 404 if the guest is not found
1277
+ *
1278
+ * @example
1279
+ * ```typescript
1280
+ * const folios = await client.guests.getFolios("guest_42");
1281
+ * ```
1282
+ */
1283
+ getFolios(guestId, params) {
1284
+ return this._get(
1285
+ this._buildPath(guestId, "folios"),
1286
+ params ? this._buildHistoryQuery(params) : void 0
1287
+ );
1288
+ }
1289
+ /**
1290
+ * Get a guest's order history.
1291
+ *
1292
+ * Returns lightweight order summaries with pagination support.
1293
+ *
1294
+ * @throws {NotFoundError} 404 if the guest is not found
1295
+ *
1296
+ * @example
1297
+ * ```typescript
1298
+ * const orders = await client.guests.getOrders("guest_42", {
1299
+ * limit: 5,
1300
+ * cursor: "next_page",
1301
+ * });
1302
+ * ```
1303
+ */
1304
+ getOrders(guestId, params) {
1305
+ return this._get(
1306
+ this._buildPath(guestId, "orders"),
1307
+ params ? this._buildHistoryQuery(params) : void 0
1308
+ );
1309
+ }
1310
+ /** Build query params from GuestHistoryParams, omitting undefined values */
1311
+ _buildHistoryQuery(params) {
1312
+ const query = {};
1313
+ if (params.limit !== void 0) query.limit = params.limit;
1314
+ if (params.cursor !== void 0) query.cursor = params.cursor;
1315
+ if (params.from !== void 0) query.from = params.from;
1316
+ if (params.to !== void 0) query.to = params.to;
1317
+ return query;
1318
+ }
1319
+ };
1320
+
1042
1321
  // src/services/properties.ts
1043
1322
  var PropertiesService = class extends BaseService {
1044
1323
  constructor() {
@@ -1268,6 +1547,11 @@ var BookingClient = class {
1268
1547
  this._bookings ?? (this._bookings = new BookingsService(this.httpClient));
1269
1548
  return this._bookings;
1270
1549
  }
1550
+ /** Guests service — lazy-initialized on first access */
1551
+ get guests() {
1552
+ this._guests ?? (this._guests = new GuestsService(this.httpClient));
1553
+ return this._guests;
1554
+ }
1271
1555
  /** Properties service — lazy-initialized on first access */
1272
1556
  get properties() {
1273
1557
  this._properties ?? (this._properties = new PropertiesService(this.httpClient));
@@ -1401,6 +1685,7 @@ export {
1401
1685
  ConflictError,
1402
1686
  DEFAULT_MODULES,
1403
1687
  ForbiddenError,
1688
+ GuestsService,
1404
1689
  HttpClient,
1405
1690
  NotFoundError,
1406
1691
  PROPERTY_MODULES,