sabre-client 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/dist/index.js CHANGED
@@ -1,29 +1,3 @@
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 });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- Sabre: () => Sabre
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
-
27
1
  // src/authentication/authentication.ts
28
2
  var grantType = new URLSearchParams({ "grant_type": "client_credentials" }).toString();
29
3
  var Authentication = class {
@@ -31,24 +5,22 @@ var Authentication = class {
31
5
  this.sabre = sabre;
32
6
  }
33
7
  /**
34
- * V2 AUTH TOKEN
8
+ * OAuth Token Create REST API v2
35
9
  * See https://developer.sabre.com/docs/rest_apis/session_management/token_create_api/v2
36
10
  * @param payload El tipo de concesión utilizado para obtener el token. Sólo se admiten 'client_credentials'.
37
- * @param options CreateTokenRequestOptions
38
11
  * @returns TokenResponse
39
12
  */
40
- async OAuthTokenV2(payload = grantType, options = {}) {
13
+ async OAuthTokenV2(payload = grantType) {
41
14
  const data = await this.sabre.auth(
42
15
  "/v2/auth/token",
43
- payload,
44
- options
16
+ payload
45
17
  );
46
18
  this.sabre.setAuthorization(data.access_token);
47
19
  return data;
48
20
  }
49
21
  };
50
22
 
51
- // src/booking-management/booking/booking.ts
23
+ // src/booking-management/booking.ts
52
24
  var Booking = class {
53
25
  /**
54
26
  * Booking
@@ -65,9 +37,9 @@ var Booking = class {
65
37
  *
66
38
  * payload - Contiene elementos tanto obligatorios como opcionales para realizar una solicitud de reserva.
67
39
  * @param payload GetBookingOptions
68
- * @returns GetBookingResponse
40
+ * @returns {Promise<GetBookingResponseSuccess>}
69
41
  */
70
- async get(payload) {
42
+ get(payload) {
71
43
  const path = "/v1/trip/orders/getBooking";
72
44
  return this.sabre.post(path, payload);
73
45
  }
@@ -76,7 +48,7 @@ var Booking = class {
76
48
  *
77
49
  * payload - Contiene elementos obligatorios y opcionales para realizar una solicitud de reserva.
78
50
  * @param payload CreateBookingOptions
79
- * @returns CreateBookingResponse
51
+ * @returns {Promise<CreateBookingResponseSuccess>}
80
52
  */
81
53
  async create(payload) {
82
54
  const path = "/v1/trip/orders/createBooking";
@@ -87,7 +59,7 @@ var Booking = class {
87
59
  *
88
60
  * payload - Contiene elementos obligatorios y opcionales para cancelar la totalidad o partes de una reserva.
89
61
  * @param payload CancelBookingOptions
90
- * @returns CancelBookingRequest
62
+ * @returns {Promise<CancelBookingResponseSuccess>}
91
63
  */
92
64
  async cancel(payload) {
93
65
  const path = "/v1/trip/orders/cancelBooking";
@@ -98,7 +70,7 @@ var Booking = class {
98
70
  *
99
71
  * payload - Contiene elementos obligatorios y opcionales para modificar datos no relacionados con el itinerario en la reserva existente.
100
72
  * @param payload ModifyBookingOptions
101
- * @returns ModifyBookingResponse
73
+ * @returns {Promise<ModifyBookingResponseSuccess>}
102
74
  */
103
75
  async modify(payload) {
104
76
  const path = "/v1/trip/orders/modifyBooking";
@@ -106,7 +78,7 @@ var Booking = class {
106
78
  }
107
79
  };
108
80
 
109
- // src/booking-management/flight-tickets/flight-tickets.ts
81
+ // src/booking-management/flight-tickets.ts
110
82
  var FlightTickets = class {
111
83
  /**
112
84
  * Flight Tickets
@@ -124,7 +96,7 @@ var FlightTickets = class {
124
96
  *
125
97
  * payload - Contiene elementos obligatorios y opcionales para anular los billetes.
126
98
  * @param payload VoidTicketsOptions
127
- * @returns VoidTicketsResponse
99
+ * @returns {Promise<VoidTicketsResponseSuccess>}
128
100
  */
129
101
  async void(payload) {
130
102
  const path = "/v1/trip/orders/voidFlightTickets";
@@ -136,7 +108,7 @@ var FlightTickets = class {
136
108
  *
137
109
  * payload - Contiene elementos obligatorios y opcionales para el reembolso de los billetes.
138
110
  * @param payload RefundTicketsOptions
139
- * @returns RefundTicketsResponse
111
+ * @returns {Promise<RefundTicketsResponseSuccess>}
140
112
  */
141
113
  async refund(payload) {
142
114
  const path = "/v1/trip/orders/refundFlightTickets";
@@ -148,19 +120,19 @@ var FlightTickets = class {
148
120
  *
149
121
  * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
150
122
  * @param payload CheckTicketsOptions
151
- * @returns CheckTicketsResponse
123
+ * @returns {Promise<CheckTicketsResponseSuccess>} CheckTicketsResponse
152
124
  */
153
125
  async check(payload) {
154
126
  const path = "/v1/trip/orders/checkFlightTickets";
155
127
  return this.sabre.post(path, payload);
156
128
  }
157
129
  /**
158
- * Procesa tickets proporcionando una solicitud que contiene una lista de números de ticket que se verificarán.
130
+ * Procesa la emisión de billetes y documentos varios electrónicos (EMD).
159
131
  * Actualmente, los EMD no son compatibles.
160
132
  *
161
- * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
162
- * @param payload CheckTicketsOptions
163
- * @returns CheckTicketsResponse
133
+ * payload - Contiene elementos obligatorios y opcionales para la emisión de billetes.
134
+ * @param payload FulfillTicketsOptions
135
+ * @returns {Promise<FulfillTicketsResponseSuccess>}
164
136
  */
165
137
  async fulfill(payload) {
166
138
  const path = "/v1/trip/orders/fulfillFlightTickets";
@@ -169,7 +141,7 @@ var FlightTickets = class {
169
141
  };
170
142
 
171
143
  // package.json
172
- var version = "0.1.0";
144
+ var version = "0.2.0";
173
145
 
174
146
  // src/config.ts
175
147
  var defaultBaseUrl = "https://api.platform.sabre.com";
@@ -181,6 +153,18 @@ var userAgent = typeof process !== "undefined" && process.env ? process.env.SABR
181
153
  var domain = typeof process !== "undefined" && process.env ? process.env.SABRE_DOMAIN || defaultDomain : defaultDomain;
182
154
  var conversationId = typeof process !== "undefined" && process.env ? process.env.SABRE_CONVERSATION_ID || defaultConversationId : defaultConversationId;
183
155
 
156
+ // src/errors.ts
157
+ var SabreError = class extends Error {
158
+ details;
159
+ statusCode;
160
+ constructor(message, statusCode, details) {
161
+ super(message);
162
+ this.name = "SabreError";
163
+ this.statusCode = statusCode;
164
+ this.details = details;
165
+ }
166
+ };
167
+
184
168
  // src/sabre.ts
185
169
  var Sabre = class {
186
170
  constructor(options = {}) {
@@ -217,8 +201,19 @@ var Sabre = class {
217
201
  async fetchRequest(path, options = {}) {
218
202
  const response = await fetch(`${baseUrl}${path}`, options);
219
203
  if (!response.ok) {
220
- const error = await response.json();
221
- throw new Error(JSON.stringify(error));
204
+ let errorDetails = `Request failed with status ${response.status}`;
205
+ try {
206
+ const jsonError = await response.json();
207
+ errorDetails = JSON.stringify(jsonError);
208
+ } catch (e) {
209
+ console.error(e);
210
+ errorDetails = response.statusText;
211
+ }
212
+ throw new SabreError(
213
+ `Request failed with status ${response.status}`,
214
+ response.status,
215
+ errorDetails
216
+ );
222
217
  }
223
218
  const data = await response.json();
224
219
  return data;
@@ -251,7 +246,6 @@ var Sabre = class {
251
246
  return btoa(`V1:${this.options.username}:${this.options.organization}:${domain}`);
252
247
  }
253
248
  };
254
- // Annotate the CommonJS export names for ESM import in node:
255
- 0 && (module.exports = {
249
+ export {
256
250
  Sabre
257
- });
251
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sabre-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
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
+ }