aves-sdk 1.0.0 → 1.0.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.md +30 -20
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -26
- package/dist/index.d.ts +12 -26
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ A comprehensive TypeScript SDK for integrating with the AVES XML REST API in Nes
|
|
|
7
7
|
- **Full NestJS Integration** - Native module with `forRoot`/`forRootAsync` support and global availability
|
|
8
8
|
- **Complete Type Safety** - Comprehensive TypeScript interfaces with clean API abstractions
|
|
9
9
|
- **Advanced Validation** - Modern Zod validation with `AvesValidator` class and utility functions
|
|
10
|
+
- **Enhanced Date Handling** - date-fns integration for robust date manipulation and validation
|
|
10
11
|
- **Error Handling** - Structured error handling with AVES-specific error codes
|
|
11
12
|
- **Configuration** - Environment-based configuration with validation
|
|
12
13
|
- **Dependency Injection** - Interface-based DI following NestJS patterns
|
|
@@ -152,7 +153,7 @@ const customer: Customer = {
|
|
|
152
153
|
title: 'mr',
|
|
153
154
|
firstName: 'John',
|
|
154
155
|
lastName: 'Doe',
|
|
155
|
-
dateOfBirth:
|
|
156
|
+
dateOfBirth: '1990-01-01',
|
|
156
157
|
gender: 'male',
|
|
157
158
|
},
|
|
158
159
|
address: {
|
|
@@ -197,7 +198,7 @@ const booking: CreateBookingRequest = {
|
|
|
197
198
|
title: 'mr',
|
|
198
199
|
firstName: 'John',
|
|
199
200
|
lastName: 'Doe',
|
|
200
|
-
dateOfBirth:
|
|
201
|
+
dateOfBirth: '1990-01-01',
|
|
201
202
|
gender: 'male',
|
|
202
203
|
},
|
|
203
204
|
],
|
|
@@ -207,8 +208,8 @@ const booking: CreateBookingRequest = {
|
|
|
207
208
|
type: 'flight',
|
|
208
209
|
status: 'confirmed',
|
|
209
210
|
description: 'Flight from NYC to LAX',
|
|
210
|
-
startDate:
|
|
211
|
-
endDate:
|
|
211
|
+
startDate: '2024-06-01',
|
|
212
|
+
endDate: '2024-06-01',
|
|
212
213
|
},
|
|
213
214
|
],
|
|
214
215
|
};
|
|
@@ -240,7 +241,7 @@ const booking: CreateBookingRequest = {
|
|
|
240
241
|
title: 'mr',
|
|
241
242
|
firstName: 'John',
|
|
242
243
|
lastName: 'Doe',
|
|
243
|
-
dateOfBirth:
|
|
244
|
+
dateOfBirth: '1990-01-01',
|
|
244
245
|
gender: 'male',
|
|
245
246
|
},
|
|
246
247
|
contact: {
|
|
@@ -322,8 +323,7 @@ Advanced validation class for comprehensive data validation scenarios.
|
|
|
322
323
|
**Utility Functions:**
|
|
323
324
|
|
|
324
325
|
- `createValidator(schema)` - Create validator instance
|
|
325
|
-
-
|
|
326
|
-
- `quickSafeValidate(data, schema)` - Quick safe validation
|
|
326
|
+
- Date utilities with date-fns integration for enhanced date manipulation
|
|
327
327
|
|
|
328
328
|
### Configuration
|
|
329
329
|
|
|
@@ -354,19 +354,35 @@ type CustomerType = 'customer' | 'agent' | 'supplier';
|
|
|
354
354
|
type BookingType = 'individual' | 'group' | 'corporate';
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
####
|
|
357
|
+
#### Date Utilities
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
Enhanced date manipulation with date-fns integration:
|
|
360
360
|
|
|
361
361
|
```typescript
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
import {
|
|
363
|
+
createDateString,
|
|
364
|
+
createDateTimeString,
|
|
365
|
+
createTimeString,
|
|
366
|
+
formatDateString,
|
|
367
|
+
isValidDateString,
|
|
368
|
+
calculateAge,
|
|
369
|
+
isValidBookingDate,
|
|
370
|
+
} from 'aves-sdk';
|
|
365
371
|
|
|
366
|
-
//
|
|
372
|
+
// Create validated date strings
|
|
367
373
|
const dateString = createDateString('2024-01-01');
|
|
368
374
|
const dateTimeString = createDateTimeString('2024-01-01T10:30:00');
|
|
369
375
|
const timeString = createTimeString('10:30:00');
|
|
376
|
+
|
|
377
|
+
// Format dates for display
|
|
378
|
+
const formattedDate = formatDateString('2024-01-01', 'MMM dd, yyyy'); // "Jan 01, 2024"
|
|
379
|
+
|
|
380
|
+
// Validate date strings
|
|
381
|
+
const isValid = isValidDateString('2024-01-01'); // true
|
|
382
|
+
|
|
383
|
+
// AVES-specific utilities
|
|
384
|
+
const age = calculateAge('1990-01-01'); // Calculate customer age
|
|
385
|
+
const isBookingValid = isValidBookingDate('2024-06-01'); // Check if booking date is valid
|
|
370
386
|
```
|
|
371
387
|
|
|
372
388
|
### Validation
|
|
@@ -403,8 +419,6 @@ import {
|
|
|
403
419
|
AvesValidator,
|
|
404
420
|
configValidationSchema,
|
|
405
421
|
createValidator,
|
|
406
|
-
quickValidate,
|
|
407
|
-
quickSafeValidate,
|
|
408
422
|
} from 'aves-sdk';
|
|
409
423
|
|
|
410
424
|
// Constructor approach - validator with default schema
|
|
@@ -441,10 +455,6 @@ const searchResult = validator.safeValidateAndParse(
|
|
|
441
455
|
SearchCustomerRequestValidation
|
|
442
456
|
);
|
|
443
457
|
|
|
444
|
-
// Utility functions for quick validation
|
|
445
|
-
const validConfig = quickValidate(configData, configValidationSchema);
|
|
446
|
-
const safeResult = quickSafeValidate(configData, configValidationSchema);
|
|
447
|
-
|
|
448
458
|
// Factory function approach
|
|
449
459
|
const validator = createValidator(configValidationSchema);
|
|
450
460
|
const result = validator.validate(configData);
|
|
@@ -686,6 +696,6 @@ For issues and questions:
|
|
|
686
696
|
|
|
687
697
|
- Replaced `class-validator` with Zod validation
|
|
688
698
|
- Introduced clean API interfaces alongside XML interfaces
|
|
689
|
-
-
|
|
699
|
+
- Enhanced date utilities with date-fns integration
|
|
690
700
|
- Updated module configuration with enhanced validation
|
|
691
701
|
- Improved error handling structure
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ut=Object.create;var S=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var Et=(e,t,n)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var o=(e,t)=>S(e,"name",{value:t,configurable:!0});var gt=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},Ae=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!lt.call(e,s)&&s!==n&&S(e,s,{get:()=>t[s],enumerable:!(i=ct(t,s))||i.enumerable});return e};var It=(e,t,n)=>(n=e!=null?ut(ft(e)):{},Ae(t||!e||!e.__esModule?S(n,"default",{value:e,enumerable:!0}):n,e)),Rt=e=>Ae(S({},"__esModule",{value:!0}),e);var p=(e,t,n)=>Et(e,typeof t!="symbol"?t+"":t,n);var Vt={};gt(Vt,{AVES_CONFIG_NAMESPACE:()=>nt,AVES_SDK_CONFIG:()=>g,AddressValidation:()=>rt,AvesErrorCodes:()=>a,AvesErrorHandler:()=>O,AvesException:()=>c,AvesModule:()=>C,AvesService:()=>E,AvesSeverity:()=>d,AvesStatus:()=>Mt,AvesValidator:()=>ue,BookFileRQValidation:()=>Ft,CancelFileRQValidation:()=>_t,ContactInfoValidation:()=>it,LanguageCodeValidation:()=>ot,PassengerValidation:()=>at,PaymentValidation:()=>Ot,PrintBookingDocumentRQValidation:()=>Xt,SearchMasterRecordRQValidation:()=>Pt,ServiceValidation:()=>st,XML_HTTP_CLIENT:()=>R,XmlHttpClient:()=>y,avesConfig:()=>me,configValidationSchema:()=>he,createAvesValidator:()=>bt,createDateString:()=>l,createDateTimeString:()=>I,createTimeString:()=>Ce,getCurrentDateString:()=>yt,getCurrentDateTimeString:()=>Tt,isValidDateString:()=>St,isValidDateTimeString:()=>ht,isValidTimeString:()=>Nt,mapAddPaymentToXml:()=>je,mapAddressToXml:()=>te,mapAddressTypeFromXml:()=>F,mapAddressTypeToXml:()=>P,mapBookingFromXml:()=>ie,mapBookingResponseFromXml:()=>qe,mapBookingTypeToXml:()=>K,mapCancelBookingToXml:()=>He,mapCancelReasonToXml:()=>Y,mapCancelResponseFromXml:()=>Qe,mapContactToXml:()=>oe,mapContactTypeFromXml:()=>X,mapContactTypeToXml:()=>_,mapCreateBookingToXml:()=>xe,mapCustomerToXml:()=>ge,mapCustomerTypeToXml:()=>D,mapDeliveryMethodToXml:()=>J,mapDocumentFormatToXml:()=>Z,mapDocumentResponseFromXml:()=>We,mapDocumentTypeToXml:()=>z,mapEmailTypeFromXml:()=>M,mapEmailTypeToXml:()=>L,mapMasterRecordFromXml:()=>$e,mapPassengerToXml:()=>fe,mapPassengerTypeFromXml:()=>v,mapPassengerTypeToXml:()=>b,mapPaymentResponseFromXml:()=>Ye,mapPaymentStatusFromXml:()=>q,mapPaymentStatusToXml:()=>G,mapPaymentToXml:()=>Ee,mapPaymentTypeFromXml:()=>j,mapPaymentTypeToXml:()=>k,mapPrintDocumentToXml:()=>ke,mapPriorityToXml:()=>W,mapRefundMethodToXml:()=>$,mapSearchCustomerToXml:()=>Ue,mapSearchOperatorToXml:()=>ee,mapSearchResponseFromXml:()=>Ke,mapServiceStatusFromXml:()=>H,mapServiceStatusToXml:()=>x,mapServiceToXml:()=>le,mapServiceTypeFromXml:()=>U,mapServiceTypeToXml:()=>B,mapSpecialRequestTypeToXml:()=>Q,mapTitleFromXml:()=>w,mapTitleToXml:()=>V});module.exports=Rt(Vt);var Mn=require("reflect-metadata");var l=o(e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error(`Invalid date format. Expected YYYY-MM-DD, got: ${e}`);let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date value: ${e}`);return e},"createDateString"),I=o(e=>{if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/.test(e))throw new Error(`Invalid datetime format. Expected ISO 8601, got: ${e}`);let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid datetime value: ${e}`);return e},"createDateTimeString"),Ce=o(e=>{if(!/^\d{2}:\d{2}:\d{2}$/.test(e))throw new Error(`Invalid time format. Expected HH:MM:SS, got: ${e}`);let[t,n,i]=e.split(":").map(Number);if(t<0||t>23||n<0||n>59||i<0||i>59)throw new Error(`Invalid time value: ${e}`);return e},"createTimeString"),yt=o(()=>l(new Date().toISOString().split("T")[0]),"getCurrentDateString"),Tt=o(()=>I(new Date().toISOString()),"getCurrentDateTimeString"),St=o(e=>{try{return l(e),!0}catch{return!1}},"isValidDateString"),ht=o(e=>{try{return I(e),!0}catch{return!1}},"isValidDateTimeString"),Nt=o(e=>{try{return Ce(e),!0}catch{return!1}},"isValidTimeString");function P(e){return{home:"HOME",work:"WORK",billing:"BILLING",delivery:"DELIVERY"}[e]||"HOME"}o(P,"mapAddressTypeToXml");function F(e){return{HOME:"home",WORK:"work",BILLING:"billing",DELIVERY:"delivery"}[e]||"home"}o(F,"mapAddressTypeFromXml");function _(e){return{home:"HOME",work:"WORK",mobile:"MOBILE",fax:"FAX"}[e]||"HOME"}o(_,"mapContactTypeToXml");function X(e){return{HOME:"home",WORK:"work",MOBILE:"mobile",FAX:"fax"}[e]||"home"}o(X,"mapContactTypeFromXml");function L(e){return{home:"HOME",work:"WORK"}[e]||"HOME"}o(L,"mapEmailTypeToXml");function M(e){return{HOME:"home",WORK:"work"}[e]||"home"}o(M,"mapEmailTypeFromXml");function b(e){return{adult:"ADT",child:"CHD",infant:"INF"}[e]||"ADT"}o(b,"mapPassengerTypeToXml");function v(e){return{ADT:"adult",CHD:"child",INF:"infant"}[e]||"adult"}o(v,"mapPassengerTypeFromXml");function V(e){return{mr:"MR",mrs:"MRS",ms:"MS",dr:"DR",prof:"PROF"}[e]||"MR"}o(V,"mapTitleToXml");function w(e){return{MR:"mr",MRS:"mrs",MS:"ms",DR:"dr",PROF:"prof"}[e]||"mr"}o(w,"mapTitleFromXml");function B(e){return{flight:"FLIGHT",hotel:"HOTEL",car:"CAR",transfer:"TRANSFER",insurance:"INSURANCE"}[e]||"FLIGHT"}o(B,"mapServiceTypeToXml");function U(e){return{FLIGHT:"flight",HOTEL:"hotel",CAR:"car",TRANSFER:"transfer",INSURANCE:"insurance"}[e]||"flight"}o(U,"mapServiceTypeFromXml");function x(e){return{confirmed:"CONFIRMED",pending:"PENDING",cancelled:"CANCELLED"}[e]||"PENDING"}o(x,"mapServiceStatusToXml");function H(e){return{CONFIRMED:"confirmed",PENDING:"pending",CANCELLED:"cancelled"}[e]||"pending"}o(H,"mapServiceStatusFromXml");function k(e){return{credit_card:"CREDIT_CARD",debit_card:"DEBIT_CARD",bank_transfer:"BANK_TRANSFER",cash:"CASH"}[e]||"CASH"}o(k,"mapPaymentTypeToXml");function j(e){return{CREDIT_CARD:"credit_card",DEBIT_CARD:"debit_card",BANK_TRANSFER:"bank_transfer",CASH:"cash"}[e]||"cash"}o(j,"mapPaymentTypeFromXml");function G(e){return{pending:"PENDING",confirmed:"CONFIRMED",failed:"FAILED"}[e]||"PENDING"}o(G,"mapPaymentStatusToXml");function q(e){return{PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"}[e]||"pending"}o(q,"mapPaymentStatusFromXml");function D(e){return{customer:"CUSTOMER",agent:"AGENT",supplier:"SUPPLIER"}[e]||"CUSTOMER"}o(D,"mapCustomerTypeToXml");function Oe(e){return{CUSTOMER:"customer",AGENT:"agent",SUPPLIER:"supplier"}[e]||"customer"}o(Oe,"mapCustomerTypeFromXml");function Pe(e){return{active:"ACTIVE",inactive:"INACTIVE",suspended:"SUSPENDED"}[e]||"ACTIVE"}o(Pe,"mapCustomerStatusToXml");function Fe(e){return{ACTIVE:"active",INACTIVE:"inactive",SUSPENDED:"suspended"}[e]||"active"}o(Fe,"mapCustomerStatusFromXml");function _e(e){return{email:"EMAIL",sms:"SMS",phone:"PHONE"}[e]||"EMAIL"}o(_e,"mapCommunicationMethodToXml");function Xe(e){return{EMAIL:"email",SMS:"sms",PHONE:"phone"}[e]||"email"}o(Xe,"mapCommunicationMethodFromXml");function K(e){return{individual:"INDIVIDUAL",group:"GROUP",corporate:"CORPORATE"}[e]||"INDIVIDUAL"}o(K,"mapBookingTypeToXml");function Le(e){return{PENDING:"pending",CONFIRMED:"confirmed",CANCELLED:"cancelled",COMPLETED:"completed"}[e]||"pending"}o(Le,"mapBookingStatusFromXml");function W(e){return{low:"LOW",normal:"NORMAL",high:"HIGH",urgent:"URGENT"}[e]||"NORMAL"}o(W,"mapPriorityToXml");function Q(e){return{meal:"MEAL",seat:"SEAT",wheelchair:"WHEELCHAIR",other:"OTHER"}[e]||"OTHER"}o(Q,"mapSpecialRequestTypeToXml");function Y(e){return{customer_request:"CUSTOMER_REQUEST",no_show:"NO_SHOW",operational:"OPERATIONAL",other:"OTHER"}[e]||"OTHER"}o(Y,"mapCancelReasonToXml");function $(e){return{original_payment:"ORIGINAL_PAYMENT",credit:"CREDIT",cash:"CASH"}[e]||"CASH"}o($,"mapRefundMethodToXml");function z(e){return{confirmation:"CONFIRMATION",invoice:"INVOICE",voucher:"VOUCHER",ticket:"TICKET",all:"ALL"}[e]||"ALL"}o(z,"mapDocumentTypeToXml");function Z(e){return{pdf:"PDF",html:"HTML",xml:"XML"}[e]||"PDF"}o(Z,"mapDocumentFormatToXml");function J(e){return{email:"EMAIL",sms:"SMS",download:"DOWNLOAD"}[e]||"EMAIL"}o(J,"mapDeliveryMethodToXml");function ee(e){return{equals:"EQUALS",contains:"CONTAINS",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH"}[e]||"EQUALS"}o(ee,"mapSearchOperatorToXml");function Me(e){return{SERVICE:"service",TAX:"tax",FEE:"fee",DISCOUNT:"discount"}[e]||"service"}o(Me,"mapPricingItemTypeFromXml");function be(e){return{SENT:"sent",PENDING:"pending",FAILED:"failed"}[e]||"pending"}o(be,"mapDeliveryStatusFromXml");function de(e){return{male:"M",female:"F"}[e]||"M"}o(de,"mapGenderToXml");function ve(e){return{M:"male",F:"female"}[e]||"male"}o(ve,"mapGenderFromXml");function te(e){return{"@Type":e.type?P(e.type):void 0,Street:e.street,City:e.city,State:e.state,PostalCode:e.postalCode,Country:e.country}}o(te,"mapAddressToXml");function ne(e){return{type:e["@Type"]?F(e["@Type"]):void 0,street:e.Street,city:e.City,state:e.State,postalCode:e.PostalCode,country:e.Country}}o(ne,"mapAddressFromXml");function oe(e){return{Phone:e.phone?{"@Type":e.phone.type?_(e.phone.type):void 0,"@Number":e.phone.number}:void 0,Email:e.email?{"@Type":e.email.type?L(e.email.type):void 0,"@Address":e.email.address}:void 0}}o(oe,"mapContactToXml");function re(e){return{phone:e.Phone?{type:e.Phone["@Type"]?X(e.Phone["@Type"]):void 0,number:e.Phone["@Number"]}:void 0,email:e.Email?{type:e.Email["@Type"]?M(e.Email["@Type"]):void 0,address:e.Email["@Address"]}:void 0}}o(re,"mapContactFromXml");function fe(e){return{"@PassengerID":e.id,"@Type":b(e.type),"@Title":e.title?V(e.title):void 0,FirstName:e.firstName,LastName:e.lastName,MiddleName:e.middleName,DateOfBirth:e.dateOfBirth,Gender:e.gender?de(e.gender):void 0,Nationality:e.nationality,Passport:e.passport?{"@Number":e.passport.number,"@ExpiryDate":e.passport.expiryDate,"@IssuingCountry":e.passport.issuingCountry}:void 0,Address:e.address?te(e.address):void 0,ContactInfo:e.contact?oe(e.contact):void 0}}o(fe,"mapPassengerToXml");function Ve(e){return{id:e["@PassengerID"],type:v(e["@Type"]),title:e["@Title"]?w(e["@Title"]):void 0,firstName:e.FirstName,lastName:e.LastName,middleName:e.MiddleName,dateOfBirth:e.DateOfBirth?l(e.DateOfBirth):void 0,gender:e.Gender?ve(e.Gender):void 0,nationality:e.Nationality,passport:e.Passport?{number:e.Passport["@Number"],expiryDate:l(e.Passport["@ExpiryDate"]),issuingCountry:e.Passport["@IssuingCountry"]}:void 0,address:e.Address?ne(e.Address):void 0,contact:e.ContactInfo?re(e.ContactInfo):void 0}}o(Ve,"mapPassengerFromXml");function le(e){return{"@ServiceID":e.id,"@Type":B(e.type),"@Status":x(e.status),ServiceDetails:{Code:e.code,Name:e.name,Description:e.description,StartDate:e.startDate,EndDate:e.endDate,Price:e.price?{"@Currency":e.price.currency,"@Amount":e.price.amount}:void 0}}}o(le,"mapServiceToXml");function we(e){return{id:e["@ServiceID"],type:U(e["@Type"]),status:H(e["@Status"]),code:e.ServiceDetails.Code,name:e.ServiceDetails.Name,description:e.ServiceDetails.Description,startDate:e.ServiceDetails.StartDate?l(e.ServiceDetails.StartDate):void 0,endDate:e.ServiceDetails.EndDate?l(e.ServiceDetails.EndDate):void 0,price:e.ServiceDetails.Price?{currency:e.ServiceDetails.Price["@Currency"],amount:e.ServiceDetails.Price["@Amount"]}:void 0}}o(we,"mapServiceFromXml");function Ee(e){return{"@PaymentID":e.id,"@Type":k(e.type),"@Status":G(e.status),Amount:{"@Currency":e.amount.currency,"@Amount":e.amount.amount},PaymentDetails:e.details?{CardNumber:e.details.cardNumber,ExpiryDate:e.details.expiryDate,CardHolderName:e.details.cardHolderName}:void 0}}o(Ee,"mapPaymentToXml");function Be(e){return{id:e["@PaymentID"],type:j(e["@Type"]),status:q(e["@Status"]),amount:{currency:e.Amount["@Currency"],amount:e.Amount["@Amount"]},details:e.PaymentDetails?{cardNumber:e.PaymentDetails.CardNumber,expiryDate:e.PaymentDetails.ExpiryDate,cardHolderName:e.PaymentDetails.CardHolderName}:void 0}}o(Be,"mapPaymentFromXml");function Ue(e){return{SearchCriteria:{MasterRecordType:D(e.type),SearchFields:{Field:e.fields.map(t=>({"@Name":t.name,"@Value":t.value,"@Operator":t.operator?ee(t.operator):void 0}))},Pagination:e.pagination?{"@PageSize":e.pagination.pageSize,"@PageNumber":e.pagination.pageNumber}:void 0}}}o(Ue,"mapSearchCustomerToXml");function ge(e){return{"@MasterRecordID":e.id,"@Type":D(e.type),"@Status":Pe(e.status),PersonalInfo:e.personalInfo?{Title:e.personalInfo.title,FirstName:e.personalInfo.firstName,LastName:e.personalInfo.lastName,MiddleName:e.personalInfo.middleName,DateOfBirth:e.personalInfo.dateOfBirth,Gender:e.personalInfo.gender?de(e.personalInfo.gender):void 0,Nationality:e.personalInfo.nationality}:void 0,ContactInfo:e.contact?oe(e.contact):void 0,Address:e.address?te(e.address):void 0,BusinessInfo:e.businessInfo?{CompanyName:e.businessInfo.companyName,TaxID:e.businessInfo.taxId,LicenseNumber:e.businessInfo.licenseNumber}:void 0,Preferences:e.preferences?{Language:e.preferences.language,Currency:e.preferences.currency,CommunicationMethod:e.preferences.communicationMethod?_e(e.preferences.communicationMethod):void 0}:void 0}}o(ge,"mapCustomerToXml");function xe(e){return{BookingDetails:{"@BookingType":K(e.type),"@Priority":W(e.priority),CustomerInfo:{"@CustomerID":e.customerId,CustomerDetails:e.customerDetails?ge(e.customerDetails):void 0},PassengerList:{Passenger:e.passengers.map(fe)},SelectedServiceList:{Service:e.services.map(le)},SpecialRequests:e.specialRequests?{Request:e.specialRequests.map(t=>({"@Type":Q(t.type),"@Description":t.description}))}:void 0}}}o(xe,"mapCreateBookingToXml");function He(e){return{"@BookingFileID":e.bookingId,CancellationDetails:{"@Reason":Y(e.reason),"@Description":e.description,RefundRequest:e.refundRequest?{"@Amount":e.refundRequest.amount,"@Currency":e.refundRequest.currency,"@Method":$(e.refundRequest.method)}:void 0}}}o(He,"mapCancelBookingToXml");function ke(e){return{"@BookingFileID":e.bookingId,DocumentRequest:{"@DocumentType":z(e.documentType),"@Format":Z(e.format),"@Language":e.language,DeliveryMethod:e.deliveryMethod?{"@Type":J(e.deliveryMethod.type),"@Address":e.deliveryMethod.address}:void 0}}}o(ke,"mapPrintDocumentToXml");function je(e){return{"@BookingFileID":e.bookingId,PaymentList:{Payment:e.payments.map(Ee)}}}o(je,"mapAddPaymentToXml");function Ge(e){return{id:e["@MasterRecordID"],type:Oe(e["@Type"]),status:Fe(e["@Status"]),personalInfo:e.PersonalInfo?{title:e.PersonalInfo.Title,firstName:e.PersonalInfo.FirstName,lastName:e.PersonalInfo.LastName,middleName:e.PersonalInfo.MiddleName,dateOfBirth:e.PersonalInfo.DateOfBirth?l(e.PersonalInfo.DateOfBirth):void 0,gender:e.PersonalInfo.Gender==="M"?"male":"female",nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?re(e.ContactInfo):void 0,address:e.Address?ne(e.Address):void 0,businessInfo:e.BusinessInfo?{companyName:e.BusinessInfo.CompanyName,taxId:e.BusinessInfo.TaxID,licenseNumber:e.BusinessInfo.LicenseNumber}:void 0,preferences:e.Preferences?{language:e.Preferences.Language,currency:e.Preferences.Currency,communicationMethod:e.Preferences.CommunicationMethod?Xe(e.Preferences.CommunicationMethod):void 0}:void 0}}o(Ge,"mapCustomerFromXml");function ie(e){return{id:e["@BookingFileID"],status:Le(e["@Status"]),createdAt:I(e["@CreationDate"]),updatedAt:I(e["@LastModified"]),customer:Ge(e.CustomerInfo),passengers:e.PassengerList.Passenger.map(Ve),services:e.ServiceList.Service.map(we),pricing:{totalAmount:{currency:e.Pricing.TotalAmount["@Currency"],amount:e.Pricing.TotalAmount["@Amount"]},breakdowns:e.Pricing.Breakdown?.Item.map(t=>({type:Me(t["@Type"]),description:t["@Description"],amount:t["@Amount"]}))}}}o(ie,"mapBookingFromXml");function qe(e){let t=ie(e.BookingFile);return{...t,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:t}}o(qe,"mapBookingResponseFromXml");function Ke(e){return{results:e.SearchResults.MasterRecord.map(Ge),pagination:e.SearchResults.PaginationInfo?{totalRecords:e.SearchResults.PaginationInfo["@TotalRecords"],pageSize:e.SearchResults.PaginationInfo["@PageSize"],pageNumber:e.SearchResults.PaginationInfo["@PageNumber"],totalPages:e.SearchResults.PaginationInfo["@TotalPages"]}:void 0}}o(Ke,"mapSearchResponseFromXml");function We(e){return{id:e.DocumentInfo["@DocumentID"],type:e.DocumentInfo["@DocumentType"],format:e.DocumentInfo["@Format"],size:e.DocumentInfo["@Size"],createdAt:I(e.DocumentInfo["@CreationDate"]),downloadUrl:e.DocumentInfo.DownloadURL,deliveryStatus:e.DocumentInfo.DeliveryStatus?{status:be(e.DocumentInfo.DeliveryStatus["@Status"]),method:e.DocumentInfo.DeliveryStatus["@Method"],address:e.DocumentInfo.DeliveryStatus["@Address"]}:void 0,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"]}}o(We,"mapDocumentResponseFromXml");function Qe(e){return{success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:{refundInfo:e.OperationResult.RefundInfo?{refundAmount:e.OperationResult.RefundInfo["@RefundAmount"],currency:e.OperationResult.RefundInfo["@Currency"],refundMethod:e.OperationResult.RefundInfo["@RefundMethod"],processingTime:e.OperationResult.RefundInfo["@ProcessingTime"]}:void 0}}}o(Qe,"mapCancelResponseFromXml");function Ye(e){let t=ie(e.BookingFile);return{success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:{booking:t,paymentSummary:{totalPaid:{currency:e.PaymentSummary.TotalPaid["@Currency"],amount:e.PaymentSummary.TotalPaid["@Amount"]},outstandingAmount:{currency:e.PaymentSummary.OutstandingAmount["@Currency"],amount:e.PaymentSummary.OutstandingAmount["@Amount"]},paymentHistory:e.PaymentSummary.PaymentHistory.Payment.map(Be)}}}}o(Ye,"mapPaymentResponseFromXml");function $e(e){return{id:e["@MasterRecordID"],type:e["@Type"].toLowerCase(),status:e["@Status"].toLowerCase(),personalInfo:e.PersonalInfo?{title:e.PersonalInfo.Title,firstName:e.PersonalInfo.FirstName,lastName:e.PersonalInfo.LastName,middleName:e.PersonalInfo.MiddleName,dateOfBirth:e.PersonalInfo.DateOfBirth,gender:e.PersonalInfo.Gender?.toLowerCase(),nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?re(e.ContactInfo):void 0,address:e.Address?ne(e.Address):void 0,businessInfo:e.BusinessInfo?{companyName:e.BusinessInfo.CompanyName,taxId:e.BusinessInfo.TaxID,licenseNumber:e.BusinessInfo.LicenseNumber}:void 0,preferences:e.Preferences?{language:e.Preferences.Language,currency:e.Preferences.Currency,communicationMethod:e.Preferences.CommunicationMethod?.toLowerCase()}:void 0}}o($e,"mapMasterRecordFromXml");var pe=require("@nestjs/common"),Ne=require("@nestjs/config");var A=require("@nestjs/common");var g=Symbol("AVES_SDK_CONFIG"),R=Symbol("XML_HTTP_CLIENT");var Re=class Re{constructor(t){p(this,"RqHeader");p(this,"Body");Object.assign(this,t)}};o(Re,"RequestPayload");var Ie=Re,ye=class ye{constructor(t){p(this,"Request");this.Request=new Ie(t)}};o(ye,"WrapRequestDto");var ae=ye;function Dt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}o(Dt,"_ts_decorate");function ze(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}o(ze,"_ts_metadata");function Ze(e,t){return function(n,i){t(n,i,e)}}o(Ze,"_ts_param");var Te=class Te{constructor(t,n){p(this,"config");p(this,"http");this.config=t,this.http=n}buildHeader(){let{hostId:t,xtoken:n,languageCode:i}=this.config;return{"@HostID":t,"@Xtoken":n,"@Interface":"WEB","@UserName":"WEB","@LanguageCode":i}}wrapRequest(t){return new ae({RqHeader:this.buildHeader(),Body:t})}async searchMasterRecord(t){return this.http.postXml("/interop/masterRecords/v2/rest/Search","SearchMasterRecordRQ",this.wrapRequest(t))}async insertOrUpdateMasterRecord(t){return this.http.postXml("/interop/masterRecords/v2/rest/InsertOrUpdate","ManageMasterRecordRQ",this.wrapRequest(t))}async createBookingFile(t){return this.http.postXml("/interop/booking/v2/rest/CreateBookingFile","BookFileRQ",this.wrapRequest(t))}async modBookingFileHeader(t){return this.http.postXml("/interop/booking/v2/rest/ModBookingFileHeader","ModiFileHeaderRQ",this.wrapRequest(t))}async modBookingFileServices(t){return this.http.postXml("/interop/booking/v2/rest/ModBookingFileServices","ModFileServicesRQ",this.wrapRequest(t))}async setBookingFileStatus(t){return this.http.postXml("/interop/booking/v2/rest/SetBookingFileStatus","SetStatusRQ",this.wrapRequest(t))}async cancelBookingFile(t){return this.http.postXml("/interop/booking/v2/rest/CancelBookingFile","CancelFileRQ",this.wrapRequest(t))}async insertFilePaymentList(t){return this.http.postXml("/interop/booking/v2/rest/InsertFilePaymentList","FilePaymentListRQ",this.wrapRequest(t))}async printBookingDocument(t){return this.http.postXml("/interop/document/v2/rest/PrintBookingDocument","PrintBookingDocumentRQ",this.wrapRequest(t))}};o(Te,"AvesService");var E=Te;E=Dt([(0,A.Injectable)(),Ze(0,(0,A.Inject)(g)),Ze(1,(0,A.Inject)(R)),ze("design:type",Function),ze("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig,typeof IXmlHttpClient>"u"?Object:IXmlHttpClient])],E);var et=It(require("axios"),1),se=require("fast-xml-parser"),h=require("@nestjs/common");function At(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}o(At,"_ts_decorate");function Je(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}o(Je,"_ts_metadata");function Ct(e,t){return function(n,i){t(n,i,e)}}o(Ct,"_ts_param");var Se=class Se{constructor(t){p(this,"config");p(this,"httpClient");p(this,"xmlBuilder");p(this,"xmlParser");this.config=t,this.httpClient=et.default.create({baseURL:t.baseUrl,timeout:typeof t.timeout=="number"?t.timeout:3e4,headers:{"Content-Type":"application/xml",Accept:"application/xml, text/xml, */*;q=0.1"},transitional:{clarifyTimeoutError:!0},validateStatus:o(n=>n>=200&&n<300,"validateStatus")}),this.xmlBuilder=new se.XMLBuilder({attributeNamePrefix:"@",ignoreAttributes:!1,suppressEmptyNode:!0,format:process.env.NODE_ENV?.toLowerCase()==="development"}),this.xmlParser=new se.XMLParser({attributeNamePrefix:"@",ignoreAttributes:!1,parseAttributeValue:!1,trimValues:!0,isArray:o(n=>["Field","Item","Service","Passenger","Payment","MasterRecord","Request","Notes","ServiceID"].includes(n),"isArray")})}async postXml(t,n,i,s){let m=this.xmlBuilder.build({[n]:i}),u=await this.httpClient.post(t,m,s);return this.xmlParser.parse(u.data)}};o(Se,"XmlHttpClient");var y=Se;y=At([(0,h.Injectable)({scope:h.Scope.DEFAULT}),Ct(0,(0,h.Inject)(g)),Je("design:type",Function),Je("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig])],y);var tt=require("@nestjs/config"),nt="aves",me=(0,tt.registerAs)(nt,()=>({baseUrl:process.env.AVES_BASE_URL??"",hostId:process.env.AVES_HOST_ID??"",xtoken:process.env.AVES_XTOKEN??"",languageCode:process.env.AVES_LANGUAGE_CODE,timeout:process.env.AVES_TIMEOUT?Number(process.env.AVES_TIMEOUT):void 0}));var r=require("zod"),ot=r.z.enum(["01","02"]),he=r.z.object({baseUrl:r.z.url(),hostId:r.z.string().length(6),xtoken:r.z.string(),languageCode:ot.optional(),timeout:r.z.number().optional()}),rt=r.z.object({"@Type":r.z.enum(["HOME","WORK","BILLING","DELIVERY"]).optional(),Street:r.z.string().max(100).optional(),City:r.z.string().max(50).optional(),State:r.z.string().max(50).optional(),PostalCode:r.z.string().max(20).optional(),Country:r.z.string().max(50).optional()}),it=r.z.object({Phone:r.z.object({"@Type":r.z.enum(["HOME","WORK","MOBILE","FAX"]).optional(),"@Number":r.z.string()}).optional(),Email:r.z.object({"@Type":r.z.enum(["HOME","WORK"]).optional(),"@Address":r.z.string()}).optional()}),at=r.z.object({"@PassengerID":r.z.string().min(1),"@Type":r.z.enum(["ADT","CHD","INF"]),"@Title":r.z.enum(["MR","MRS","MS","DR","PROF"]).optional(),FirstName:r.z.string().min(1).max(50),LastName:r.z.string().min(1).max(50),MiddleName:r.z.string().max(50).optional(),DateOfBirth:r.z.string().datetime().optional(),Gender:r.z.enum(["M","F"]).optional(),Nationality:r.z.string().max(3).optional(),Address:rt.optional(),ContactInfo:it.optional()}),st=r.z.object({"@ServiceID":r.z.string().min(1),"@Type":r.z.enum(["FLIGHT","HOTEL","CAR","TRANSFER","INSURANCE"]),"@Status":r.z.enum(["CONFIRMED","PENDING","CANCELLED"]),ServiceDetails:r.z.object({Code:r.z.string().optional(),Name:r.z.string().optional(),Description:r.z.string().optional(),StartDate:r.z.string().optional(),EndDate:r.z.string().optional(),Price:r.z.object({"@Currency":r.z.string(),"@Amount":r.z.number()}).optional()})}),Ot=r.z.object({"@PaymentID":r.z.string().min(1),"@Type":r.z.enum(["CREDIT_CARD","DEBIT_CARD","BANK_TRANSFER","CASH"]),"@Status":r.z.enum(["PENDING","CONFIRMED","FAILED"]),Amount:r.z.object({"@Currency":r.z.string(),"@Amount":r.z.number()}),PaymentDetails:r.z.object({CardNumber:r.z.string().optional(),ExpiryDate:r.z.string().optional(),CardHolderName:r.z.string().optional()}).optional()}),Pt=r.z.object({SearchCriteria:r.z.object({MasterRecordType:r.z.enum(["CUSTOMER","AGENT","SUPPLIER"]),SearchFields:r.z.object({Field:r.z.array(r.z.object({"@Name":r.z.string(),"@Value":r.z.string(),"@Operator":r.z.enum(["EQUALS","CONTAINS","STARTS_WITH","ENDS_WITH"]).optional()}))}),Pagination:r.z.object({"@PageSize":r.z.number(),"@PageNumber":r.z.number()}).optional()})}),Ft=r.z.object({BookingDetails:r.z.object({"@BookingType":r.z.enum(["INDIVIDUAL","GROUP","CORPORATE"]),"@Priority":r.z.enum(["LOW","NORMAL","HIGH","URGENT"]),CustomerInfo:r.z.object({"@CustomerID":r.z.string().optional(),CustomerDetails:r.z.any().optional()}),PassengerList:r.z.object({Passenger:r.z.array(at)}),SelectedServiceList:r.z.object({Service:r.z.array(st)}),SpecialRequests:r.z.object({Request:r.z.array(r.z.object({"@Type":r.z.enum(["MEAL","SEAT","WHEELCHAIR","OTHER"]),"@Description":r.z.string()}))}).optional()})}),_t=r.z.object({"@BookingFileID":r.z.string().min(1),CancellationDetails:r.z.object({"@Reason":r.z.enum(["CUSTOMER_REQUEST","NO_SHOW","OPERATIONAL","OTHER"]),"@Description":r.z.string().optional(),RefundRequest:r.z.object({"@Amount":r.z.number(),"@Currency":r.z.string(),"@Method":r.z.enum(["ORIGINAL_PAYMENT","CREDIT","CASH"])}).optional()})}),Xt=r.z.object({"@BookingFileID":r.z.string().min(1),DocumentRequest:r.z.object({"@DocumentType":r.z.enum(["CONFIRMATION","INVOICE","VOUCHER","TICKET","ALL"]),"@Format":r.z.enum(["PDF","HTML","XML"]),"@Language":r.z.string().optional(),DeliveryMethod:r.z.object({"@Type":r.z.enum(["EMAIL","SMS","DOWNLOAD"]),"@Address":r.z.string().optional()}).optional()})});function Lt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}o(Lt,"_ts_decorate");var T=class T{static forRoot(t){let n=this.validateConfig(t);return{module:T,imports:[Ne.ConfigModule.forFeature(me)],providers:[{provide:g,useValue:n},this.createXmlHttpClientProvider(),E],exports:[E,R]}}static forRootAsync(t){let n=this.createAsyncProviders(t);return{module:T,imports:[...t.imports??[],Ne.ConfigModule.forFeature(me)],providers:[...n,this.createXmlHttpClientProvider(),E],exports:[E,R]}}static createXmlHttpClientProvider(){return{provide:R,useClass:y}}static createAsyncProviders(t){if(t.useFactory)return[{provide:g,useFactory:o(async(...s)=>{try{let m=await t.useFactory(...s);return this.validateConfig(m)}catch(m){throw new Error(`Failed to create Aves configuration: ${m.message}`)}},"useFactory"),inject:t.inject??[]}];let n=t.useClass||t.useExisting;if(!n)throw new Error("Invalid AvesModule async options: provide useFactory, useClass, or useExisting");let i=[{provide:g,useFactory:o(async s=>{try{let m=await s.createAvesOptions();return this.validateConfig(m)}catch(m){throw new Error(`Failed to create Aves configuration: ${m.message}`)}},"useFactory"),inject:[n]}];return t.useClass&&i.push({provide:t.useClass,useClass:t.useClass}),i}static validateConfig(t){let n=he.safeParse(t);if(!n.success)throw new Error(`Invalid AVES SDK configuration: ${n.error.issues.map(i=>i.message).join(", ")}`);return n.data}};o(T,"AvesModule"),p(T,"MODULE_NAME","AvesModule"),p(T,"VERSION","1.0.0");var C=T;C=Lt([(0,pe.Global)(),(0,pe.Module)({})],C);var Mt=(function(e){return e.OK="OK",e.ERROR="ERROR",e.WARNING="WARNING",e.TIMEOUT="TIMEOUT",e})({}),d=(function(e){return e.ERROR="ERROR",e.WARNING="WARNING",e.INFO="INFO",e})({}),a=(function(e){return e.INVALID_TOKEN="AVES_001",e.TOKEN_EXPIRED="AVES_002",e.INSUFFICIENT_PERMISSIONS="AVES_003",e.INVALID_REQUEST_FORMAT="AVES_100",e.MISSING_REQUIRED_FIELD="AVES_101",e.INVALID_FIELD_VALUE="AVES_102",e.INVALID_DATE_FORMAT="AVES_103",e.BOOKING_NOT_FOUND="AVES_200",e.BOOKING_ALREADY_CANCELLED="AVES_201",e.INVALID_BOOKING_STATUS="AVES_202",e.PAYMENT_FAILED="AVES_203",e.INSUFFICIENT_INVENTORY="AVES_204",e.INTERNAL_SERVER_ERROR="AVES_500",e.SERVICE_UNAVAILABLE="AVES_501",e.TIMEOUT="AVES_502",e.RATE_LIMIT_EXCEEDED="AVES_503",e})({});var mt=require("zod");var ce=class ce{constructor(t){p(this,"schema");this.schema=t}validate(t){if(!this.schema)throw new Error("No schema provided. Either pass schema to constructor or as method parameter.");return this.schema.parse(t)}async asyncValidate(t){if(!this.schema)throw new Error("No schema provided. Either pass schema to constructor or as method parameter.");return this.schema.parseAsync(t)}safeValidateAndParse(t){return this.schema?this.schema.safeParse(t):this.createError({message:"No schema provided. Either pass schema to constructor or as method parameter.",path:[]})}async safeAsyncValidateAndParse(t){return this.schema?this.schema.safeParseAsync(t):this.createError({message:"No schema provided. Either pass schema to constructor or as method parameter.",path:[]})}getErrorMessage(t,n="; "){return t.issues.map(i=>`${i.path.length>0?`${i.path.join(".")}: `:""}${i.message}`).join(n)}createError({message:t,path:n}){return{success:!1,error:new mt.ZodError([{code:"custom",message:t,path:n}])}}static withSchema(t){return new ce(t)}};o(ce,"AvesValidator");var ue=ce;function bt(e){return new ue(e)}o(bt,"createAvesValidator");var pt=require("@nestjs/common");var N=class N extends Error{constructor(n,i,s={}){super(i);p(this,"code");p(this,"severity");p(this,"timestamp");p(this,"requestId");p(this,"context");this.name="AvesException",this.code=n,this.severity=s.severity||d.ERROR,this.timestamp=new Date().toISOString(),this.context=s.context,this.requestId=s.requestId||this.generateRequestId(),Object.setPrototypeOf(this,N.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,N)}static fromAvesError(n){return new N(n.code,n.message,{severity:n.severity,context:n.context,requestId:n.requestId})}isRetryable(){return[a.TIMEOUT,a.SERVICE_UNAVAILABLE,a.INTERNAL_SERVER_ERROR,a.RATE_LIMIT_EXCEEDED].includes(this.code)}getUserFriendlyMessage(){return{[a.INVALID_TOKEN]:"Your session has expired. Please log in again.",[a.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[a.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[a.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[a.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[a.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[a.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[a.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[a.TIMEOUT]:"The request timed out. Please try again.",[a.RATE_LIMIT_EXCEEDED]:"Too many requests. Please wait a moment and try again."}[this.code]||this.message}toJSON(){return{name:this.name,code:this.code,message:this.message,severity:this.severity,timestamp:this.timestamp,requestId:this.requestId,context:this.context,stack:this.stack,isRetryable:this.isRetryable(),userFriendlyMessage:this.getUserFriendlyMessage()}}toAvesError(){return{code:this.code,message:this.message,severity:this.severity,timestamp:this.timestamp,requestId:this.requestId,context:this.context}}getHttpStatusCode(){switch(this.code){case a.INVALID_TOKEN:case a.TOKEN_EXPIRED:return 401;case a.INSUFFICIENT_PERMISSIONS:return 403;case a.BOOKING_NOT_FOUND:return 404;case a.INVALID_REQUEST_FORMAT:case a.MISSING_REQUIRED_FIELD:case a.INVALID_FIELD_VALUE:return 400;case a.RATE_LIMIT_EXCEEDED:return 429;case a.SERVICE_UNAVAILABLE:return 503;case a.TIMEOUT:return 408;default:return 500}}getCategory(){return this.code.startsWith("AVES_1")?"Authentication":this.code.startsWith("AVES_2")?"Business Logic":this.code.startsWith("AVES_5")?"System":"Unknown"}generateRequestId(){return`aves_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}};o(N,"AvesException");var c=N;function vt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}o(vt,"_ts_decorate");var De=class De{parseError(t){return t instanceof c?t:this.isHttpError(t)?this.parseHttpError(t):this.isAvesXmlResponse(t)?this.parseAvesXmlError(t):t instanceof Error?new c(a.INTERNAL_SERVER_ERROR,t.message,{severity:d.ERROR,context:this.buildContext({type:"javascript_error",errorName:t.name,stack:t.stack||"No stack trace available"})}):new c(a.INTERNAL_SERVER_ERROR,"Unknown error occurred",{severity:d.ERROR,context:this.buildContext({type:"unknown_error",errorName:typeof t,errorValue:String(t)})})}parseHttpError(t){if(t.response){let n=t.response.status,i=t.response.statusText;switch(n){case 400:return new c(a.INVALID_REQUEST_FORMAT,`Bad Request: ${i}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",errorName:n,statusText:i,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 401:return new c(a.INVALID_TOKEN,"Authentication failed",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 403:return new c(a.INSUFFICIENT_PERMISSIONS,"Access forbidden",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 404:return new c(a.BOOKING_NOT_FOUND,"Resource not found",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 429:return new c(a.RATE_LIMIT_EXCEEDED,"Rate limit exceeded",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,retryAfter:t.response.headers?.["retry-after"]})});case 500:return new c(a.INTERNAL_SERVER_ERROR,"Internal server error",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 503:return new c(a.SERVICE_UNAVAILABLE,"Service unavailable",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});default:return new c(a.INTERNAL_SERVER_ERROR,`HTTP ${n}: ${i}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,statusText:i,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})})}}else return t.request?new c(a.TIMEOUT,"Request timeout - no response from AVES API",{severity:d.ERROR,context:this.buildContext({type:"http_error",timeout:!0,url:t.config?.url,method:t.config?.method,configuredTimeout:t.config?.timeout})}):new c(a.INTERNAL_SERVER_ERROR,`Request setup error: ${t.message}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",setupError:!0})})}parseAvesXmlError(t){if(!t?.Response?.RsStatus)return new c(a.INVALID_REQUEST_FORMAT,"Invalid response format from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",missingRsStatus:!0})});let n=t.Response.RsStatus;if(n["@Status"]==="ERROR")return new c(n.ErrorCode||a.INTERNAL_SERVER_ERROR,n.ErrorDescription||"Unknown error from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",originalResponse:n})});if(n.Warnings?.Warning){let i=Array.isArray(n.Warnings.Warning)?n.Warnings.Warning:[n.Warnings.Warning];return new c(a.INVALID_FIELD_VALUE,i.join("; "),{severity:d.WARNING,context:this.buildContext({type:"aves_xml_warning",warnings:i})})}return new c(a.INTERNAL_SERVER_ERROR,"Unexpected response from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",unexpectedResponse:!0,status:n["@Status"]})})}isRetryable(t){return[a.TIMEOUT,a.SERVICE_UNAVAILABLE,a.INTERNAL_SERVER_ERROR,a.RATE_LIMIT_EXCEEDED].includes(t.code)}getUserFriendlyMessage(t){return{[a.INVALID_TOKEN]:"Your session has expired. Please log in again.",[a.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[a.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[a.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[a.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[a.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[a.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[a.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[a.TIMEOUT]:"The request timed out. Please try again.",[a.RATE_LIMIT_EXCEEDED]:"Too many requests. Please wait a moment and try again."}[t.code]||t.message}buildContext(t){let n={};return typeof t=="object"&&t!==null?Object.keys(t).forEach(i=>{let s=t[i];if(this.isSensitiveKey(i)){n[i]="********";return}this.isSerializableValue(s)?n[i]=s:typeof s=="function"?n[i]="[Function]":s instanceof Error?n[i]={name:s.name,message:s.message,stack:s.stack?.split(`
|
|
1
|
+
var ut=Object.create;var h=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var Et=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var r=(e,t)=>h(e,"name",{value:t,configurable:!0});var gt=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},Ce=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!lt.call(e,s)&&s!==n&&h(e,s,{get:()=>t[s],enumerable:!(i=ct(t,s))||i.enumerable});return e};var It=(e,t,n)=>(n=e!=null?ut(ft(e)):{},Ce(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),Rt=e=>Ce(h({},"__esModule",{value:!0}),e);var p=(e,t,n)=>Et(e,typeof t!="symbol"?t+"":t,n);var Lt={};gt(Lt,{AVES_CONFIG_NAMESPACE:()=>nt,AVES_SDK_CONFIG:()=>g,AddressValidation:()=>rt,AvesErrorCodes:()=>a,AvesErrorHandler:()=>P,AvesException:()=>c,AvesModule:()=>O,AvesService:()=>l,AvesSeverity:()=>d,AvesStatus:()=>Ft,AvesValidator:()=>ce,BookFileRQValidation:()=>At,CancelFileRQValidation:()=>Ct,ContactInfoValidation:()=>it,LanguageCodeValidation:()=>ot,PassengerValidation:()=>at,PaymentValidation:()=>Nt,PrintBookingDocumentRQValidation:()=>Ot,SearchMasterRecordRQValidation:()=>Dt,ServiceValidation:()=>st,XML_HTTP_CLIENT:()=>R,XmlHttpClient:()=>y,avesConfig:()=>pe,configValidationSchema:()=>Ne,createAvesValidator:()=>_t,createDateString:()=>I,createDateTimeString:()=>D,createTimeString:()=>yt,mapAddPaymentToXml:()=>je,mapAddressToXml:()=>ne,mapAddressTypeFromXml:()=>_,mapAddressTypeToXml:()=>F,mapBookingFromXml:()=>ae,mapBookingResponseFromXml:()=>qe,mapBookingTypeToXml:()=>W,mapCancelBookingToXml:()=>xe,mapCancelReasonToXml:()=>$,mapCancelResponseFromXml:()=>Qe,mapContactToXml:()=>re,mapContactTypeFromXml:()=>L,mapContactTypeToXml:()=>X,mapCreateBookingToXml:()=>He,mapCustomerToXml:()=>Ie,mapCustomerTypeToXml:()=>A,mapDeliveryMethodToXml:()=>ee,mapDocumentFormatToXml:()=>J,mapDocumentResponseFromXml:()=>We,mapDocumentTypeToXml:()=>Z,mapEmailTypeFromXml:()=>b,mapEmailTypeToXml:()=>M,mapMasterRecordFromXml:()=>$e,mapPassengerToXml:()=>le,mapPassengerTypeFromXml:()=>V,mapPassengerTypeToXml:()=>v,mapPaymentResponseFromXml:()=>Ye,mapPaymentStatusFromXml:()=>K,mapPaymentStatusToXml:()=>q,mapPaymentToXml:()=>ge,mapPaymentTypeFromXml:()=>G,mapPaymentTypeToXml:()=>j,mapPrintDocumentToXml:()=>ke,mapPriorityToXml:()=>Q,mapRefundMethodToXml:()=>z,mapSearchCustomerToXml:()=>Ue,mapSearchOperatorToXml:()=>te,mapSearchResponseFromXml:()=>Ke,mapServiceStatusFromXml:()=>k,mapServiceStatusToXml:()=>x,mapServiceToXml:()=>Ee,mapServiceTypeFromXml:()=>H,mapServiceTypeToXml:()=>U,mapSpecialRequestTypeToXml:()=>Y,mapTitleFromXml:()=>B,mapTitleToXml:()=>w});module.exports=Rt(Lt);var Fn=require("reflect-metadata");var E=require("date-fns");var I=r(e=>{let t;if(typeof e=="string"){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error(`Invalid date format. Expected YYYY-MM-DD, got: ${e}`);try{t=(0,E.parseISO)(e)}catch{throw new Error(`Invalid date string: ${e}`)}}else t=e;if(!(0,E.isValid)(t))throw new Error(`Invalid date value: ${e}`);return(0,E.format)(t,"yyyy-MM-dd")},"createDateString"),D=r(e=>{let t;if(typeof e=="string"){if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/.test(e))throw new Error(`Invalid datetime format. Expected ISO 8601, got: ${e}`);try{t=(0,E.parseISO)(e)}catch{throw new Error(`Invalid datetime string: ${e}`)}}else t=e;if(!(0,E.isValid)(t))throw new Error(`Invalid datetime value: ${e}`);return(0,E.format)(t,"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")},"createDateTimeString"),yt=r(e=>{if(!/^\d{2}:\d{2}:\d{2}$/.test(e))throw new Error(`Invalid time format. Expected HH:MM:SS, got: ${e}`);let[t,n,i]=e.split(":").map(Number);if(t<0||t>23||n<0||n>59||i<0||i>59)throw new Error(`Invalid time value: ${e}`);return e},"createTimeString");function F(e){return{home:"HOME",work:"WORK",billing:"BILLING",delivery:"DELIVERY"}[e]||"HOME"}r(F,"mapAddressTypeToXml");function _(e){return{HOME:"home",WORK:"work",BILLING:"billing",DELIVERY:"delivery"}[e]||"home"}r(_,"mapAddressTypeFromXml");function X(e){return{home:"HOME",work:"WORK",mobile:"MOBILE",fax:"FAX"}[e]||"HOME"}r(X,"mapContactTypeToXml");function L(e){return{HOME:"home",WORK:"work",MOBILE:"mobile",FAX:"fax"}[e]||"home"}r(L,"mapContactTypeFromXml");function M(e){return{home:"HOME",work:"WORK"}[e]||"HOME"}r(M,"mapEmailTypeToXml");function b(e){return{HOME:"home",WORK:"work"}[e]||"home"}r(b,"mapEmailTypeFromXml");function v(e){return{adult:"ADT",child:"CHD",infant:"INF"}[e]||"ADT"}r(v,"mapPassengerTypeToXml");function V(e){return{ADT:"adult",CHD:"child",INF:"infant"}[e]||"adult"}r(V,"mapPassengerTypeFromXml");function w(e){return{mr:"MR",mrs:"MRS",ms:"MS",dr:"DR",prof:"PROF"}[e]||"MR"}r(w,"mapTitleToXml");function B(e){return{MR:"mr",MRS:"mrs",MS:"ms",DR:"dr",PROF:"prof"}[e]||"mr"}r(B,"mapTitleFromXml");function U(e){return{flight:"FLIGHT",hotel:"HOTEL",car:"CAR",transfer:"TRANSFER",insurance:"INSURANCE"}[e]||"FLIGHT"}r(U,"mapServiceTypeToXml");function H(e){return{FLIGHT:"flight",HOTEL:"hotel",CAR:"car",TRANSFER:"transfer",INSURANCE:"insurance"}[e]||"flight"}r(H,"mapServiceTypeFromXml");function x(e){return{confirmed:"CONFIRMED",pending:"PENDING",cancelled:"CANCELLED"}[e]||"PENDING"}r(x,"mapServiceStatusToXml");function k(e){return{CONFIRMED:"confirmed",PENDING:"pending",CANCELLED:"cancelled"}[e]||"pending"}r(k,"mapServiceStatusFromXml");function j(e){return{credit_card:"CREDIT_CARD",debit_card:"DEBIT_CARD",bank_transfer:"BANK_TRANSFER",cash:"CASH"}[e]||"CASH"}r(j,"mapPaymentTypeToXml");function G(e){return{CREDIT_CARD:"credit_card",DEBIT_CARD:"debit_card",BANK_TRANSFER:"bank_transfer",CASH:"cash"}[e]||"cash"}r(G,"mapPaymentTypeFromXml");function q(e){return{pending:"PENDING",confirmed:"CONFIRMED",failed:"FAILED"}[e]||"PENDING"}r(q,"mapPaymentStatusToXml");function K(e){return{PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"}[e]||"pending"}r(K,"mapPaymentStatusFromXml");function A(e){return{customer:"CUSTOMER",agent:"AGENT",supplier:"SUPPLIER"}[e]||"CUSTOMER"}r(A,"mapCustomerTypeToXml");function Oe(e){return{CUSTOMER:"customer",AGENT:"agent",SUPPLIER:"supplier"}[e]||"customer"}r(Oe,"mapCustomerTypeFromXml");function Pe(e){return{active:"ACTIVE",inactive:"INACTIVE",suspended:"SUSPENDED"}[e]||"ACTIVE"}r(Pe,"mapCustomerStatusToXml");function Fe(e){return{ACTIVE:"active",INACTIVE:"inactive",SUSPENDED:"suspended"}[e]||"active"}r(Fe,"mapCustomerStatusFromXml");function _e(e){return{email:"EMAIL",sms:"SMS",phone:"PHONE"}[e]||"EMAIL"}r(_e,"mapCommunicationMethodToXml");function Xe(e){return{EMAIL:"email",SMS:"sms",PHONE:"phone"}[e]||"email"}r(Xe,"mapCommunicationMethodFromXml");function W(e){return{individual:"INDIVIDUAL",group:"GROUP",corporate:"CORPORATE"}[e]||"INDIVIDUAL"}r(W,"mapBookingTypeToXml");function Le(e){return{PENDING:"pending",CONFIRMED:"confirmed",CANCELLED:"cancelled",COMPLETED:"completed"}[e]||"pending"}r(Le,"mapBookingStatusFromXml");function Q(e){return{low:"LOW",normal:"NORMAL",high:"HIGH",urgent:"URGENT"}[e]||"NORMAL"}r(Q,"mapPriorityToXml");function Y(e){return{meal:"MEAL",seat:"SEAT",wheelchair:"WHEELCHAIR",other:"OTHER"}[e]||"OTHER"}r(Y,"mapSpecialRequestTypeToXml");function $(e){return{customer_request:"CUSTOMER_REQUEST",no_show:"NO_SHOW",operational:"OPERATIONAL",other:"OTHER"}[e]||"OTHER"}r($,"mapCancelReasonToXml");function z(e){return{original_payment:"ORIGINAL_PAYMENT",credit:"CREDIT",cash:"CASH"}[e]||"CASH"}r(z,"mapRefundMethodToXml");function Z(e){return{confirmation:"CONFIRMATION",invoice:"INVOICE",voucher:"VOUCHER",ticket:"TICKET",all:"ALL"}[e]||"ALL"}r(Z,"mapDocumentTypeToXml");function J(e){return{pdf:"PDF",html:"HTML",xml:"XML"}[e]||"PDF"}r(J,"mapDocumentFormatToXml");function ee(e){return{email:"EMAIL",sms:"SMS",download:"DOWNLOAD"}[e]||"EMAIL"}r(ee,"mapDeliveryMethodToXml");function te(e){return{equals:"EQUALS",contains:"CONTAINS",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH"}[e]||"EQUALS"}r(te,"mapSearchOperatorToXml");function Me(e){return{SERVICE:"service",TAX:"tax",FEE:"fee",DISCOUNT:"discount"}[e]||"service"}r(Me,"mapPricingItemTypeFromXml");function be(e){return{SENT:"sent",PENDING:"pending",FAILED:"failed"}[e]||"pending"}r(be,"mapDeliveryStatusFromXml");function fe(e){return{male:"M",female:"F"}[e]||"M"}r(fe,"mapGenderToXml");function ve(e){return{M:"male",F:"female"}[e]||"male"}r(ve,"mapGenderFromXml");function ne(e){return{"@Type":e.type?F(e.type):void 0,Street:e.street,City:e.city,State:e.state,PostalCode:e.postalCode,Country:e.country}}r(ne,"mapAddressToXml");function oe(e){return{type:e["@Type"]?_(e["@Type"]):void 0,street:e.Street,city:e.City,state:e.State,postalCode:e.PostalCode,country:e.Country}}r(oe,"mapAddressFromXml");function re(e){return{Phone:e.phone?{"@Type":e.phone.type?X(e.phone.type):void 0,"@Number":e.phone.number}:void 0,Email:e.email?{"@Type":e.email.type?M(e.email.type):void 0,"@Address":e.email.address}:void 0}}r(re,"mapContactToXml");function ie(e){return{phone:e.Phone?{type:e.Phone["@Type"]?L(e.Phone["@Type"]):void 0,number:e.Phone["@Number"]}:void 0,email:e.Email?{type:e.Email["@Type"]?b(e.Email["@Type"]):void 0,address:e.Email["@Address"]}:void 0}}r(ie,"mapContactFromXml");function le(e){return{"@PassengerID":e.id,"@Type":v(e.type),"@Title":e.title?w(e.title):void 0,FirstName:e.firstName,LastName:e.lastName,MiddleName:e.middleName,DateOfBirth:e.dateOfBirth,Gender:e.gender?fe(e.gender):void 0,Nationality:e.nationality,Passport:e.passport?{"@Number":e.passport.number,"@ExpiryDate":e.passport.expiryDate,"@IssuingCountry":e.passport.issuingCountry}:void 0,Address:e.address?ne(e.address):void 0,ContactInfo:e.contact?re(e.contact):void 0}}r(le,"mapPassengerToXml");function Ve(e){return{id:e["@PassengerID"],type:V(e["@Type"]),title:e["@Title"]?B(e["@Title"]):void 0,firstName:e.FirstName,lastName:e.LastName,middleName:e.MiddleName,dateOfBirth:e.DateOfBirth?I(e.DateOfBirth):void 0,gender:e.Gender?ve(e.Gender):void 0,nationality:e.Nationality,passport:e.Passport?{number:e.Passport["@Number"],expiryDate:I(e.Passport["@ExpiryDate"]),issuingCountry:e.Passport["@IssuingCountry"]}:void 0,address:e.Address?oe(e.Address):void 0,contact:e.ContactInfo?ie(e.ContactInfo):void 0}}r(Ve,"mapPassengerFromXml");function Ee(e){return{"@ServiceID":e.id,"@Type":U(e.type),"@Status":x(e.status),ServiceDetails:{Code:e.code,Name:e.name,Description:e.description,StartDate:e.startDate,EndDate:e.endDate,Price:e.price?{"@Currency":e.price.currency,"@Amount":e.price.amount}:void 0}}}r(Ee,"mapServiceToXml");function we(e){return{id:e["@ServiceID"],type:H(e["@Type"]),status:k(e["@Status"]),code:e.ServiceDetails.Code,name:e.ServiceDetails.Name,description:e.ServiceDetails.Description,startDate:e.ServiceDetails.StartDate?I(e.ServiceDetails.StartDate):void 0,endDate:e.ServiceDetails.EndDate?I(e.ServiceDetails.EndDate):void 0,price:e.ServiceDetails.Price?{currency:e.ServiceDetails.Price["@Currency"],amount:e.ServiceDetails.Price["@Amount"]}:void 0}}r(we,"mapServiceFromXml");function ge(e){return{"@PaymentID":e.id,"@Type":j(e.type),"@Status":q(e.status),Amount:{"@Currency":e.amount.currency,"@Amount":e.amount.amount},PaymentDetails:e.details?{CardNumber:e.details.cardNumber,ExpiryDate:e.details.expiryDate,CardHolderName:e.details.cardHolderName}:void 0}}r(ge,"mapPaymentToXml");function Be(e){return{id:e["@PaymentID"],type:G(e["@Type"]),status:K(e["@Status"]),amount:{currency:e.Amount["@Currency"],amount:e.Amount["@Amount"]},details:e.PaymentDetails?{cardNumber:e.PaymentDetails.CardNumber,expiryDate:e.PaymentDetails.ExpiryDate,cardHolderName:e.PaymentDetails.CardHolderName}:void 0}}r(Be,"mapPaymentFromXml");function Ue(e){return{SearchCriteria:{MasterRecordType:A(e.type),SearchFields:{Field:e.fields.map(t=>({"@Name":t.name,"@Value":t.value,"@Operator":t.operator?te(t.operator):void 0}))},Pagination:e.pagination?{"@PageSize":e.pagination.pageSize,"@PageNumber":e.pagination.pageNumber}:void 0}}}r(Ue,"mapSearchCustomerToXml");function Ie(e){return{"@MasterRecordID":e.id,"@Type":A(e.type),"@Status":Pe(e.status),PersonalInfo:e.personalInfo?{Title:e.personalInfo.title,FirstName:e.personalInfo.firstName,LastName:e.personalInfo.lastName,MiddleName:e.personalInfo.middleName,DateOfBirth:e.personalInfo.dateOfBirth,Gender:e.personalInfo.gender?fe(e.personalInfo.gender):void 0,Nationality:e.personalInfo.nationality}:void 0,ContactInfo:e.contact?re(e.contact):void 0,Address:e.address?ne(e.address):void 0,BusinessInfo:e.businessInfo?{CompanyName:e.businessInfo.companyName,TaxID:e.businessInfo.taxId,LicenseNumber:e.businessInfo.licenseNumber}:void 0,Preferences:e.preferences?{Language:e.preferences.language,Currency:e.preferences.currency,CommunicationMethod:e.preferences.communicationMethod?_e(e.preferences.communicationMethod):void 0}:void 0}}r(Ie,"mapCustomerToXml");function He(e){return{BookingDetails:{"@BookingType":W(e.type),"@Priority":Q(e.priority),CustomerInfo:{"@CustomerID":e.customerId,CustomerDetails:e.customerDetails?Ie(e.customerDetails):void 0},PassengerList:{Passenger:e.passengers.map(le)},SelectedServiceList:{Service:e.services.map(Ee)},SpecialRequests:e.specialRequests?{Request:e.specialRequests.map(t=>({"@Type":Y(t.type),"@Description":t.description}))}:void 0}}}r(He,"mapCreateBookingToXml");function xe(e){return{"@BookingFileID":e.bookingId,CancellationDetails:{"@Reason":$(e.reason),"@Description":e.description,RefundRequest:e.refundRequest?{"@Amount":e.refundRequest.amount,"@Currency":e.refundRequest.currency,"@Method":z(e.refundRequest.method)}:void 0}}}r(xe,"mapCancelBookingToXml");function ke(e){return{"@BookingFileID":e.bookingId,DocumentRequest:{"@DocumentType":Z(e.documentType),"@Format":J(e.format),"@Language":e.language,DeliveryMethod:e.deliveryMethod?{"@Type":ee(e.deliveryMethod.type),"@Address":e.deliveryMethod.address}:void 0}}}r(ke,"mapPrintDocumentToXml");function je(e){return{"@BookingFileID":e.bookingId,PaymentList:{Payment:e.payments.map(ge)}}}r(je,"mapAddPaymentToXml");function Ge(e){return{id:e["@MasterRecordID"],type:Oe(e["@Type"]),status:Fe(e["@Status"]),personalInfo:e.PersonalInfo?{title:e.PersonalInfo.Title,firstName:e.PersonalInfo.FirstName,lastName:e.PersonalInfo.LastName,middleName:e.PersonalInfo.MiddleName,dateOfBirth:e.PersonalInfo.DateOfBirth?I(e.PersonalInfo.DateOfBirth):void 0,gender:e.PersonalInfo.Gender==="M"?"male":"female",nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?ie(e.ContactInfo):void 0,address:e.Address?oe(e.Address):void 0,businessInfo:e.BusinessInfo?{companyName:e.BusinessInfo.CompanyName,taxId:e.BusinessInfo.TaxID,licenseNumber:e.BusinessInfo.LicenseNumber}:void 0,preferences:e.Preferences?{language:e.Preferences.Language,currency:e.Preferences.Currency,communicationMethod:e.Preferences.CommunicationMethod?Xe(e.Preferences.CommunicationMethod):void 0}:void 0}}r(Ge,"mapCustomerFromXml");function ae(e){return{id:e["@BookingFileID"],status:Le(e["@Status"]),createdAt:D(e["@CreationDate"]),updatedAt:D(e["@LastModified"]),customer:Ge(e.CustomerInfo),passengers:e.PassengerList.Passenger.map(Ve),services:e.ServiceList.Service.map(we),pricing:{totalAmount:{currency:e.Pricing.TotalAmount["@Currency"],amount:e.Pricing.TotalAmount["@Amount"]},breakdowns:e.Pricing.Breakdown?.Item.map(t=>({type:Me(t["@Type"]),description:t["@Description"],amount:t["@Amount"]}))}}}r(ae,"mapBookingFromXml");function qe(e){let t=ae(e.BookingFile);return{...t,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:t}}r(qe,"mapBookingResponseFromXml");function Ke(e){return{results:e.SearchResults.MasterRecord.map(Ge),pagination:e.SearchResults.PaginationInfo?{totalRecords:e.SearchResults.PaginationInfo["@TotalRecords"],pageSize:e.SearchResults.PaginationInfo["@PageSize"],pageNumber:e.SearchResults.PaginationInfo["@PageNumber"],totalPages:e.SearchResults.PaginationInfo["@TotalPages"]}:void 0}}r(Ke,"mapSearchResponseFromXml");function We(e){return{id:e.DocumentInfo["@DocumentID"],type:e.DocumentInfo["@DocumentType"],format:e.DocumentInfo["@Format"],size:e.DocumentInfo["@Size"],createdAt:D(e.DocumentInfo["@CreationDate"]),downloadUrl:e.DocumentInfo.DownloadURL,deliveryStatus:e.DocumentInfo.DeliveryStatus?{status:be(e.DocumentInfo.DeliveryStatus["@Status"]),method:e.DocumentInfo.DeliveryStatus["@Method"],address:e.DocumentInfo.DeliveryStatus["@Address"]}:void 0,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"]}}r(We,"mapDocumentResponseFromXml");function Qe(e){return{success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:{refundInfo:e.OperationResult.RefundInfo?{refundAmount:e.OperationResult.RefundInfo["@RefundAmount"],currency:e.OperationResult.RefundInfo["@Currency"],refundMethod:e.OperationResult.RefundInfo["@RefundMethod"],processingTime:e.OperationResult.RefundInfo["@ProcessingTime"]}:void 0}}}r(Qe,"mapCancelResponseFromXml");function Ye(e){let t=ae(e.BookingFile);return{success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:{booking:t,paymentSummary:{totalPaid:{currency:e.PaymentSummary.TotalPaid["@Currency"],amount:e.PaymentSummary.TotalPaid["@Amount"]},outstandingAmount:{currency:e.PaymentSummary.OutstandingAmount["@Currency"],amount:e.PaymentSummary.OutstandingAmount["@Amount"]},paymentHistory:e.PaymentSummary.PaymentHistory.Payment.map(Be)}}}}r(Ye,"mapPaymentResponseFromXml");function $e(e){return{id:e["@MasterRecordID"],type:e["@Type"].toLowerCase(),status:e["@Status"].toLowerCase(),personalInfo:e.PersonalInfo?{title:e.PersonalInfo.Title,firstName:e.PersonalInfo.FirstName,lastName:e.PersonalInfo.LastName,middleName:e.PersonalInfo.MiddleName,dateOfBirth:e.PersonalInfo.DateOfBirth,gender:e.PersonalInfo.Gender?.toLowerCase(),nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?ie(e.ContactInfo):void 0,address:e.Address?oe(e.Address):void 0,businessInfo:e.BusinessInfo?{companyName:e.BusinessInfo.CompanyName,taxId:e.BusinessInfo.TaxID,licenseNumber:e.BusinessInfo.LicenseNumber}:void 0,preferences:e.Preferences?{language:e.Preferences.Language,currency:e.Preferences.Currency,communicationMethod:e.Preferences.CommunicationMethod?.toLowerCase()}:void 0}}r($e,"mapMasterRecordFromXml");var ue=require("@nestjs/common"),De=require("@nestjs/config");var C=require("@nestjs/common");var g=Symbol("AVES_SDK_CONFIG"),R=Symbol("XML_HTTP_CLIENT");var ye=class ye{constructor(t){p(this,"RqHeader");p(this,"Body");Object.assign(this,t)}};r(ye,"RequestPayload");var Re=ye,Te=class Te{constructor(t){p(this,"Request");this.Request=new Re(t)}};r(Te,"WrapRequestDto");var se=Te;function Tt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}r(Tt,"_ts_decorate");function ze(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}r(ze,"_ts_metadata");function Ze(e,t){return function(n,i){t(n,i,e)}}r(Ze,"_ts_param");var he=class he{constructor(t,n){p(this,"config");p(this,"http");this.config=t,this.http=n}buildHeader(){let{hostId:t,xtoken:n,languageCode:i}=this.config;return{"@HostID":t,"@Xtoken":n,"@Interface":"WEB","@UserName":"WEB","@LanguageCode":i}}wrapRequest(t){return new se({RqHeader:this.buildHeader(),Body:t})}async searchMasterRecord(t){return this.http.postXml("/interop/masterRecords/v2/rest/Search","SearchMasterRecordRQ",this.wrapRequest(t))}async insertOrUpdateMasterRecord(t){return this.http.postXml("/interop/masterRecords/v2/rest/InsertOrUpdate","ManageMasterRecordRQ",this.wrapRequest(t))}async createBookingFile(t){return this.http.postXml("/interop/booking/v2/rest/CreateBookingFile","BookFileRQ",this.wrapRequest(t))}async modBookingFileHeader(t){return this.http.postXml("/interop/booking/v2/rest/ModBookingFileHeader","ModiFileHeaderRQ",this.wrapRequest(t))}async modBookingFileServices(t){return this.http.postXml("/interop/booking/v2/rest/ModBookingFileServices","ModFileServicesRQ",this.wrapRequest(t))}async setBookingFileStatus(t){return this.http.postXml("/interop/booking/v2/rest/SetBookingFileStatus","SetStatusRQ",this.wrapRequest(t))}async cancelBookingFile(t){return this.http.postXml("/interop/booking/v2/rest/CancelBookingFile","CancelFileRQ",this.wrapRequest(t))}async insertFilePaymentList(t){return this.http.postXml("/interop/booking/v2/rest/InsertFilePaymentList","FilePaymentListRQ",this.wrapRequest(t))}async printBookingDocument(t){return this.http.postXml("/interop/document/v2/rest/PrintBookingDocument","PrintBookingDocumentRQ",this.wrapRequest(t))}};r(he,"AvesService");var l=he;l=Tt([(0,C.Injectable)(),Ze(0,(0,C.Inject)(g)),Ze(1,(0,C.Inject)(R)),ze("design:type",Function),ze("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig,typeof IXmlHttpClient>"u"?Object:IXmlHttpClient])],l);var et=It(require("axios"),1),me=require("fast-xml-parser"),S=require("@nestjs/common");function ht(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}r(ht,"_ts_decorate");function Je(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}r(Je,"_ts_metadata");function St(e,t){return function(n,i){t(n,i,e)}}r(St,"_ts_param");var Se=class Se{constructor(t){p(this,"config");p(this,"httpClient");p(this,"xmlBuilder");p(this,"xmlParser");this.config=t,this.httpClient=et.default.create({baseURL:t.baseUrl,timeout:typeof t.timeout=="number"?t.timeout:3e4,headers:{"Content-Type":"application/xml",Accept:"application/xml, text/xml, */*;q=0.1"},transitional:{clarifyTimeoutError:!0},validateStatus:r(n=>n>=200&&n<300,"validateStatus")}),this.xmlBuilder=new me.XMLBuilder({attributeNamePrefix:"@",ignoreAttributes:!1,suppressEmptyNode:!0,format:process.env.NODE_ENV?.toLowerCase()==="development"}),this.xmlParser=new me.XMLParser({attributeNamePrefix:"@",ignoreAttributes:!1,parseAttributeValue:!1,trimValues:!0,isArray:r(n=>["Field","Item","Service","Passenger","Payment","MasterRecord","Request","Notes","ServiceID"].includes(n),"isArray")})}async postXml(t,n,i,s){let m=this.xmlBuilder.build({[n]:i}),u=await this.httpClient.post(t,m,s);return this.xmlParser.parse(u.data)}};r(Se,"XmlHttpClient");var y=Se;y=ht([(0,S.Injectable)({scope:S.Scope.DEFAULT}),St(0,(0,S.Inject)(g)),Je("design:type",Function),Je("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig])],y);var tt=require("@nestjs/config"),nt="aves",pe=(0,tt.registerAs)(nt,()=>({baseUrl:process.env.AVES_BASE_URL??"",hostId:process.env.AVES_HOST_ID??"",xtoken:process.env.AVES_XTOKEN??"",languageCode:process.env.AVES_LANGUAGE_CODE,timeout:process.env.AVES_TIMEOUT?Number(process.env.AVES_TIMEOUT):void 0}));var o=require("zod"),ot=o.z.enum(["01","02"]),Ne=o.z.object({baseUrl:o.z.url(),hostId:o.z.string().length(6),xtoken:o.z.string(),languageCode:ot.optional(),timeout:o.z.number().optional()}),rt=o.z.object({"@Type":o.z.enum(["HOME","WORK","BILLING","DELIVERY"]).optional(),Street:o.z.string().max(100).optional(),City:o.z.string().max(50).optional(),State:o.z.string().max(50).optional(),PostalCode:o.z.string().max(20).optional(),Country:o.z.string().max(50).optional()}),it=o.z.object({Phone:o.z.object({"@Type":o.z.enum(["HOME","WORK","MOBILE","FAX"]).optional(),"@Number":o.z.string()}).optional(),Email:o.z.object({"@Type":o.z.enum(["HOME","WORK"]).optional(),"@Address":o.z.string()}).optional()}),at=o.z.object({"@PassengerID":o.z.string().min(1),"@Type":o.z.enum(["ADT","CHD","INF"]),"@Title":o.z.enum(["MR","MRS","MS","DR","PROF"]).optional(),FirstName:o.z.string().min(1).max(50),LastName:o.z.string().min(1).max(50),MiddleName:o.z.string().max(50).optional(),DateOfBirth:o.z.string().datetime().optional(),Gender:o.z.enum(["M","F"]).optional(),Nationality:o.z.string().max(3).optional(),Address:rt.optional(),ContactInfo:it.optional()}),st=o.z.object({"@ServiceID":o.z.string().min(1),"@Type":o.z.enum(["FLIGHT","HOTEL","CAR","TRANSFER","INSURANCE"]),"@Status":o.z.enum(["CONFIRMED","PENDING","CANCELLED"]),ServiceDetails:o.z.object({Code:o.z.string().optional(),Name:o.z.string().optional(),Description:o.z.string().optional(),StartDate:o.z.string().optional(),EndDate:o.z.string().optional(),Price:o.z.object({"@Currency":o.z.string(),"@Amount":o.z.number()}).optional()})}),Nt=o.z.object({"@PaymentID":o.z.string().min(1),"@Type":o.z.enum(["CREDIT_CARD","DEBIT_CARD","BANK_TRANSFER","CASH"]),"@Status":o.z.enum(["PENDING","CONFIRMED","FAILED"]),Amount:o.z.object({"@Currency":o.z.string(),"@Amount":o.z.number()}),PaymentDetails:o.z.object({CardNumber:o.z.string().optional(),ExpiryDate:o.z.string().optional(),CardHolderName:o.z.string().optional()}).optional()}),Dt=o.z.object({SearchCriteria:o.z.object({MasterRecordType:o.z.enum(["CUSTOMER","AGENT","SUPPLIER"]),SearchFields:o.z.object({Field:o.z.array(o.z.object({"@Name":o.z.string(),"@Value":o.z.string(),"@Operator":o.z.enum(["EQUALS","CONTAINS","STARTS_WITH","ENDS_WITH"]).optional()}))}),Pagination:o.z.object({"@PageSize":o.z.number(),"@PageNumber":o.z.number()}).optional()})}),At=o.z.object({BookingDetails:o.z.object({"@BookingType":o.z.enum(["INDIVIDUAL","GROUP","CORPORATE"]),"@Priority":o.z.enum(["LOW","NORMAL","HIGH","URGENT"]),CustomerInfo:o.z.object({"@CustomerID":o.z.string().optional(),CustomerDetails:o.z.any().optional()}),PassengerList:o.z.object({Passenger:o.z.array(at)}),SelectedServiceList:o.z.object({Service:o.z.array(st)}),SpecialRequests:o.z.object({Request:o.z.array(o.z.object({"@Type":o.z.enum(["MEAL","SEAT","WHEELCHAIR","OTHER"]),"@Description":o.z.string()}))}).optional()})}),Ct=o.z.object({"@BookingFileID":o.z.string().min(1),CancellationDetails:o.z.object({"@Reason":o.z.enum(["CUSTOMER_REQUEST","NO_SHOW","OPERATIONAL","OTHER"]),"@Description":o.z.string().optional(),RefundRequest:o.z.object({"@Amount":o.z.number(),"@Currency":o.z.string(),"@Method":o.z.enum(["ORIGINAL_PAYMENT","CREDIT","CASH"])}).optional()})}),Ot=o.z.object({"@BookingFileID":o.z.string().min(1),DocumentRequest:o.z.object({"@DocumentType":o.z.enum(["CONFIRMATION","INVOICE","VOUCHER","TICKET","ALL"]),"@Format":o.z.enum(["PDF","HTML","XML"]),"@Language":o.z.string().optional(),DeliveryMethod:o.z.object({"@Type":o.z.enum(["EMAIL","SMS","DOWNLOAD"]),"@Address":o.z.string().optional()}).optional()})});function Pt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}r(Pt,"_ts_decorate");var T=class T{static forRoot(t){let n=this.validateConfig(t);return{module:T,imports:[De.ConfigModule.forFeature(pe)],providers:[{provide:g,useValue:n},this.createXmlHttpClientProvider(),l],exports:[l,R]}}static forRootAsync(t){let n=this.createAsyncProviders(t);return{module:T,imports:[...t.imports??[],De.ConfigModule.forFeature(pe)],providers:[...n,this.createXmlHttpClientProvider(),l],exports:[l,R]}}static createXmlHttpClientProvider(){return{provide:R,useClass:y}}static createAsyncProviders(t){if(t.useFactory)return[{provide:g,useFactory:r(async(...s)=>{try{let m=await t.useFactory(...s);return this.validateConfig(m)}catch(m){throw new Error(`Failed to create Aves configuration: ${m.message}`)}},"useFactory"),inject:t.inject??[]}];let n=t.useClass||t.useExisting;if(!n)throw new Error("Invalid AvesModule async options: provide useFactory, useClass, or useExisting");let i=[{provide:g,useFactory:r(async s=>{try{let m=await s.createAvesOptions();return this.validateConfig(m)}catch(m){throw new Error(`Failed to create Aves configuration: ${m.message}`)}},"useFactory"),inject:[n]}];return t.useClass&&i.push({provide:t.useClass,useClass:t.useClass}),i}static validateConfig(t){let n=Ne.safeParse(t);if(!n.success)throw new Error(`Invalid AVES SDK configuration: ${n.error.issues.map(i=>i.message).join(", ")}`);return n.data}};r(T,"AvesModule"),p(T,"MODULE_NAME","AvesModule"),p(T,"VERSION","1.0.0");var O=T;O=Pt([(0,ue.Global)(),(0,ue.Module)({})],O);var Ft=(function(e){return e.OK="OK",e.ERROR="ERROR",e.WARNING="WARNING",e.TIMEOUT="TIMEOUT",e})({}),d=(function(e){return e.ERROR="ERROR",e.WARNING="WARNING",e.INFO="INFO",e})({}),a=(function(e){return e.INVALID_TOKEN="AVES_001",e.TOKEN_EXPIRED="AVES_002",e.INSUFFICIENT_PERMISSIONS="AVES_003",e.INVALID_REQUEST_FORMAT="AVES_100",e.MISSING_REQUIRED_FIELD="AVES_101",e.INVALID_FIELD_VALUE="AVES_102",e.INVALID_DATE_FORMAT="AVES_103",e.BOOKING_NOT_FOUND="AVES_200",e.BOOKING_ALREADY_CANCELLED="AVES_201",e.INVALID_BOOKING_STATUS="AVES_202",e.PAYMENT_FAILED="AVES_203",e.INSUFFICIENT_INVENTORY="AVES_204",e.INTERNAL_SERVER_ERROR="AVES_500",e.SERVICE_UNAVAILABLE="AVES_501",e.TIMEOUT="AVES_502",e.RATE_LIMIT_EXCEEDED="AVES_503",e})({});var mt=require("zod");var de=class de{constructor(t){p(this,"schema");this.schema=t}validate(t){if(!this.schema)throw new Error("No schema provided. Either pass schema to constructor or as method parameter.");return this.schema.parse(t)}async asyncValidate(t){if(!this.schema)throw new Error("No schema provided. Either pass schema to constructor or as method parameter.");return this.schema.parseAsync(t)}safeValidateAndParse(t){return this.schema?this.schema.safeParse(t):this.createError({message:"No schema provided. Either pass schema to constructor or as method parameter.",path:[]})}async safeAsyncValidateAndParse(t){return this.schema?this.schema.safeParseAsync(t):this.createError({message:"No schema provided. Either pass schema to constructor or as method parameter.",path:[]})}getErrorMessage(t,n="; "){return t.issues.map(i=>`${i.path.length>0?`${i.path.join(".")}: `:""}${i.message}`).join(n)}createError({message:t,path:n}){return{success:!1,error:new mt.ZodError([{code:"custom",message:t,path:n}])}}static withSchema(t){return new de(t)}};r(de,"AvesValidator");var ce=de;function _t(e){return new ce(e)}r(_t,"createAvesValidator");var pt=require("@nestjs/common");var N=class N extends Error{constructor(n,i,s={}){super(i);p(this,"code");p(this,"severity");p(this,"timestamp");p(this,"requestId");p(this,"context");this.name="AvesException",this.code=n,this.severity=s.severity||d.ERROR,this.timestamp=new Date().toISOString(),this.context=s.context,this.requestId=s.requestId||this.generateRequestId(),Object.setPrototypeOf(this,N.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,N)}static fromAvesError(n){return new N(n.code,n.message,{severity:n.severity,context:n.context,requestId:n.requestId})}isRetryable(){return[a.TIMEOUT,a.SERVICE_UNAVAILABLE,a.INTERNAL_SERVER_ERROR,a.RATE_LIMIT_EXCEEDED].includes(this.code)}getUserFriendlyMessage(){return{[a.INVALID_TOKEN]:"Your session has expired. Please log in again.",[a.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[a.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[a.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[a.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[a.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[a.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[a.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[a.TIMEOUT]:"The request timed out. Please try again.",[a.RATE_LIMIT_EXCEEDED]:"Too many requests. Please wait a moment and try again."}[this.code]||this.message}toJSON(){return{name:this.name,code:this.code,message:this.message,severity:this.severity,timestamp:this.timestamp,requestId:this.requestId,context:this.context,stack:this.stack,isRetryable:this.isRetryable(),userFriendlyMessage:this.getUserFriendlyMessage()}}toAvesError(){return{code:this.code,message:this.message,severity:this.severity,timestamp:this.timestamp,requestId:this.requestId,context:this.context}}getHttpStatusCode(){switch(this.code){case a.INVALID_TOKEN:case a.TOKEN_EXPIRED:return 401;case a.INSUFFICIENT_PERMISSIONS:return 403;case a.BOOKING_NOT_FOUND:return 404;case a.INVALID_REQUEST_FORMAT:case a.MISSING_REQUIRED_FIELD:case a.INVALID_FIELD_VALUE:return 400;case a.RATE_LIMIT_EXCEEDED:return 429;case a.SERVICE_UNAVAILABLE:return 503;case a.TIMEOUT:return 408;default:return 500}}getCategory(){return this.code.startsWith("AVES_1")?"Authentication":this.code.startsWith("AVES_2")?"Business Logic":this.code.startsWith("AVES_5")?"System":"Unknown"}generateRequestId(){return`aves_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}};r(N,"AvesException");var c=N;function Xt(e,t,n,i){var s=arguments.length,m=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(e,t,n,i);else for(var f=e.length-1;f>=0;f--)(u=e[f])&&(m=(s<3?u(m):s>3?u(t,n,m):u(t,n))||m);return s>3&&m&&Object.defineProperty(t,n,m),m}r(Xt,"_ts_decorate");var Ae=class Ae{parseError(t){return t instanceof c?t:this.isHttpError(t)?this.parseHttpError(t):this.isAvesXmlResponse(t)?this.parseAvesXmlError(t):t instanceof Error?new c(a.INTERNAL_SERVER_ERROR,t.message,{severity:d.ERROR,context:this.buildContext({type:"javascript_error",errorName:t.name,stack:t.stack||"No stack trace available"})}):new c(a.INTERNAL_SERVER_ERROR,"Unknown error occurred",{severity:d.ERROR,context:this.buildContext({type:"unknown_error",errorName:typeof t,errorValue:String(t)})})}parseHttpError(t){if(t.response){let n=t.response.status,i=t.response.statusText;switch(n){case 400:return new c(a.INVALID_REQUEST_FORMAT,`Bad Request: ${i}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",errorName:n,statusText:i,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 401:return new c(a.INVALID_TOKEN,"Authentication failed",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 403:return new c(a.INSUFFICIENT_PERMISSIONS,"Access forbidden",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 404:return new c(a.BOOKING_NOT_FOUND,"Resource not found",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 429:return new c(a.RATE_LIMIT_EXCEEDED,"Rate limit exceeded",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,retryAfter:t.response.headers?.["retry-after"]})});case 500:return new c(a.INTERNAL_SERVER_ERROR,"Internal server error",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 503:return new c(a.SERVICE_UNAVAILABLE,"Service unavailable",{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});default:return new c(a.INTERNAL_SERVER_ERROR,`HTTP ${n}: ${i}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",status:n,statusText:i,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})})}}else return t.request?new c(a.TIMEOUT,"Request timeout - no response from AVES API",{severity:d.ERROR,context:this.buildContext({type:"http_error",timeout:!0,url:t.config?.url,method:t.config?.method,configuredTimeout:t.config?.timeout})}):new c(a.INTERNAL_SERVER_ERROR,`Request setup error: ${t.message}`,{severity:d.ERROR,context:this.buildContext({type:"http_error",setupError:!0})})}parseAvesXmlError(t){if(!t?.Response?.RsStatus)return new c(a.INVALID_REQUEST_FORMAT,"Invalid response format from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",missingRsStatus:!0})});let n=t.Response.RsStatus;if(n["@Status"]==="ERROR")return new c(n.ErrorCode||a.INTERNAL_SERVER_ERROR,n.ErrorDescription||"Unknown error from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",originalResponse:n})});if(n.Warnings?.Warning){let i=Array.isArray(n.Warnings.Warning)?n.Warnings.Warning:[n.Warnings.Warning];return new c(a.INVALID_FIELD_VALUE,i.join("; "),{severity:d.WARNING,context:this.buildContext({type:"aves_xml_warning",warnings:i})})}return new c(a.INTERNAL_SERVER_ERROR,"Unexpected response from AVES API",{severity:d.ERROR,context:this.buildContext({type:"aves_xml_error",unexpectedResponse:!0,status:n["@Status"]})})}isRetryable(t){return[a.TIMEOUT,a.SERVICE_UNAVAILABLE,a.INTERNAL_SERVER_ERROR,a.RATE_LIMIT_EXCEEDED].includes(t.code)}getUserFriendlyMessage(t){return{[a.INVALID_TOKEN]:"Your session has expired. Please log in again.",[a.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[a.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[a.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[a.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[a.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[a.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[a.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[a.TIMEOUT]:"The request timed out. Please try again.",[a.RATE_LIMIT_EXCEEDED]:"Too many requests. Please wait a moment and try again."}[t.code]||t.message}buildContext(t){let n={};return typeof t=="object"&&t!==null?Object.keys(t).forEach(i=>{let s=t[i];if(this.isSensitiveKey(i)){n[i]="********";return}this.isSerializableValue(s)?n[i]=s:typeof s=="function"?n[i]="[Function]":s instanceof Error?n[i]={name:s.name,message:s.message,stack:s.stack?.split(`
|
|
2
2
|
`).slice(0,3).join(`
|
|
3
|
-
`)}:n[i]=String(s)}):typeof t=="string"?n.message=t:typeof t=="number"||typeof t=="boolean"?n.value=t:n.input=String(t),n.timestamp=new Date().toISOString(),n.contextType=typeof t,n}isSensitiveKey(t){let n=["password","token","secret","key","auth","credential","xtoken","authorization","cookie","session","private"],i=t.toLowerCase();return n.some(s=>i.includes(s))}isSerializableValue(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:Array.isArray(t)?t.length<=10:typeof t=="object"&&t.constructor===Object?Object.keys(t).length<=20:!1}isHttpError(t){return t&&(t.response||t.request||t.config)}isAvesXmlResponse(t){return t&&t.Response&&t.Response.RsStatus}};
|
|
3
|
+
`)}:n[i]=String(s)}):typeof t=="string"?n.message=t:typeof t=="number"||typeof t=="boolean"?n.value=t:n.input=String(t),n.timestamp=new Date().toISOString(),n.contextType=typeof t,n}isSensitiveKey(t){let n=["password","token","secret","key","auth","credential","xtoken","authorization","cookie","session","private"],i=t.toLowerCase();return n.some(s=>i.includes(s))}isSerializableValue(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:Array.isArray(t)?t.length<=10:typeof t=="object"&&t.constructor===Object?Object.keys(t).length<=20:!1}isHttpError(t){return t&&(t.response||t.request||t.config)}isAvesXmlResponse(t){return t&&t.Response&&t.Response.RsStatus}};r(Ae,"AvesErrorHandler");var P=Ae;P=Xt([(0,pt.Injectable)()],P);0&&(module.exports={AVES_CONFIG_NAMESPACE,AVES_SDK_CONFIG,AddressValidation,AvesErrorCodes,AvesErrorHandler,AvesException,AvesModule,AvesService,AvesSeverity,AvesStatus,AvesValidator,BookFileRQValidation,CancelFileRQValidation,ContactInfoValidation,LanguageCodeValidation,PassengerValidation,PaymentValidation,PrintBookingDocumentRQValidation,SearchMasterRecordRQValidation,ServiceValidation,XML_HTTP_CLIENT,XmlHttpClient,avesConfig,configValidationSchema,createAvesValidator,createDateString,createDateTimeString,createTimeString,mapAddPaymentToXml,mapAddressToXml,mapAddressTypeFromXml,mapAddressTypeToXml,mapBookingFromXml,mapBookingResponseFromXml,mapBookingTypeToXml,mapCancelBookingToXml,mapCancelReasonToXml,mapCancelResponseFromXml,mapContactToXml,mapContactTypeFromXml,mapContactTypeToXml,mapCreateBookingToXml,mapCustomerToXml,mapCustomerTypeToXml,mapDeliveryMethodToXml,mapDocumentFormatToXml,mapDocumentResponseFromXml,mapDocumentTypeToXml,mapEmailTypeFromXml,mapEmailTypeToXml,mapMasterRecordFromXml,mapPassengerToXml,mapPassengerTypeFromXml,mapPassengerTypeToXml,mapPaymentResponseFromXml,mapPaymentStatusFromXml,mapPaymentStatusToXml,mapPaymentToXml,mapPaymentTypeFromXml,mapPaymentTypeToXml,mapPrintDocumentToXml,mapPriorityToXml,mapRefundMethodToXml,mapSearchCustomerToXml,mapSearchOperatorToXml,mapSearchResponseFromXml,mapServiceStatusFromXml,mapServiceStatusToXml,mapServiceToXml,mapServiceTypeFromXml,mapServiceTypeToXml,mapSpecialRequestTypeToXml,mapTitleFromXml,mapTitleToXml});
|
|
4
4
|
//# sourceMappingURL=index.cjs.map
|