aves-sdk 1.0.1 → 1.0.3
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 +4 -4
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1792 -1
- package/dist/index.d.ts +1792 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -7,7 +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** -
|
|
10
|
+
- **Enhanced Date Handling** - Native JavaScript Date integration for robust date manipulation and validation
|
|
11
11
|
- **Error Handling** - Structured error handling with AVES-specific error codes
|
|
12
12
|
- **Configuration** - Environment-based configuration with validation
|
|
13
13
|
- **Dependency Injection** - Interface-based DI following NestJS patterns
|
|
@@ -323,7 +323,7 @@ Advanced validation class for comprehensive data validation scenarios.
|
|
|
323
323
|
**Utility Functions:**
|
|
324
324
|
|
|
325
325
|
- `createValidator(schema)` - Create validator instance
|
|
326
|
-
- Date utilities with
|
|
326
|
+
- Date utilities with native JavaScript Date for enhanced date manipulation
|
|
327
327
|
|
|
328
328
|
### Configuration
|
|
329
329
|
|
|
@@ -356,7 +356,7 @@ type BookingType = 'individual' | 'group' | 'corporate';
|
|
|
356
356
|
|
|
357
357
|
#### Date Utilities
|
|
358
358
|
|
|
359
|
-
Enhanced date manipulation with
|
|
359
|
+
Enhanced date manipulation with native JavaScript Date:
|
|
360
360
|
|
|
361
361
|
```typescript
|
|
362
362
|
import {
|
|
@@ -696,6 +696,6 @@ For issues and questions:
|
|
|
696
696
|
|
|
697
697
|
- Replaced `class-validator` with Zod validation
|
|
698
698
|
- Introduced clean API interfaces alongside XML interfaces
|
|
699
|
-
- Enhanced date utilities with
|
|
699
|
+
- Enhanced date utilities with native JavaScript Date
|
|
700
700
|
- Updated module configuration with enhanced validation
|
|
701
701
|
- Improved error handling structure
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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(`
|
|
1
|
+
var Zt=Object.create;var h=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,nn=Object.prototype.hasOwnProperty;var on=(e,t,o)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var i=(e,t)=>h(e,"name",{value:t,configurable:!0});var rn=(e,t)=>{for(var o in t)h(e,o,{get:t[o],enumerable:!0})},it=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of en(t))!nn.call(e,m)&&m!==o&&h(e,m,{get:()=>t[m],enumerable:!(a=Jt(t,m))||a.enumerable});return e};var an=(e,t,o)=>(o=e!=null?Zt(tn(e)):{},it(t||!e||!e.__esModule?h(o,"default",{value:e,enumerable:!0}):o,e)),sn=e=>it(h({},"__esModule",{value:!0}),e);var u=(e,t,o)=>on(e,typeof t!="symbol"?t+"":t,o);var Sn={};rn(Sn,{AVES_CONFIG_NAMESPACE:()=>Lt,AVES_SDK_CONFIG:()=>y,AddressValidation:()=>wt,AvesErrorCodes:()=>s,AvesErrorHandler:()=>F,AvesException:()=>d,AvesModule:()=>b,AvesService:()=>g,AvesSeverity:()=>l,AvesStatus:()=>En,AvesValidator:()=>le,BookFileRQValidation:()=>fn,CancelFileRQValidation:()=>gn,ContactInfoValidation:()=>Vt,LanguageCodeValidation:()=>xt,PassengerValidation:()=>Bt,PaymentValidation:()=>dn,PrintBookingDocumentRQValidation:()=>yn,SearchMasterRecordRQValidation:()=>ln,ServiceValidation:()=>jt,XML_HTTP_CLIENT:()=>E,XmlHttpClient:()=>R,addPaymentRequestSchema:()=>Kt,addressTypeSchema:()=>Me,apiSchemas:()=>In,avesConfig:()=>ce,bookingPassengerSchema:()=>Re,bookingPaymentSchema:()=>ot,bookingResponseSchema:()=>Wt,bookingServiceSchema:()=>Ie,bookingStatusTypeSchema:()=>Ze,bookingTypeSchema:()=>He,cancelBookingRequestSchema:()=>Ht,cancelReasonTypeSchema:()=>We,communicationMethodTypeSchema:()=>nt,configValidationSchema:()=>ve,contactTypeSchema:()=>Le,createAvesValidator:()=>Rn,createBookingRequestSchema:()=>Ut,createDateString:()=>T,createDateTimeString:()=>D,createTimeString:()=>mn,customerAddressSchema:()=>Te,customerContactSchema:()=>Ee,customerSchema:()=>P,customerStatusTypeSchema:()=>tt,customerTypeSchema:()=>ye,deliveryMethodTypeSchema:()=>ze,deliveryStatusTypeSchema:()=>et,documentFormatTypeSchema:()=>Qe,documentResponseSchema:()=>$t,documentTypeSchema:()=>$e,emailTypeSchema:()=>xe,genderTypeSchema:()=>ge,mapAddPaymentToXml:()=>St,mapAddressToXml:()=>re,mapAddressTypeFromXml:()=>_,mapAddressTypeToXml:()=>v,mapBookingFromXml:()=>me,mapBookingResponseFromXml:()=>Dt,mapBookingTypeToXml:()=>$,mapCancelBookingToXml:()=>It,mapCancelReasonToXml:()=>Z,mapCancelResponseFromXml:()=>bt,mapContactToXml:()=>ae,mapContactTypeFromXml:()=>M,mapContactTypeToXml:()=>X,mapCreateBookingToXml:()=>Rt,mapCustomerToXml:()=>Ae,mapCustomerTypeToXml:()=>A,mapDeliveryMethodToXml:()=>ne,mapDocumentFormatToXml:()=>te,mapDocumentResponseFromXml:()=>Ct,mapDocumentTypeToXml:()=>ee,mapEmailTypeFromXml:()=>x,mapEmailTypeToXml:()=>L,mapMasterRecordFromXml:()=>Pt,mapPassengerToXml:()=>Se,mapPassengerTypeFromXml:()=>V,mapPassengerTypeToXml:()=>w,mapPaymentResponseFromXml:()=>Ot,mapPaymentStatusFromXml:()=>Y,mapPaymentStatusToXml:()=>W,mapPaymentToXml:()=>De,mapPaymentTypeFromXml:()=>K,mapPaymentTypeToXml:()=>G,mapPrintDocumentToXml:()=>ht,mapPriorityToXml:()=>Q,mapRefundMethodToXml:()=>J,mapSearchCustomerToXml:()=>Et,mapSearchOperatorToXml:()=>oe,mapSearchResponseFromXml:()=>At,mapServiceStatusFromXml:()=>H,mapServiceStatusToXml:()=>U,mapServiceToXml:()=>Ne,mapServiceTypeFromXml:()=>q,mapServiceTypeToXml:()=>k,mapSpecialRequestTypeToXml:()=>z,mapTitleFromXml:()=>j,mapTitleToXml:()=>B,operationResponseSchema:()=>Qt,passengerTypeSchema:()=>we,paymentStatusTypeSchema:()=>qe,paymentTypeSchema:()=>ke,pricingItemTypeSchema:()=>Je,printDocumentRequestSchema:()=>Gt,priorityTypeSchema:()=>Ge,refundMethodTypeSchema:()=>Ye,searchCustomerRequestSchema:()=>qt,searchOperatorTypeSchema:()=>Ue,searchResponseSchema:()=>Yt,serviceStatusTypeSchema:()=>je,serviceTypeSchema:()=>Be,specialRequestTypeSchema:()=>Ke,titleTypeSchema:()=>Ve});module.exports=sn(Sn);var Io=require("reflect-metadata");var T=i(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=new Date(e+"T00:00:00.000Z")}catch{throw new Error(`Invalid date string: ${e}`)}}else t=e;if(isNaN(t.getTime()))throw new Error(`Invalid date value: ${e}`);let o=t.getUTCFullYear(),a=String(t.getUTCMonth()+1).padStart(2,"0"),m=String(t.getUTCDate()).padStart(2,"0");return`${o}-${a}-${m}`},"createDateString"),D=i(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=new Date(e)}catch{throw new Error(`Invalid datetime string: ${e}`)}}else t=e;if(isNaN(t.getTime()))throw new Error(`Invalid datetime value: ${e}`);return t.toISOString()},"createDateTimeString"),mn=i(e=>{if(!/^\d{2}:\d{2}:\d{2}$/.test(e))throw new Error(`Invalid time format. Expected HH:MM:SS, got: ${e}`);let[t,o,a]=e.split(":").map(Number);if(t<0||t>23||o<0||o>59||a<0||a>59)throw new Error(`Invalid time value: ${e}`);return e},"createTimeString");function v(e){return{home:"HOME",work:"WORK",billing:"BILLING",delivery:"DELIVERY"}[e]||"HOME"}i(v,"mapAddressTypeToXml");function _(e){return{HOME:"home",WORK:"work",BILLING:"billing",DELIVERY:"delivery"}[e]||"home"}i(_,"mapAddressTypeFromXml");function X(e){return{home:"HOME",work:"WORK",mobile:"MOBILE",fax:"FAX"}[e]||"HOME"}i(X,"mapContactTypeToXml");function M(e){return{HOME:"home",WORK:"work",MOBILE:"mobile",FAX:"fax"}[e]||"home"}i(M,"mapContactTypeFromXml");function L(e){return{home:"HOME",work:"WORK"}[e]||"HOME"}i(L,"mapEmailTypeToXml");function x(e){return{HOME:"home",WORK:"work"}[e]||"home"}i(x,"mapEmailTypeFromXml");function w(e){return{adult:"ADT",child:"CHD",infant:"INF"}[e]||"ADT"}i(w,"mapPassengerTypeToXml");function V(e){return{ADT:"adult",CHD:"child",INF:"infant"}[e]||"adult"}i(V,"mapPassengerTypeFromXml");function B(e){return{mr:"MR",mrs:"MRS",ms:"MS",dr:"DR",prof:"PROF"}[e]||"MR"}i(B,"mapTitleToXml");function j(e){return{MR:"mr",MRS:"mrs",MS:"ms",DR:"dr",PROF:"prof"}[e]||"mr"}i(j,"mapTitleFromXml");function k(e){return{flight:"FLIGHT",hotel:"HOTEL",car:"CAR",transfer:"TRANSFER",insurance:"INSURANCE"}[e]||"FLIGHT"}i(k,"mapServiceTypeToXml");function q(e){return{FLIGHT:"flight",HOTEL:"hotel",CAR:"car",TRANSFER:"transfer",INSURANCE:"insurance"}[e]||"flight"}i(q,"mapServiceTypeFromXml");function U(e){return{confirmed:"CONFIRMED",pending:"PENDING",cancelled:"CANCELLED"}[e]||"PENDING"}i(U,"mapServiceStatusToXml");function H(e){return{CONFIRMED:"confirmed",PENDING:"pending",CANCELLED:"cancelled"}[e]||"pending"}i(H,"mapServiceStatusFromXml");function G(e){return{credit_card:"CREDIT_CARD",debit_card:"DEBIT_CARD",bank_transfer:"BANK_TRANSFER",cash:"CASH"}[e]||"CASH"}i(G,"mapPaymentTypeToXml");function K(e){return{CREDIT_CARD:"credit_card",DEBIT_CARD:"debit_card",BANK_TRANSFER:"bank_transfer",CASH:"cash"}[e]||"cash"}i(K,"mapPaymentTypeFromXml");function W(e){return{pending:"PENDING",confirmed:"CONFIRMED",failed:"FAILED"}[e]||"PENDING"}i(W,"mapPaymentStatusToXml");function Y(e){return{PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"}[e]||"pending"}i(Y,"mapPaymentStatusFromXml");function A(e){return{customer:"CUSTOMER",agent:"AGENT",supplier:"SUPPLIER"}[e]||"CUSTOMER"}i(A,"mapCustomerTypeToXml");function at(e){return{CUSTOMER:"customer",AGENT:"agent",SUPPLIER:"supplier"}[e]||"customer"}i(at,"mapCustomerTypeFromXml");function st(e){return{active:"ACTIVE",inactive:"INACTIVE",suspended:"SUSPENDED"}[e]||"ACTIVE"}i(st,"mapCustomerStatusToXml");function mt(e){return{ACTIVE:"active",INACTIVE:"inactive",SUSPENDED:"suspended"}[e]||"active"}i(mt,"mapCustomerStatusFromXml");function pt(e){return{email:"EMAIL",sms:"SMS",phone:"PHONE"}[e]||"EMAIL"}i(pt,"mapCommunicationMethodToXml");function ut(e){return{EMAIL:"email",SMS:"sms",PHONE:"phone"}[e]||"email"}i(ut,"mapCommunicationMethodFromXml");function $(e){return{individual:"INDIVIDUAL",group:"GROUP",corporate:"CORPORATE"}[e]||"INDIVIDUAL"}i($,"mapBookingTypeToXml");function ct(e){return{PENDING:"pending",CONFIRMED:"confirmed",CANCELLED:"cancelled",COMPLETED:"completed"}[e]||"pending"}i(ct,"mapBookingStatusFromXml");function Q(e){return{low:"LOW",normal:"NORMAL",high:"HIGH",urgent:"URGENT"}[e]||"NORMAL"}i(Q,"mapPriorityToXml");function z(e){return{meal:"MEAL",seat:"SEAT",wheelchair:"WHEELCHAIR",other:"OTHER"}[e]||"OTHER"}i(z,"mapSpecialRequestTypeToXml");function Z(e){return{customer_request:"CUSTOMER_REQUEST",no_show:"NO_SHOW",operational:"OPERATIONAL",other:"OTHER"}[e]||"OTHER"}i(Z,"mapCancelReasonToXml");function J(e){return{original_payment:"ORIGINAL_PAYMENT",credit:"CREDIT",cash:"CASH"}[e]||"CASH"}i(J,"mapRefundMethodToXml");function ee(e){return{confirmation:"CONFIRMATION",invoice:"INVOICE",voucher:"VOUCHER",ticket:"TICKET",all:"ALL"}[e]||"ALL"}i(ee,"mapDocumentTypeToXml");function te(e){return{pdf:"PDF",html:"HTML",xml:"XML"}[e]||"PDF"}i(te,"mapDocumentFormatToXml");function ne(e){return{email:"EMAIL",sms:"SMS",download:"DOWNLOAD"}[e]||"EMAIL"}i(ne,"mapDeliveryMethodToXml");function oe(e){return{equals:"EQUALS",contains:"CONTAINS",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH"}[e]||"EQUALS"}i(oe,"mapSearchOperatorToXml");function dt(e){return{SERVICE:"service",TAX:"tax",FEE:"fee",DISCOUNT:"discount"}[e]||"service"}i(dt,"mapPricingItemTypeFromXml");function lt(e){return{SENT:"sent",PENDING:"pending",FAILED:"failed"}[e]||"pending"}i(lt,"mapDeliveryStatusFromXml");function he(e){return{male:"M",female:"F"}[e]||"M"}i(he,"mapGenderToXml");function ft(e){return{M:"male",F:"female"}[e]||"male"}i(ft,"mapGenderFromXml");function re(e){return{"@Type":e.type?v(e.type):void 0,Street:e.street,City:e.city,State:e.state,PostalCode:e.postalCode,Country:e.country}}i(re,"mapAddressToXml");function ie(e){return{type:e["@Type"]?_(e["@Type"]):void 0,street:e.Street,city:e.City,state:e.State,postalCode:e.PostalCode,country:e.Country}}i(ie,"mapAddressFromXml");function ae(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?L(e.email.type):void 0,"@Address":e.email.address}:void 0}}i(ae,"mapContactToXml");function se(e){return{phone:e.Phone?{type:e.Phone["@Type"]?M(e.Phone["@Type"]):void 0,number:e.Phone["@Number"]}:void 0,email:e.Email?{type:e.Email["@Type"]?x(e.Email["@Type"]):void 0,address:e.Email["@Address"]}:void 0}}i(se,"mapContactFromXml");function Se(e){return{"@PassengerID":e.id,"@Type":w(e.type),"@Title":e.title?B(e.title):void 0,FirstName:e.firstName,LastName:e.lastName,MiddleName:e.middleName,DateOfBirth:e.dateOfBirth,Gender:e.gender?he(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?re(e.address):void 0,ContactInfo:e.contact?ae(e.contact):void 0}}i(Se,"mapPassengerToXml");function gt(e){return{id:e["@PassengerID"],type:V(e["@Type"]),title:e["@Title"]?j(e["@Title"]):void 0,firstName:e.FirstName,lastName:e.LastName,middleName:e.MiddleName,dateOfBirth:e.DateOfBirth?T(e.DateOfBirth):void 0,gender:e.Gender?ft(e.Gender):void 0,nationality:e.Nationality,passport:e.Passport?{number:e.Passport["@Number"],expiryDate:T(e.Passport["@ExpiryDate"]),issuingCountry:e.Passport["@IssuingCountry"]}:void 0,address:e.Address?ie(e.Address):void 0,contact:e.ContactInfo?se(e.ContactInfo):void 0}}i(gt,"mapPassengerFromXml");function Ne(e){return{"@ServiceID":e.id,"@Type":k(e.type),"@Status":U(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}}}i(Ne,"mapServiceToXml");function yt(e){return{id:e["@ServiceID"],type:q(e["@Type"]),status:H(e["@Status"]),code:e.ServiceDetails.Code,name:e.ServiceDetails.Name,description:e.ServiceDetails.Description,startDate:e.ServiceDetails.StartDate?T(e.ServiceDetails.StartDate):void 0,endDate:e.ServiceDetails.EndDate?T(e.ServiceDetails.EndDate):void 0,price:e.ServiceDetails.Price?{currency:e.ServiceDetails.Price["@Currency"],amount:e.ServiceDetails.Price["@Amount"]}:void 0}}i(yt,"mapServiceFromXml");function De(e){return{"@PaymentID":e.id,"@Type":G(e.type),"@Status":W(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}}i(De,"mapPaymentToXml");function Tt(e){return{id:e["@PaymentID"],type:K(e["@Type"]),status:Y(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}}i(Tt,"mapPaymentFromXml");function Et(e){return{SearchCriteria:{MasterRecordType:A(e.type),SearchFields:{Field:e.fields.map(t=>({"@Name":t.name,"@Value":t.value,"@Operator":t.operator?oe(t.operator):void 0}))},Pagination:e.pagination?{"@PageSize":e.pagination.pageSize,"@PageNumber":e.pagination.pageNumber}:void 0}}}i(Et,"mapSearchCustomerToXml");function Ae(e){return{"@MasterRecordID":e.id,"@Type":A(e.type),"@Status":st(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?he(e.personalInfo.gender):void 0,Nationality:e.personalInfo.nationality}:void 0,ContactInfo:e.contact?ae(e.contact):void 0,Address:e.address?re(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?pt(e.preferences.communicationMethod):void 0}:void 0}}i(Ae,"mapCustomerToXml");function Rt(e){return{BookingDetails:{"@BookingType":$(e.type),"@Priority":Q(e.priority),CustomerInfo:{"@CustomerID":e.customerId,CustomerDetails:e.customerDetails?Ae(e.customerDetails):void 0},PassengerList:{Passenger:e.passengers.map(Se)},SelectedServiceList:{Service:e.services.map(Ne)},SpecialRequests:e.specialRequests?{Request:e.specialRequests.map(t=>({"@Type":z(t.type),"@Description":t.description}))}:void 0}}}i(Rt,"mapCreateBookingToXml");function It(e){return{"@BookingFileID":e.bookingId,CancellationDetails:{"@Reason":Z(e.reason),"@Description":e.description,RefundRequest:e.refundRequest?{"@Amount":e.refundRequest.amount,"@Currency":e.refundRequest.currency,"@Method":J(e.refundRequest.method)}:void 0}}}i(It,"mapCancelBookingToXml");function ht(e){return{"@BookingFileID":e.bookingId,DocumentRequest:{"@DocumentType":ee(e.documentType),"@Format":te(e.format),"@Language":e.language,DeliveryMethod:e.deliveryMethod?{"@Type":ne(e.deliveryMethod.type),"@Address":e.deliveryMethod.address}:void 0}}}i(ht,"mapPrintDocumentToXml");function St(e){return{"@BookingFileID":e.bookingId,PaymentList:{Payment:e.payments.map(De)}}}i(St,"mapAddPaymentToXml");function Nt(e){return{id:e["@MasterRecordID"],type:at(e["@Type"]),status:mt(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?T(e.PersonalInfo.DateOfBirth):void 0,gender:e.PersonalInfo.Gender==="M"?"male":"female",nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?se(e.ContactInfo):void 0,address:e.Address?ie(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?ut(e.Preferences.CommunicationMethod):void 0}:void 0}}i(Nt,"mapCustomerFromXml");function me(e){return{id:e["@BookingFileID"],status:ct(e["@Status"]),createdAt:D(e["@CreationDate"]),updatedAt:D(e["@LastModified"]),customer:Nt(e.CustomerInfo),passengers:e.PassengerList.Passenger.map(gt),services:e.ServiceList.Service.map(yt),pricing:{totalAmount:{currency:e.Pricing.TotalAmount["@Currency"],amount:e.Pricing.TotalAmount["@Amount"]},breakdowns:e.Pricing.Breakdown?.Item.map(t=>({type:dt(t["@Type"]),description:t["@Description"],amount:t["@Amount"]}))}}}i(me,"mapBookingFromXml");function Dt(e){let t=me(e.BookingFile);return{...t,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:t}}i(Dt,"mapBookingResponseFromXml");function At(e){return{results:e.SearchResults.MasterRecord.map(Nt),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}}i(At,"mapSearchResponseFromXml");function Ct(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:lt(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"]}}i(Ct,"mapDocumentResponseFromXml");function bt(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}}}i(bt,"mapCancelResponseFromXml");function Ot(e){let t=me(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(Tt)}}}}i(Ot,"mapPaymentResponseFromXml");function Pt(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?se(e.ContactInfo):void 0,address:e.Address?ie(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}}i(Pt,"mapMasterRecordFromXml");var de=require("@nestjs/common"),_e=require("@nestjs/config");var C=require("@nestjs/common");var y=Symbol("AVES_SDK_CONFIG"),E=Symbol("XML_HTTP_CLIENT");var be=class be{constructor(t){u(this,"RqHeader");u(this,"Body");Object.assign(this,t)}};i(be,"RequestPayload");var Ce=be,Oe=class Oe{constructor(t){u(this,"Request");this.Request=new Ce(t)}};i(Oe,"WrapRequestDto");var pe=Oe;function pn(e,t,o,a){var m=arguments.length,p=m<3?t:a===null?a=Object.getOwnPropertyDescriptor(t,o):a,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(e,t,o,a);else for(var f=e.length-1;f>=0;f--)(c=e[f])&&(p=(m<3?c(p):m>3?c(t,o,p):c(t,o))||p);return m>3&&p&&Object.defineProperty(t,o,p),p}i(pn,"_ts_decorate");function Ft(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}i(Ft,"_ts_metadata");function vt(e,t){return function(o,a){t(o,a,e)}}i(vt,"_ts_param");var Pe=class Pe{constructor(t,o){u(this,"config");u(this,"http");this.config=t,this.http=o}buildHeader(){let{hostId:t,xtoken:o,languageCode:a}=this.config;return{"@HostID":t,"@Xtoken":o,"@Interface":"WEB","@UserName":"WEB","@LanguageCode":a}}wrapRequest(t){return new pe({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))}};i(Pe,"AvesService");var g=Pe;g=pn([(0,C.Injectable)(),vt(0,(0,C.Inject)(y)),vt(1,(0,C.Inject)(E)),Ft("design:type",Function),Ft("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig,typeof IXmlHttpClient>"u"?Object:IXmlHttpClient])],g);var Xt=an(require("axios"),1),ue=require("fast-xml-parser"),S=require("@nestjs/common");function un(e,t,o,a){var m=arguments.length,p=m<3?t:a===null?a=Object.getOwnPropertyDescriptor(t,o):a,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(e,t,o,a);else for(var f=e.length-1;f>=0;f--)(c=e[f])&&(p=(m<3?c(p):m>3?c(t,o,p):c(t,o))||p);return m>3&&p&&Object.defineProperty(t,o,p),p}i(un,"_ts_decorate");function _t(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}i(_t,"_ts_metadata");function cn(e,t){return function(o,a){t(o,a,e)}}i(cn,"_ts_param");var Fe=class Fe{constructor(t){u(this,"config");u(this,"httpClient");u(this,"xmlBuilder");u(this,"xmlParser");this.config=t,this.httpClient=Xt.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:i(o=>o>=200&&o<300,"validateStatus")}),this.xmlBuilder=new ue.XMLBuilder({attributeNamePrefix:"@",ignoreAttributes:!1,suppressEmptyNode:!0,format:process.env.NODE_ENV?.toLowerCase()==="development"}),this.xmlParser=new ue.XMLParser({attributeNamePrefix:"@",ignoreAttributes:!1,parseAttributeValue:!1,trimValues:!0,isArray:i(o=>["Field","Item","Service","Passenger","Payment","MasterRecord","Request","Notes","ServiceID"].includes(o),"isArray")})}async postXml(t,o,a,m){let p=this.xmlBuilder.build({[o]:a}),c=await this.httpClient.post(t,p,m);return this.xmlParser.parse(c.data)}};i(Fe,"XmlHttpClient");var R=Fe;R=un([(0,S.Injectable)({scope:S.Scope.DEFAULT}),cn(0,(0,S.Inject)(y)),_t("design:type",Function),_t("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig])],R);var Mt=require("@nestjs/config"),Lt="aves",ce=(0,Mt.registerAs)(Lt,()=>({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"),xt=r.z.enum(["01","02"]),ve=r.z.object({baseUrl:r.z.url(),hostId:r.z.string().length(6),xtoken:r.z.string(),languageCode:xt.optional(),timeout:r.z.number().optional()}),wt=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()}),Vt=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()}),Bt=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:wt.optional(),ContactInfo:Vt.optional()}),jt=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()})}),dn=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()}),ln=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()})}),fn=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(Bt)}),SelectedServiceList:r.z.object({Service:r.z.array(jt)}),SpecialRequests:r.z.object({Request:r.z.array(r.z.object({"@Type":r.z.enum(["MEAL","SEAT","WHEELCHAIR","OTHER"]),"@Description":r.z.string()}))}).optional()})}),gn=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()})}),yn=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 Tn(e,t,o,a){var m=arguments.length,p=m<3?t:a===null?a=Object.getOwnPropertyDescriptor(t,o):a,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(e,t,o,a);else for(var f=e.length-1;f>=0;f--)(c=e[f])&&(p=(m<3?c(p):m>3?c(t,o,p):c(t,o))||p);return m>3&&p&&Object.defineProperty(t,o,p),p}i(Tn,"_ts_decorate");var I=class I{static forRoot(t){let o=this.validateConfig(t);return{module:I,imports:[_e.ConfigModule.forFeature(ce)],providers:[{provide:y,useValue:o},this.createXmlHttpClientProvider(),g],exports:[g,E]}}static forRootAsync(t){let o=this.createAsyncProviders(t);return{module:I,imports:[...t.imports??[],_e.ConfigModule.forFeature(ce)],providers:[...o,this.createXmlHttpClientProvider(),g],exports:[g,E]}}static createXmlHttpClientProvider(){return{provide:E,useClass:R}}static createAsyncProviders(t){if(t.useFactory)return[{provide:y,useFactory:i(async(...m)=>{try{let p=await t.useFactory(...m);return this.validateConfig(p)}catch(p){throw new Error(`Failed to create Aves configuration: ${p.message}`)}},"useFactory"),inject:t.inject??[]}];let o=t.useClass||t.useExisting;if(!o)throw new Error("Invalid AvesModule async options: provide useFactory, useClass, or useExisting");let a=[{provide:y,useFactory:i(async m=>{try{let p=await m.createAvesOptions();return this.validateConfig(p)}catch(p){throw new Error(`Failed to create Aves configuration: ${p.message}`)}},"useFactory"),inject:[o]}];return t.useClass&&a.push({provide:t.useClass,useClass:t.useClass}),a}static validateConfig(t){let o=ve.safeParse(t);if(!o.success)throw new Error(`Invalid AVES SDK configuration: ${o.error.issues.map(a=>a.message).join(", ")}`);return o.data}};i(I,"AvesModule"),u(I,"MODULE_NAME","AvesModule"),u(I,"VERSION","1.0.0");var b=I;b=Tn([(0,de.Global)(),(0,de.Module)({})],b);var En=(function(e){return e.OK="OK",e.ERROR="ERROR",e.WARNING="WARNING",e.TIMEOUT="TIMEOUT",e})({}),l=(function(e){return e.ERROR="ERROR",e.WARNING="WARNING",e.INFO="INFO",e})({}),s=(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 kt=require("zod");var fe=class fe{constructor(t){u(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,o="; "){return t.issues.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`).join(o)}createError({message:t,path:o}){return{success:!1,error:new kt.ZodError([{code:"custom",message:t,path:o}])}}static withSchema(t){return new fe(t)}};i(fe,"AvesValidator");var le=fe;function Rn(e){return new le(e)}i(Rn,"createAvesValidator");var n=require("zod"),Me=n.z.enum(["home","work","billing","delivery"]),Le=n.z.enum(["home","work","mobile","fax"]),xe=n.z.enum(["home","work"]),we=n.z.enum(["adult","child","infant"]),Ve=n.z.enum(["mr","mrs","ms","dr","prof"]),ge=n.z.enum(["male","female"]),Be=n.z.enum(["flight","hotel","car","transfer","insurance"]),je=n.z.enum(["confirmed","pending","cancelled"]),ke=n.z.enum(["credit_card","debit_card","bank_transfer","cash"]),qe=n.z.enum(["pending","confirmed","failed"]),ye=n.z.enum(["customer","agent","supplier"]),Ue=n.z.enum(["equals","contains","starts_with","ends_with"]),He=n.z.enum(["individual","group","corporate"]),Ge=n.z.enum(["low","normal","high","urgent"]),Ke=n.z.enum(["meal","seat","wheelchair","other"]),We=n.z.enum(["customer_request","no_show","operational","other"]),Ye=n.z.enum(["original_payment","credit","cash"]),$e=n.z.enum(["confirmation","invoice","voucher","ticket","all"]),Qe=n.z.enum(["pdf","html","xml"]),ze=n.z.enum(["email","sms","download"]),Ze=n.z.enum(["pending","confirmed","cancelled","completed"]),Je=n.z.enum(["service","tax","fee","discount"]),et=n.z.enum(["sent","pending","failed"]),tt=n.z.enum(["active","inactive","suspended"]),nt=n.z.enum(["email","sms","phone"]),O=n.z.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Date must be in YYYY-MM-DD format"),Xe=n.z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/,"DateTime must be in ISO 8601 format"),Te=n.z.object({type:Me.optional(),street:n.z.string().optional(),city:n.z.string().optional(),state:n.z.string().optional(),postalCode:n.z.string().optional(),country:n.z.string().optional()}),Ee=n.z.object({phone:n.z.object({type:Le.optional(),number:n.z.string().min(1,"Phone number is required")}).optional(),email:n.z.object({type:xe.optional(),address:n.z.string().email("Valid email address is required")}).optional()}),P=n.z.object({id:n.z.string().min(1,"Customer ID is required"),type:ye,status:tt,personalInfo:n.z.object({title:n.z.string().optional(),firstName:n.z.string().min(1,"First name is required"),lastName:n.z.string().min(1,"Last name is required"),middleName:n.z.string().optional(),dateOfBirth:O.optional(),gender:ge.optional(),nationality:n.z.string().optional()}).optional(),contact:Ee.optional(),address:Te.optional(),businessInfo:n.z.object({companyName:n.z.string().optional(),taxId:n.z.string().optional(),licenseNumber:n.z.string().optional()}).optional(),preferences:n.z.object({language:n.z.string().optional(),currency:n.z.string().optional(),communicationMethod:nt.optional()}).optional()}),Re=n.z.object({id:n.z.string().min(1,"Passenger ID is required"),type:we,title:Ve.optional(),firstName:n.z.string().min(1,"First name is required"),lastName:n.z.string().min(1,"Last name is required"),middleName:n.z.string().optional(),dateOfBirth:O.optional(),gender:ge.optional(),nationality:n.z.string().optional(),passport:n.z.object({number:n.z.string().min(1,"Passport number is required"),expiryDate:O,issuingCountry:n.z.string().min(1,"Issuing country is required")}).optional(),address:Te.optional(),contact:Ee.optional()}),Ie=n.z.object({id:n.z.string().min(1,"Service ID is required"),type:Be,status:je,code:n.z.string().optional(),name:n.z.string().optional(),description:n.z.string().optional(),startDate:O.optional(),endDate:O.optional(),price:n.z.object({currency:n.z.string().min(1,"Currency is required"),amount:n.z.number().positive("Amount must be positive")}).optional()}),ot=n.z.object({id:n.z.string().min(1,"Payment ID is required"),type:ke,status:qe,amount:n.z.object({currency:n.z.string().min(1,"Currency is required"),amount:n.z.number().positive("Amount must be positive")}),details:n.z.object({cardNumber:n.z.string().optional(),expiryDate:n.z.string().optional(),cardHolderName:n.z.string().optional()}).optional()}),qt=n.z.object({type:ye,fields:n.z.array(n.z.object({name:n.z.string().min(1,"Field name is required"),value:n.z.string().min(1,"Field value is required"),operator:Ue.optional()})).min(1,"At least one search field is required"),pagination:n.z.object({pageSize:n.z.number().int().positive("Page size must be a positive integer"),pageNumber:n.z.number().int().min(1,"Page number must be at least 1")}).optional()}),Ut=n.z.object({type:He,priority:Ge,customerId:n.z.string().optional(),customerDetails:P.optional(),passengers:n.z.array(Re).min(1,"At least one passenger is required"),services:n.z.array(Ie).min(1,"At least one service is required"),specialRequests:n.z.array(n.z.object({type:Ke,description:n.z.string().min(1,"Special request description is required")})).optional()}),Ht=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),reason:We,description:n.z.string().optional(),refundRequest:n.z.object({amount:n.z.number().positive("Refund amount must be positive"),currency:n.z.string().min(1,"Currency is required"),method:Ye}).optional()}),Gt=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),documentType:$e,format:Qe,language:n.z.string().optional(),deliveryMethod:n.z.object({type:ze,address:n.z.string().optional()}).optional()}),Kt=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),payments:n.z.array(ot).min(1,"At least one payment is required")}),Wt=n.z.object({id:n.z.string().min(1,"Booking ID is required"),status:Ze,createdAt:Xe,updatedAt:Xe,customer:P,passengers:n.z.array(Re),services:n.z.array(Ie),pricing:n.z.object({totalAmount:n.z.object({currency:n.z.string().min(1,"Currency is required"),amount:n.z.number().positive("Amount must be positive")}),breakdowns:n.z.array(n.z.object({type:Je,description:n.z.string().min(1,"Description is required"),amount:n.z.number()})).optional()})}),Yt=n.z.object({results:n.z.array(P),pagination:n.z.object({totalRecords:n.z.number().int().min(0),pageSize:n.z.number().int().positive(),pageNumber:n.z.number().int().min(1),totalPages:n.z.number().int().min(0)}).optional()}),$t=n.z.object({id:n.z.string().min(1,"Document ID is required"),type:n.z.string().min(1,"Document type is required"),format:n.z.string().min(1,"Document format is required"),size:n.z.number().int().positive("Document size must be positive"),createdAt:Xe,downloadUrl:n.z.string().url("Download URL must be valid").optional(),deliveryStatus:n.z.object({status:et,method:n.z.string().min(1,"Delivery method is required"),address:n.z.string().optional()}).optional()}),Qt=n.z.object({success:n.z.boolean(),message:n.z.string().optional(),data:n.z.any().optional()}),In={addressType:Me,contactType:Le,emailType:xe,passengerType:we,titleType:Ve,genderType:ge,serviceType:Be,serviceStatusType:je,paymentType:ke,paymentStatusType:qe,customerType:ye,searchOperatorType:Ue,bookingType:He,priorityType:Ge,specialRequestType:Ke,cancelReasonType:We,refundMethodType:Ye,documentType:$e,documentFormatType:Qe,deliveryMethodType:ze,bookingStatusType:Ze,pricingItemType:Je,deliveryStatusType:et,customerStatusType:tt,communicationMethodType:nt,customerAddress:Te,customerContact:Ee,customer:P,bookingPassenger:Re,bookingService:Ie,bookingPayment:ot,searchCustomerRequest:qt,createBookingRequest:Ut,cancelBookingRequest:Ht,printDocumentRequest:Gt,addPaymentRequest:Kt,bookingResponse:Wt,searchResponse:Yt,documentResponse:$t,operationResponse:Qt};var zt=require("@nestjs/common");var N=class N extends Error{constructor(o,a,m={}){super(a);u(this,"code");u(this,"severity");u(this,"timestamp");u(this,"requestId");u(this,"context");this.name="AvesException",this.code=o,this.severity=m.severity||l.ERROR,this.timestamp=new Date().toISOString(),this.context=m.context,this.requestId=m.requestId||this.generateRequestId(),Object.setPrototypeOf(this,N.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,N)}static fromAvesError(o){return new N(o.code,o.message,{severity:o.severity,context:o.context,requestId:o.requestId})}isRetryable(){return[s.TIMEOUT,s.SERVICE_UNAVAILABLE,s.INTERNAL_SERVER_ERROR,s.RATE_LIMIT_EXCEEDED].includes(this.code)}getUserFriendlyMessage(){return{[s.INVALID_TOKEN]:"Your session has expired. Please log in again.",[s.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[s.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[s.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[s.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[s.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[s.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[s.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[s.TIMEOUT]:"The request timed out. Please try again.",[s.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 s.INVALID_TOKEN:case s.TOKEN_EXPIRED:return 401;case s.INSUFFICIENT_PERMISSIONS:return 403;case s.BOOKING_NOT_FOUND:return 404;case s.INVALID_REQUEST_FORMAT:case s.MISSING_REQUIRED_FIELD:case s.INVALID_FIELD_VALUE:return 400;case s.RATE_LIMIT_EXCEEDED:return 429;case s.SERVICE_UNAVAILABLE:return 503;case s.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)}`}};i(N,"AvesException");var d=N;function hn(e,t,o,a){var m=arguments.length,p=m<3?t:a===null?a=Object.getOwnPropertyDescriptor(t,o):a,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(e,t,o,a);else for(var f=e.length-1;f>=0;f--)(c=e[f])&&(p=(m<3?c(p):m>3?c(t,o,p):c(t,o))||p);return m>3&&p&&Object.defineProperty(t,o,p),p}i(hn,"_ts_decorate");var rt=class rt{parseError(t){return t instanceof d?t:this.isHttpError(t)?this.parseHttpError(t):this.isAvesXmlResponse(t)?this.parseAvesXmlError(t):t instanceof Error?new d(s.INTERNAL_SERVER_ERROR,t.message,{severity:l.ERROR,context:this.buildContext({type:"javascript_error",errorName:t.name,stack:t.stack||"No stack trace available"})}):new d(s.INTERNAL_SERVER_ERROR,"Unknown error occurred",{severity:l.ERROR,context:this.buildContext({type:"unknown_error",errorName:typeof t,errorValue:String(t)})})}parseHttpError(t){if(t.response){let o=t.response.status,a=t.response.statusText;switch(o){case 400:return new d(s.INVALID_REQUEST_FORMAT,`Bad Request: ${a}`,{severity:l.ERROR,context:this.buildContext({type:"http_error",errorName:o,statusText:a,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 401:return new d(s.INVALID_TOKEN,"Authentication failed",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 403:return new d(s.INSUFFICIENT_PERMISSIONS,"Access forbidden",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 404:return new d(s.BOOKING_NOT_FOUND,"Resource not found",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 429:return new d(s.RATE_LIMIT_EXCEEDED,"Rate limit exceeded",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,retryAfter:t.response.headers?.["retry-after"]})});case 500:return new d(s.INTERNAL_SERVER_ERROR,"Internal server error",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});case 503:return new d(s.SERVICE_UNAVAILABLE,"Service unavailable",{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})});default:return new d(s.INTERNAL_SERVER_ERROR,`HTTP ${o}: ${a}`,{severity:l.ERROR,context:this.buildContext({type:"http_error",status:o,statusText:a,url:t.config?.url,method:t.config?.method,timeout:t.config?.timeout})})}}else return t.request?new d(s.TIMEOUT,"Request timeout - no response from AVES API",{severity:l.ERROR,context:this.buildContext({type:"http_error",timeout:!0,url:t.config?.url,method:t.config?.method,configuredTimeout:t.config?.timeout})}):new d(s.INTERNAL_SERVER_ERROR,`Request setup error: ${t.message}`,{severity:l.ERROR,context:this.buildContext({type:"http_error",setupError:!0})})}parseAvesXmlError(t){if(!t?.Response?.RsStatus)return new d(s.INVALID_REQUEST_FORMAT,"Invalid response format from AVES API",{severity:l.ERROR,context:this.buildContext({type:"aves_xml_error",missingRsStatus:!0})});let o=t.Response.RsStatus;if(o["@Status"]==="ERROR")return new d(o.ErrorCode||s.INTERNAL_SERVER_ERROR,o.ErrorDescription||"Unknown error from AVES API",{severity:l.ERROR,context:this.buildContext({type:"aves_xml_error",originalResponse:o})});if(o.Warnings?.Warning){let a=Array.isArray(o.Warnings.Warning)?o.Warnings.Warning:[o.Warnings.Warning];return new d(s.INVALID_FIELD_VALUE,a.join("; "),{severity:l.WARNING,context:this.buildContext({type:"aves_xml_warning",warnings:a})})}return new d(s.INTERNAL_SERVER_ERROR,"Unexpected response from AVES API",{severity:l.ERROR,context:this.buildContext({type:"aves_xml_error",unexpectedResponse:!0,status:o["@Status"]})})}isRetryable(t){return[s.TIMEOUT,s.SERVICE_UNAVAILABLE,s.INTERNAL_SERVER_ERROR,s.RATE_LIMIT_EXCEEDED].includes(t.code)}getUserFriendlyMessage(t){return{[s.INVALID_TOKEN]:"Your session has expired. Please log in again.",[s.TOKEN_EXPIRED]:"Your session has expired. Please log in again.",[s.INSUFFICIENT_PERMISSIONS]:"You do not have permission to perform this action.",[s.BOOKING_NOT_FOUND]:"The requested booking could not be found.",[s.BOOKING_ALREADY_CANCELLED]:"This booking has already been cancelled.",[s.PAYMENT_FAILED]:"Payment processing failed. Please try again.",[s.INSUFFICIENT_INVENTORY]:"The requested service is no longer available.",[s.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[s.TIMEOUT]:"The request timed out. Please try again.",[s.RATE_LIMIT_EXCEEDED]:"Too many requests. Please wait a moment and try again."}[t.code]||t.message}buildContext(t){let o={};return typeof t=="object"&&t!==null?Object.keys(t).forEach(a=>{let m=t[a];if(this.isSensitiveKey(a)){o[a]="********";return}this.isSerializableValue(m)?o[a]=m:typeof m=="function"?o[a]="[Function]":m instanceof Error?o[a]={name:m.name,message:m.message,stack:m.stack?.split(`
|
|
2
2
|
`).slice(0,3).join(`
|
|
3
|
-
`)}:
|
|
3
|
+
`)}:o[a]=String(m)}):typeof t=="string"?o.message=t:typeof t=="number"||typeof t=="boolean"?o.value=t:o.input=String(t),o.timestamp=new Date().toISOString(),o.contextType=typeof t,o}isSensitiveKey(t){let o=["password","token","secret","key","auth","credential","xtoken","authorization","cookie","session","private"],a=t.toLowerCase();return o.some(m=>a.includes(m))}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}};i(rt,"AvesErrorHandler");var F=rt;F=hn([(0,zt.Injectable)()],F);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,addPaymentRequestSchema,addressTypeSchema,apiSchemas,avesConfig,bookingPassengerSchema,bookingPaymentSchema,bookingResponseSchema,bookingServiceSchema,bookingStatusTypeSchema,bookingTypeSchema,cancelBookingRequestSchema,cancelReasonTypeSchema,communicationMethodTypeSchema,configValidationSchema,contactTypeSchema,createAvesValidator,createBookingRequestSchema,createDateString,createDateTimeString,createTimeString,customerAddressSchema,customerContactSchema,customerSchema,customerStatusTypeSchema,customerTypeSchema,deliveryMethodTypeSchema,deliveryStatusTypeSchema,documentFormatTypeSchema,documentResponseSchema,documentTypeSchema,emailTypeSchema,genderTypeSchema,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,operationResponseSchema,passengerTypeSchema,paymentStatusTypeSchema,paymentTypeSchema,pricingItemTypeSchema,printDocumentRequestSchema,priorityTypeSchema,refundMethodTypeSchema,searchCustomerRequestSchema,searchOperatorTypeSchema,searchResponseSchema,serviceStatusTypeSchema,serviceTypeSchema,specialRequestTypeSchema,titleTypeSchema});
|
|
4
4
|
//# sourceMappingURL=index.cjs.map
|