aves-sdk 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +239 -0
- package/README.md +231 -88
- package/dist/index.d.mts +5016 -749
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/docs/guida-implementazione-booking-ops.md +0 -528
- package/docs/spike-api-aves-analisi.md +0 -196
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{request as e}from"undici";import*as t from"valibot";import{ValiError as n,parse as r,safeParse as i}from"valibot";import a from"fast-xml-builder";import{XMLParser as o}from"fast-xml-parser";const s={VALIDATION:`validation`,API:`api`,UNKNOWN:`unknown`};var c=class extends Error{kind;message;status;code;constructor(e,t,n,r){super(t),this.kind=e,this.message=t,this.status=n,this.code=r,this.name=`AvesError`,this.status=n?.toLowerCase(),this.code=this.parseCode(r)}parseCode(e){return typeof e==`string`?Number.parseInt(e,10):e??0}};function l(e){return new c(s.VALIDATION,e)}function u(e,t,n){return new c(s.API,e,t,n)}function d(e){return new c(s.UNKNOWN,e)}function ee(e){return e.map(f).join(`; `)}function f(e){let t=te(e.path),n=e.message??`Invalid value`;return t?`${t}: ${n}`:n}function te(e){if(!e||e.length===0)return;let t=e.map(ne).filter(e=>e!==void 0);return t.length>0?t.join(`.`):void 0}function ne(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`key`in e)return String(e.key)}function re(e){return e instanceof Error&&e.name===`AbortError`}function ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function p(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error}const m=new Set(Object.values({header:[`hostID`,`xtoken`,`interface`,`userName`,`status`],masterRecord:[`recordCode`,`insertCriteria`],financialDetail:[`currencyCode`,`creditLimit`,`c_PaymentType`,`c_SpecPaymentTypeCode`,`s_PaymentType`,`s_SpecPaymentTypeCode`,`enableElectronicInvoicing`,`electronicInvoicingType`],idDocumentDetail:[`idType`,`idCode`,`idIssueLocation`,`idIssueCounty`,`idIssueDate`,`idExpireDate`],accountPolicies:[`acceptProfilingPolicies`,`acceptPrivacyPolicies`,`acceptNewsletterPolicies`],dynamicFields:[`key`,`value`],search:[`minDate`,`maxDate`],bookingFileStatus:[`value`,`expiredDate`],statisticCodes:[`sCode1`,`sCode2`,`sCode3`,`sCode4`,`sCode5`,`sCode6`],destination:[`code`,`iataCode`,`nationCode`],customerDetail:[`recordCode`],bookingFileDocument:[`printDoc`,`sendDocViaEmail`],financialDeadlineDetail:[`reschedulingCode`,`expireDate`,`totalAmount`],deadlineDetail:[`deadlineCode`,`description`,`expireDate`],paymentDetail:[`paymentDate`,`paumentNote`,`amount`,`paymentUser`,`paymentType`],filePaymentDetail:[`paymentDate`,`paymentNote`,`payerMasterCode`,`payerName`,`amount`,`paymentType`],selectedPackageDetail:[`pCode`,`startDate`,`endDate`,`getServicesFromPackage`],selectedServiceDetail:[`sCode`,`ssCode`,`supplierMasterCode`,`supplierName`,`supplierMasterSearchField`,`supplierFiscalCode`],extraQuoteServiceDetail:[`sCode`,`ssCode`,`supplierMasterCode`,`supplierName`,`supplierMasterSearchField`,`supplierFiscalCode`],serviceFare:[`currencyCode`,`exchangeRate`,`cost`,`costTax`,`costType`,`vatCostCurrencyCode`,`price`,`priceTax`,`priceType`],cancellableBookedServiceDetail:[`cancelOperationType`,`serviceRefType`,`serviceRefValue`],fileStatus:[`value`,`expiredDate`,`optionedFileExpireDatePolicy`],penalty:[`apply`,`specificCode`],noteDetail:[`nType`,`title`],passengerDetail:[`rph`,`roomRph`,`billingHolder`],bookingFinancialInfo:[`customer_PaymentType`,`customer_SpecPaymentTypeCode`],reservationFormCustomizablePrintParameters:[`makeDocumentTo`],supplierRefMasterRecords:[`supplierRefCode`,`companyMainBusinessType`,`carrierType`]}).flat()),oe=(e,t,n=!1)=>n||t===`sCode`||t===`ssCode`||t===`pCode`?`@${t}`:`@${e}`,se=new Map([[`toServiceType`,`TOServiceType`],[`rph`,`RPH`]]),ce=new Map([[`TOServiceType`,`toServiceType`],[`RPH`,`rph`]]);function h(e,t){if(!e||typeof e!=`object`||p(e))return e;if(Array.isArray(e))return e.map(e=>h(e));let n=t?.excludeFromAttributePrefix,r=t?.excludeAttributeFromCamelToPascal,i={};for(let[t,a]of Object.entries(e)){let e=se.has(t)?se.get(t):ie(t),o=m.has(t)&&!n?.includes(t),s=oe(e,t,r?.includes(t)),c=o?s:e;i[c]=_(a,e=>h(e,void 0))}return i}function g(e){if(typeof e!=`object`||!e||p(e))return e;if(Array.isArray(e))return e.map(e=>g(e));let t={};for(let[n,r]of Object.entries(e)){let e=n.startsWith(`@`)?n.slice(1):n,i=ce.has(e)?ce.get(e):ae(e);t[i]=_(r,g)}return t}function _(e,t){return!e||typeof e!=`object`||p(e)?e:Array.isArray(e)?e.map(e=>_(e,t)):t(e)}const le={financialDeadlineList:`deadlineDetail`};function ue(e){return le[e]??e.replace(/List$/,`Detail`)}function de(e,{listKeys:t,arrayOfOne:n}){let r={...e},i=n??new Set;for(let e of t){let t=r[e];if(!Array.isArray(t))continue;let n=ue(e);r[e]=i.has(e)?t.map(e=>({[n]:e})):{[n]:t}}return r}const fe=[`selectedServiceList`,`passengerList`,`selectedPackageList`,`extraQuoteServiceList`,`deadlineList`,`financialDeadlineList`,`paymentList`,`noteList`],pe=new Set([`selectedServiceList`,`passengerList`]),me=[`selectedServiceList`,`passengerList`,`cancellableBookedServiceList`,`deadlineList`],he=[`passengerList`,`financialDeadlineList`],ge=[`filePaymentList`];function _e(e){let t=e=>{if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(t);let n={};for(let[r,i]of Object.entries(e)){if(r===`paxAssociated`&&Array.isArray(i)&&!i.length){n[r]=``;continue}n[r]=t(i)}return n};return t(e)}function ve(e,t){return h(_e(t?de(e,t):e),{excludeFromAttributePrefix:[`startDate`,`endDate`],excludeAttributeFromCamelToPascal:[`sCode`,`ssCode`,`pCode`]})}function v(e,n){return t.pipe(e,t.transform(e=>ve(e,n)))}function y(e){return t.pipe(e,t.transform(e=>h(e)))}function b(e){return t.pipe(t.union([t.array(e),e]),t.transform(e=>Array.isArray(e)?e:[e]))}function x(e){return t.pipe(e,t.transform(e=>g(e)))}function S(e){let n={};for(let t in e.entries){let r=m.has(t),i=t.charAt(0).toUpperCase()+t.slice(1),a=r?`@${i}`:i;n[a]=e.entries[t]}return t.object(n)}const C=t.union([t.literal(`true`),t.literal(`false`),t.boolean()]),ye=t.union([t.literal(`QUOTATION`),t.literal(`WORK_IN_PROGRESS`),t.literal(`CONFIRMED`),t.literal(`OPTIONED`),t.literal(`CANCELED`)]),be=t.union([t.literal(`QUOTATION`),t.literal(`WORK_IN_PROGRESS`),t.literal(`CONFIRMED`),t.literal(`OPTIONED`),t.literal(`NULLIFIED`),t.literal(`CANCELED`)]),xe=t.union([t.literal(`QUOTATION`),t.literal(`WORK_IN_PROGRESS`),t.literal(`CONFIRM`),t.literal(`CONFIRMED`),t.literal(`OPTION`),t.literal(`OPTIONED`),t.literal(`REQUEST`),t.literal(`REQUESTED`),t.literal(`NULLIFIED`),t.literal(`CANCELED`)]),w={CONFIRM:`CONFIRMED`,OPTION:`OPTIONED`,REQUESTED:`REQUEST`};function Se(e){return e in w?w[e]:e}const T=t.union([t.literal(`TOP`),t.literal(`TOP_SS`),t.literal(`ADV`),t.literal(`GRP`),t.literal(`OTHER`)]),E=t.union([t.literal(`ACCOMODATION`),t.literal(`TRANSPORT`),t.literal(`CHARTER`),t.literal(`TRANSFER`),t.literal(`PULLMAN`),t.literal(`FERRY`),t.literal(`CRUISE`),t.literal(`INSURANCE`),t.literal(`EXTRAFEE`),t.literal(`PENALTY`),t.literal(`PROMO`),t.literal(`OTHER`),t.literal(`NOT_SET`),t.literal(`RESIDENCE`)]),Ce=t.union([t.literal(`REQUEST`),t.literal(`ALLOTMENT_REQUEST`),t.literal(`CONFIRMED_REQUEST`),t.literal(`CONFIRMED_EXTRA_ALLOTMENT`),t.literal(`WAITLISTED`),t.literal(`ALLOTMENT`),t.literal(`REFUSED`),t.literal(`NULLIFIED`),t.literal(`CANCELED`),t.literal(`MESSAGE`)]),D=t.union([t.literal(`C`),t.literal(`B`),t.literal(`D`),t.literal(`T`),t.literal(`P`),t.literal(`R`),t.literal(`A`),t.literal(`H`),t.literal(`I`),t.literal(`J`),t.literal(`K`),t.literal(`L`),t.literal(`M`),t.literal(`N`),t.literal(`O`),t.literal(`Q`),t.literal(`S`),t.literal(`U`),t.literal(`V`)]),O=t.union([t.string(),t.number()]),we=t.pipe(t.object({"@Value":xe,"@ExpiredDate":t.optional(t.string()),"@ExpireDate":t.optional(t.string())}),t.transform(e=>({"@Value":Se(e[`@Value`]),"@ExpiredDate":e[`@ExpiredDate`]??e[`@ExpireDate`]}))),Te=t.object({"@PaxRef":t.string(),"@Price":O}),Ee=t.object({PricePerPaxDetail:t.optional(b(Te))}),De=t.object({"@CommissionCode":t.optional(t.string()),"@CommissionPercentage":t.optional(O),"@CommissionAmount":t.optional(O),"@PriceListCode":t.optional(t.string()),"@CostListCode":t.optional(t.string()),"@ServiceTotalPrice":t.optional(O),PaxPriceList:t.optional(Ee)}),Oe=t.object({"@Code":t.optional(t.string()),"@Name":t.optional(t.string()),"@Email":t.optional(t.string()),"@LanguageCode":t.optional(t.string())}),ke=t.object({"@Code":t.optional(t.string()),"@Description":t.optional(t.string())}),Ae=t.object({"@RPH":t.string(),"@ServiceCode":t.optional(t.string()),"@FromExternalProvider":t.optional(O),"@isFromExternalProvider":t.optional(O),AvesServiceType:t.optional(T),TOServiceType:t.optional(E),FirstDescription:t.optional(t.string()),SecondDescription:t.optional(t.string()),ThirdDescription:t.optional(t.string()),FourthDescription:t.optional(t.string()),ServiceStatus:t.optional(Ce),StartDate:t.optional(t.string()),EndDate:t.optional(t.string()),Qty:t.optional(O),Pax:t.optional(O),PeriodType:t.optional(t.string()),PaxMultiplier:t.optional(t.string()),ExternalProviderCode:t.optional(t.string()),WebStatisticCode:t.optional(t.string()),WebStatisticDescription:t.optional(t.string()),WebStatistic:t.optional(ke),SupplierInfo:t.optional(Oe),ServiceTotalAmountDetail:t.optional(De)}),je=t.pipe(Ae,t.transform(e=>({"@RPH":e[`@RPH`],"@ServiceCode":e[`@ServiceCode`],"@FromExternalProvider":e[`@FromExternalProvider`]??e[`@isFromExternalProvider`],AvesServiceType:e.AvesServiceType,TOServiceType:e.TOServiceType,FirstDescription:e.FirstDescription,SecondDescription:e.SecondDescription,ThirdDescription:e.ThirdDescription,FourthDescription:e.FourthDescription,ServiceStatus:e.ServiceStatus,StartDate:e.StartDate,EndDate:e.EndDate,Qty:e.Qty,Pax:e.Pax,PeriodType:e.PeriodType,PaxMultiplier:e.PaxMultiplier,ExternalProviderCode:e.ExternalProviderCode,WebStatisticCode:e.WebStatisticCode,WebStatisticDescription:e.WebStatisticDescription,WebStatistic:e.WebStatistic,SupplierInfo:e.SupplierInfo,ServiceTotalAmountDetail:e.ServiceTotalAmountDetail}))),Me=t.object({BookedServiceDetail:t.optional(b(je))}),k=t.object({"@CurrencyCode":t.optional(t.string()),"@TotalAmountBeforeDiscount":t.optional(O),"@TotalAmountAfterDiscount":t.optional(O),"@TotalDiscount":t.optional(O),"@TotalAmountWithoutVat":t.optional(O),"@DueAmount":t.optional(O),"@PaiedAmount":t.optional(O),"@Balance":t.optional(O)}),Ne=t.object({"@RPH":t.string(),"@RoomRPH":t.optional(t.string()),"@BillingHolder":t.optional(O),Name:t.optional(t.string()),CategoryCode:t.optional(t.string()),Sex:t.optional(t.string()),BirthDate:t.optional(t.string()),BirthPlace:t.optional(t.string()),NationCode:t.optional(t.string()),CitizenshipCode:t.optional(t.string()),FiscalCode:t.optional(t.string()),PhoneNumber:t.optional(t.string()),EMail:t.optional(t.string()),MasterRecordCode:t.optional(t.string())}),Pe=t.object({PassengerDetail:t.optional(b(Ne))}),Fe=t.object({"@ReschedulingCode":t.optional(t.string()),"@ExpireDate":t.optional(t.string()),"@TotalAmount":t.optional(O),ReschedulingCode:t.optional(t.string()),ExpireDate:t.optional(t.string()),TotalAmount:t.optional(O)}),Ie=t.pipe(Fe,t.transform(e=>({"@ReschedulingCode":e[`@ReschedulingCode`]??e.ReschedulingCode,"@ExpireDate":e[`@ExpireDate`]??e.ExpireDate,"@TotalAmount":e[`@TotalAmount`]??e.TotalAmount}))),Le=t.object({DeadlineDetail:t.optional(b(Ie))}),Re=t.object({DocumentRefCode:t.optional(t.string()),DocumentType:t.optional(t.string()),DocumentName:t.optional(t.string()),ArchiviationDescription:t.optional(t.string())}),ze=t.object({StoredDocumentDetail:t.optional(b(Re))}),Be=t.object({DocumentType:t.optional(t.string()),DocumentName:t.optional(t.string()),Enabled:t.optional(O)}),Ve=t.object({PrintableDocumentDetail:t.optional(b(Be))}),He=t.object({"@BookingFileCode":t.optional(t.string()),BookingFileCode:t.optional(t.string()),CustomerRecordCode:t.optional(t.string()),CustomerName:t.optional(t.string()),CustomerEmail:t.optional(t.string()),TravelAgencyName:t.optional(t.string()),TravelAgencyEmail:t.optional(t.string()),BookingFileStatus:t.optional(we),Description:t.optional(t.string()),Nation:t.optional(t.string()),Destination:t.optional(t.string()),CreationDate:t.optional(t.string()),FirstConfirmationDate:t.optional(t.string()),StartDate:t.optional(t.string()),EndDate:t.optional(t.string()),PackageCode:t.optional(t.string()),BookedServiceList:t.optional(Me),TotalAmountDetail:t.optional(k),PaxNumber:t.optional(O),PassengerList:t.optional(Pe),Reference:t.optional(t.string()),ClerkName:t.optional(t.string()),StoredDocumentsList:t.optional(ze),PrintableDocumentsList:t.optional(Ve),FinancialDeadlineList:t.optional(Le)}),Ue=t.pipe(He,t.transform(e=>({"@BookingFileCode":e[`@BookingFileCode`]??e.BookingFileCode,CustomerRecordCode:e.CustomerRecordCode,CustomerName:e.CustomerName,CustomerEmail:e.CustomerEmail,TravelAgencyName:e.TravelAgencyName,TravelAgencyEmail:e.TravelAgencyEmail,BookingFileStatus:e.BookingFileStatus,Description:e.Description,Nation:e.Nation,Destination:e.Destination,CreationDate:e.CreationDate,FirstConfirmationDate:e.FirstConfirmationDate,StartDate:e.StartDate,EndDate:e.EndDate,PackageCode:e.PackageCode,BookedServiceList:e.BookedServiceList,TotalAmountDetail:e.TotalAmountDetail,PaxNumber:e.PaxNumber,PassengerList:e.PassengerList,Reference:e.Reference,ClerkName:e.ClerkName,StoredDocumentsList:e.StoredDocumentsList,PrintableDocumentsList:e.PrintableDocumentsList,FinancialDeadlineList:e.FinancialDeadlineList}))),We=t.object({"@HostID":t.pipe(t.string(),t.minLength(6),t.maxLength(6)),"@Xtoken":t.string(),"@Interface":t.literal(`WEB`),"@UserName":t.literal(`WEB`),"@LanguageCode":t.optional(t.pipe(t.string(),t.minLength(2),t.maxLength(2)))}),Ge=t.optional(t.pipe(t.string(),t.transform(e=>e.split(`,`)))),A=t.pipe(t.object({"@Status":t.union([t.literal(`OK`),t.literal(`ERROR`),t.literal(`WARNING`),t.literal(`TIMEOUT`)]),ErrorCode:t.optional(t.pipe(t.union([t.string(),t.number()]),t.transform(e=>Number(e)))),ErrorDescription:t.optional(t.string()),Warnings:Ge}),t.transform(e=>({status:e[`@Status`],errorCode:e.ErrorCode,errorDescription:e.ErrorDescription,warnings:e.Warnings}))),Ke=t.object({value:ye,expiredDate:t.optional(t.string())}),j=t.object({sCode1:t.optional(t.pipe(t.string(),t.maxLength(4))),sCode2:t.optional(t.pipe(t.string(),t.maxLength(4))),sCode3:t.optional(t.pipe(t.string(),t.maxLength(4))),sCode4:t.optional(t.pipe(t.string(),t.maxLength(4))),sCode5:t.optional(t.pipe(t.string(),t.maxLength(4))),sCode6:t.optional(t.pipe(t.string(),t.maxLength(4)))}),qe=t.object({code:t.optional(t.string()),iataCode:t.optional(t.string()),nationCode:t.optional(t.string())}),Je=t.object({recordCode:t.optional(t.string())}),Ye=t.union([t.literal(`VISA_REQUEST`),t.literal(`TRAVEL_INFORMATION`),t.literal(`VOUCHER`),t.literal(`BOOKING_CONTRACT`),t.literal(`BOOKING_CONFIRMATION`),t.literal(`SUPPLIER_SERVICE_LIST`),t.literal(`INVOICE`),t.literal(`PROFORMA_INVOICE`),t.literal(`ADEGUAMENTO`),t.literal(`RESERVATION_FORM`),t.literal(`OPEN_XML`),t.literal(`SALES_INVOICE`),t.literal(`TICKETING_TMASTER`),t.literal(`SUMMARY_FORM`)]),Xe=t.object({makeDocumentTo:t.optional(t.union([t.literal(`BOOKING_CUSTOMER`),t.literal(`FIRST_PASSENGER`)]))}),Ze=t.object({fillInCode:t.optional(t.string())}),Qe=t.union([Xe,Ze]),$e=t.object({documentType:Ye,documentCustomizablePrintParameters:t.optional(Qe)}),et=t.object({printDoc:t.optional(C),sendDocViaEmail:t.optional(C),infoDocumentsToPrint:t.optional(t.array($e))}),tt=t.object({reschedulingCode:t.optional(t.string()),expireDate:t.optional(t.string()),totalAmount:t.optional(t.string())}),nt=t.object({deadlineCode:t.optional(t.string()),description:t.optional(t.string()),expireDate:t.optional(t.string())}),rt=t.object({paymentDate:t.optional(t.string()),paumentNote:t.optional(t.string()),amount:t.optional(t.string()),paymentUser:t.optional(t.string()),paymentType:t.optional(D)}),it=t.union([t.literal(`PAX_QTY_DAY`),t.literal(`PAX_QTY_NIGHT`),t.literal(`PAX_QTY_WEEK`),t.literal(`PAX_QTY`),t.literal(`PAX_DAY`),t.literal(`PAX_NIGHT`),t.literal(`PAX_WEEK`),t.literal(`PAX`),t.literal(`QTY_DAY`),t.literal(`QTY_NIGHT`),t.literal(`QTY_WEE`),t.literal(`QTY`),t.literal(`DAY`),t.literal(`NIGHT`),t.literal(`WEEK`),t.literal(`FORFAIT`)]),at=t.object({currencyCode:t.optional(t.string()),exchangeRate:t.optional(t.string()),cost:t.optional(t.string()),costTax:t.optional(t.string()),costType:t.optional(it),vatCostCurrencyCode:t.optional(t.string()),price:t.optional(t.string()),priceTax:t.optional(t.string()),priceType:t.optional(it)}),ot=t.object({packageCode:t.optional(t.string()),packageReference:t.optional(t.string()),suballotmentCode:t.optional(t.string()),priceListCode:t.optional(t.string()),costListCode:t.optional(t.string()),externalFileCode:t.optional(t.string()),externalReference:t.optional(t.string()),serviceStatus:t.optional(t.string()),serviceStatisticCode:t.optional(t.string()),serviceFare:t.optional(at)}),st=t.object({pax:t.string()}),M=t.object({sCode:t.string(),ssCode:t.optional(t.string()),avesServiceType:T,toServiceType:t.optional(E),subServiceDesc:t.optional(t.string()),startDate:t.string(),endDate:t.string(),qty:t.string(),pax:t.string(),paxAssociated:t.optional(t.array(st)),avesSession:t.string(),avesServiceInfo:t.optional(ot),serviceFare:t.optional(at),bookedServiceRef:t.optional(t.string()),supplierMasterCode:t.optional(t.string()),voucherMasterCode:t.optional(t.string()),hotelServiceInfo:t.optional(t.string()),carRentalServiceInfo:t.optional(t.string()),flightServiceInfo:t.optional(t.string()),shipServiceInfo:t.optional(t.string()),ticketServiceInfo:t.optional(t.string()),commission:t.optional(t.string()),noteList:t.optional(t.string()),voucherInfo:t.optional(t.string()),firstDescription:t.optional(t.string()),secondDescription:t.optional(t.string())}),N=t.object({pCode:t.string(),startDate:t.string(),endDate:t.string(),getServicesFromPackage:t.optional(C)}),P=t.object({nType:t.optional(t.string()),title:t.optional(t.string()),text:t.optional(t.string())}),F=t.union([t.literal(`AD`),t.literal(`CH`),t.literal(`IN`),t.literal(`OV`)]),I={rph:t.string(),roomRph:t.optional(t.string()),billingHolder:t.optional(C),masterRecordCode:t.optional(t.string()),name:t.string(),sex:t.union([t.literal(`M`),t.literal(`F`)]),birthDate:t.optional(t.string()),birthPlace:t.optional(t.string()),nationCode:t.optional(t.string()),citizenshipCode:t.optional(t.string()),fiscalCode:t.optional(t.string()),phoneNumber:t.optional(t.string()),eMail:t.optional(t.string()),notes:t.optional(t.array(P)),flagStatus:t.optional(t.string()),offerCode:t.optional(t.string()),idDocInfo:t.optional(t.object({idType:t.optional(t.string()),idCode:t.optional(t.string()),idIssueLocation:t.optional(t.string()),idIssueCounty:t.optional(t.string()),idIssueDate:t.optional(t.string()),idExpireDate:t.optional(t.string())}))},ct=t.object({...I,categoryCode:F}),L=t.object({...I,categoryCode:t.optional(F)}),lt=t.union([t.literal(`CASH`),t.literal(`BANK`),t.literal(`RID`),t.literal(`RIBA`),t.literal(`SPECIFIC_CODE`),t.literal(`NOT_SET`)]),R=t.object({customer_PaymentType:t.optional(lt),customer_SpecPaymentTypeCode:t.optional(t.string())}),ut=t.union([t.literal(`GROUPED_PAX`),t.literal(`NOT_GROUPED_PAX`),t.literal(`ONE_PAX_ONLY`)]),dt=t.union([t.literal(`AVES2AVES`),t.literal(`AVES2AVESVIA`),t.literal(`AVES2AVESITA`)]),ft=v(t.object({createDate:t.optional(t.string()),bookingFileRefCode:t.optional(t.string()),travelAgentCode:t.optional(t.string()),clerkName:t.optional(t.string()),customerDetail:Je,currencyCode:t.optional(t.string()),markupCode:t.optional(t.string()),bookingFileStatus:Ke,statisticCodes:t.optional(j),destination:t.optional(qe),bookingFileDescription:t.optional(t.string()),startDate:t.string(),endDate:t.string(),earlyBookingDate:t.optional(t.string()),cupCode:t.optional(t.string()),cigCode:t.optional(t.string()),customerPromoterCode:t.optional(t.string()),billingReferenceCode:t.optional(t.string()),paymentReferenceCode:t.optional(t.string()),bookingFileDocument:t.optional(et),financialDeadlineList:t.optional(t.array(tt)),deadlineList:t.optional(t.array(nt)),paymentList:t.optional(t.array(rt)),selectedPackageList:t.optional(t.array(N)),selectedServiceList:t.array(M),extraQuotaRefCode:t.optional(t.string()),extraQuoteServiceList:t.optional(t.array(M)),getExtraQuoteFromSystem:t.optional(C),passengerList:t.array(ct),noteList:t.optional(t.array(P)),bookingFinancialInfo:t.optional(R),bookingFileCode:t.optional(t.string()),groupingPaxPolicy:t.optional(ut),groupBookingFile:t.optional(C),typeDownloadFile:t.optional(dt),setBookingFileCodeFromStartDate:t.optional(C)}),{listKeys:fe,arrayOfOne:pe}),z=x(t.object({RsStatus:A,BookingFileDetail:t.optional(Ue),PrintableDocumentsList:t.optional(Ve),TotalAmountDetailAfterCancellation:t.optional(k),Base64DocContent:t.optional(t.string())})),B=x(t.object({RsStatus:A})),V=z,pt=t.object({reschedulingCode:t.string(),description:t.optional(t.string()),expireDate:t.optional(t.string())}),mt=t.object({cancelOperationType:t.union([t.literal(`NULLIFY`),t.literal(`DELETE`)]),serviceRefType:t.union([t.literal(`RPH`),t.literal(`FILE`)]),serviceRefValue:t.string()}),ht=v(t.object({customerRecordCode:t.string(),bookingFileCode:t.string(),currencyCode:t.optional(t.string()),deadlineList:t.optional(t.array(pt)),selectedPackageDetail:t.optional(N),selectedServiceList:t.pipe(t.array(M),t.minLength(1)),cancellableBookedServiceList:t.optional(t.array(mt)),passengerList:t.optional(t.array(L))}),{listKeys:me}),gt=v(t.object({bookingFileCode:t.string(),bookingFileStartDate:t.string(),customerRecordCode:t.string(),newCustomerRecordCode:t.optional(t.string()),bookingFileReferenceName:t.optional(t.string()),travelAgentCode:t.optional(t.string()),billingReferenceCode:t.optional(t.string()),paymentReferenceCode:t.optional(t.string()),cupCode:t.optional(t.string()),cigCode:t.optional(t.string()),customerPromoterCode:t.optional(t.string()),bookingNote:t.optional(t.string()),passengerList:t.optional(t.array(L)),statisticCodes:t.optional(j),bookingFinancialInfo:t.optional(R),financialDeadlineList:t.optional(t.array(t.object({reschedulingCode:t.string(),expireDate:t.string(),totalAmount:t.string()})))}),{listKeys:he}),_t=y(t.object({bookingFileCode:t.string(),customerRecordCode:t.string()})),vt=t.union([t.literal(`NOT_SET`),t.literal(`CONSIDER_HOLIDAY`),t.literal(`CONSIDER_HOLIDAY_AND_SATURDAY`)]),yt=y(t.object({customerRecordCode:t.string(),bookingFileCode:t.string(),fileStatus:t.object({value:be,expiredDate:t.optional(t.string()),optionedFileExpireDatePolicy:t.optional(vt)}),backOfficeRequest:t.optional(C),bookingFileDocument:t.optional(et),penalty:t.optional(t.object({apply:t.optional(C),specificCode:t.optional(t.string())})),simulateCancelAndGetPenaltyAmount:t.optional(C)})),bt=y(t.object({customerRecordCode:t.string(),bookingFileCode:t.string(),bookingServiceRef:t.string(),bookingFileServiceStatus:t.literal(`NULLIFIED`),bookingFileServiceStatusDate:t.optional(t.string())})),xt=t.union([t.literal(`AbsoluteAmountsInsertion`),t.literal(`FinalAmountToAchieve`),t.literal(`FinalAmountToAchieveWithoutControls`)]),St=t.object({paymentDate:t.string(),paymentNote:t.optional(t.string()),payerMasterCode:t.optional(t.string()),payerName:t.optional(t.string()),amount:t.string(),paymentType:D}),Ct=v(t.pipe(t.object({bookingFileCode:t.optional(t.string()),bookingFileRefCode:t.optional(t.string()),paymentUser:t.optional(t.string()),enableMultiplePayments:C,operationType:xt,filePaymentList:t.pipe(t.array(St),t.minLength(1))}),t.check(e=>!!(e.bookingFileCode||e.bookingFileRefCode),`bookingFileCode or bookingFileRefCode is required`)),{listKeys:ge}),H=t.union([t.literal(`CASH`),t.literal(`BANK`),t.literal(`RID`),t.literal(`RIBA`),t.literal(`SPECIFIC_CODE`)]),U=t.object({currencyCode:t.optional(t.string()),creditLimit:t.optional(t.string()),c_PaymentType:t.optional(H),c_SpecPaymentTypeCode:t.optional(t.string()),s_PaymentType:t.optional(H),s_SpecPaymentTypeCode:t.optional(t.string()),enableElectronicInvoicing:t.optional(t.union([t.literal(`true`),t.literal(`false`),t.boolean()])),electronicInvoicingType:t.optional(t.string())});y(U);const wt=S(U),W=t.object({idType:t.optional(t.string()),idCode:t.optional(t.string()),idIssueLocation:t.optional(t.string()),idIssueCounty:t.optional(t.string()),idIssueDate:t.optional(t.string()),idExpireDate:t.optional(t.string())});y(W);const Tt=S(W),G=t.object({key:t.string(),value:t.string()});y(t.array(G));const Et=S(G),Dt=t.union([t.literal(`NOT_SET`),t.literal(`FLIGHT`),t.literal(`SHIP`),t.literal(`TRAIN`),t.literal(`RENTCAR`),t.literal(`BUS`),t.literal(`DP_HOTEL`),t.literal(`TO_HOTEL`),t.literal(`TO_TOUR`),t.literal(`TO_HOTEL_AND_TOUR`),t.literal(`DP_AUTO`),t.literal(`DP_GDS_NAVI`),t.literal(`DP_GDS_VOLI`),t.literal(`TOUR_OPERATOR`),t.literal(`TICKETING_EV`),t.literal(`OTHER`)]),K=t.object({supplierRefCode:t.optional(t.string()),companyMainBusinessType:t.optional(t.string()),carrierType:t.optional(Dt)});y(K);const Ot=S(K),q=t.union([t.literal(0),t.literal(1)]),kt=t.union([t.literal(`ENABLED`),t.literal(`DISABLED`),t.literal(`WARNING`),t.literal(`BLACKLISTED`)]),At=t.union([t.literal(`CUSTOMER`),t.literal(`SUPPLIER`),t.literal(`GENERAL`)]),jt=t.union([t.literal(`S`),t.literal(`N`),t.literal(`T`),t.literal(`M`)]),J=t.object({acceptProfilingPolicies:t.optional(q),acceptPrivacyPolicies:t.optional(q),acceptNewsletterPolicies:t.optional(q)});y(J);const Mt=S(J),Nt=y(t.object({recordCode:t.optional(t.pipe(t.string(),t.minLength(6),t.maxLength(6))),insertCriteria:t.optional(jt),createdDate:t.optional(t.string()),recordType:t.optional(t.union([At],`CUSTOMER`)),recordStatus:t.optional(t.union([kt],`ENABLED`)),moniker:t.optional(t.string()),name:t.optional(t.string()),extraInfo:t.optional(t.string()),languageCode:t.pipe(t.string(),t.minLength(2),t.maxLength(2)),address:t.optional(t.string()),zipCode:t.optional(t.string()),cityName:t.optional(t.string()),countyCode:t.optional(t.string()),stateCode:t.optional(t.string()),categoryCode:t.optional(t.string()),firstPhoneNumber:t.optional(t.string()),mobilePhoneNumber:t.optional(t.string()),email:t.optional(t.string()),gender:t.optional(t.union([t.literal(`M`),t.literal(`F`)])),birthDate:t.optional(t.string()),birthCity:t.optional(t.string()),birthCounty:t.optional(t.string()),fiscalCode:t.optional(t.string()),vatCode:t.optional(t.string()),thirdPartRecordCode:t.optional(t.string()),idDocumentDetail:t.optional(W),accountPolicies:t.optional(J),financialDetail:t.optional(U),dynamicFields:t.optional(G),supplierRefMasterRecords:t.optional(K)}));x(Nt);const Y=t.object({"@RecordCode":t.optional(t.pipe(t.string(),t.minLength(6),t.maxLength(6))),"@InsertCriteria":t.optional(jt),CreatedDate:t.optional(t.string()),ModifiedDate:t.optional(t.string()),RecordType:t.optional(t.union([t.literal(`CUSTOMER`),t.literal(`SUPPLIER`),t.literal(`GENERAL`)])),LoginType:t.optional(t.string()),RecordStatus:t.optional(kt),Moniker:t.optional(t.string()),Name:t.optional(t.string()),ExtraInfo:t.optional(t.string()),LanguageCode:t.optional(t.pipe(t.string(),t.minLength(1),t.maxLength(2))),Address:t.optional(t.string()),ZipCode:t.optional(t.string()),CityName:t.optional(t.string()),CountyCode:t.optional(t.string()),StateCode:t.optional(t.string()),CategoryCode:t.optional(t.string()),PromoterCode:t.optional(t.string()),FirstPhoneNumber:t.optional(t.string()),MobilePhoneNumber:t.optional(t.string()),Email:t.optional(t.string()),Gender:t.optional(t.union([t.literal(`M`),t.literal(`F`)])),BirthDate:t.optional(t.string()),BirthCity:t.optional(t.string()),BirthCounty:t.optional(t.string()),EncryptedPassword:t.optional(t.union([t.literal(`true`),t.literal(`false`),t.boolean()])),FiscalCode:t.optional(t.string()),VatCode:t.optional(t.string()),ThirdPartRecordCode:t.optional(t.string()),IdDocumentDetail:t.optional(Tt),NewsletterDisabled:t.optional(t.union([t.literal(`true`),t.literal(`false`),t.boolean()])),SupplierRefMasterRecords:t.optional(Ot),AccountPolicies:t.optional(Mt),FinancialDetail:t.optional(wt),DynamicFields:t.optional(Et)}),Pt=t.object({minDate:t.string(),maxDate:t.string()}),X=t.optional(t.pipe(t.string(),t.minLength(2),t.maxLength(2))),Ft=t.object({searchType:t.literal(`CODE`),recordCode:t.pipe(t.string(),t.minLength(5),t.maxLength(6)),languageCode:X}),It=t.object({searchType:t.literal(`NAME`),name:t.string(),city:t.optional(t.string()),languageCode:X}),Lt=t.object({searchType:t.literal(`VATCODE`),vatCode:t.string(),phoneNumber:t.optional(t.string()),languageCode:X}),Rt=t.object({searchType:t.literal(`ZONE`),zipCode:t.string(),countyCode:t.string(),city:t.optional(t.string()),languageCode:X}),zt=t.object({searchType:t.literal(`CATEGORY`),categoryCode:t.string(),languageCode:X}),Bt=t.object({searchType:t.literal(`EMAIL`),email:t.string(),languageCode:X}),Vt=t.object({searchType:t.literal(`LASTMODDATE`),lastModificationDate:Pt,languageCode:X}),Ht=t.object({searchType:t.literal(`SEARCH_FIELD`),searchFieldValue:t.string(),languageCode:X}),Ut=t.object({searchType:t.literal(`EXTERNAL_REF_CODE`),searchFieldValue:t.string(),languageCode:X}),Wt=t.union([Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut]),Gt=e=>{if(!(`@RecordCode`in e))return e;let t=e[`@RecordCode`];if(!t)return e;let{"@RecordCode":n,...r}=e;return{...r,RecordCode:t}},Kt=t.pipe(y(Wt),t.transform(e=>Gt(e))),qt=t.pipe(t.object({RqHeader:We,SearchMasterRecord:Kt}),t.transform(e=>{let{SearchMasterRecord:t,RqHeader:n,...r}=e;return{RqHeader:n,...t,...r}})),Jt=t.object({MasterRecordDetail:t.optional(t.pipe(t.union([t.array(Y),Y]),t.transform(e=>{if(e)return Array.isArray(e)?e:[e]})))}),Yt=x(t.object({RsStatus:A,MasterRecordList:t.optional(Jt)})),Xt=t.object({RqHeader:We,MasterRecordDetail:Y}),Zt=x(t.object({RsStatus:A,MasterRecordDetail:t.optional(Y)}));function Qt(e){return{success:!0,data:e}}function Z(e){return{success:!1,error:e}}function $t(e){return e===200}function en(e){let t=new AbortController;if(!e||e<=0)return{signal:t.signal};let n=setTimeout(()=>t.abort(),e);return{signal:t.signal,clear:()=>clearTimeout(n)}}function tn(e,t){try{let n=new URL(e),r=(n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname)+t;return new URL(r,n)}catch(e){throw new c(`validation`,`Invalid baseURL: ${e instanceof Error?e.message:`Invalid URL format`}`)}}function nn(e,t){if(!t.startsWith(`/`))throw new c(`validation`,`Invalid endpoint: endpoint must start with '/' but got '${t}'`);let n=tn(e.replace(/\/$/,``),t);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new c(`validation`,`Invalid protocol: baseURL must use http:// or https:// but got '${n.protocol}'`);return n.toString()}const rn={ignoreAttributes:!1,attributeNamePrefix:`@`,parseAttributeValue:!1,trimValues:!0,ignoreNameSpace:!0,removeNSPrefix:!0,parseTagValue:!1},an={ignoreAttributes:!1,attributeNamePrefix:`@`,suppressEmptyNode:!0},on=new o(rn),sn=new a(an);function cn(e){try{return sn.build(e)}catch(e){throw new c(`validation`,`Failed to convert JSON to XML: ${e instanceof Error?e.message:`Unknown error`}`)}}function ln(e){try{return on.parse(e)}catch(e){throw new c(`validation`,`Failed to convert XML to JSON: ${e instanceof Error?e.message:`Unknown error`}`)}}const Q={SEARCH_REQUEST:`SearchMasterRecordRQ`,SEARCH_RESPONSE:`SearchMasterRecordRS`,UPSERT_REQUEST:`ManageMasterRecordRQ`,UPSERT_RESPONSE:`ManageMasterRecordRS`,BOOKING_REQUEST:`BookFileRQ`,BOOKING_RESPONSE:`BookingFileRS`,MOD_FILE_SERVICES_REQUEST:`ModFileServicesRQ`,MOD_FILE_HEADER_REQUEST:`ModFileHeaderRQ`,MOD_FILE_HEADER_RESPONSE:`ModFileHeaderRS`,CANCEL_FILE_REQUEST:`CancelFileRQ`,CANCEL_FILE_RESPONSE:`CancelFileRS`,SET_STATUS_REQUEST:`SetStatusRQ`,SET_STATUS_RESPONSE:`SetStatusRS`,SET_STATUS_SERVICE_REQUEST:`SetStatusServiceRQ`,SET_STATUS_SERVICE_RESPONSE:`SetStatusServiceRS`,FILE_PAYMENT_LIST_REQUEST:`FilePaymentListRQ`,FILE_PAYMENT_LIST_RESPONSE:`FilePaymentListRS`};function $(e,t){return{[e]:t}}var un=class{options;constructor(e){this.options=e}createRqHeader(){return{"@HostID":this.options.hostID,"@Xtoken":this.options.xtoken,"@Interface":`WEB`,"@UserName":`WEB`,...this.options.languageCode&&{"@LanguageCode":this.options.languageCode}}}createUrl(e){return nn(this.options.baseURL,e)}get endpoints(){return{search:`/interop/masterRecords/v2/rest/Search`,upsert:`/interop/masterRecords/v2/rest/InsertOrUpdate`,createBooking:`/interop/booking/v2/rest/CreateBookingFile`,modBookingServices:`/interop/booking/v2/rest/ModBookingFileServices`,modBookingHeader:`/interop/booking/v2/rest/ModBookingFileHeader`,cancelBooking:`/interop/booking/v2/rest/CancelBookingFile`,setBookingStatus:`/interop/booking/v2/rest/SetBookingFileStatus`,setBookingServiceStatus:`/interop/booking/v2/rest/SetBookingFileServiceStatus`,insertFilePaymentList:`/interop/booking/v2/rest/InsertFilePaymentList`}}handleApiStatus(e){let t=e.rsStatus,n=t?.status;return n===`OK`?Qt(e):Z(u(t.errorDescription,n,t.errorCode))}toAvesError(e,t){return e instanceof c?e:e instanceof n?l(`Validation error: ${ee(e.issues)}`):e instanceof Error?d(e.message):d(t)}async request(t,n,r,a){let{signal:o,clear:s}=en(this.options.timeoutMs??3e4);try{let s=await e(this.createUrl(t),{method:`POST`,headers:{"Content-Type":`application/xml`},body:cn(n),signal:o}),c=await s.body.text();if(!$t(s.statusCode))return Z(u(c,`ERROR`,s.statusCode));let d=ln(c)[r];if(!d)return Z(l(`Invalid response structure: missing root element '${r}'`));let f=i(a,d);return f.success?this.handleApiStatus(f.output):Z(l(`Invalid response format: ${ee(f.issues)}`))}catch(e){return re(e)?Z(u(`Request timed out`,`TIMEOUT`)):Z(this.toAvesError(e,`Unknown error occurred`))}finally{s?.()}}async invokeOp(e){try{let t=r(e.apiSchema,e.params);return this.request(e.endpoint,$(e.requestRoot,{RqHeader:this.createRqHeader(),...t}),e.responseRoot,e.responseSchema)}catch(t){return Z(this.toAvesError(t,`Validation error occurred during ${e.op}`))}}async search(e){try{let t=r(qt,{RqHeader:this.createRqHeader(),SearchMasterRecord:e}),n=$(Q.SEARCH_REQUEST,t);return this.request(this.endpoints.search,n,Q.SEARCH_RESPONSE,Yt)}catch(e){return Z(this.toAvesError(e,`Validation error occurred during search`))}}async upsertRecord(e){try{let t=r(Nt,e),n=r(Xt,{RqHeader:this.createRqHeader(),MasterRecordDetail:t}),i=$(Q.UPSERT_REQUEST,n);return this.request(this.endpoints.upsert,i,Q.UPSERT_RESPONSE,Zt)}catch(e){return Z(this.toAvesError(e,`Validation error occurred during upsert`))}}async createBooking(e){return this.invokeOp({op:`createBooking`,params:e,apiSchema:ft,endpoint:this.endpoints.createBooking,requestRoot:Q.BOOKING_REQUEST,responseRoot:Q.BOOKING_RESPONSE,responseSchema:z})}async modBookingServices(e){return this.invokeOp({op:`modBookingServices`,params:e,apiSchema:ht,endpoint:this.endpoints.modBookingServices,requestRoot:Q.MOD_FILE_SERVICES_REQUEST,responseRoot:Q.BOOKING_RESPONSE,responseSchema:V})}async modBookingHeader(e){return this.invokeOp({op:`modBookingHeader`,params:e,apiSchema:gt,endpoint:this.endpoints.modBookingHeader,requestRoot:Q.MOD_FILE_HEADER_REQUEST,responseRoot:Q.MOD_FILE_HEADER_RESPONSE,responseSchema:B})}async cancelBooking(e){return this.invokeOp({op:`cancelBooking`,params:e,apiSchema:_t,endpoint:this.endpoints.cancelBooking,requestRoot:Q.CANCEL_FILE_REQUEST,responseRoot:Q.CANCEL_FILE_RESPONSE,responseSchema:B})}async setBookingStatus(e){return this.invokeOp({op:`setBookingStatus`,params:e,apiSchema:yt,endpoint:this.endpoints.setBookingStatus,requestRoot:Q.SET_STATUS_REQUEST,responseRoot:Q.SET_STATUS_RESPONSE,responseSchema:V})}async setBookingServiceStatus(e){return this.invokeOp({op:`setBookingServiceStatus`,params:e,apiSchema:bt,endpoint:this.endpoints.setBookingServiceStatus,requestRoot:Q.SET_STATUS_SERVICE_REQUEST,responseRoot:Q.SET_STATUS_SERVICE_RESPONSE,responseSchema:V})}async insertFilePaymentList(e){return this.invokeOp({op:`insertFilePaymentList`,params:e,apiSchema:Ct,endpoint:this.endpoints.insertFilePaymentList,requestRoot:Q.FILE_PAYMENT_LIST_REQUEST,responseRoot:Q.FILE_PAYMENT_LIST_RESPONSE,responseSchema:B})}};export{un as AvesClient,c as AvesError};
|
|
1
|
+
import*as e from"valibot";import{ValiError as t,parse as n,safeParse as r}from"valibot";import{request as i}from"undici";import a from"fast-xml-builder";import{XMLParser as o}from"fast-xml-parser";function s(e){return e.charAt(0).toUpperCase()+e.slice(1)}function c(e){return e.charAt(0).toLowerCase()+e.slice(1)}function l(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error}const u=new Map([[`toServiceType`,`TOServiceType`],[`rph`,`RPH`]]),ee=new Map([[`TOServiceType`,`toServiceType`],[`RPH`,`rph`]]);function te(e,t,n){return n?`@${t}`:`@${e}`}function ne(e,t){if(!e||typeof e!=`object`||l(e))return e;if(Array.isArray(e))return e.map(e=>ne(e,t));let n=t?.attrs,r=t?.preserveCamel,i={};for(let[a,o]of Object.entries(e)){let e=u.get(a)??s(a),c=n?.includes(a)?te(e,a,!!r?.includes(a)):e,l=t?.children?.[a];i[c]=re(o,e=>ne(e,l))}return i}function d(e){if(typeof e!=`object`||!e||l(e))return e;if(Array.isArray(e))return e.map(e=>d(e));let t={};for(let[n,r]of Object.entries(e)){let e=n.startsWith(`@`)?n.slice(1):n,i=ee.get(e)??c(e);t[i]=re(r,d)}return t}function re(e,t){return!e||typeof e!=`object`||l(e)?e:Array.isArray(e)?e.map(e=>re(e,t)):t(e)}const ie={financialDeadlineList:`deadlineDetail`};function ae(e){return ie[e]??e.replace(/List$/,`Detail`)}function oe(e,{listKeys:t,arrayOfOne:n}){let r={...e},i=n??new Set;for(let e of t){let t=r[e];if(!Array.isArray(t))continue;let n=ae(e);r[e]=i.has(e)?t.map(e=>({[n]:e})):{[n]:t}}return r}const se=[`selectedServiceList`,`passengerList`,`selectedPackageList`,`extraQuoteServiceList`,`deadlineList`,`financialDeadlineList`,`paymentList`,`noteList`],ce=new Set([`selectedServiceList`,`passengerList`]),le=[`selectedServiceList`,`passengerList`,`cancellableBookedServiceList`,`deadlineList`],ue=[`passengerList`,`financialDeadlineList`],de=[`filePaymentList`];function fe(e){let t=e=>{if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(t);let n={};for(let[r,i]of Object.entries(e)){if(r===`paxAssociated`&&Array.isArray(i)&&!i.length){n[r]=``;continue}n[r]=t(i)}return n};return t(e)}function f(e,t,n){return ne(fe(n?oe(e,n):e),t)}function p(t,n,r){return e.pipe(t,e.transform(e=>f(e,n,r)))}function m(t){return e.pipe(e.union([e.array(t),t]),e.transform(e=>Array.isArray(e)?e:[e]))}function h(t){return e.pipe(t,e.transform(e=>d(e)))}function g(t,n={}){let r={},i=n.attrs??[],a=n.preserveCamel??[];for(let e in t.entries){let n=e.charAt(0).toUpperCase()+e.slice(1),o=i.includes(e)?a.includes(e)?`@${e}`:`@${n}`:n;r[o]=t.entries[e]}return e.object(r)}const _={attrs:[`currencyCode`,`creditLimit`,`c_PaymentType`,`c_SpecPaymentTypeCode`,`s_PaymentType`,`s_SpecPaymentTypeCode`,`enableElectronicInvoicing`,`electronicInvoicingType`]},v={attrs:[`idType`,`idCode`,`idIssueLocation`,`idIssueCounty`,`idIssueDate`,`idExpireDate`]},y={attrs:[`acceptProfilingPolicies`,`acceptPrivacyPolicies`,`acceptNewsletterPolicies`]},b={attrs:[`key`,`value`]},x={attrs:[`supplierRefCode`,`companyMainBusinessType`,`carrierType`]},pe={attrs:[`recordCode`,`insertCriteria`],children:{financialDetail:_,idDocumentDetail:v,accountPolicies:y,dynamicFields:b,supplierRefMasterRecords:x}},me={children:{lastModificationDate:{attrs:[`minDate`,`maxDate`]}}},S={attrs:[`sCode1`,`sCode2`,`sCode3`,`sCode4`,`sCode5`,`sCode6`],preserveCamel:[`sCode1`,`sCode2`,`sCode3`,`sCode4`,`sCode5`,`sCode6`]},he={attrs:[`code`,`iataCode`,`nationCode`,`type`]},ge={attrs:[`nType`,`title`]},_e={attrs:[`rph`,`roomRph`,`billingHolder`],children:{notes:{children:{noteDetail:ge}},idDocInfo:v}},ve={attrs:[`currencyCode`,`exchangeRate`,`cost`,`costTax`,`costType`,`vatCostCurrencyCode`,`price`,`priceTax`,`priceType`]},ye={attrs:[`pCode`,`startDate`,`endDate`,`getServicesFromPackage`],preserveCamel:[`pCode`]},be={children:{selectedServiceDetail:{attrs:[`sCode`,`ssCode`,`supplierMasterCode`,`supplierName`,`supplierMasterSearchField`,`supplierFiscalCode`],preserveCamel:[`sCode`,`ssCode`],children:{serviceFare:ve,avesServiceInfo:{children:{serviceFare:ve}},noteList:{children:{noteDetail:ge}}}}}},xe={children:{passengerDetail:_e}},Se={children:{selectedPackageDetail:ye}},Ce={children:{deadlineDetail:{attrs:[`deadlineCode`,`description`,`expireDate`,`reschedulingCode`]}}},we={children:{deadlineDetail:{attrs:[`reschedulingCode`,`expireDate`,`totalAmount`]}}},Te={children:{paymentDetail:{attrs:[`paymentDate`,`paumentNote`,`amount`,`paymentUser`,`paymentType`]}}},Ee={children:{filePaymentDetail:{attrs:[`paymentDate`,`paymentNote`,`payerMasterCode`,`payerName`,`amount`,`paymentType`]}}},De={children:{cancellableBookedServiceDetail:{attrs:[`cancelOperationType`,`serviceRefType`,`serviceRefValue`]}}},Oe={children:{noteDetail:ge}},ke={attrs:[`printDoc`,`sendDocViaEmail`],children:{infoDocumentsToPrint:{children:{infoDocumentToPrint:{children:{documentCustomizablePrintParameters:{attrs:[`makeDocumentTo`,`fillInCode`]}}}}}}},Ae={attrs:[`value`,`expiredDate`]},je={attrs:[`recordCode`]},Me={attrs:[`customer_PaymentType`,`customer_SpecPaymentTypeCode`]},Ne={attrs:[`getAllDeptDate`,`getFlightPlan`,`getAllAccomodation`,`getRealAvailability`]},Pe={attrs:[`compatibleAccomodation`,`alternativeAccomodation`]},Fe={children:{featureDetail:{attrs:[`code`,`name`]}}},Ie={attrs:[`value`,`expiredDate`,`optionedFileExpireDatePolicy`]},Le={attrs:[`apply`,`specificCode`]},Re={children:{customerDetail:je,bookingFileStatus:Ae,statisticCodes:S,destination:he,bookingFileDocument:ke,bookingFinancialInfo:Me,selectedPackageDetail:ye,selectedPackageList:Se,selectedServiceList:be,extraQuoteServiceList:be,passengerList:xe,deadlineList:Ce,financialDeadlineList:we,paymentList:Te,cancellableBookedServiceList:De,noteList:Oe}},ze={attrs:[`paymentUser`],children:{filePaymentList:Ee}},Be={children:{fileStatus:{attrs:[`value`,`expireDate`]},startDate:{attrs:[`minDate`,`maxDate`]},createdDate:{attrs:[`minDate`,`maxDate`]},lastModificationDate:{attrs:[`minDate`,`maxDate`]},insurance:{attrs:[`code`,`number`]}}},Ve={children:{statisticCodes:S,selectedServiceList:{children:{selectedServiceDetail:{attrs:[`serviceCode`,`packageRow`]}}},passengerList:xe}},He={children:{passengerList:xe}},Ue={children:{destination:he,statisticCodes:S,packageParams:Ne,topServiceParams:Pe,featureList:Fe}},We={children:{fileStatus:Ie,penalty:Le,bookingFileDocument:ke}},Ge={};function C(t){let n=Object.values(t);return e.picklist(n)}const Ke={M:`M`,F:`F`},w=C(Ke),qe={OK:`OK`,ERROR:`ERROR`,WARNING:`WARNING`,TIMEOUT:`TIMEOUT`},Je=C(qe),T={CODE:`CODE`,NAME:`NAME`,VATCODE:`VATCODE`,ZONE:`ZONE`,CATEGORY:`CATEGORY`,EMAIL:`EMAIL`,LASTMODDATE:`LASTMODDATE`,SEARCH_FIELD:`SEARCH_FIELD`,EXTERNAL_REF_CODE:`EXTERNAL_REF_CODE`},Ye=C(T),E={CUSTOMER:`CUSTOMER`,SUPPLIER:`SUPPLIER`,GENERAL:`GENERAL`},Xe=C(E),D={ENABLED:`ENABLED`,DISABLED:`DISABLED`,WARNING:`WARNING`,BLACKLISTED:`BLACKLISTED`},Ze=C(D),Qe={S:`S`,N:`N`,T:`T`,M:`M`},$e=C(Qe),et={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`},tt=C(et),nt={NOT_SET:`NOT_SET`,FLIGHT:`FLIGHT`,SHIP:`SHIP`,TRAIN:`TRAIN`,RENTCAR:`RENTCAR`,BUS:`BUS`,DP_HOTEL:`DP_HOTEL`,TO_HOTEL:`TO_HOTEL`,TO_TOUR:`TO_TOUR`,TO_HOTEL_AND_TOUR:`TO_HOTEL_AND_TOUR`,DP_AUTO:`DP_AUTO`,DP_GDS_NAVI:`DP_GDS_NAVI`,DP_GDS_VOLI:`DP_GDS_VOLI`,TOUR_OPERATOR:`TOUR_OPERATOR`,TICKETING_EV:`TICKETING_EV`,OTHER:`OTHER`},rt=C(nt),O={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRMED:`CONFIRMED`,OPTIONED:`OPTIONED`,CANCELED:`CANCELED`},it=C(O),at={...O,NULLIFIED:`NULLIFIED`},ot=C(at),k={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRM:`CONFIRM`,CONFIRMED:`CONFIRMED`,OPTION:`OPTION`,OPTIONED:`OPTIONED`,REQUEST:`REQUEST`,REQUESTED:`REQUESTED`,NULLIFIED:`NULLIFIED`,CANCELED:`CANCELED`},A=C(k),st={TOP:`TOP`,TOP_SS:`TOP_SS`,ADV:`ADV`,GRP:`GRP`,OTHER:`OTHER`},j=C(st),ct={ACCOMODATION:`ACCOMODATION`,TRANSPORT:`TRANSPORT`,CHARTER:`CHARTER`,TRANSFER:`TRANSFER`,PULLMAN:`PULLMAN`,FERRY:`FERRY`,CRUISE:`CRUISE`,INSURANCE:`INSURANCE`,EXTRAFEE:`EXTRAFEE`,PENALTY:`PENALTY`,PROMO:`PROMO`,OTHER:`OTHER`,NOT_SET:`NOT_SET`,RESIDENCE:`RESIDENCE`},M=C(ct),lt={REQUEST:`REQUEST`,ALLOTMENT_REQUEST:`ALLOTMENT_REQUEST`,CONFIRMED_REQUEST:`CONFIRMED_REQUEST`,CONFIRMED_EXTRA_ALLOTMENT:`CONFIRMED_EXTRA_ALLOTMENT`,WAITLISTED:`WAITLISTED`,ALLOTMENT:`ALLOTMENT`,REFUSED:`REFUSED`,NULLIFIED:`NULLIFIED`,CANCELED:`CANCELED`,MESSAGE:`MESSAGE`},ut=C(lt),dt={C:`C`,B:`B`,D:`D`,T:`T`,P:`P`,R:`R`,A:`A`,H:`H`,I:`I`,J:`J`,K:`K`,L:`L`,M:`M`,N:`N`,O:`O`,Q:`Q`,S:`S`,U:`U`,V:`V`},N=C(dt),ft={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`,NOT_SET:`NOT_SET`},pt=C(ft),mt={AD:`AD`,CH:`CH`,IN:`IN`,OV:`OV`},ht=C(mt),gt={NULLIFY:`NULLIFY`,DELETE:`DELETE`},_t=C(gt),vt={RPH:`RPH`,FILE:`FILE`},yt=C(vt),bt={NOT_SET:`NOT_SET`,CONSIDER_HOLIDAY:`CONSIDER_HOLIDAY`,CONSIDER_HOLIDAY_AND_SATURDAY:`CONSIDER_HOLIDAY_AND_SATURDAY`},xt=C(bt),St={AbsoluteAmountsInsertion:`AbsoluteAmountsInsertion`,FinalAmountToAchieve:`FinalAmountToAchieve`,FinalAmountToAchieveWithoutControls:`FinalAmountToAchieveWithoutControls`},Ct=C(St),wt={VISA_REQUEST:`VISA_REQUEST`,TRAVEL_INFORMATION:`TRAVEL_INFORMATION`,VOUCHER:`VOUCHER`,BOOKING_CONTRACT:`BOOKING_CONTRACT`,BOOKING_CONFIRMATION:`BOOKING_CONFIRMATION`,SUPPLIER_SERVICE_LIST:`SUPPLIER_SERVICE_LIST`,INVOICE:`INVOICE`,PROFORMA_INVOICE:`PROFORMA_INVOICE`,ADEGUAMENTO:`ADEGUAMENTO`,RESERVATION_FORM:`RESERVATION_FORM`,OPEN_XML:`OPEN_XML`,SALES_INVOICE:`SALES_INVOICE`,TICKETING_TMASTER:`TICKETING_TMASTER`,SUMMARY_FORM:`SUMMARY_FORM`},Tt=C(wt),Et={BOOKING_CUSTOMER:`BOOKING_CUSTOMER`,FIRST_PASSENGER:`FIRST_PASSENGER`},Dt=C(Et),Ot={PAX_QTY_DAY:`PAX_QTY_DAY`,PAX_QTY_NIGHT:`PAX_QTY_NIGHT`,PAX_QTY_WEEK:`PAX_QTY_WEEK`,PAX_QTY:`PAX_QTY`,PAX_DAY:`PAX_DAY`,PAX_NIGHT:`PAX_NIGHT`,PAX_WEEK:`PAX_WEEK`,PAX:`PAX`,QTY_DAY:`QTY_DAY`,QTY_NIGHT:`QTY_NIGHT`,QTY_WEE:`QTY_WEE`,QTY:`QTY`,DAY:`DAY`,NIGHT:`NIGHT`,WEEK:`WEEK`,FORFAIT:`FORFAIT`},kt=C(Ot),At={GROUPED_PAX:`GROUPED_PAX`,NOT_GROUPED_PAX:`NOT_GROUPED_PAX`,ONE_PAX_ONLY:`ONE_PAX_ONLY`},jt=C(At),Mt={AVES2AVES:`AVES2AVES`,AVES2AVESVIA:`AVES2AVESVIA`,AVES2AVESITA:`AVES2AVESITA`},Nt=C(Mt),P={FILE_CODE:`FILE_CODE`,PAX_NAME:`PAX_NAME`,PACKAGE_CODE:`PACKAGE_CODE`,OTHER:`OTHER`},Pt=C(P),F={SERVICE:`SERVICE`,PROGRAM:`PROGRAM`,PACKAGE:`PACKAGE`},Ft=C(F),I={GREATER_THAN:`GREATER_THAN`,GREATER_OR_EQUAL:`GREATER_OR_EQUAL`,EQUAL_TO:`EQUAL_TO`,LESS_OR_EQUAL:`LESS_OR_EQUAL`,LESS_THAN:`LESS_THAN`},It=C(I),Lt={CODE:`CODE`,SUB_LOCALITY:`SUB_LOCALITY`,LOCALITY:`LOCALITY`,SUB_SUB_ISLAND:`SUB_SUB_ISLAND`,SUB_ISLAND:`SUB_ISLAND`,ISLAND_COUNTY:`ISLAND_COUNTY`,SUB_ARCHIPELAGO:`SUB_ARCHIPELAGO`,ARCHIPELAGO:`ARCHIPELAGO`,REGION_STATE:`REGION_STATE`,SUB_SUB_NATION:`SUB_SUB_NATION`,SUB_NATION:`SUB_NATION`,NATION:`NATION`,SUB_SUB_CONTINENT:`SUB_SUB_CONTINENT`,SUB_CONTINENT:`SUB_CONTINENT`,CONTINENT:`CONTINENT`},Rt=C(Lt),L=e.union([e.literal(`true`),e.literal(`false`),e.boolean()]),zt={[k.CONFIRM]:`CONFIRMED`,[k.OPTION]:`OPTIONED`,[k.REQUESTED]:`REQUEST`};function Bt(e){return e in zt?zt[e]:e}const R=e.union([e.string(),e.number()]),Vt=e.pipe(e.object({"@Value":A,"@ExpiredDate":e.optional(e.string()),"@ExpireDate":e.optional(e.string())}),e.transform(e=>({"@Value":Bt(e[`@Value`]),"@ExpiredDate":e[`@ExpiredDate`]??e[`@ExpireDate`]}))),Ht=e.object({"@PaxRef":e.string(),"@Price":R}),Ut=e.object({PricePerPaxDetail:e.optional(m(Ht))}),Wt=e.object({"@CommissionCode":e.optional(e.string()),"@CommissionPercentage":e.optional(R),"@CommissionAmount":e.optional(R),"@PriceListCode":e.optional(e.string()),"@CostListCode":e.optional(e.string()),"@ServiceTotalPrice":e.optional(R),PaxPriceList:e.optional(Ut)}),Gt=e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),"@Email":e.optional(e.string()),"@LanguageCode":e.optional(e.string())}),Kt=e.object({"@Code":e.optional(e.string()),"@Description":e.optional(e.string())}),qt=e.object({"@RPH":e.string(),"@ServiceCode":e.optional(e.string()),"@FromExternalProvider":e.optional(R),"@isFromExternalProvider":e.optional(R),AvesServiceType:e.optional(j),TOServiceType:e.optional(M),FirstDescription:e.optional(e.string()),SecondDescription:e.optional(e.string()),ThirdDescription:e.optional(e.string()),FourthDescription:e.optional(e.string()),ServiceStatus:e.optional(ut),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),Qty:e.optional(R),Pax:e.optional(R),PeriodType:e.optional(e.string()),PaxMultiplier:e.optional(e.string()),ExternalProviderCode:e.optional(e.string()),WebStatisticCode:e.optional(e.string()),WebStatisticDescription:e.optional(e.string()),WebStatistic:e.optional(Kt),SupplierInfo:e.optional(Gt),ServiceTotalAmountDetail:e.optional(Wt)}),Jt=e.pipe(qt,e.transform(e=>({"@RPH":e[`@RPH`],"@ServiceCode":e[`@ServiceCode`],"@FromExternalProvider":e[`@FromExternalProvider`]??e[`@isFromExternalProvider`],AvesServiceType:e.AvesServiceType,TOServiceType:e.TOServiceType,FirstDescription:e.FirstDescription,SecondDescription:e.SecondDescription,ThirdDescription:e.ThirdDescription,FourthDescription:e.FourthDescription,ServiceStatus:e.ServiceStatus,StartDate:e.StartDate,EndDate:e.EndDate,Qty:e.Qty,Pax:e.Pax,PeriodType:e.PeriodType,PaxMultiplier:e.PaxMultiplier,ExternalProviderCode:e.ExternalProviderCode,WebStatisticCode:e.WebStatisticCode,WebStatisticDescription:e.WebStatisticDescription,WebStatistic:e.WebStatistic,SupplierInfo:e.SupplierInfo,ServiceTotalAmountDetail:e.ServiceTotalAmountDetail}))),Yt=e.object({BookedServiceDetail:e.optional(m(Jt))}),Xt=e.object({"@CurrencyCode":e.optional(e.string()),"@TotalAmountBeforeDiscount":e.optional(R),"@TotalAmountAfterDiscount":e.optional(R),"@TotalDiscount":e.optional(R),"@TotalAmountWithoutVat":e.optional(R),"@DueAmount":e.optional(R),"@PaiedAmount":e.optional(R),"@Balance":e.optional(R)}),Zt=e.object({"@RPH":e.string(),"@RoomRPH":e.optional(e.string()),"@BillingHolder":e.optional(R),Name:e.optional(e.string()),CategoryCode:e.optional(e.string()),Sex:e.optional(e.string()),BirthDate:e.optional(e.string()),BirthPlace:e.optional(e.string()),NationCode:e.optional(e.string()),CitizenshipCode:e.optional(e.string()),FiscalCode:e.optional(e.string()),PhoneNumber:e.optional(e.string()),EMail:e.optional(e.string()),MasterRecordCode:e.optional(e.string())}),Qt=e.object({PassengerDetail:e.optional(m(Zt))}),$t=e.object({"@ReschedulingCode":e.optional(e.string()),"@ExpireDate":e.optional(e.string()),"@TotalAmount":e.optional(R),ReschedulingCode:e.optional(e.string()),ExpireDate:e.optional(e.string()),TotalAmount:e.optional(R)}),en=e.pipe($t,e.transform(e=>({"@ReschedulingCode":e[`@ReschedulingCode`]??e.ReschedulingCode,"@ExpireDate":e[`@ExpireDate`]??e.ExpireDate,"@TotalAmount":e[`@TotalAmount`]??e.TotalAmount}))),tn=e.object({DeadlineDetail:e.optional(m(en))}),nn=e.object({DocumentRefCode:e.optional(e.string()),DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),ArchiviationDescription:e.optional(e.string())}),rn=e.object({StoredDocumentDetail:e.optional(m(nn))}),an=e.object({DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),Enabled:e.optional(R)}),on=e.object({PrintableDocumentDetail:e.optional(m(an))}),sn=e.object({"@BookingFileCode":e.optional(e.string()),BookingFileCode:e.optional(e.string()),CustomerRecordCode:e.optional(e.string()),CustomerName:e.optional(e.string()),CustomerEmail:e.optional(e.string()),TravelAgencyName:e.optional(e.string()),TravelAgencyEmail:e.optional(e.string()),BookingFileStatus:e.optional(Vt),Description:e.optional(e.string()),Nation:e.optional(e.string()),Destination:e.optional(e.string()),CreationDate:e.optional(e.string()),FirstConfirmationDate:e.optional(e.string()),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),PackageCode:e.optional(e.string()),BookedServiceList:e.optional(Yt),TotalAmountDetail:e.optional(Xt),PaxNumber:e.optional(R),PassengerList:e.optional(Qt),Reference:e.optional(e.string()),ClerkName:e.optional(e.string()),StoredDocumentsList:e.optional(rn),PrintableDocumentsList:e.optional(on),FinancialDeadlineList:e.optional(tn)}),cn=e.pipe(sn,e.transform(e=>({"@BookingFileCode":e[`@BookingFileCode`]??e.BookingFileCode,CustomerRecordCode:e.CustomerRecordCode,CustomerName:e.CustomerName,CustomerEmail:e.CustomerEmail,TravelAgencyName:e.TravelAgencyName,TravelAgencyEmail:e.TravelAgencyEmail,BookingFileStatus:e.BookingFileStatus,Description:e.Description,Nation:e.Nation,Destination:e.Destination,CreationDate:e.CreationDate,FirstConfirmationDate:e.FirstConfirmationDate,StartDate:e.StartDate,EndDate:e.EndDate,PackageCode:e.PackageCode,BookedServiceList:e.BookedServiceList,TotalAmountDetail:e.TotalAmountDetail,PaxNumber:e.PaxNumber,PassengerList:e.PassengerList,Reference:e.Reference,ClerkName:e.ClerkName,StoredDocumentsList:e.StoredDocumentsList,PrintableDocumentsList:e.PrintableDocumentsList,FinancialDeadlineList:e.FinancialDeadlineList}))),ln=e.object({"@HostID":e.pipe(e.string(),e.minLength(6),e.maxLength(6)),"@Xtoken":e.string(),"@Interface":e.literal(`WEB`),"@UserName":e.literal(`WEB`),"@LanguageCode":e.optional(e.pipe(e.string(),e.minLength(2),e.maxLength(2)))}),un=e.optional(e.pipe(e.string(),e.transform(e=>e.split(`,`)))),z=e.pipe(e.object({"@Status":Je,ErrorCode:e.optional(e.pipe(e.union([e.string(),e.number()]),e.transform(e=>Number(e)))),ErrorDescription:e.optional(e.string()),Warnings:un}),e.transform(e=>({status:e[`@Status`],errorCode:e.ErrorCode,errorDescription:e.ErrorDescription,warnings:e.Warnings}))),dn=e.object({value:it,expiredDate:e.optional(e.string())}),B=e.object({sCode1:e.optional(e.pipe(e.string(),e.maxLength(4))),sCode2:e.optional(e.pipe(e.string(),e.maxLength(4))),sCode3:e.optional(e.pipe(e.string(),e.maxLength(4))),sCode4:e.optional(e.pipe(e.string(),e.maxLength(4))),sCode5:e.optional(e.pipe(e.string(),e.maxLength(4))),sCode6:e.optional(e.pipe(e.string(),e.maxLength(4)))}),fn=e.object({code:e.optional(e.string()),iataCode:e.optional(e.string()),nationCode:e.optional(e.string())}),pn=e.object({recordCode:e.optional(e.string())}),mn=Tt,hn=e.object({makeDocumentTo:e.optional(Dt)}),gn=e.object({fillInCode:e.optional(e.string())}),_n=e.union([hn,gn]),vn=e.object({documentType:mn,documentCustomizablePrintParameters:e.optional(_n)}),yn=e.object({printDoc:e.optional(L),sendDocViaEmail:e.optional(L),infoDocumentsToPrint:e.optional(e.array(vn))}),bn=e.object({reschedulingCode:e.optional(e.string()),expireDate:e.optional(e.string()),totalAmount:e.optional(e.string())}),xn=e.object({deadlineCode:e.optional(e.string()),description:e.optional(e.string()),expireDate:e.optional(e.string())}),Sn=e.object({paymentDate:e.optional(e.string()),paumentNote:e.optional(e.string()),amount:e.optional(e.string()),paymentUser:e.optional(e.string()),paymentType:e.optional(N)}),Cn=kt,wn=e.object({currencyCode:e.optional(e.string()),exchangeRate:e.optional(e.string()),cost:e.optional(e.string()),costTax:e.optional(e.string()),costType:e.optional(Cn),vatCostCurrencyCode:e.optional(e.string()),price:e.optional(e.string()),priceTax:e.optional(e.string()),priceType:e.optional(Cn)}),Tn=e.object({packageCode:e.optional(e.string()),packageReference:e.optional(e.string()),suballotmentCode:e.optional(e.string()),priceListCode:e.optional(e.string()),costListCode:e.optional(e.string()),externalFileCode:e.optional(e.string()),externalReference:e.optional(e.string()),serviceStatus:e.optional(e.string()),serviceStatisticCode:e.optional(e.string()),serviceFare:e.optional(wn)}),En=e.object({pax:e.string()}),V=e.object({sCode:e.string(),ssCode:e.optional(e.string()),avesServiceType:j,toServiceType:e.optional(M),subServiceDesc:e.optional(e.string()),startDate:e.string(),endDate:e.string(),qty:e.string(),pax:e.string(),paxAssociated:e.optional(e.array(En)),avesSession:e.string(),avesServiceInfo:e.optional(Tn),serviceFare:e.optional(wn),bookedServiceRef:e.optional(e.string()),supplierMasterCode:e.optional(e.string()),voucherMasterCode:e.optional(e.string()),hotelServiceInfo:e.optional(e.string()),carRentalServiceInfo:e.optional(e.string()),flightServiceInfo:e.optional(e.string()),shipServiceInfo:e.optional(e.string()),ticketServiceInfo:e.optional(e.string()),commission:e.optional(e.string()),noteList:e.optional(e.string()),voucherInfo:e.optional(e.string()),firstDescription:e.optional(e.string()),secondDescription:e.optional(e.string())}),Dn=e.object({pCode:e.string(),startDate:e.string(),endDate:e.string(),getServicesFromPackage:e.optional(L)}),On=e.object({nType:e.optional(e.string()),title:e.optional(e.string()),text:e.optional(e.string())}),kn=ht,An={rph:e.string(),roomRph:e.optional(e.string()),billingHolder:e.optional(L),masterRecordCode:e.optional(e.string()),name:e.string(),sex:w,birthDate:e.optional(e.string()),birthPlace:e.optional(e.string()),nationCode:e.optional(e.string()),citizenshipCode:e.optional(e.string()),fiscalCode:e.optional(e.string()),phoneNumber:e.optional(e.string()),eMail:e.optional(e.string()),notes:e.optional(e.array(On)),flagStatus:e.optional(e.string()),offerCode:e.optional(e.string()),idDocInfo:e.optional(e.object({idType:e.optional(e.string()),idCode:e.optional(e.string()),idIssueLocation:e.optional(e.string()),idIssueCounty:e.optional(e.string()),idIssueDate:e.optional(e.string()),idExpireDate:e.optional(e.string())}))},H=e.object({...An,categoryCode:kn}),jn=e.object({...An,categoryCode:e.optional(kn)}),Mn=e.object({customer_PaymentType:e.optional(pt),customer_SpecPaymentTypeCode:e.optional(e.string())}),Nn=jt,Pn=Nt,Fn=p(e.object({createDate:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),travelAgentCode:e.optional(e.string()),clerkName:e.optional(e.string()),customerDetail:pn,currencyCode:e.optional(e.string()),markupCode:e.optional(e.string()),bookingFileStatus:dn,statisticCodes:e.optional(B),destination:e.optional(fn),bookingFileDescription:e.optional(e.string()),startDate:e.string(),endDate:e.string(),earlyBookingDate:e.optional(e.string()),cupCode:e.optional(e.string()),cigCode:e.optional(e.string()),customerPromoterCode:e.optional(e.string()),billingReferenceCode:e.optional(e.string()),paymentReferenceCode:e.optional(e.string()),bookingFileDocument:e.optional(yn),financialDeadlineList:e.optional(e.array(bn)),deadlineList:e.optional(e.array(xn)),paymentList:e.optional(e.array(Sn)),selectedPackageList:e.optional(e.array(Dn)),selectedServiceList:e.array(V),extraQuotaRefCode:e.optional(e.string()),extraQuoteServiceList:e.optional(e.array(V)),getExtraQuoteFromSystem:e.optional(L),passengerList:e.array(H),noteList:e.optional(e.array(On)),bookingFinancialInfo:e.optional(Mn),bookingFileCode:e.optional(e.string()),groupingPaxPolicy:e.optional(Nn),groupBookingFile:e.optional(L),typeDownloadFile:e.optional(Pn),setBookingFileCodeFromStartDate:e.optional(L)}),Re,{listKeys:se,arrayOfOne:ce}),In=h(e.object({RsStatus:z,BookingFileDetail:e.optional(cn),PrintableDocumentsList:e.optional(on),TotalAmountDetailAfterCancellation:e.optional(Xt),Base64DocContent:e.optional(e.string())})),U=h(e.object({RsStatus:z})),W=In,Ln=e.object({reschedulingCode:e.string(),description:e.optional(e.string()),expireDate:e.optional(e.string())}),Rn=e.object({cancelOperationType:_t,serviceRefType:yt,serviceRefValue:e.string()}),zn=p(e.object({customerRecordCode:e.string(),bookingFileCode:e.string(),currencyCode:e.optional(e.string()),deadlineList:e.optional(e.array(Ln)),selectedPackageDetail:e.optional(Dn),selectedServiceList:e.pipe(e.array(V),e.minLength(1)),cancellableBookedServiceList:e.optional(e.array(Rn)),passengerList:e.optional(e.array(jn))}),Re,{listKeys:le}),Bn=p(e.object({bookingFileCode:e.string(),bookingFileStartDate:e.string(),customerRecordCode:e.string(),newCustomerRecordCode:e.optional(e.string()),bookingFileReferenceName:e.optional(e.string()),travelAgentCode:e.optional(e.string()),billingReferenceCode:e.optional(e.string()),paymentReferenceCode:e.optional(e.string()),cupCode:e.optional(e.string()),cigCode:e.optional(e.string()),customerPromoterCode:e.optional(e.string()),bookingNote:e.optional(e.string()),passengerList:e.optional(e.array(jn)),statisticCodes:e.optional(B),bookingFinancialInfo:e.optional(Mn),financialDeadlineList:e.optional(e.array(e.object({reschedulingCode:e.string(),expireDate:e.string(),totalAmount:e.string()})))}),Re,{listKeys:ue}),Vn=p(e.object({bookingFileCode:e.string(),customerRecordCode:e.string()}),Ge),Hn=xt,Un=p(e.object({customerRecordCode:e.string(),bookingFileCode:e.string(),fileStatus:e.object({value:ot,expiredDate:e.optional(e.string()),optionedFileExpireDatePolicy:e.optional(Hn)}),backOfficeRequest:e.optional(L),bookingFileDocument:e.optional(yn),penalty:e.optional(e.object({apply:e.optional(L),specificCode:e.optional(e.string())})),simulateCancelAndGetPenaltyAmount:e.optional(L)}),We),Wn=p(e.object({customerRecordCode:e.string(),bookingFileCode:e.string(),bookingServiceRef:e.string(),bookingFileServiceStatus:e.literal(`NULLIFIED`),bookingFileServiceStatusDate:e.optional(e.string())}),Ge),Gn=Ct,Kn=e.object({paymentDate:e.string(),paymentNote:e.optional(e.string()),payerMasterCode:e.optional(e.string()),payerName:e.optional(e.string()),amount:e.string(),paymentType:N}),qn=p(e.pipe(e.object({bookingFileCode:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),paymentUser:e.optional(e.string()),enableMultiplePayments:L,operationType:Gn,filePaymentList:e.pipe(e.array(Kn),e.minLength(1))}),e.check(e=>!!(e.bookingFileCode||e.bookingFileRefCode),`bookingFileCode or bookingFileRefCode is required`)),ze,{listKeys:de}),Jn=e.object({minDate:e.string(),maxDate:e.string()}),Yn=e.object({value:A,expireDate:e.optional(e.string())}),Xn=e.object({code:e.optional(e.string()),number:e.optional(e.string())}),G={customerRecordCode:e.string(),customerPromoterCode:e.optional(e.string()),getSupplierInfo:e.optional(L),user:e.optional(e.string()),officeCode:e.optional(e.string())},Zn=e.object({...G,searchType:e.literal(P.FILE_CODE),bookingFileCode:e.string()}),Qn=e.object({...G,searchType:e.literal(P.PAX_NAME),firstPaxName:e.string()}),$n=e.object({...G,searchType:e.literal(P.PACKAGE_CODE),packageCode:e.string()}),er=e.object({...G,searchType:e.literal(P.OTHER),fileStatus:e.optional(Yn),startDate:e.optional(Jn),createdDate:e.optional(Jn),lastModificationDate:e.optional(Jn),insurance:e.optional(Xn),isSearchForB2C:e.optional(L)}),tr=e.union([Zn,Qn,$n,er]),nr=e.pipe(tr,e.transform(e=>f(e,Be))),rr=h(e.object({RsStatus:z,BookingFileList:e.optional(e.object({BookingFileDetail:e.optional(m(cn))}))})),K={SEARCH_REQUEST:`SearchMasterRecordRQ`,SEARCH_RESPONSE:`SearchMasterRecordRS`,UPSERT_REQUEST:`ManageMasterRecordRQ`,UPSERT_RESPONSE:`ManageMasterRecordRS`,BOOKING_REQUEST:`BookFileRQ`,BOOKING_RESPONSE:`BookingFileRS`,MOD_FILE_SERVICES_REQUEST:`ModFileServicesRQ`,MOD_FILE_HEADER_REQUEST:`ModFileHeaderRQ`,MOD_FILE_HEADER_RESPONSE:`ModFileHeaderRS`,CANCEL_FILE_REQUEST:`CancelFileRQ`,CANCEL_FILE_RESPONSE:`CancelFileRS`,SET_STATUS_REQUEST:`SetStatusRQ`,SET_STATUS_RESPONSE:`SetStatusRS`,SET_STATUS_SERVICE_REQUEST:`SetStatusServiceRQ`,SET_STATUS_SERVICE_RESPONSE:`SetStatusServiceRS`,FILE_PAYMENT_LIST_REQUEST:`FilePaymentListRQ`,FILE_PAYMENT_LIST_RESPONSE:`FilePaymentListRS`,AVES_SEARCH_REQUEST:`AvesSearchRQ`,SEARCH_PACKAGE_RESPONSE:`SearchPackageRS`,SEARCH_SERVICES_RESPONSE:`SearchServicesRS`,PACKAGE_DETAIL_REQUEST:`PackageDetailRQ`,PACKAGE_DETAIL_RESPONSE:`PackageDetailRS`,COMMIT_PACKAGE_REQUEST:`CommitPackRQ`,COMMIT_PACKAGE_RESPONSE:`CommitPackRS`,SEARCH_BOOKING_FILE_REQUEST:`SearchFileRQ`,SEARCH_BOOKING_FILE_RESPONSE:`SearchFileRS`};function ir(e,t){return{[e]:t}}const q={search:`/interop/masterRecords/v2/rest/Search`,upsert:`/interop/masterRecords/v2/rest/InsertOrUpdate`,createBooking:`/interop/booking/v2/rest/CreateBookingFile`,modBookingServices:`/interop/booking/v2/rest/ModBookingFileServices`,modBookingHeader:`/interop/booking/v2/rest/ModBookingFileHeader`,cancelBooking:`/interop/booking/v2/rest/CancelBookingFile`,setBookingStatus:`/interop/booking/v2/rest/SetBookingFileStatus`,setBookingServiceStatus:`/interop/booking/v2/rest/SetBookingFileServiceStatus`,insertFilePaymentList:`/interop/booking/v2/rest/InsertFilePaymentList`,searchAvesPackages:`/interop/booking/v2/rest/SearchAvesPackages`,searchTopServices:`/interop/booking/v2/rest/SearchTopServices`,getPackageDetail:`/interop/booking/v2/rest/GetPackageDetail`,commitPackage:`/interop/booking/v2/rest/CommitPackage`,searchBookingFile:`/interop/booking/v2/rest/SearchBookingFile`};var ar=class{transport;constructor(e){this.transport=e}createBooking(e){return this.transport.invokeOp({op:`createBooking`,params:e,apiSchema:Fn,endpoint:q.createBooking,requestRoot:K.BOOKING_REQUEST,responseRoot:K.BOOKING_RESPONSE,responseSchema:In})}modBookingServices(e){return this.transport.invokeOp({op:`modBookingServices`,params:e,apiSchema:zn,endpoint:q.modBookingServices,requestRoot:K.MOD_FILE_SERVICES_REQUEST,responseRoot:K.BOOKING_RESPONSE,responseSchema:W})}modBookingHeader(e){return this.transport.invokeOp({op:`modBookingHeader`,params:e,apiSchema:Bn,endpoint:q.modBookingHeader,requestRoot:K.MOD_FILE_HEADER_REQUEST,responseRoot:K.MOD_FILE_HEADER_RESPONSE,responseSchema:U})}cancelBooking(e){return this.transport.invokeOp({op:`cancelBooking`,params:e,apiSchema:Vn,endpoint:q.cancelBooking,requestRoot:K.CANCEL_FILE_REQUEST,responseRoot:K.CANCEL_FILE_RESPONSE,responseSchema:U})}setBookingStatus(e){return this.transport.invokeOp({op:`setBookingStatus`,params:e,apiSchema:Un,endpoint:q.setBookingStatus,requestRoot:K.SET_STATUS_REQUEST,responseRoot:K.SET_STATUS_RESPONSE,responseSchema:W})}setBookingServiceStatus(e){return this.transport.invokeOp({op:`setBookingServiceStatus`,params:e,apiSchema:Wn,endpoint:q.setBookingServiceStatus,requestRoot:K.SET_STATUS_SERVICE_REQUEST,responseRoot:K.SET_STATUS_SERVICE_RESPONSE,responseSchema:W})}insertFilePaymentList(e){return this.transport.invokeOp({op:`insertFilePaymentList`,params:e,apiSchema:qn,endpoint:q.insertFilePaymentList,requestRoot:K.FILE_PAYMENT_LIST_REQUEST,responseRoot:K.FILE_PAYMENT_LIST_RESPONSE,responseSchema:U})}searchBookingFiles(e){return this.transport.invokeOp({op:`searchBookingFiles`,params:e,apiSchema:nr,endpoint:q.searchBookingFile,requestRoot:K.SEARCH_BOOKING_FILE_REQUEST,responseRoot:K.SEARCH_BOOKING_FILE_RESPONSE,responseSchema:rr})}};const or=tt,sr=e.object({currencyCode:e.optional(e.string()),creditLimit:e.optional(e.string()),c_PaymentType:e.optional(or),c_SpecPaymentTypeCode:e.optional(e.string()),s_PaymentType:e.optional(or),s_SpecPaymentTypeCode:e.optional(e.string()),enableElectronicInvoicing:e.optional(L),electronicInvoicingType:e.optional(e.string())});p(sr,_);const cr=g(sr,_),lr=e.object({idType:e.optional(e.string()),idCode:e.optional(e.string()),idIssueLocation:e.optional(e.string()),idIssueCounty:e.optional(e.string()),idIssueDate:e.optional(e.string()),idExpireDate:e.optional(e.string())});p(lr,v);const ur=g(lr,v),dr=e.object({key:e.string(),value:e.string()});p(e.array(dr),b);const fr=g(dr,b),J=e.object({supplierRefCode:e.optional(e.string()),companyMainBusinessType:e.optional(e.string()),carrierType:e.optional(rt)});p(J,x);const pr=g(J,x),mr=e.union([e.literal(0),e.literal(1)]),hr=Ze,gr=Xe,_r=$e,vr=e.object({acceptProfilingPolicies:e.optional(mr),acceptPrivacyPolicies:e.optional(mr),acceptNewsletterPolicies:e.optional(mr)});p(vr,y);const yr=g(vr,y),br=p(e.object({recordCode:e.optional(e.pipe(e.string(),e.minLength(6),e.maxLength(6))),insertCriteria:e.optional(_r),createdDate:e.optional(e.string()),recordType:e.optional(e.union([gr],E.CUSTOMER)),recordStatus:e.optional(e.union([hr],D.ENABLED)),moniker:e.optional(e.string()),name:e.optional(e.string()),extraInfo:e.optional(e.string()),languageCode:e.pipe(e.string(),e.minLength(2),e.maxLength(2)),address:e.optional(e.string()),zipCode:e.optional(e.string()),cityName:e.optional(e.string()),countyCode:e.optional(e.string()),stateCode:e.optional(e.string()),categoryCode:e.optional(e.string()),firstPhoneNumber:e.optional(e.string()),mobilePhoneNumber:e.optional(e.string()),email:e.optional(e.string()),gender:e.optional(w),birthDate:e.optional(e.string()),birthCity:e.optional(e.string()),birthCounty:e.optional(e.string()),fiscalCode:e.optional(e.string()),vatCode:e.optional(e.string()),thirdPartRecordCode:e.optional(e.string()),idDocumentDetail:e.optional(lr),accountPolicies:e.optional(vr),financialDetail:e.optional(sr),dynamicFields:e.optional(dr),supplierRefMasterRecords:e.optional(J)}),pe);h(br);const Y=e.object({"@RecordCode":e.optional(e.pipe(e.string(),e.minLength(6),e.maxLength(6))),"@InsertCriteria":e.optional(_r),CreatedDate:e.optional(e.string()),ModifiedDate:e.optional(e.string()),RecordType:e.optional(gr),LoginType:e.optional(e.string()),RecordStatus:e.optional(hr),Moniker:e.optional(e.string()),Name:e.optional(e.string()),ExtraInfo:e.optional(e.string()),LanguageCode:e.optional(e.pipe(e.string(),e.minLength(1),e.maxLength(2))),Address:e.optional(e.string()),ZipCode:e.optional(e.string()),CityName:e.optional(e.string()),CountyCode:e.optional(e.string()),StateCode:e.optional(e.string()),CategoryCode:e.optional(e.string()),PromoterCode:e.optional(e.string()),FirstPhoneNumber:e.optional(e.string()),MobilePhoneNumber:e.optional(e.string()),Email:e.optional(e.string()),Gender:e.optional(w),BirthDate:e.optional(e.string()),BirthCity:e.optional(e.string()),BirthCounty:e.optional(e.string()),EncryptedPassword:e.optional(L),FiscalCode:e.optional(e.string()),VatCode:e.optional(e.string()),ThirdPartRecordCode:e.optional(e.string()),IdDocumentDetail:e.optional(ur),NewsletterDisabled:e.optional(L),SupplierRefMasterRecords:e.optional(pr),AccountPolicies:e.optional(yr),FinancialDetail:e.optional(cr),DynamicFields:e.optional(fr)}),xr=e.object({minDate:e.string(),maxDate:e.string()}),X=e.optional(e.pipe(e.string(),e.minLength(2),e.maxLength(2))),Sr=e.object({searchType:e.literal(T.CODE),recordCode:e.pipe(e.string(),e.minLength(5),e.maxLength(6)),languageCode:X}),Cr=e.object({searchType:e.literal(T.NAME),name:e.string(),city:e.optional(e.string()),languageCode:X}),wr=e.object({searchType:e.literal(T.VATCODE),vatCode:e.string(),phoneNumber:e.optional(e.string()),languageCode:X}),Tr=e.object({searchType:e.literal(T.ZONE),zipCode:e.string(),countyCode:e.string(),city:e.optional(e.string()),languageCode:X}),Er=e.object({searchType:e.literal(T.CATEGORY),categoryCode:e.string(),languageCode:X}),Dr=e.object({searchType:e.literal(T.EMAIL),email:e.string(),languageCode:X}),Or=e.object({searchType:e.literal(T.LASTMODDATE),lastModificationDate:xr,languageCode:X}),kr=e.object({searchType:e.literal(T.SEARCH_FIELD),searchFieldValue:e.string(),languageCode:X}),Ar=e.object({searchType:e.literal(T.EXTERNAL_REF_CODE),searchFieldValue:e.string(),languageCode:X}),jr=p(e.union([Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar]),me);e.pipe(e.object({RqHeader:ln,SearchMasterRecord:jr}),e.transform(e=>{let{SearchMasterRecord:t,RqHeader:n,...r}=e;return{RqHeader:n,...t,...r}}));const Mr=e.object({MasterRecordDetail:e.optional(e.pipe(e.union([e.array(Y),Y]),e.transform(e=>{if(e)return Array.isArray(e)?e:[e]})))}),Nr=h(e.object({RsStatus:z,MasterRecordList:e.optional(Mr)}));e.object({RqHeader:ln,MasterRecordDetail:Y});const Pr=h(e.object({RsStatus:z,MasterRecordDetail:e.optional(Y)}));var Fr=class{transport;constructor(e){this.transport=e}search(e){return this.transport.invokeOp({op:`search`,params:e,apiSchema:jr,endpoint:q.search,requestRoot:K.SEARCH_REQUEST,responseRoot:K.SEARCH_RESPONSE,responseSchema:Nr})}upsertRecord(e){return this.transport.invokeOp({op:`upsertRecord`,params:e,apiSchema:br,bodyKey:`MasterRecordDetail`,endpoint:q.upsert,requestRoot:K.UPSERT_REQUEST,responseRoot:K.UPSERT_RESPONSE,responseSchema:Pr})}};const Z=e.union([e.string(),e.number(),e.boolean()]),Ir=e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),ValueCode:e.optional(e.string()),ValueName:e.optional(e.string())}),Lr=e.object({FeatureDetail:e.optional(m(Ir))}),Rr=e.object({"@PackageCode":e.optional(e.string()),"@PackageReference":e.optional(e.string()),"@PackageServiceType":e.optional(e.string()),"@ServiceCodeForPackageDetail":e.optional(e.string())}),zr=e.object({"@ssCode":e.optional(e.string()),FirstDescription:e.optional(e.string()),SubServiceType:e.optional(e.string()),SubServiceLevel:e.optional(Z),StartDate:e.optional(e.string()),EndDate:e.optional(e.string())}),Br=e.object({SubServiceDetail:e.optional(m(zr))}),Vr=e.object({"@sCode":e.optional(e.string()),FirstDescription:e.optional(e.string()),SecondDescription:e.optional(e.string()),AvesServiceType:e.optional(e.string()),TOServiceType:e.optional(e.string()),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),RefPackageInfo:e.optional(Rr),SubServiceList:e.optional(Br)}),Hr=e.object({ServiceDetail:e.optional(m(Vr))}),Ur=e.object({"@pCode":e.optional(e.string()),FirstDescription:e.optional(e.string()),SecondDescription:e.optional(e.string()),FrequencyType:e.optional(e.string()),ProgramType:e.optional(e.string()),StartValidation:e.optional(e.string()),EndValidation:e.optional(e.string()),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),BasePrice:e.optional(Z),BasePax:e.optional(Z),CanCommitPack:e.optional(Z),FeatureList:e.optional(Lr),ServiceList:e.optional(Hr)}),Wr=e.object({PackageDetail:e.optional(m(Ur))}),Gr=e.object({code:e.optional(e.string()),type:e.optional(Rt)}),Kr=e.object({code:e.string(),name:e.optional(e.string())}),qr=e.object({getAllDeptDate:e.optional(L),getFlightPlan:e.optional(L),getAllAccomodation:e.optional(L),getRealAvailability:e.optional(L),minStay:e.optional(e.union([e.string(),e.number()])),maxStay:e.optional(e.union([e.string(),e.number()]))}),Jr=e.object({compatibleAccomodation:e.optional(L),alternativeAccomodation:e.optional(L)}),Yr=e.pipe(e.string(),e.minLength(2),e.maxLength(2)),Xr=e.object({customerRecordCode:e.string(),languageCode:e.optional(Yr),currencyCode:e.optional(e.string()),startDate:e.string(),endDate:e.string(),earlyBookingDate:e.optional(e.string()),passengerList:e.pipe(e.array(H),e.minLength(1)),avesSearchType:e.optional(Ft),paxQty:e.optional(e.union([e.string(),e.number()])),paxQtyCriteria:e.optional(It),discartNotAvailables:e.optional(L),discartNotAvailablesMinSales:e.optional(L),discartNotAvailablesDaysInOut:e.optional(L),discardPriceZero:e.optional(L),discardZeroPriceDays:e.optional(L),destination:e.optional(Gr),objectTypeCode:e.optional(e.string()),featureList:e.optional(e.array(Kr)),servOrPackCode:e.optional(e.string()),servOrPackDesc:e.optional(e.string()),priceListCode:e.optional(e.string()),costListCode:e.optional(e.string()),suballotmentCode:e.optional(e.string()),markupCode:e.optional(e.string()),statisticCodes:e.optional(B),mergeBoardAndAccomodation:e.optional(L),packageParams:e.optional(qr),topServiceParams:e.optional(Jr),getDocumentation:e.optional(L)}),Zr=e.required(Xr,[`languageCode`,`avesSearchType`]);function Qr(e){let{customerRecordCode:t,languageCode:n,currencyCode:r,startDate:i,endDate:a,earlyBookingDate:o,passengerList:s,paxQty:c,paxQtyCriteria:l,avesSearchType:u,...ee}=e;return{BaseSearch:f({customerRecordCode:t,languageCode:n,currencyCode:r,startDate:i,endDate:a,earlyBookingDate:o,passengerList:oe({passengerList:s},{listKeys:[`passengerList`]}).passengerList},He),...f({...ee,avesSearchType:u,paxQty:c??s.length,paxQtyCriteria:l??I.GREATER_OR_EQUAL},Ue,{listKeys:[`featureList`]})}}const $r=e.pipe(Zr,e.transform(Qr)),ei=h(e.object({RsStatus:z,PackageList:e.optional(Wr)})),ti=h(e.object({RsStatus:z,ServiceList:e.optional(Hr)})),ni=e.object({serviceCode:e.string(),packageRow:e.string()}),ri=e.object({customerRecordCode:e.string(),languageCode:e.optional(e.string()),currencyCode:e.optional(e.string()),packageCode:e.string(),startDate:e.string(),endDate:e.string(),priceListCode:e.optional(e.string()),costListCode:e.optional(e.string()),markupCode:e.optional(e.string()),statisticCodes:e.optional(B),selectedServiceList:e.pipe(e.array(ni),e.minLength(1)),passengerList:e.optional(e.array(H))}),ii=[`selectedServiceList`,`passengerList`],ai=e.pipe(ri,e.transform(e=>f(e,Ve,{listKeys:ii}))),oi=h(e.object({RsStatus:z,PackageDetail:e.optional(Ur)})),si=p(e.object({packageCode:e.string()}),Ge),ci=h(e.object({RsStatus:z}));var li=class{transport;constructor(e){this.transport=e}prepareSearch(e,t){return{...this.transport.languageCode&&{languageCode:this.transport.languageCode},avesSearchType:t,...e}}searchPackages(e){return this.transport.invokeOp({op:`searchPackages`,params:this.prepareSearch(e,F.PACKAGE),apiSchema:$r,endpoint:q.searchAvesPackages,requestRoot:K.AVES_SEARCH_REQUEST,responseRoot:K.SEARCH_PACKAGE_RESPONSE,responseSchema:ei})}searchTopServices(e){return this.transport.invokeOp({op:`searchTopServices`,params:this.prepareSearch(e,F.SERVICE),apiSchema:$r,endpoint:q.searchTopServices,requestRoot:K.AVES_SEARCH_REQUEST,responseRoot:K.SEARCH_SERVICES_RESPONSE,responseSchema:ti})}getPackageDetail(e){return this.transport.invokeOp({op:`getPackageDetail`,params:e,apiSchema:ai,endpoint:q.getPackageDetail,requestRoot:K.PACKAGE_DETAIL_REQUEST,responseRoot:K.PACKAGE_DETAIL_RESPONSE,responseSchema:oi})}commitPackage(e){return this.transport.invokeOp({op:`commitPackage`,params:e,apiSchema:si,endpoint:q.commitPackage,requestRoot:K.COMMIT_PACKAGE_REQUEST,responseRoot:K.COMMIT_PACKAGE_RESPONSE,responseSchema:ci})}};const ui={VALIDATION:`validation`,API:`api`,UNKNOWN:`unknown`};var Q=class extends Error{kind;message;status;code;constructor(e,t,n,r){super(t),this.kind=e,this.message=t,this.status=n,this.code=r,this.name=`AvesError`,this.status=n?.toLowerCase(),this.code=this.parseCode(r)}parseCode(e){return typeof e==`string`?Number.parseInt(e,10):e??0}};function di(e){return new Q(ui.VALIDATION,e)}function fi(e,t,n){return new Q(ui.API,e,t,n)}function pi(e){return new Q(ui.UNKNOWN,e)}function mi(e){return e.map(hi).join(`; `)}function hi(e){let t=gi(e.path),n=e.message??`Invalid value`;return t?`${t}: ${n}`:n}function gi(e){if(!e||e.length===0)return;let t=e.map(_i).filter(e=>e!==void 0);return t.length>0?t.join(`.`):void 0}function _i(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`key`in e)return String(e.key)}function vi(e){return e instanceof Error&&e.name===`AbortError`}function yi(e){return{success:!0,data:e}}function $(e){return{success:!1,error:e}}function bi(e){return e===200}function xi(e){let t=new AbortController;if(!e||e<=0)return{signal:t.signal};let n=setTimeout(()=>t.abort(),e);return{signal:t.signal,clear:()=>clearTimeout(n)}}function Si(e,t){try{let n=new URL(e),r=(n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname)+t;return new URL(r,n)}catch(e){throw new Q(`validation`,`Invalid baseURL: ${e instanceof Error?e.message:`Invalid URL format`}`)}}function Ci(e,t){if(!t.startsWith(`/`))throw new Q(`validation`,`Invalid endpoint: endpoint must start with '/' but got '${t}'`);let n=Si(e.replace(/\/$/,``),t);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new Q(`validation`,`Invalid protocol: baseURL must use http:// or https:// but got '${n.protocol}'`);return n.toString()}const wi={ignoreAttributes:!1,attributeNamePrefix:`@`,parseAttributeValue:!1,trimValues:!0,ignoreNameSpace:!0,removeNSPrefix:!0,parseTagValue:!1},Ti={ignoreAttributes:!1,attributeNamePrefix:`@`,suppressEmptyNode:!0},Ei=new o(wi),Di=new a(Ti);function Oi(e){try{return Di.build(e)}catch(e){throw new Q(`validation`,`Failed to convert JSON to XML: ${e instanceof Error?e.message:`Unknown error`}`)}}function ki(e){try{return Ei.parse(e)}catch(e){throw new Q(`validation`,`Failed to convert XML to JSON: ${e instanceof Error?e.message:`Unknown error`}`)}}var Ai=class{options;constructor(e){this.options=e}get languageCode(){return this.options.languageCode}createRqHeader(){return{"@HostID":this.options.hostID,"@Xtoken":this.options.xtoken,"@Interface":`WEB`,"@UserName":`WEB`,...this.options.languageCode&&{"@LanguageCode":this.options.languageCode}}}toAvesError(e,n){return e instanceof Q?e:e instanceof t?di(`Validation error: ${mi(e.issues)}`):e instanceof Error?pi(e.message):pi(n)}handleApiStatus(e){let{rsStatus:t}=e;return t?.status===`OK`?yi(e):$(fi(t.errorDescription??``,t.status,t.errorCode))}async request(e,t,n,a){let{signal:o,clear:s}=xi(this.options.timeoutMs??3e4);try{let s=await i(Ci(this.options.baseURL,e),{method:`POST`,headers:{"Content-Type":`application/xml`},body:Oi(t),signal:o}),c=await s.body.text();if(!bi(s.statusCode))return $(fi(c,`ERROR`,s.statusCode));let l=ki(c)[n];if(!l)return $(di(`Invalid response structure: missing root element '${n}'`));let u=r(a,l);return u.success?this.handleApiStatus(u.output):$(di(`Invalid response format: ${mi(u.issues)}`))}catch(e){return vi(e)?$(fi(`Request timed out`,`TIMEOUT`)):$(this.toAvesError(e,`Unknown error occurred`))}finally{s?.()}}async invokeOp(e){try{let t=n(e.apiSchema,e.params),r=e.bodyKey?{[e.bodyKey]:t}:t;return this.request(e.endpoint,ir(e.requestRoot,{RqHeader:this.createRqHeader(),...r}),e.responseRoot,e.responseSchema)}catch(t){return $(this.toAvesError(t,`Validation error occurred during ${e.op}`))}}};const ji=[`master`,`booking`,`packages`];function Mi(e){for(let t of ji){let n=e[t],r=Object.getPrototypeOf(n);for(let t of Object.getOwnPropertyNames(r)){if(t===`constructor`||t in e)continue;let i=Object.getOwnPropertyDescriptor(r,t)?.value;typeof i==`function`&&Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:i.bind(n)})}}}const Ni=class{transport;master;booking;packages;constructor(e,t={}){this.transport=t.transport??new Ai(e),this.master=t.master??new Fr(this.transport),this.booking=t.booking??new ar(this.transport),this.packages=t.packages??new li(this.transport),Mi(this)}};export{Ni as AvesClient,Q as AvesError,F as AvesSearchType,Ft as AvesSearchTypeSchema,st as AvesServiceType,j as AvesServiceTypeSchema,Ai as AvesTransport,lt as BookedServiceStatus,ut as BookedServiceStatusSchema,ar as BookingClient,O as BookingFileStatus,it as BookingFileStatusSchema,k as BookingFileStatusWire,A as BookingFileStatusWireSchema,gt as CancelOperationType,_t as CancelOperationTypeSchema,nt as CarrierType,rt as CarrierTypeSchema,Ot as CostPriceType,kt as CostPriceTypeSchema,ft as CustomerPaymentType,pt as CustomerPaymentTypeSchema,Lt as DestinationType,Rt as DestinationTypeSchema,wt as DocumentType,Tt as DocumentTypeSchema,St as FilePaymentOperationType,Ct as FilePaymentOperationTypeSchema,Ke as Gender,w as GenderSchema,At as GroupingPaxPolicy,jt as GroupingPaxPolicySchema,Qe as InsertCriteria,$e as InsertCriteriaSchema,Et as MakeDocumentTo,Dt as MakeDocumentToSchema,et as MasterPaymentType,tt as MasterPaymentTypeSchema,Fr as MasterRecordsClient,bt as OptionedExpirePolicy,xt as OptionedExpirePolicySchema,li as PackageCatalogClient,mt as PassengerCategory,ht as PassengerCategorySchema,I as PaxQtyCriteria,It as PaxQtyCriteriaSchema,dt as PaymentType,N as PaymentTypeSchema,D as RecordStatus,Ze as RecordStatusSchema,E as RecordType,Xe as RecordTypeSchema,qe as RsStatusValue,Je as RsStatusValueSchema,P as SearchBookingFileType,Pt as SearchBookingFileTypeSchema,T as SearchMasterType,Ye as SearchMasterTypeSchema,vt as ServiceRefType,yt as ServiceRefTypeSchema,at as SetFileStatusValue,ot as SetFileStatusValueSchema,ct as ToServiceType,M as ToServiceTypeSchema,Mt as TypeDownloadFile,Nt as TypeDownloadFileSchema};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|