aves-sdk 1.0.0 → 1.0.2
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 +1803 -26
- package/dist/index.d.ts +1803 -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 Jt=Object.create;var S=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,on=Object.prototype.hasOwnProperty;var rn=(e,t,o)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var i=(e,t)=>S(e,"name",{value:t,configurable:!0});var an=(e,t)=>{for(var o in t)S(e,o,{get:t[o],enumerable:!0})},at=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of tn(t))!on.call(e,m)&&m!==o&&S(e,m,{get:()=>t[m],enumerable:!(a=en(t,m))||a.enumerable});return e};var sn=(e,t,o)=>(o=e!=null?Jt(nn(e)):{},at(t||!e||!e.__esModule?S(o,"default",{value:e,enumerable:!0}):o,e)),mn=e=>at(S({},"__esModule",{value:!0}),e);var u=(e,t,o)=>rn(e,typeof t!="symbol"?t+"":t,o);var Nn={};an(Nn,{AVES_CONFIG_NAMESPACE:()=>xt,AVES_SDK_CONFIG:()=>T,AddressValidation:()=>wt,AvesErrorCodes:()=>s,AvesErrorHandler:()=>v,AvesException:()=>d,AvesModule:()=>O,AvesService:()=>g,AvesSeverity:()=>l,AvesStatus:()=>Rn,AvesValidator:()=>fe,BookFileRQValidation:()=>gn,CancelFileRQValidation:()=>yn,ContactInfoValidation:()=>Bt,LanguageCodeValidation:()=>Vt,PassengerValidation:()=>jt,PaymentValidation:()=>ln,PrintBookingDocumentRQValidation:()=>Tn,SearchMasterRecordRQValidation:()=>fn,ServiceValidation:()=>kt,XML_HTTP_CLIENT:()=>R,XmlHttpClient:()=>I,addPaymentRequestSchema:()=>Wt,addressTypeSchema:()=>Le,apiSchemas:()=>hn,avesConfig:()=>de,bookingPassengerSchema:()=>Ie,bookingPaymentSchema:()=>rt,bookingResponseSchema:()=>Yt,bookingServiceSchema:()=>he,bookingStatusTypeSchema:()=>Je,bookingTypeSchema:()=>Ge,cancelBookingRequestSchema:()=>Gt,cancelReasonTypeSchema:()=>Ye,communicationMethodTypeSchema:()=>ot,configValidationSchema:()=>_e,contactTypeSchema:()=>xe,createAvesValidator:()=>In,createBookingRequestSchema:()=>Ht,createDateString:()=>E,createDateTimeString:()=>A,createTimeString:()=>pn,customerAddressSchema:()=>Ee,customerContactSchema:()=>Re,customerSchema:()=>F,customerStatusTypeSchema:()=>nt,customerTypeSchema:()=>Te,deliveryMethodTypeSchema:()=>Ze,deliveryStatusTypeSchema:()=>tt,documentFormatTypeSchema:()=>ze,documentResponseSchema:()=>Qt,documentTypeSchema:()=>Qe,emailTypeSchema:()=>Ve,genderTypeSchema:()=>ye,mapAddPaymentToXml:()=>Nt,mapAddressToXml:()=>ie,mapAddressTypeFromXml:()=>M,mapAddressTypeToXml:()=>_,mapBookingFromXml:()=>pe,mapBookingResponseFromXml:()=>At,mapBookingTypeToXml:()=>Q,mapCancelBookingToXml:()=>ht,mapCancelReasonToXml:()=>J,mapCancelResponseFromXml:()=>Ot,mapContactToXml:()=>se,mapContactTypeFromXml:()=>L,mapContactTypeToXml:()=>X,mapCreateBookingToXml:()=>It,mapCustomerToXml:()=>Ce,mapCustomerTypeToXml:()=>C,mapDeliveryMethodToXml:()=>oe,mapDocumentFormatToXml:()=>ne,mapDocumentResponseFromXml:()=>bt,mapDocumentTypeToXml:()=>te,mapEmailTypeFromXml:()=>V,mapEmailTypeToXml:()=>x,mapMasterRecordFromXml:()=>Ft,mapPassengerToXml:()=>Ne,mapPassengerTypeFromXml:()=>B,mapPassengerTypeToXml:()=>w,mapPaymentResponseFromXml:()=>Pt,mapPaymentStatusFromXml:()=>$,mapPaymentStatusToXml:()=>Y,mapPaymentToXml:()=>Ae,mapPaymentTypeFromXml:()=>W,mapPaymentTypeToXml:()=>K,mapPrintDocumentToXml:()=>St,mapPriorityToXml:()=>z,mapRefundMethodToXml:()=>ee,mapSearchCustomerToXml:()=>Rt,mapSearchOperatorToXml:()=>re,mapSearchResponseFromXml:()=>Ct,mapServiceStatusFromXml:()=>G,mapServiceStatusToXml:()=>H,mapServiceToXml:()=>De,mapServiceTypeFromXml:()=>U,mapServiceTypeToXml:()=>q,mapSpecialRequestTypeToXml:()=>Z,mapTitleFromXml:()=>k,mapTitleToXml:()=>j,operationResponseSchema:()=>zt,passengerTypeSchema:()=>we,paymentStatusTypeSchema:()=>Ue,paymentTypeSchema:()=>qe,pricingItemTypeSchema:()=>et,printDocumentRequestSchema:()=>Kt,priorityTypeSchema:()=>Ke,refundMethodTypeSchema:()=>$e,searchCustomerRequestSchema:()=>Ut,searchOperatorTypeSchema:()=>He,searchResponseSchema:()=>$t,serviceStatusTypeSchema:()=>ke,serviceTypeSchema:()=>je,specialRequestTypeSchema:()=>We,titleTypeSchema:()=>Be});module.exports=mn(Nn);var So=require("reflect-metadata");var y=require("date-fns");var E=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=(0,y.parseISO)(e)}catch{throw new Error(`Invalid date string: ${e}`)}}else t=e;if(!(0,y.isValid)(t))throw new Error(`Invalid date value: ${e}`);return(0,y.format)(t,"yyyy-MM-dd")},"createDateString"),A=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=(0,y.parseISO)(e)}catch{throw new Error(`Invalid datetime string: ${e}`)}}else t=e;if(!(0,y.isValid)(t))throw new Error(`Invalid datetime value: ${e}`);return(0,y.format)(t,"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")},"createDateTimeString"),pn=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 _(e){return{home:"HOME",work:"WORK",billing:"BILLING",delivery:"DELIVERY"}[e]||"HOME"}i(_,"mapAddressTypeToXml");function M(e){return{HOME:"home",WORK:"work",BILLING:"billing",DELIVERY:"delivery"}[e]||"home"}i(M,"mapAddressTypeFromXml");function X(e){return{home:"HOME",work:"WORK",mobile:"MOBILE",fax:"FAX"}[e]||"HOME"}i(X,"mapContactTypeToXml");function L(e){return{HOME:"home",WORK:"work",MOBILE:"mobile",FAX:"fax"}[e]||"home"}i(L,"mapContactTypeFromXml");function x(e){return{home:"HOME",work:"WORK"}[e]||"HOME"}i(x,"mapEmailTypeToXml");function V(e){return{HOME:"home",WORK:"work"}[e]||"home"}i(V,"mapEmailTypeFromXml");function w(e){return{adult:"ADT",child:"CHD",infant:"INF"}[e]||"ADT"}i(w,"mapPassengerTypeToXml");function B(e){return{ADT:"adult",CHD:"child",INF:"infant"}[e]||"adult"}i(B,"mapPassengerTypeFromXml");function j(e){return{mr:"MR",mrs:"MRS",ms:"MS",dr:"DR",prof:"PROF"}[e]||"MR"}i(j,"mapTitleToXml");function k(e){return{MR:"mr",MRS:"mrs",MS:"ms",DR:"dr",PROF:"prof"}[e]||"mr"}i(k,"mapTitleFromXml");function q(e){return{flight:"FLIGHT",hotel:"HOTEL",car:"CAR",transfer:"TRANSFER",insurance:"INSURANCE"}[e]||"FLIGHT"}i(q,"mapServiceTypeToXml");function U(e){return{FLIGHT:"flight",HOTEL:"hotel",CAR:"car",TRANSFER:"transfer",INSURANCE:"insurance"}[e]||"flight"}i(U,"mapServiceTypeFromXml");function H(e){return{confirmed:"CONFIRMED",pending:"PENDING",cancelled:"CANCELLED"}[e]||"PENDING"}i(H,"mapServiceStatusToXml");function G(e){return{CONFIRMED:"confirmed",PENDING:"pending",CANCELLED:"cancelled"}[e]||"pending"}i(G,"mapServiceStatusFromXml");function K(e){return{credit_card:"CREDIT_CARD",debit_card:"DEBIT_CARD",bank_transfer:"BANK_TRANSFER",cash:"CASH"}[e]||"CASH"}i(K,"mapPaymentTypeToXml");function W(e){return{CREDIT_CARD:"credit_card",DEBIT_CARD:"debit_card",BANK_TRANSFER:"bank_transfer",CASH:"cash"}[e]||"cash"}i(W,"mapPaymentTypeFromXml");function Y(e){return{pending:"PENDING",confirmed:"CONFIRMED",failed:"FAILED"}[e]||"PENDING"}i(Y,"mapPaymentStatusToXml");function $(e){return{PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"}[e]||"pending"}i($,"mapPaymentStatusFromXml");function C(e){return{customer:"CUSTOMER",agent:"AGENT",supplier:"SUPPLIER"}[e]||"CUSTOMER"}i(C,"mapCustomerTypeToXml");function st(e){return{CUSTOMER:"customer",AGENT:"agent",SUPPLIER:"supplier"}[e]||"customer"}i(st,"mapCustomerTypeFromXml");function mt(e){return{active:"ACTIVE",inactive:"INACTIVE",suspended:"SUSPENDED"}[e]||"ACTIVE"}i(mt,"mapCustomerStatusToXml");function pt(e){return{ACTIVE:"active",INACTIVE:"inactive",SUSPENDED:"suspended"}[e]||"active"}i(pt,"mapCustomerStatusFromXml");function ut(e){return{email:"EMAIL",sms:"SMS",phone:"PHONE"}[e]||"EMAIL"}i(ut,"mapCommunicationMethodToXml");function ct(e){return{EMAIL:"email",SMS:"sms",PHONE:"phone"}[e]||"email"}i(ct,"mapCommunicationMethodFromXml");function Q(e){return{individual:"INDIVIDUAL",group:"GROUP",corporate:"CORPORATE"}[e]||"INDIVIDUAL"}i(Q,"mapBookingTypeToXml");function dt(e){return{PENDING:"pending",CONFIRMED:"confirmed",CANCELLED:"cancelled",COMPLETED:"completed"}[e]||"pending"}i(dt,"mapBookingStatusFromXml");function z(e){return{low:"LOW",normal:"NORMAL",high:"HIGH",urgent:"URGENT"}[e]||"NORMAL"}i(z,"mapPriorityToXml");function Z(e){return{meal:"MEAL",seat:"SEAT",wheelchair:"WHEELCHAIR",other:"OTHER"}[e]||"OTHER"}i(Z,"mapSpecialRequestTypeToXml");function J(e){return{customer_request:"CUSTOMER_REQUEST",no_show:"NO_SHOW",operational:"OPERATIONAL",other:"OTHER"}[e]||"OTHER"}i(J,"mapCancelReasonToXml");function ee(e){return{original_payment:"ORIGINAL_PAYMENT",credit:"CREDIT",cash:"CASH"}[e]||"CASH"}i(ee,"mapRefundMethodToXml");function te(e){return{confirmation:"CONFIRMATION",invoice:"INVOICE",voucher:"VOUCHER",ticket:"TICKET",all:"ALL"}[e]||"ALL"}i(te,"mapDocumentTypeToXml");function ne(e){return{pdf:"PDF",html:"HTML",xml:"XML"}[e]||"PDF"}i(ne,"mapDocumentFormatToXml");function oe(e){return{email:"EMAIL",sms:"SMS",download:"DOWNLOAD"}[e]||"EMAIL"}i(oe,"mapDeliveryMethodToXml");function re(e){return{equals:"EQUALS",contains:"CONTAINS",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH"}[e]||"EQUALS"}i(re,"mapSearchOperatorToXml");function lt(e){return{SERVICE:"service",TAX:"tax",FEE:"fee",DISCOUNT:"discount"}[e]||"service"}i(lt,"mapPricingItemTypeFromXml");function ft(e){return{SENT:"sent",PENDING:"pending",FAILED:"failed"}[e]||"pending"}i(ft,"mapDeliveryStatusFromXml");function Se(e){return{male:"M",female:"F"}[e]||"M"}i(Se,"mapGenderToXml");function gt(e){return{M:"male",F:"female"}[e]||"male"}i(gt,"mapGenderFromXml");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,"mapAddressToXml");function ae(e){return{type:e["@Type"]?M(e["@Type"]):void 0,street:e.Street,city:e.City,state:e.State,postalCode:e.PostalCode,country:e.Country}}i(ae,"mapAddressFromXml");function se(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?x(e.email.type):void 0,"@Address":e.email.address}:void 0}}i(se,"mapContactToXml");function me(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"]?V(e.Email["@Type"]):void 0,address:e.Email["@Address"]}:void 0}}i(me,"mapContactFromXml");function Ne(e){return{"@PassengerID":e.id,"@Type":w(e.type),"@Title":e.title?j(e.title):void 0,FirstName:e.firstName,LastName:e.lastName,MiddleName:e.middleName,DateOfBirth:e.dateOfBirth,Gender:e.gender?Se(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?ie(e.address):void 0,ContactInfo:e.contact?se(e.contact):void 0}}i(Ne,"mapPassengerToXml");function yt(e){return{id:e["@PassengerID"],type:B(e["@Type"]),title:e["@Title"]?k(e["@Title"]):void 0,firstName:e.FirstName,lastName:e.LastName,middleName:e.MiddleName,dateOfBirth:e.DateOfBirth?E(e.DateOfBirth):void 0,gender:e.Gender?gt(e.Gender):void 0,nationality:e.Nationality,passport:e.Passport?{number:e.Passport["@Number"],expiryDate:E(e.Passport["@ExpiryDate"]),issuingCountry:e.Passport["@IssuingCountry"]}:void 0,address:e.Address?ae(e.Address):void 0,contact:e.ContactInfo?me(e.ContactInfo):void 0}}i(yt,"mapPassengerFromXml");function De(e){return{"@ServiceID":e.id,"@Type":q(e.type),"@Status":H(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(De,"mapServiceToXml");function Tt(e){return{id:e["@ServiceID"],type:U(e["@Type"]),status:G(e["@Status"]),code:e.ServiceDetails.Code,name:e.ServiceDetails.Name,description:e.ServiceDetails.Description,startDate:e.ServiceDetails.StartDate?E(e.ServiceDetails.StartDate):void 0,endDate:e.ServiceDetails.EndDate?E(e.ServiceDetails.EndDate):void 0,price:e.ServiceDetails.Price?{currency:e.ServiceDetails.Price["@Currency"],amount:e.ServiceDetails.Price["@Amount"]}:void 0}}i(Tt,"mapServiceFromXml");function Ae(e){return{"@PaymentID":e.id,"@Type":K(e.type),"@Status":Y(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(Ae,"mapPaymentToXml");function Et(e){return{id:e["@PaymentID"],type:W(e["@Type"]),status:$(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(Et,"mapPaymentFromXml");function Rt(e){return{SearchCriteria:{MasterRecordType:C(e.type),SearchFields:{Field:e.fields.map(t=>({"@Name":t.name,"@Value":t.value,"@Operator":t.operator?re(t.operator):void 0}))},Pagination:e.pagination?{"@PageSize":e.pagination.pageSize,"@PageNumber":e.pagination.pageNumber}:void 0}}}i(Rt,"mapSearchCustomerToXml");function Ce(e){return{"@MasterRecordID":e.id,"@Type":C(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,Gender:e.personalInfo.gender?Se(e.personalInfo.gender):void 0,Nationality:e.personalInfo.nationality}:void 0,ContactInfo:e.contact?se(e.contact):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(Ce,"mapCustomerToXml");function It(e){return{BookingDetails:{"@BookingType":Q(e.type),"@Priority":z(e.priority),CustomerInfo:{"@CustomerID":e.customerId,CustomerDetails:e.customerDetails?Ce(e.customerDetails):void 0},PassengerList:{Passenger:e.passengers.map(Ne)},SelectedServiceList:{Service:e.services.map(De)},SpecialRequests:e.specialRequests?{Request:e.specialRequests.map(t=>({"@Type":Z(t.type),"@Description":t.description}))}:void 0}}}i(It,"mapCreateBookingToXml");function ht(e){return{"@BookingFileID":e.bookingId,CancellationDetails:{"@Reason":J(e.reason),"@Description":e.description,RefundRequest:e.refundRequest?{"@Amount":e.refundRequest.amount,"@Currency":e.refundRequest.currency,"@Method":ee(e.refundRequest.method)}:void 0}}}i(ht,"mapCancelBookingToXml");function St(e){return{"@BookingFileID":e.bookingId,DocumentRequest:{"@DocumentType":te(e.documentType),"@Format":ne(e.format),"@Language":e.language,DeliveryMethod:e.deliveryMethod?{"@Type":oe(e.deliveryMethod.type),"@Address":e.deliveryMethod.address}:void 0}}}i(St,"mapPrintDocumentToXml");function Nt(e){return{"@BookingFileID":e.bookingId,PaymentList:{Payment:e.payments.map(Ae)}}}i(Nt,"mapAddPaymentToXml");function Dt(e){return{id:e["@MasterRecordID"],type:st(e["@Type"]),status:pt(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?E(e.PersonalInfo.DateOfBirth):void 0,gender:e.PersonalInfo.Gender==="M"?"male":"female",nationality:e.PersonalInfo.Nationality}:void 0,contact:e.ContactInfo?me(e.ContactInfo):void 0,address:e.Address?ae(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?ct(e.Preferences.CommunicationMethod):void 0}:void 0}}i(Dt,"mapCustomerFromXml");function pe(e){return{id:e["@BookingFileID"],status:dt(e["@Status"]),createdAt:A(e["@CreationDate"]),updatedAt:A(e["@LastModified"]),customer:Dt(e.CustomerInfo),passengers:e.PassengerList.Passenger.map(yt),services:e.ServiceList.Service.map(Tt),pricing:{totalAmount:{currency:e.Pricing.TotalAmount["@Currency"],amount:e.Pricing.TotalAmount["@Amount"]},breakdowns:e.Pricing.Breakdown?.Item.map(t=>({type:lt(t["@Type"]),description:t["@Description"],amount:t["@Amount"]}))}}}i(pe,"mapBookingFromXml");function At(e){let t=pe(e.BookingFile);return{...t,success:e.OperationResult["@Status"]==="SUCCESS",message:e.OperationResult["@Message"],data:t}}i(At,"mapBookingResponseFromXml");function Ct(e){return{results:e.SearchResults.MasterRecord.map(Dt),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(Ct,"mapSearchResponseFromXml");function bt(e){return{id:e.DocumentInfo["@DocumentID"],type:e.DocumentInfo["@DocumentType"],format:e.DocumentInfo["@Format"],size:e.DocumentInfo["@Size"],createdAt:A(e.DocumentInfo["@CreationDate"]),downloadUrl:e.DocumentInfo.DownloadURL,deliveryStatus:e.DocumentInfo.DeliveryStatus?{status:ft(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(bt,"mapDocumentResponseFromXml");function Ot(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(Ot,"mapCancelResponseFromXml");function Pt(e){let t=pe(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(Et)}}}}i(Pt,"mapPaymentResponseFromXml");function Ft(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?me(e.ContactInfo):void 0,address:e.Address?ae(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(Ft,"mapMasterRecordFromXml");var le=require("@nestjs/common"),Me=require("@nestjs/config");var b=require("@nestjs/common");var T=Symbol("AVES_SDK_CONFIG"),R=Symbol("XML_HTTP_CLIENT");var Oe=class Oe{constructor(t){u(this,"RqHeader");u(this,"Body");Object.assign(this,t)}};i(Oe,"RequestPayload");var be=Oe,Pe=class Pe{constructor(t){u(this,"Request");this.Request=new be(t)}};i(Pe,"WrapRequestDto");var ue=Pe;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 vt(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}i(vt,"_ts_metadata");function _t(e,t){return function(o,a){t(o,a,e)}}i(_t,"_ts_param");var Fe=class Fe{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 ue({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(Fe,"AvesService");var g=Fe;g=un([(0,b.Injectable)(),_t(0,(0,b.Inject)(T)),_t(1,(0,b.Inject)(R)),vt("design:type",Function),vt("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig,typeof IXmlHttpClient>"u"?Object:IXmlHttpClient])],g);var Xt=sn(require("axios"),1),ce=require("fast-xml-parser"),N=require("@nestjs/common");function cn(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(cn,"_ts_decorate");function Mt(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}i(Mt,"_ts_metadata");function dn(e,t){return function(o,a){t(o,a,e)}}i(dn,"_ts_param");var ve=class ve{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 ce.XMLBuilder({attributeNamePrefix:"@",ignoreAttributes:!1,suppressEmptyNode:!0,format:process.env.NODE_ENV?.toLowerCase()==="development"}),this.xmlParser=new ce.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(ve,"XmlHttpClient");var I=ve;I=cn([(0,N.Injectable)({scope:N.Scope.DEFAULT}),dn(0,(0,N.Inject)(T)),Mt("design:type",Function),Mt("design:paramtypes",[typeof AvesSdkConfig>"u"?Object:AvesSdkConfig])],I);var Lt=require("@nestjs/config"),xt="aves",de=(0,Lt.registerAs)(xt,()=>({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"),Vt=r.z.enum(["01","02"]),_e=r.z.object({baseUrl:r.z.url(),hostId:r.z.string().length(6),xtoken:r.z.string(),languageCode:Vt.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()}),Bt=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()}),jt=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:Bt.optional()}),kt=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()})}),ln=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()}),fn=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()})}),gn=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(jt)}),SelectedServiceList:r.z.object({Service:r.z.array(kt)}),SpecialRequests:r.z.object({Request:r.z.array(r.z.object({"@Type":r.z.enum(["MEAL","SEAT","WHEELCHAIR","OTHER"]),"@Description":r.z.string()}))}).optional()})}),yn=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()})}),Tn=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 En(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(En,"_ts_decorate");var h=class h{static forRoot(t){let o=this.validateConfig(t);return{module:h,imports:[Me.ConfigModule.forFeature(de)],providers:[{provide:T,useValue:o},this.createXmlHttpClientProvider(),g],exports:[g,R]}}static forRootAsync(t){let o=this.createAsyncProviders(t);return{module:h,imports:[...t.imports??[],Me.ConfigModule.forFeature(de)],providers:[...o,this.createXmlHttpClientProvider(),g],exports:[g,R]}}static createXmlHttpClientProvider(){return{provide:R,useClass:I}}static createAsyncProviders(t){if(t.useFactory)return[{provide:T,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:T,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=_e.safeParse(t);if(!o.success)throw new Error(`Invalid AVES SDK configuration: ${o.error.issues.map(a=>a.message).join(", ")}`);return o.data}};i(h,"AvesModule"),u(h,"MODULE_NAME","AvesModule"),u(h,"VERSION","1.0.0");var O=h;O=En([(0,le.Global)(),(0,le.Module)({})],O);var Rn=(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 qt=require("zod");var ge=class ge{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 qt.ZodError([{code:"custom",message:t,path:o}])}}static withSchema(t){return new ge(t)}};i(ge,"AvesValidator");var fe=ge;function In(e){return new fe(e)}i(In,"createAvesValidator");var n=require("zod"),Le=n.z.enum(["home","work","billing","delivery"]),xe=n.z.enum(["home","work","mobile","fax"]),Ve=n.z.enum(["home","work"]),we=n.z.enum(["adult","child","infant"]),Be=n.z.enum(["mr","mrs","ms","dr","prof"]),ye=n.z.enum(["male","female"]),je=n.z.enum(["flight","hotel","car","transfer","insurance"]),ke=n.z.enum(["confirmed","pending","cancelled"]),qe=n.z.enum(["credit_card","debit_card","bank_transfer","cash"]),Ue=n.z.enum(["pending","confirmed","failed"]),Te=n.z.enum(["customer","agent","supplier"]),He=n.z.enum(["equals","contains","starts_with","ends_with"]),Ge=n.z.enum(["individual","group","corporate"]),Ke=n.z.enum(["low","normal","high","urgent"]),We=n.z.enum(["meal","seat","wheelchair","other"]),Ye=n.z.enum(["customer_request","no_show","operational","other"]),$e=n.z.enum(["original_payment","credit","cash"]),Qe=n.z.enum(["confirmation","invoice","voucher","ticket","all"]),ze=n.z.enum(["pdf","html","xml"]),Ze=n.z.enum(["email","sms","download"]),Je=n.z.enum(["pending","confirmed","cancelled","completed"]),et=n.z.enum(["service","tax","fee","discount"]),tt=n.z.enum(["sent","pending","failed"]),nt=n.z.enum(["active","inactive","suspended"]),ot=n.z.enum(["email","sms","phone"]),P=n.z.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Date must be in YYYY-MM-DD format"),lo=n.z.string().regex(/^\d{2}:\d{2}:\d{2}$/,"Time must be in HH:MM:SS 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"),Ee=n.z.object({type:Le.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()}),Re=n.z.object({phone:n.z.object({type:xe.optional(),number:n.z.string().min(1,"Phone number is required")}).optional(),email:n.z.object({type:Ve.optional(),address:n.z.string().email("Valid email address is required")}).optional()}),F=n.z.object({id:n.z.string().min(1,"Customer ID is required"),type:Te,status:nt,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:P.optional(),gender:ye.optional(),nationality:n.z.string().optional()}).optional(),contact:Re.optional(),address:Ee.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:ot.optional()}).optional()}),Ie=n.z.object({id:n.z.string().min(1,"Passenger ID is required"),type:we,title:Be.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:P.optional(),gender:ye.optional(),nationality:n.z.string().optional(),passport:n.z.object({number:n.z.string().min(1,"Passport number is required"),expiryDate:P,issuingCountry:n.z.string().min(1,"Issuing country is required")}).optional(),address:Ee.optional(),contact:Re.optional()}),he=n.z.object({id:n.z.string().min(1,"Service ID is required"),type:je,status:ke,code:n.z.string().optional(),name:n.z.string().optional(),description:n.z.string().optional(),startDate:P.optional(),endDate:P.optional(),price:n.z.object({currency:n.z.string().min(1,"Currency is required"),amount:n.z.number().positive("Amount must be positive")}).optional()}),rt=n.z.object({id:n.z.string().min(1,"Payment ID is required"),type:qe,status:Ue,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()}),Ut=n.z.object({type:Te,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:He.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()}),Ht=n.z.object({type:Ge,priority:Ke,customerId:n.z.string().optional(),customerDetails:F.optional(),passengers:n.z.array(Ie).min(1,"At least one passenger is required"),services:n.z.array(he).min(1,"At least one service is required"),specialRequests:n.z.array(n.z.object({type:We,description:n.z.string().min(1,"Special request description is required")})).optional()}),Gt=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),reason:Ye,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:$e}).optional()}),Kt=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),documentType:Qe,format:ze,language:n.z.string().optional(),deliveryMethod:n.z.object({type:Ze,address:n.z.string().optional()}).optional()}),Wt=n.z.object({bookingId:n.z.string().min(1,"Booking ID is required"),payments:n.z.array(rt).min(1,"At least one payment is required")}),Yt=n.z.object({id:n.z.string().min(1,"Booking ID is required"),status:Je,createdAt:Xe,updatedAt:Xe,customer:F,passengers:n.z.array(Ie),services:n.z.array(he),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:et,description:n.z.string().min(1,"Description is required"),amount:n.z.number()})).optional()})}),$t=n.z.object({results:n.z.array(F),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()}),Qt=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:tt,method:n.z.string().min(1,"Delivery method is required"),address:n.z.string().optional()}).optional()}),zt=n.z.object({success:n.z.boolean(),message:n.z.string().optional(),data:n.z.any().optional()}),hn={addressType:Le,contactType:xe,emailType:Ve,passengerType:we,titleType:Be,genderType:ye,serviceType:je,serviceStatusType:ke,paymentType:qe,paymentStatusType:Ue,customerType:Te,searchOperatorType:He,bookingType:Ge,priorityType:Ke,specialRequestType:We,cancelReasonType:Ye,refundMethodType:$e,documentType:Qe,documentFormatType:ze,deliveryMethodType:Ze,bookingStatusType:Je,pricingItemType:et,deliveryStatusType:tt,customerStatusType:nt,communicationMethodType:ot,customerAddress:Ee,customerContact:Re,customer:F,bookingPassenger:Ie,bookingService:he,bookingPayment:rt,searchCustomerRequest:Ut,createBookingRequest:Ht,cancelBookingRequest:Gt,printDocumentRequest:Kt,addPaymentRequest:Wt,bookingResponse:Yt,searchResponse:$t,documentResponse:Qt,operationResponse:zt};var Zt=require("@nestjs/common");var D=class D 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,D.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,D)}static fromAvesError(o){return new D(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(D,"AvesException");var d=D;function Sn(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(Sn,"_ts_decorate");var it=class it{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(it,"AvesErrorHandler");var v=it;v=Sn([(0,Zt.Injectable)()],v);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
|