sabre-client 0.1.0 → 0.2.1

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
@@ -1,28 +1,88 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1
+ // src/air/search.ts
2
+ var Search = class {
3
+ /**
4
+ * Bargain Finder Max v5
5
+ *
6
+ * Bargain Finder Max (BFM),
7
+ * nuestro producto de búsqueda de tarifas bajas líder en su clase,
8
+ * se utiliza para buscar los itinerarios con los precios más bajos disponibles según una fecha específica.
9
+ *
10
+ * Revalidate Itinerary v5
11
+ *
12
+ * La API Revalidate Itinerary permite volver a consultar la disponibilidad
13
+ * y el precio de una opción de itinerario específica sin tener que reservarla.
14
+ * La solución revalida si la opción de itinerario es válida para la compra.
15
+ * Revalidate Itinerary no admite contenido NDC.
16
+ *
17
+ * @param sabre Sabre Client Reference
18
+ */
19
+ constructor(sabre) {
20
+ this.sabre = sabre;
21
+ }
22
+ /**
23
+ * Crear solicitud de Buscador de ofertas Max.
24
+ *
25
+ * payload - El mensaje de solicitud de búsqueda de tarifa baja solicita opciones
26
+ * de itinerario para vuelos entre pares de ciudades específicos, en fechas específicas,
27
+ * para un número y tipo de pasajeros específicos.
28
+ * La información opcional de la solicitud puede incluir:
29
+ * hora/ventana horaria, ciudades de conexión
30
+ * y preferencias del cliente (aerolíneas, cabina, tipo de vuelo, etc.).
31
+ * La solicitud de búsqueda de tarifa baja contiene información similar a
32
+ * la de una búsqueda de tarifa baja en el CRS o GDS de una aerolínea.
33
+ * @param payload BargainFinderMaxOptions
34
+ * @returns {Promise<BargainFinderMaxResponseSuccess>}
35
+ */
36
+ async shop(payload) {
37
+ const path = "/v5/offers/shop";
38
+ return this.sabre.post(path, payload);
39
+ }
40
+ /**
41
+ * Crear solicitud de revalidación de itinerario.
42
+ *
43
+ * payload - El mensaje de solicitud de búsqueda de tarifa baja solicita opciones
44
+ * de itinerario para vuelos entre pares de ciudades específicos, en fechas específicas,
45
+ * para un número y tipo de pasajeros específicos.
46
+ * La información opcional de la solicitud puede incluir:
47
+ * hora/ventana horaria, ciudades de conexión
48
+ * y preferencias del cliente (aerolíneas, cabina, tipo de vuelo, etc.).
49
+ * La solicitud de búsqueda de tarifa baja contiene información similar a
50
+ * la de una búsqueda de tarifa baja en el CRS o GDS de una aerolínea.
51
+ * @param payload RevalidateItineraryOptions
52
+ * @returns {Promise<RevalidateItineraryResponseSuccess>}
53
+ */
54
+ async revalidate(payload) {
55
+ const path = "/v5/shop/flights/revalidate";
56
+ return this.sabre.post(path, payload);
15
57
  }
16
- return to;
17
58
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
59
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- Sabre: () => Sabre
24
- });
25
- module.exports = __toCommonJS(index_exports);
60
+ // src/air/ticketing.ts
61
+ var Ticketing = class {
62
+ /**
63
+ * Enhanced Air Ticket v1.3.0
64
+ *
65
+ * La API de boletos aéreos mejorados se utiliza para emitir uno o varios boletos aéreos
66
+ * y/o EMD (documentos electrónicos varios) dentro de una sola llamada API.
67
+ *
68
+ * @param sabre Sabre Client Reference
69
+ */
70
+ constructor(sabre) {
71
+ this.sabre = sabre;
72
+ }
73
+ /**
74
+ * La API de boletos aéreos mejorados (AirTicketRQ)
75
+ * se utiliza para emitir boletos aéreos y documentos electrónicos varios (EMD) en una sola solicitud.
76
+ *
77
+ * payload - Solicitud de API de boletos aéreos orquestada.
78
+ * @param payload EnhancedAirTicketOptions
79
+ * @returns {Promise<EnhancedAirTicketResponseSuccess>}
80
+ */
81
+ async issue(payload) {
82
+ const path = "/v1.3.0/air/ticket";
83
+ return this.sabre.post(path, payload);
84
+ }
85
+ };
26
86
 
27
87
  // src/authentication/authentication.ts
28
88
  var grantType = new URLSearchParams({ "grant_type": "client_credentials" }).toString();
@@ -31,24 +91,22 @@ var Authentication = class {
31
91
  this.sabre = sabre;
32
92
  }
33
93
  /**
34
- * V2 AUTH TOKEN
94
+ * OAuth Token Create REST API v2
35
95
  * See https://developer.sabre.com/docs/rest_apis/session_management/token_create_api/v2
36
96
  * @param payload El tipo de concesión utilizado para obtener el token. Sólo se admiten 'client_credentials'.
37
- * @param options CreateTokenRequestOptions
38
97
  * @returns TokenResponse
39
98
  */
40
- async OAuthTokenV2(payload = grantType, options = {}) {
99
+ async OAuthTokenV2(payload = grantType) {
41
100
  const data = await this.sabre.auth(
42
101
  "/v2/auth/token",
43
- payload,
44
- options
102
+ payload
45
103
  );
46
104
  this.sabre.setAuthorization(data.access_token);
47
105
  return data;
48
106
  }
49
107
  };
50
108
 
51
- // src/booking-management/booking/booking.ts
109
+ // src/booking-management/booking.ts
52
110
  var Booking = class {
53
111
  /**
54
112
  * Booking
@@ -65,9 +123,9 @@ var Booking = class {
65
123
  *
66
124
  * payload - Contiene elementos tanto obligatorios como opcionales para realizar una solicitud de reserva.
67
125
  * @param payload GetBookingOptions
68
- * @returns GetBookingResponse
126
+ * @returns {Promise<GetBookingResponseSuccess>}
69
127
  */
70
- async get(payload) {
128
+ get(payload) {
71
129
  const path = "/v1/trip/orders/getBooking";
72
130
  return this.sabre.post(path, payload);
73
131
  }
@@ -76,7 +134,7 @@ var Booking = class {
76
134
  *
77
135
  * payload - Contiene elementos obligatorios y opcionales para realizar una solicitud de reserva.
78
136
  * @param payload CreateBookingOptions
79
- * @returns CreateBookingResponse
137
+ * @returns {Promise<CreateBookingResponseSuccess>}
80
138
  */
81
139
  async create(payload) {
82
140
  const path = "/v1/trip/orders/createBooking";
@@ -87,7 +145,7 @@ var Booking = class {
87
145
  *
88
146
  * payload - Contiene elementos obligatorios y opcionales para cancelar la totalidad o partes de una reserva.
89
147
  * @param payload CancelBookingOptions
90
- * @returns CancelBookingRequest
148
+ * @returns {Promise<CancelBookingResponseSuccess>}
91
149
  */
92
150
  async cancel(payload) {
93
151
  const path = "/v1/trip/orders/cancelBooking";
@@ -98,7 +156,7 @@ var Booking = class {
98
156
  *
99
157
  * payload - Contiene elementos obligatorios y opcionales para modificar datos no relacionados con el itinerario en la reserva existente.
100
158
  * @param payload ModifyBookingOptions
101
- * @returns ModifyBookingResponse
159
+ * @returns {Promise<ModifyBookingResponseSuccess>}
102
160
  */
103
161
  async modify(payload) {
104
162
  const path = "/v1/trip/orders/modifyBooking";
@@ -106,7 +164,7 @@ var Booking = class {
106
164
  }
107
165
  };
108
166
 
109
- // src/booking-management/flight-tickets/flight-tickets.ts
167
+ // src/booking-management/flight-tickets.ts
110
168
  var FlightTickets = class {
111
169
  /**
112
170
  * Flight Tickets
@@ -124,7 +182,7 @@ var FlightTickets = class {
124
182
  *
125
183
  * payload - Contiene elementos obligatorios y opcionales para anular los billetes.
126
184
  * @param payload VoidTicketsOptions
127
- * @returns VoidTicketsResponse
185
+ * @returns {Promise<VoidTicketsResponseSuccess>}
128
186
  */
129
187
  async void(payload) {
130
188
  const path = "/v1/trip/orders/voidFlightTickets";
@@ -136,7 +194,7 @@ var FlightTickets = class {
136
194
  *
137
195
  * payload - Contiene elementos obligatorios y opcionales para el reembolso de los billetes.
138
196
  * @param payload RefundTicketsOptions
139
- * @returns RefundTicketsResponse
197
+ * @returns {Promise<RefundTicketsResponseSuccess>}
140
198
  */
141
199
  async refund(payload) {
142
200
  const path = "/v1/trip/orders/refundFlightTickets";
@@ -148,19 +206,19 @@ var FlightTickets = class {
148
206
  *
149
207
  * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
150
208
  * @param payload CheckTicketsOptions
151
- * @returns CheckTicketsResponse
209
+ * @returns {Promise<CheckTicketsResponseSuccess>} CheckTicketsResponse
152
210
  */
153
211
  async check(payload) {
154
212
  const path = "/v1/trip/orders/checkFlightTickets";
155
213
  return this.sabre.post(path, payload);
156
214
  }
157
215
  /**
158
- * Procesa tickets proporcionando una solicitud que contiene una lista de números de ticket que se verificarán.
216
+ * Procesa la emisión de billetes y documentos varios electrónicos (EMD).
159
217
  * Actualmente, los EMD no son compatibles.
160
218
  *
161
- * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
162
- * @param payload CheckTicketsOptions
163
- * @returns CheckTicketsResponse
219
+ * payload - Contiene elementos obligatorios y opcionales para la emisión de billetes.
220
+ * @param payload FulfillTicketsOptions
221
+ * @returns {Promise<FulfillTicketsResponseSuccess>}
164
222
  */
165
223
  async fulfill(payload) {
166
224
  const path = "/v1/trip/orders/fulfillFlightTickets";
@@ -169,7 +227,7 @@ var FlightTickets = class {
169
227
  };
170
228
 
171
229
  // package.json
172
- var version = "0.1.0";
230
+ var version = "0.2.1";
173
231
 
174
232
  // src/config.ts
175
233
  var defaultBaseUrl = "https://api.platform.sabre.com";
@@ -181,6 +239,18 @@ var userAgent = typeof process !== "undefined" && process.env ? process.env.SABR
181
239
  var domain = typeof process !== "undefined" && process.env ? process.env.SABRE_DOMAIN || defaultDomain : defaultDomain;
182
240
  var conversationId = typeof process !== "undefined" && process.env ? process.env.SABRE_CONVERSATION_ID || defaultConversationId : defaultConversationId;
183
241
 
242
+ // src/errors.ts
243
+ var SabreError = class extends Error {
244
+ details;
245
+ statusCode;
246
+ constructor(message, statusCode, details) {
247
+ super(message);
248
+ this.name = "SabreError";
249
+ this.statusCode = statusCode;
250
+ this.details = details;
251
+ }
252
+ };
253
+
184
254
  // src/sabre.ts
185
255
  var Sabre = class {
186
256
  constructor(options = {}) {
@@ -210,6 +280,8 @@ var Sabre = class {
210
280
  authentication = new Authentication(this);
211
281
  booking = new Booking(this);
212
282
  flightTickets = new FlightTickets(this);
283
+ search = new Search(this);
284
+ ticketing = new Ticketing(this);
213
285
  setAuthorization(token) {
214
286
  this.headers.set("Authorization", `Bearer ${token}`);
215
287
  this.headers.set("Content-Type", "application/json");
@@ -217,8 +289,19 @@ var Sabre = class {
217
289
  async fetchRequest(path, options = {}) {
218
290
  const response = await fetch(`${baseUrl}${path}`, options);
219
291
  if (!response.ok) {
220
- const error = await response.json();
221
- throw new Error(JSON.stringify(error));
292
+ let errorDetails = `Request failed with status ${response.status}`;
293
+ try {
294
+ const jsonError = await response.json();
295
+ errorDetails = JSON.stringify(jsonError);
296
+ } catch (e) {
297
+ console.error(e);
298
+ errorDetails = response.statusText;
299
+ }
300
+ throw new SabreError(
301
+ `Request failed with status ${response.status}`,
302
+ response.status,
303
+ errorDetails
304
+ );
222
305
  }
223
306
  const data = await response.json();
224
307
  return data;
@@ -251,7 +334,6 @@ var Sabre = class {
251
334
  return btoa(`V1:${this.options.username}:${this.options.organization}:${domain}`);
252
335
  }
253
336
  };
254
- // Annotate the CommonJS export names for ESM import in node:
255
- 0 && (module.exports = {
337
+ export {
256
338
  Sabre
257
- });
339
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sabre-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Sabre Node.js SDK",
5
5
  "keywords": [
6
6
  "sabre",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "Carlos Ivan Soto <csoto_99@outlook.com>",
21
+ "type": "module",
21
22
  "main": "./dist/index.js",
22
23
  "module": "./dist/index.mjs",
23
24
  "types": "./dist/index.d.ts",
@@ -39,18 +40,20 @@
39
40
  "scripts": {
40
41
  "build": "tsup src/index.ts --format esm,cjs --dts",
41
42
  "test": "jest --passWithNoTests",
42
- "test:watch": "jest --watch"
43
+ "test:watch": "jest --watch",
44
+ "lint": "eslint . --ext .ts --report-unused-disable-directives --max-warnings 0",
45
+ "type-check": "tsc --noEmit"
43
46
  },
44
47
  "devDependencies": {
45
- "@eslint/js": "^9.21.0",
46
- "@types/jest": "^29.5.14",
47
- "@types/node": "^22.13.3",
48
- "eslint": "^9.22.0",
49
- "jest": "^29.7.0",
50
- "ts-jest": "^29.2.5",
48
+ "@eslint/js": "^9.38.0",
49
+ "@types/jest": "^30.0.0",
50
+ "@types/node": "^24.8.1",
51
+ "eslint": "^9.38.0",
52
+ "jest": "^30.2.0",
53
+ "ts-jest": "^29.4.5",
51
54
  "ts-node": "^10.9.2",
52
- "tsup": "^8.4.0",
53
- "typescript": "^5.7.3",
54
- "typescript-eslint": "^8.25.0"
55
+ "tsup": "^8.5.0",
56
+ "typescript": "^5.9.3",
57
+ "typescript-eslint": "^8.46.1"
55
58
  }
56
59
  }