sabre-client 0.4.0 → 0.4.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/README.es.md CHANGED
@@ -88,6 +88,11 @@ const sabre = new Sabre({
88
88
  | `fetch` | `fetch` global | `fetch` propio (proxies, tests, otros runtimes) |
89
89
  | `tokenStore` | solo en memoria | Comparte el token entre procesos (ver [Reutilizar el token](#reutilizar-el-token)) |
90
90
 
91
+ > **`pcc` está deprecado** desde la `0.4.1` y se quita en la `0.5.0`. Era un campo reservado, y
92
+ > ningún cliente lo lee. El PCC con el que te autenticas va en `credentials` (ver
93
+ > [Credenciales](#credenciales) y `buildCredentials`). Para trabajar en otro PCC, pásalo en cada
94
+ > operación: `targetPcc` en REST y `pcc` en las operaciones de colas.
95
+
91
96
  ### Credenciales
92
97
 
93
98
  Hay **un solo juego de credenciales** para REST y SOAP: el mismo objeto `credentials` sirve para
@@ -115,6 +120,12 @@ const sabre = new Sabre({ environment: 'sandbox', credentials });
115
120
  const legacy = new SabreLegacy({ environment: 'sandbox', credentials });
116
121
  ```
117
122
 
123
+ El objeto que devuelve `buildCredentials` lleva su `authVersion`, así que la config no necesita
124
+ repetirlo: con `authVersion: 'v2'` en `buildCredentials`, `{ environment, credentials }` ya es una
125
+ config v2. Si también pasas `authVersion` en la config, tiene que coincidir; si no, el cliente lanza
126
+ un `TypeError`. Las credenciales que armas a mano no llevan `authVersion`, así que con v2 la config
127
+ sigue necesitando `authVersion: 'v2'`.
128
+
118
129
  El PCC de las credenciales es con el que te autenticas. Trabajar en otro PCC no requiere otro
119
130
  juego de credenciales: se pasa en cada operación, como `targetPcc` en `booking.create`, `get` y
120
131
  `cancel`, o como `pcc` en las operaciones de colas.
package/README.md CHANGED
@@ -88,6 +88,11 @@ const sabre = new Sabre({
88
88
  | `fetch` | global `fetch` | Custom `fetch` (proxies, tests, other runtimes) |
89
89
  | `tokenStore` | in-memory only | Shares the token between processes (see [Token reuse](#token-reuse)) |
90
90
 
91
+ > **`pcc` is deprecated** since `0.4.1` and will be removed in `0.5.0`. It was a reserved field,
92
+ > and no client reads it. The PCC you authenticate with goes in `credentials` (see
93
+ > [Credentials](#credentials) and `buildCredentials`). To work in another PCC, pass it per
94
+ > operation: `targetPcc` in REST, `pcc` in the queue operations.
95
+
91
96
  ### Credentials
92
97
 
93
98
  There is **one set of credentials** for REST and SOAP: the same `credentials` object works for
@@ -115,6 +120,12 @@ const sabre = new Sabre({ environment: 'sandbox', credentials });
115
120
  const legacy = new SabreLegacy({ environment: 'sandbox', credentials });
116
121
  ```
117
122
 
123
+ The object that `buildCredentials` returns carries its `authVersion`, so the config does not
124
+ need to repeat it: with `authVersion: 'v2'` in `buildCredentials`, `{ environment, credentials }`
125
+ is already a v2 config. If you pass `authVersion` in the config too, it must match, or the client
126
+ throws a `TypeError`. Credentials you build by hand have no `authVersion`, so with v2 the config
127
+ still needs `authVersion: 'v2'`.
128
+
118
129
  The PCC in the credentials is the one you authenticate with. Working in another PCC is not a
119
130
  second set of credentials: pass it per operation, as `targetPcc` in `booking.create`, `get` and
120
131
  `cancel`, or as `pcc` in the queue operations.
package/dist/index.d.ts CHANGED
@@ -53,6 +53,11 @@ type SabreEnvironment = 'sandbox' | 'production';
53
53
  type SabreAuthVersion = 'v3' | 'v2';
54
54
  /** Credenciales para OAuth Token Create v3: Client ID/Secret más usuario EPR. */
55
55
  interface SabreCredentials {
56
+ /**
57
+ * Versión de OAuth para la que se armaron. `buildCredentials` la pone; la config la usa cuando
58
+ * no trae su propio `authVersion`.
59
+ */
60
+ authVersion?: 'v3';
56
61
  clientId: string;
57
62
  clientSecret: string;
58
63
  /** Usuario EPR. */
@@ -62,6 +67,11 @@ interface SabreCredentials {
62
67
  }
63
68
  /** Credenciales para OAuth Token Create v2: solo EPR; `clientId`/`clientSecret` se ignoran. */
64
69
  interface SabreCredentialsV2 {
70
+ /**
71
+ * Versión de OAuth para la que se armaron. `buildCredentials` la pone, y con ella la config no
72
+ * necesita repetir `authVersion: 'v2'`.
73
+ */
74
+ authVersion?: 'v2';
65
75
  clientId?: string;
66
76
  clientSecret?: string;
67
77
  /** Usuario EPR. */
@@ -71,7 +81,11 @@ interface SabreCredentialsV2 {
71
81
  }
72
82
  interface SabreBaseConfig {
73
83
  environment: SabreEnvironment;
74
- /** Campo reservado: PCC vs iPCC sigue sin resolver. */
84
+ /**
85
+ * @deprecated Desde 0.4.1; se quita en 0.5.0. Ningún cliente lo lee. El PCC con el que te
86
+ * autenticas va en `credentials` (ver `buildCredentials`). Para trabajar en otro PCC, se pasa en
87
+ * cada operación: `targetPcc` en REST, `pcc` en colas.
88
+ */
75
89
  pcc?: string;
76
90
  logger?: SabreLogger;
77
91
  /** Reintentos por defecto del cliente; cada request puede pisarlos. */
@@ -94,8 +108,21 @@ interface SabreConfigV2 extends SabreBaseConfig {
94
108
  authVersion: 'v2';
95
109
  credentials: SabreCredentialsV2;
96
110
  }
97
- /** Config del cliente, discriminada por `authVersion`. */
98
- type SabreConfig = SabreConfigV3 | SabreConfigV2;
111
+ /**
112
+ * OAuth Token Create v2 sin `authVersion` en la config: la versión sale de las credenciales,
113
+ * como las devuelve `buildCredentials({ authVersion: 'v2', … })`.
114
+ */
115
+ interface SabreConfigV2FromCredentials extends SabreBaseConfig {
116
+ authVersion?: never;
117
+ credentials: SabreCredentialsV2 & {
118
+ authVersion: 'v2';
119
+ };
120
+ }
121
+ /**
122
+ * Config del cliente, discriminada por `authVersion`: el de la config o, si falta, el de
123
+ * `credentials`. Sin ninguno de los dos, es v3.
124
+ */
125
+ type SabreConfig = SabreConfigV3 | SabreConfigV2 | SabreConfigV2FromCredentials;
99
126
  /** Config validada y con defaults aplicados. */
100
127
  interface ResolvedConfig {
101
128
  credentials: Readonly<SabreCredentials | SabreCredentialsV2>;
@@ -2030,15 +2057,27 @@ interface BuildCredentialsOptionsV2 extends BuildCredentialsBase {
2030
2057
  clientSecret?: string;
2031
2058
  }
2032
2059
  type BuildCredentialsOptions = BuildCredentialsOptionsV3 | BuildCredentialsOptionsV2;
2060
+ /** Lo que devuelve `buildCredentials` para v3: lleva `authVersion: 'v3'`. */
2061
+ type BuiltCredentialsV3 = SabreCredentials & {
2062
+ authVersion: 'v3';
2063
+ };
2064
+ /**
2065
+ * Lo que devuelve `buildCredentials` para v2: lleva `authVersion: 'v2'`, así que la config no
2066
+ * necesita repetirlo (#148).
2067
+ */
2068
+ type BuiltCredentialsV2 = SabreCredentialsV2 & {
2069
+ authVersion: 'v2';
2070
+ };
2033
2071
  /**
2034
2072
  * Arma el `credentials` para `Sabre` y `SabreLegacy` a partir del usuario, el PCC, el domain y
2035
2073
  * la contraseña del EPR, más `clientId`/`clientSecret` cuando los hay. El username queda como
2036
2074
  * `<user>-<PCC>-<domain>` (v3) o `V1:<user>:<PCC>:<domain>` (v2). No lee variables de entorno
2037
- * ni toca la red; un dato inválido lanza `TypeError` sin repetir secretos.
2075
+ * ni toca la red; un dato inválido lanza `TypeError` sin repetir secretos. El resultado lleva
2076
+ * `authVersion`, que la config usa si no trae el suyo.
2038
2077
  */
2039
- declare function buildCredentials(options: BuildCredentialsOptionsV3): SabreCredentials;
2040
- declare function buildCredentials(options: BuildCredentialsOptionsV2): SabreCredentialsV2;
2041
- declare function buildCredentials(options: BuildCredentialsOptions): SabreCredentials | SabreCredentialsV2;
2078
+ declare function buildCredentials(options: BuildCredentialsOptionsV3): BuiltCredentialsV3;
2079
+ declare function buildCredentials(options: BuildCredentialsOptionsV2): BuiltCredentialsV2;
2080
+ declare function buildCredentials(options: BuildCredentialsOptions): BuiltCredentialsV3 | BuiltCredentialsV2;
2042
2081
 
2043
2082
  /**
2044
2083
  * Cómo se elige el año cuando el texto no lo trae:
@@ -2284,6 +2323,6 @@ interface BookingFlightDetailsSource {
2284
2323
  */
2285
2324
  declare function buildBookingFlightDetails(source: BookingFlightDetailsSource): FlightDetails;
2286
2325
 
2287
- declare const VERSION = "0.4.0";
2326
+ declare const VERSION = "0.4.1";
2288
2327
 
2289
- export { Air, type BaggageAllowanceDesc, type BaggageInformation, type BargainFinderMaxRequest, type BargainFinderMaxResponse, type BookContactInformation, type BookGenericSeat, type BookSeat, type BookTraveler, type Booking, type BookingAgency, type BookingFlightDetailsSource, type BookingItemReference, BookingManagement, type BookingResponseError, type BookingSeatSelection, type BookingSource, type BrandedFare, type BuildCredentialsOptions, type BuildCredentialsOptionsV2, type BuildCredentialsOptionsV3, type CancelBookingErrorPolicy, type CancelBookingNotification, type CancelBookingOptions, type CancelBookingRequest, type CancelBookingResponse, type CancelSegmentReference, type CreateBookingErrorPolicy, type CreateBookingOptions, type CreateBookingRequest, type CreateBookingResponse, type CreateBookingResponseError, type CurrencyConversion, type Fare, type FareComponent, type FareComponentDesc, type FareComponentDescSegment, type FareComponentSegment, type FareComponentSegmentDetail, type FareMessage, type FlightDetails, type FlightStatusCode, type FlightTicketOperation, type FlightToBook, type GetBookingExtraFeatures, type GetBookingOptions, type GetBookingRequest, type GetBookingResponse, type GetBookingReturnOnly, type GetSeatsRequest, type GetSeatsResponse, type GroupedItineraryResponse, type HostDateDirection, type Itinerary, type ItineraryGroup, type ItineraryMessage, type Leg, type LegDesc, type LegDescription, type LegSchedule, type LegScheduleRef, type LowFareSearchFlight, type LowFareSearchLocation, type LowFareSearchOriginDestination, type LowFareSearchPassengerTypeQuantity, type LowFareSearchRequestorId, type LowFareSearchSource, type LowFareSearchTpaExtensions, type LowFareSearchTravelPreferences, type LowFareSearchTravelerInfoSummary, type ObFeeDesc, type OpenSessionOptions, type OtaAirLowFareSearchRq, type PassengerInfo, type PassengerPricing, type PassengerTotalFare, type PaymentMethod, type PriceComparison, type PriceComparisonType, type PricedSeat, type PricingDetails, type PricingInformation, type PricingQualifiers, type QueueAccessOptions, type QueueAccessRequest, type QueueCount, type QueueCountOptions, type QueueCountRequest, type QueueCountResponse, type QueueEndReason, type QueueItem, type QueueListEntry, type QueueListOptions, type QueueListRequest, type QueueListResponse, QueueManagement, type QueueNavigationOptions, type QueueParagraph, type QueueParagraphAirSegment, type QueueParagraphMessage, type QueueParagraphOptions, type QueueParagraphOtherSegment, type QueueParagraphPassenger, type QueueParagraphReceivedFrom, type QueueParagraphSegment, type QueueParagraphTicketing, type QueueParagraphTicketingEntry, type QueuePlaceOptions, type QueuePlaceRequest, type QueuePlaceResponse, type QueuePlaceResult, type QueuePlaceTarget, type QueuePlacement, type QueueProcessAction, type QueueProcessRequest, type QueueProcessResult, QueueRef, type QueueRemoveRequest, type QueueRemoveTarget, type QueueSelection, type QueueState, type QueueStep, type RawSeatAvailabilityRs, type Ref, type RefundDocumentsType, type RequestOptions, type ResolveHostDateOptions, type RetryOptions, type RevalidateItineraryRequest, type RevalidateItineraryRequestSource, type RevalidateItineraryResponse, Sabre, type SabreAuthVersion, SabreBusinessError, type SabreBusinessErrorOptions, type SabreCommandOptions, type SabreCommandResponse, type SabreConfig, type SabreConfigV2, type SabreConfigV3, type SabreCredentials, type SabreCredentialsV2, type SabreEnvironment, SabreError, type SabreErrorOptions, SabreGatewayError, type SabreGatewayErrorOptions, SabreLegacy, type SabreLogEvent, type SabreLogLevel, type SabreLogger, SabreOrchestrationError, type SabreOrchestrationErrorOptions, type SabreProtocol, type SabreRawResponse, type SabreRawResponseCallback, type SabreServiceErrorOptions, SabreSession, SabreSessionError, type SabreSessionErrorKind, type SabreSessionErrorOptions, type SabreTokenStore, SabreWarning, type ScheduleCarrier, type ScheduleDesc, type ScheduleEndpoint, type ScheduleEquipment, type Seat, type SeatAreaPreference, type SeatAvailabilityByPayloadRq, type SeatAvailabilityByPnrLocatorRq, type SeatAvailabilityIssue, type SeatAvailabilityRequestSource, type SeatAvailabilityResponse, type SeatCabinCompartment, type SeatCabinFacility, type SeatCabinLayout, type SeatCabinRowPosition, type SeatCharacteristic, type SeatDisplayOnlyItem, type SeatFareComponent, type SeatFareDetail, type SeatFareSegmentAssociation, type SeatFlightLeg, type SeatKeyValuePair, type SeatLoyaltyProgramAccount, type SeatMap, type SeatOfferItem, type SeatOfferItemDetails, type SeatPassenger, type SeatPassengerPayloadRq, type SeatPassengerRs, type SeatPriceBreakdown, type SeatPriceDefinition, type SeatRow, type SeatSegment, type SeatSegmentPayloadRq, type SeatSegmentRs, type SeatServiceDefinition, type SeatSpecialServiceRequest, type SeatTax, type SpecificFare, type StoredToken, type TaxDesc, type TaxSummaryDesc, type TicketingPolicy, type TotalFare, type TravelerPhone, type TravelerTitle, VERSION, type ValidatingCarrierDesc, buildBookingFlightDetails, buildCredentials, buildRevalidateItineraryRequest, buildSeatAvailabilityRequest, parseQueueParagraph, resolveHostDate };
2328
+ export { Air, type BaggageAllowanceDesc, type BaggageInformation, type BargainFinderMaxRequest, type BargainFinderMaxResponse, type BookContactInformation, type BookGenericSeat, type BookSeat, type BookTraveler, type Booking, type BookingAgency, type BookingFlightDetailsSource, type BookingItemReference, BookingManagement, type BookingResponseError, type BookingSeatSelection, type BookingSource, type BrandedFare, type BuildCredentialsOptions, type BuildCredentialsOptionsV2, type BuildCredentialsOptionsV3, type BuiltCredentialsV2, type BuiltCredentialsV3, type CancelBookingErrorPolicy, type CancelBookingNotification, type CancelBookingOptions, type CancelBookingRequest, type CancelBookingResponse, type CancelSegmentReference, type CreateBookingErrorPolicy, type CreateBookingOptions, type CreateBookingRequest, type CreateBookingResponse, type CreateBookingResponseError, type CurrencyConversion, type Fare, type FareComponent, type FareComponentDesc, type FareComponentDescSegment, type FareComponentSegment, type FareComponentSegmentDetail, type FareMessage, type FlightDetails, type FlightStatusCode, type FlightTicketOperation, type FlightToBook, type GetBookingExtraFeatures, type GetBookingOptions, type GetBookingRequest, type GetBookingResponse, type GetBookingReturnOnly, type GetSeatsRequest, type GetSeatsResponse, type GroupedItineraryResponse, type HostDateDirection, type Itinerary, type ItineraryGroup, type ItineraryMessage, type Leg, type LegDesc, type LegDescription, type LegSchedule, type LegScheduleRef, type LowFareSearchFlight, type LowFareSearchLocation, type LowFareSearchOriginDestination, type LowFareSearchPassengerTypeQuantity, type LowFareSearchRequestorId, type LowFareSearchSource, type LowFareSearchTpaExtensions, type LowFareSearchTravelPreferences, type LowFareSearchTravelerInfoSummary, type ObFeeDesc, type OpenSessionOptions, type OtaAirLowFareSearchRq, type PassengerInfo, type PassengerPricing, type PassengerTotalFare, type PaymentMethod, type PriceComparison, type PriceComparisonType, type PricedSeat, type PricingDetails, type PricingInformation, type PricingQualifiers, type QueueAccessOptions, type QueueAccessRequest, type QueueCount, type QueueCountOptions, type QueueCountRequest, type QueueCountResponse, type QueueEndReason, type QueueItem, type QueueListEntry, type QueueListOptions, type QueueListRequest, type QueueListResponse, QueueManagement, type QueueNavigationOptions, type QueueParagraph, type QueueParagraphAirSegment, type QueueParagraphMessage, type QueueParagraphOptions, type QueueParagraphOtherSegment, type QueueParagraphPassenger, type QueueParagraphReceivedFrom, type QueueParagraphSegment, type QueueParagraphTicketing, type QueueParagraphTicketingEntry, type QueuePlaceOptions, type QueuePlaceRequest, type QueuePlaceResponse, type QueuePlaceResult, type QueuePlaceTarget, type QueuePlacement, type QueueProcessAction, type QueueProcessRequest, type QueueProcessResult, QueueRef, type QueueRemoveRequest, type QueueRemoveTarget, type QueueSelection, type QueueState, type QueueStep, type RawSeatAvailabilityRs, type Ref, type RefundDocumentsType, type RequestOptions, type ResolveHostDateOptions, type RetryOptions, type RevalidateItineraryRequest, type RevalidateItineraryRequestSource, type RevalidateItineraryResponse, Sabre, type SabreAuthVersion, SabreBusinessError, type SabreBusinessErrorOptions, type SabreCommandOptions, type SabreCommandResponse, type SabreConfig, type SabreConfigV2, type SabreConfigV2FromCredentials, type SabreConfigV3, type SabreCredentials, type SabreCredentialsV2, type SabreEnvironment, SabreError, type SabreErrorOptions, SabreGatewayError, type SabreGatewayErrorOptions, SabreLegacy, type SabreLogEvent, type SabreLogLevel, type SabreLogger, SabreOrchestrationError, type SabreOrchestrationErrorOptions, type SabreProtocol, type SabreRawResponse, type SabreRawResponseCallback, type SabreServiceErrorOptions, SabreSession, SabreSessionError, type SabreSessionErrorKind, type SabreSessionErrorOptions, type SabreTokenStore, SabreWarning, type ScheduleCarrier, type ScheduleDesc, type ScheduleEndpoint, type ScheduleEquipment, type Seat, type SeatAreaPreference, type SeatAvailabilityByPayloadRq, type SeatAvailabilityByPnrLocatorRq, type SeatAvailabilityIssue, type SeatAvailabilityRequestSource, type SeatAvailabilityResponse, type SeatCabinCompartment, type SeatCabinFacility, type SeatCabinLayout, type SeatCabinRowPosition, type SeatCharacteristic, type SeatDisplayOnlyItem, type SeatFareComponent, type SeatFareDetail, type SeatFareSegmentAssociation, type SeatFlightLeg, type SeatKeyValuePair, type SeatLoyaltyProgramAccount, type SeatMap, type SeatOfferItem, type SeatOfferItemDetails, type SeatPassenger, type SeatPassengerPayloadRq, type SeatPassengerRs, type SeatPriceBreakdown, type SeatPriceDefinition, type SeatRow, type SeatSegment, type SeatSegmentPayloadRq, type SeatSegmentRs, type SeatServiceDefinition, type SeatSpecialServiceRequest, type SeatTax, type SpecificFare, type StoredToken, type TaxDesc, type TaxSummaryDesc, type TicketingPolicy, type TotalFare, type TravelerPhone, type TravelerTitle, VERSION, type ValidatingCarrierDesc, buildBookingFlightDetails, buildCredentials, buildRevalidateItineraryRequest, buildSeatAvailabilityRequest, parseQueueParagraph, resolveHostDate };
package/dist/index.js CHANGED
@@ -1207,12 +1207,20 @@ function resolveConfig(config) {
1207
1207
  if (environment !== "sandbox" && environment !== "production") {
1208
1208
  fail(`environment debe ser 'sandbox' o 'production' (recibido: ${JSON.stringify(environment)})`);
1209
1209
  }
1210
- const authVersion = config.authVersion ?? "v3";
1211
- if (authVersion !== "v3" && authVersion !== "v2") {
1212
- fail(`authVersion debe ser 'v3' o 'v2' (recibido: ${JSON.stringify(authVersion)})`);
1210
+ const configVersion = config.authVersion ?? void 0;
1211
+ if (configVersion !== void 0 && configVersion !== "v3" && configVersion !== "v2") {
1212
+ fail(`authVersion debe ser 'v3' o 'v2' (recibido: ${JSON.stringify(configVersion)})`);
1213
1213
  }
1214
1214
  const { credentials } = config;
1215
1215
  if (!isObject3(credentials)) fail("credentials es requerido");
1216
+ const credentialsVersion = credentials.authVersion ?? void 0;
1217
+ if (credentialsVersion !== void 0 && credentialsVersion !== "v3" && credentialsVersion !== "v2") {
1218
+ fail(`credentials.authVersion debe ser 'v3' o 'v2' (recibido: ${JSON.stringify(credentialsVersion)})`);
1219
+ }
1220
+ if (configVersion !== void 0 && credentialsVersion !== void 0 && configVersion !== credentialsVersion) {
1221
+ fail(`authVersion '${configVersion}' no coincide con credentials.authVersion '${credentialsVersion}'`);
1222
+ }
1223
+ const authVersion = configVersion ?? credentialsVersion ?? "v3";
1216
1224
  requireString(credentials.username, "credentials.username");
1217
1225
  requireString(credentials.password, "credentials.password");
1218
1226
  if (authVersion === "v3") {
@@ -2975,7 +2983,8 @@ function buildCredentials(options) {
2975
2983
  requireString2(clientSecret, authVersion === "v3" ? "clientSecret (requerido con authVersion v3)" : "clientSecret");
2976
2984
  }
2977
2985
  const username = authVersion === "v3" ? `${user}-${pcc}-${domain}` : `V1:${user}:${pcc}:${domain}`;
2978
- return clientId === void 0 ? { username, password } : { clientId, clientSecret, username, password };
2986
+ if (authVersion === "v3") return { authVersion, clientId, clientSecret, username, password };
2987
+ return clientId === void 0 ? { authVersion, username, password } : { authVersion, clientId, clientSecret, username, password };
2979
2988
  }
2980
2989
 
2981
2990
  // src/queue/host-date.ts
@@ -3360,7 +3369,7 @@ function fareComponent(fareComponentId, component) {
3360
3369
  }
3361
3370
 
3362
3371
  // src/index.ts
3363
- var VERSION = "0.4.0";
3372
+ var VERSION = "0.4.1";
3364
3373
  export {
3365
3374
  Sabre,
3366
3375
  SabreBusinessError,