aves-sdk 3.0.0 → 4.0.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/dist/index.mjs CHANGED
@@ -1 +1 @@
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(t){return e.picklist(Object.values(t))}const c={M:`M`,F:`F`},l=s(c),u={OK:`OK`,ERROR:`ERROR`,WARNING:`WARNING`,TIMEOUT:`TIMEOUT`},ee=s(u),d={CODE:`CODE`,NAME:`NAME`,VATCODE:`VATCODE`,ZONE:`ZONE`,CATEGORY:`CATEGORY`,EMAIL:`EMAIL`,LASTMODDATE:`LASTMODDATE`,SEARCH_FIELD:`SEARCH_FIELD`,EXTERNAL_REF_CODE:`EXTERNAL_REF_CODE`},te=s(d),ne={CUSTOMER:`CUSTOMER`,SUPPLIER:`SUPPLIER`,VOUCHER:`VOUCHER`,SUPPLIER_VOUCHER:`SUPPLIER_VOUCHER`,GENERAL:`GENERAL`},re=s(ne),f={ENABLED:`ENABLED`,DISABLED:`DISABLED`,WARNING:`WARNING`,BLACKLISTED:`BLACKLISTED`},ie=s(f),ae={S:`S`,N:`N`,T:`T`,M:`M`},oe=s(ae),se={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`},ce=s(se),le={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`},ue=s(le),de={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRMED:`CONFIRMED`,OPTIONED:`OPTIONED`,CANCELED:`CANCELED`},fe=s(de),pe={...de,NULLIFIED:`NULLIFIED`},me=s(pe),p={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRM:`CONFIRM`,CONFIRMED:`CONFIRMED`,OPTION:`OPTION`,OPTIONED:`OPTIONED`,REQUEST:`REQUEST`,REQUESTED:`REQUESTED`,NULLIFIED:`NULLIFIED`,CANCELED:`CANCELED`},m=s(p),he={TOP:`TOP`,TOP_SS:`TOP_SS`,ADV:`ADV`,GRP:`GRP`,OTHER:`OTHER`},h=s(he),ge={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`,TOUR:`TOUR`},g=s(ge),_e={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`},ve=s(_e),ye={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`},be=s(ye),xe={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`,NOT_SET:`NOT_SET`},Se=s(xe),Ce={AD:`AD`,CH:`CH`,IN:`IN`,OV:`OV`},we=s(Ce),Te={NULLIFY:`NULLIFY`,DELETE:`DELETE`},Ee=s(Te),De={RPH:`RPH`,FILE:`FILE`},Oe=s(De),ke={NOT_SET:`NOT_SET`,CONSIDER_HOLIDAY:`CONSIDER_HOLIDAY`,CONSIDER_HOLIDAY_AND_SATURDAY:`CONSIDER_HOLIDAY_AND_SATURDAY`},Ae=s(ke),je={AbsoluteAmountsInsertion:`AbsoluteAmountsInsertion`,FinalAmountToAchieve:`FinalAmountToAchieve`,FinalAmountToAchieveWithoutControls:`FinalAmountToAchieveWithoutControls`},Me=s(je),Ne={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`},Pe=s(Ne),Fe={BOOKING_CUSTOMER:`BOOKING_CUSTOMER`,FIRST_PASSENGER:`FIRST_PASSENGER`},Ie=s(Fe),Le={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`},_=s(Le),Re={GROUPED_PAX:`GROUPED_PAX`,NOT_GROUPED_PAX:`NOT_GROUPED_PAX`,ONE_PAX_ONLY:`ONE_PAX_ONLY`},ze=s(Re),Be={AVES2AVES:`AVES2AVES`,AVES2AVESVIA:`AVES2AVESVIA`,AVES2AVESITA:`AVES2AVESITA`},Ve=s(Be),v={FILE_CODE:`FILE_CODE`,PAX_NAME:`PAX_NAME`,PACKAGE_CODE:`PACKAGE_CODE`,OTHER:`OTHER`},He=s(v),y={SERVICE:`SERVICE`,PROGRAM:`PROGRAM`,PACKAGE:`PACKAGE`},Ue=s(y),We={GREATER_THAN:`GREATER_THAN`,GREATER_OR_EQUAL:`GREATER_OR_EQUAL`,EQUAL_TO:`EQUAL_TO`,LESS_OR_EQUAL:`LESS_OR_EQUAL`,LESS_THAN:`LESS_THAN`},Ge=s(We),Ke={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`},qe=s(Ke),Je=e.pipe(e.string(),e.minLength(2),e.maxLength(2)),b=e.optional(Je),x=e.union([e.string(),e.number()]),S=e.union([e.string(),e.number(),e.boolean()]),C=e.object({minDate:e.string(),maxDate:e.string()}),Ye=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":b}),Xe=e.optional(e.string()),w=e.pipe(e.object({"@Status":ee,ErrorCode:e.optional(e.pipe(x,e.transform(e=>Number(e)))),ErrorDescription:e.optional(e.string()),Warnings:Xe}),e.transform(e=>({status:e[`@Status`],errorCode:e.ErrorCode,errorDescription:e.ErrorDescription,warnings:e.Warnings}))),Ze=D(e.object({RsStatus:w})),Qe={rph:`RPH`,toServiceType:`TOServiceType`,text:`#text`},$e=Object.fromEntries(Object.entries(Qe).map(([e,t])=>[t,e]));function et(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error}function tt(e){return Qe[e]??e.charAt(0).toUpperCase()+e.slice(1)}function nt(e){return $e[e]??e.charAt(0).toLowerCase()+e.slice(1)}function rt(e,t){let n=t?.textContent===e?`#text`:t?.rename?.[e]??tt(e);return n===`#text`||!t?.attrs?.includes(e)?n:t.preserveCamel?.includes(e)?`@${e}`:`@${n}`}function it(e){let{listWrap:t,detailKey:n,...r}=e;return r}function at(e,t){return t?.listWrap?{children:{[t.detailKey??(e.endsWith(`List`)?`${e.slice(0,-4)}Detail`:`${e}Detail`)]:it(t)}}:t}function ot(e,t){if(typeof e!=`object`||!e||et(e))return e;if(Array.isArray(e))return e.map(e=>ot(e,t));let n={};for(let[r,i]of Object.entries(e)){let e=t?.children?.[r];n[rt(r,t)]=ot(i,at(r,e))}return n}function st(e){if(typeof e!=`object`||!e||et(e))return e;if(Array.isArray(e))return e.map(e=>st(e));let t={};for(let[n,r]of Object.entries(e)){let e=n.startsWith(`@`)?n.slice(1):n;t[nt(e)]=st(r)}return t}const ct={financialDeadlineList:`deadlineDetail`};function lt(e,t){return t?.detailKey??ct[e]??(e.endsWith(`List`)?`${e.slice(0,-4)}Detail`:`${e}Detail`)}function ut(e,t){let n=(e,t)=>{if(Array.isArray(e))return e.map(e=>n(e,t));if(typeof e!=`object`||!e)return e;let r={};for(let[i,a]of Object.entries(e)){let e=t?.children?.[i];if(e?.listWrap&&Array.isArray(a)){let t=lt(i,e),o=a.map(t=>n(t,it(e)));r[i]=e.listWrap===`one`?o.map(e=>({[t]:e})):{[t]:o};continue}r[i]=n(a,e)}return r};return n(e,t)}function dt(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)){if(!i.length){n[r]=``;continue}if(i.every(e=>typeof e==`string`)){n[r]=i.map(e=>({pax:e}));continue}}n[r]=t(i)}return n};return t(e)}function ft(e,t){return ot(dt(ut(e,t)),t)}function T(t,n){return e.pipe(t,e.transform(e=>ft(e,n)))}function pt(t){return e.pipe(e.union([e.array(t),t]),e.transform(e=>Array.isArray(e)?e:[e]))}function E(t,n){let r=e.optional(pt(n));return e.pipe(e.object({[t]:r}),e.transform(e=>e[t]??[]))}function D(t){return e.pipe(t,e.transform(e=>st(e)))}function O(t,n){let r={[t]:e.optional(n)};return D(e.object({RsStatus:w,...r}))}function mt(e){return t=>{if(typeof t!=`object`||!t)return t;let n=t,r=n[e],{[e]:i,...a}=n;return!r||typeof r!=`object`||Array.isArray(r)?a:{...a,...r}}}function ht(t,n){return e.pipe(D(t),e.transform(e=>mt(n)(e)))}function k(t,n){let r=e.object({value:t,...n??{}});return e.pipe(e.union([t,r]),e.transform(e=>typeof e==`object`&&e?e:{value:e}))}function gt(e,t){return n=>{let r=Reflect.get(n,e),i=Reflect.get(n,t),a={...n};return Reflect.deleteProperty(a,e),Reflect.set(a,t,i??(Array.isArray(r)?r[0]:void 0)),a}}function _t(e){let{customerRecordCode:t,customerDetail:n,...r}=e;return{...r,customerDetail:{...n,recordCode:n?.recordCode??t}}}function vt(e){return e.type===`object`&&`entries`in e}function yt(e){return e.type===`optional`&&`wrapped`in e}function bt(e){return e.type===`array`&&`item`in e}function A(t,n){if(yt(t)){let r=A(t.wrapped,n);return t.default===void 0?e.optional(r):e.optional(r,t.default)}return bt(t)?pt(A(t.item,n)):vt(t)?xt(t,n):t}function xt(t,n,r){let i={};for(let e in t.entries){let r=n.children?.[e]??{};i[rt(e,n)]=A(t.entries[e],r)}return e.object({...i,...r})}function j(e,t={},n){return xt(e,t,n)}function M(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t;for(let e of r)if(n[e]!==void 0&&n[e]!==null){t=n[e];break}for(let t of r)t!==e&&delete n[t];t===void 0?delete n[e]:n[e]=t}return n}function N(e,t){return{api:T(e,t),validation:j(e,t)}}function P(e){return e}function F(...e){return P({attrs:e})}function St(...e){return P({attrs:e,preserveCamel:e})}function Ct(e,t){return P({attrs:e,preserveCamel:t})}function I(e){return P({children:e})}function L(e,t){return P({attrs:e,children:t})}function R(e,t,n){return P(n?{...e,listWrap:t,detailKey:n}:{...e,listWrap:t})}function z(e,...t){return R(F(...t),e)}function wt(e){return{one:R(e,`one`),many:R(e,`many`)}}F(`hostID`,`xtoken`,`interface`,`userName`,`status`,`languageCode`);const Tt=F(`currencyCode`,`creditLimit`,`c_PaymentType`,`c_SpecPaymentTypeCode`,`s_PaymentType`,`s_SpecPaymentTypeCode`,`enableElectronicInvoicing`,`electronicInvoicingType`),Et=F(`idType`,`idCode`,`idIssueLocation`,`idIssueCounty`,`idIssueDate`,`idExpireDate`),Dt=F(`acceptProfilingPolicies`,`acceptPrivacyPolicies`,`acceptNewsletterPolicies`),Ot=F(`key`,`value`),kt=F(`supplierRefCode`,`companyMainBusinessType`,`carrierType`),At=L([`recordCode`,`insertCriteria`],{financialDetail:Tt,idDocumentDetail:Et,accountPolicies:Dt,dynamicFields:Ot,supplierRefMasterRecords:kt}),B=F(`minDate`,`maxDate`),jt=I({lastModificationDate:B}),Mt=St(`sCode1`,`sCode2`,`sCode3`,`sCode4`,`sCode5`,`sCode6`),Nt=F(`code`,`iataCode`,`nationCode`,`type`),Pt=F(`nType`,`title`),Ft=R(Pt,`many`),It=L([`rph`,`roomRph`,`billingHolder`],{notes:R(Pt,`many`,`noteDetail`),idDocInfo:Et}),Lt=F(`currencyCode`,`exchangeRate`,`cost`,`costTax`,`costType`,`vatCostCurrencyCode`,`price`,`priceTax`,`priceType`),Rt=Ct([`pCode`,`startDate`,`endDate`,`getServicesFromPackage`],[`pCode`]),V=wt(P({...Ct([`sCode`,`ssCode`],[`sCode`,`ssCode`]),children:{serviceFare:Lt,avesServiceInfo:I({serviceFare:Lt}),noteList:Ft}})),H=wt(It);H.one,H.many;const zt=R(Rt,`many`),Bt=z(`many`,`deadlineCode`,`description`,`expireDate`),Vt=z(`many`,`reschedulingCode`,`description`,`expireDate`),Ht=R(F(`reschedulingCode`,`expireDate`,`totalAmount`),`many`,`deadlineDetail`),Ut=R(P({...F(`paymentDate`,`paymentNote`,`amount`,`paymentUser`,`paymentType`),rename:{paymentNote:`PaumentNote`}}),`many`),Wt=z(`many`,`paymentDate`,`paymentNote`,`payerMasterCode`,`payerName`,`amount`,`paymentType`),Gt=z(`many`,`cancelOperationType`,`serviceRefType`,`serviceRefValue`),Kt=L([`printDoc`,`sendDocViaEmail`],{infoDocumentsToPrint:I({documentCustomizablePrintParameters:F(`makeDocumentTo`,`fillInCode`)})}),qt=F(`value`,`expiredDate`),Jt=F(`recordCode`),Yt=F(`customer_PaymentType`,`customer_SpecPaymentTypeCode`),Xt=F(`getAllDeptDate`,`getFlightPlan`,`getAllAccomodation`,`getRealAvailability`),Zt=F(`compatibleAccomodation`,`alternativeAccomodation`),Qt=z(`many`,`code`,`name`),$t=F(`value`,`expiredDate`,`optionedFileExpireDatePolicy`),en=F(`apply`,`specificCode`),tn={customerDetail:Jt,bookingFileStatus:qt,statisticCodes:Mt,destination:Nt,bookingFileDocument:Kt,bookingFinancialInfo:Yt,selectedPackageDetail:Rt,selectedPackageList:zt,financialDeadlineList:Ht,paymentList:Ut,cancellableBookedServiceList:Gt,noteList:Ft},nn=I({...tn,deadlineList:Bt,selectedServiceList:V.one,extraQuoteServiceList:V.one,passengerList:H.one}),rn=I({...tn,deadlineList:Vt,selectedServiceList:V.many,extraQuoteServiceList:V.many,passengerList:H.many}),an=L([`paymentUser`],{filePaymentList:Wt}),on=I({fileStatus:F(`value`,`expireDate`),startDate:B,createdDate:B,lastModificationDate:B,insurance:F(`code`,`number`)}),sn=I({statisticCodes:Mt,selectedServiceList:R(F(`serviceCode`,`packageRow`),`many`),passengerList:H.many}),cn=I({passengerList:H.many}),ln=I({destination:Nt,statisticCodes:Mt,packageParams:Xt,topServiceParams:Zt,featureList:Qt}),un=I({fileStatus:$t,penalty:en,bookingFileDocument:Kt}),dn=P({}),U=e.union([e.literal(`true`),e.literal(`false`),e.boolean()]),fn={[p.CONFIRM]:`CONFIRMED`,[p.OPTION]:`OPTIONED`,[p.REQUESTED]:`REQUEST`};function pn(e){return e in fn?fn[e]:e}const mn=e.pipe(e.object({"@Value":m,"@ExpiredDate":e.optional(e.string()),"@ExpireDate":e.optional(e.string())}),e.transform(e=>({...M(e,{"@ExpiredDate":[`@ExpiredDate`,`@ExpireDate`]}),"@Value":pn(e[`@Value`])}))),hn=E(`PricePerPaxDetail`,e.object({"@PaxRef":e.string(),"@Price":x})),gn=e.object({"@CommissionCode":e.optional(e.string()),"@CommissionPercentage":e.optional(x),"@CommissionAmount":e.optional(x),"@PriceListCode":e.optional(e.string()),"@CostListCode":e.optional(e.string()),"@ServiceTotalPrice":e.optional(x),PaxPriceList:e.optional(hn)}),_n=e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),"@Email":e.optional(e.string()),"@LanguageCode":e.optional(e.string())}),vn=e.object({"@Code":e.optional(e.string()),"@Description":e.optional(e.string())}),yn=e.object({"@RPH":e.string(),"@ServiceCode":e.optional(e.string()),"@FromExternalProvider":e.optional(x),"@isFromExternalProvider":e.optional(x),AvesServiceType:e.optional(h),TOServiceType:e.optional(g),FirstDescription:e.optional(e.string()),SecondDescription:e.optional(e.string()),ThirdDescription:e.optional(e.string()),FourthDescription:e.optional(e.string()),ServiceStatus:e.optional(ve),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),Qty:e.optional(x),Pax:e.optional(x),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(vn),SupplierInfo:e.optional(_n),ServiceTotalAmountDetail:e.optional(gn)}),bn=E(`BookedServiceDetail`,e.pipe(yn,e.transform(e=>M(e,{"@FromExternalProvider":[`@FromExternalProvider`,`@isFromExternalProvider`]})))),xn=e.object({"@CurrencyCode":e.optional(e.string()),"@TotalAmountBeforeDiscount":e.optional(x),"@TotalAmountAfterDiscount":e.optional(x),"@TotalDiscount":e.optional(x),"@TotalAmountWithoutVat":e.optional(x),"@DueAmount":e.optional(x),"@PaiedAmount":e.optional(x),"@Balance":e.optional(x)}),Sn=E(`PassengerDetail`,e.object({"@RPH":e.string(),"@RoomRPH":e.optional(e.string()),"@BillingHolder":e.optional(x),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())})),Cn=e.object({"@ReschedulingCode":e.optional(e.string()),"@ExpireDate":e.optional(e.string()),"@TotalAmount":e.optional(x),ReschedulingCode:e.optional(e.string()),ExpireDate:e.optional(e.string()),TotalAmount:e.optional(x)}),wn=E(`DeadlineDetail`,e.pipe(Cn,e.transform(e=>M(e,{"@ReschedulingCode":[`@ReschedulingCode`,`ReschedulingCode`],"@ExpireDate":[`@ExpireDate`,`ExpireDate`],"@TotalAmount":[`@TotalAmount`,`TotalAmount`]})))),Tn=E(`StoredDocumentDetail`,e.object({DocumentRefCode:e.optional(e.string()),DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),ArchiviationDescription:e.optional(e.string())})),En=E(`PrintableDocumentDetail`,e.object({DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),Enabled:e.optional(x)})),Dn=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(mn),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(bn),TotalAmountDetail:e.optional(xn),PaxNumber:e.optional(x),PassengerList:e.optional(Sn),Reference:e.optional(e.string()),ClerkName:e.optional(e.string()),StoredDocumentsList:e.optional(Tn),PrintableDocumentsList:e.optional(En),FinancialDeadlineList:e.optional(wn)}),On=e.pipe(Dn,e.transform(e=>M(e,{"@BookingFileCode":[`@BookingFileCode`,`BookingFileCode`]}))),kn=e.object({currencyCode:e.optional(e.string()),creditLimit:e.optional(e.string()),c_PaymentType:e.optional(ce),c_SpecPaymentTypeCode:e.optional(e.string()),s_PaymentType:e.optional(ce),s_SpecPaymentTypeCode:e.optional(e.string()),enableElectronicInvoicing:e.optional(U),electronicInvoicingType:e.optional(e.string())}),An=N(kn,Tt);An.api,An.validation;const jn=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())}),Mn=N(jn,Et);Mn.api,Mn.validation;const Nn=e.object({key:e.string(),value:e.string()});j(Nn,Ot);const Pn=e.object({supplierRefCode:e.optional(e.string()),companyMainBusinessType:e.optional(e.string()),carrierType:e.optional(ue)}),Fn=N(Pn,kt);Fn.api,Fn.validation;const In=e.union([e.literal(0),e.literal(1)]),Ln=e.object({acceptProfilingPolicies:e.optional(In),acceptPrivacyPolicies:e.optional(In),acceptNewsletterPolicies:e.optional(In)}),Rn=N(Ln,Dt);Rn.api,Rn.validation;const zn=e.object({recordCode:e.optional(e.pipe(e.string(),e.minLength(6),e.maxLength(6))),insertCriteria:e.optional(oe),createdDate:e.optional(e.string()),recordType:e.optional(re,ne.CUSTOMER),recordStatus:e.optional(ie,f.ENABLED),moniker:e.optional(e.string()),name:e.optional(e.string()),extraInfo:e.optional(e.string()),languageCode:Je,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(l),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(jn),accountPolicies:e.optional(Ln),financialDetail:e.optional(kn),dynamicFields:e.optional(e.array(Nn)),supplierRefMasterRecords:e.optional(Pn)}),Bn=T(zn,At),W=e.partial(j(zn,At,{ModifiedDate:e.optional(e.string()),LoginType:e.optional(e.string()),PromoterCode:e.optional(e.string()),EncryptedPassword:e.optional(U),NewsletterDisabled:e.optional(U)}));D(W);const Vn=k(fe,{expiredDate:e.optional(e.string())}),G=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)))}),Hn=e.object({code:e.optional(e.string()),iataCode:e.optional(e.string()),nationCode:e.optional(e.string()),type:e.optional(qe)}),Un=e.object({recordCode:e.optional(e.string())}),Wn=e.object({makeDocumentTo:e.optional(Ie)}),Gn=e.object({fillInCode:e.optional(e.string())}),Kn=e.union([Wn,Gn]),qn=e.object({documentType:Pe,documentCustomizablePrintParameters:e.optional(Kn)}),Jn=e.object({printDoc:e.optional(U),sendDocViaEmail:e.optional(U),infoDocumentsToPrint:e.optional(e.array(qn))}),Yn=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())}),Zn=e.object({paymentDate:e.optional(e.string()),paymentNote:e.optional(e.string()),amount:e.optional(e.string()),paymentUser:e.optional(e.string()),paymentType:e.optional(be)}),Qn=e.object({nType:e.optional(e.string()),title:e.optional(e.string()),text:e.optional(e.string())}),$n=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(_),vatCostCurrencyCode:e.optional(e.string()),price:e.optional(e.string()),priceTax:e.optional(e.string()),priceType:e.optional(_)}),er=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($n)}),tr=e.object({sCode:e.string(),ssCode:e.optional(e.string()),avesServiceType:h,toServiceType:e.optional(g),subServiceDesc:e.optional(e.string()),startDate:e.string(),endDate:e.string(),qty:e.string(),pax:e.string(),paxAssociated:e.optional(e.union([e.array(e.string()),e.array(e.object({pax:e.string()}))])),avesSession:e.string(),avesServiceInfo:e.optional(er),serviceFare:e.optional($n),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.array(Qn)),voucherInfo:e.optional(e.string()),firstDescription:e.optional(e.string()),secondDescription:e.optional(e.string())}),nr=e.object({pCode:e.string(),startDate:e.string(),endDate:e.string(),getServicesFromPackage:e.optional(U)}),rr={rph:e.string(),roomRph:e.optional(e.string()),billingHolder:e.optional(U),masterRecordCode:e.optional(e.string()),name:e.string(),sex:l,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(Qn)),flagStatus:e.optional(e.string()),offerCode:e.optional(e.string()),idDocInfo:e.optional(jn)},ir=e.object({...rr,categoryCode:we}),ar=e.object({...rr,categoryCode:e.optional(we)}),or=e.object({customer_PaymentType:e.optional(Se),customer_SpecPaymentTypeCode:e.optional(e.string())}),sr=T(e.pipe(e.object({createDate:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),travelAgentCode:e.optional(e.string()),clerkName:e.optional(e.string()),customerDetail:e.optional(Un),customerRecordCode:e.optional(e.string()),currencyCode:e.optional(e.string()),markupCode:e.optional(e.string()),bookingFileStatus:Vn,statisticCodes:e.optional(G),destination:e.optional(Hn),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(Jn),financialDeadlineList:e.optional(e.array(Yn)),deadlineList:e.optional(e.array(Xn)),paymentList:e.optional(e.array(Zn)),selectedPackageList:e.optional(e.array(nr)),selectedServiceList:e.array(tr),extraQuotaRefCode:e.optional(e.string()),extraQuoteServiceList:e.optional(e.array(tr)),getExtraQuoteFromSystem:e.optional(U),passengerList:e.array(ir),noteList:e.optional(e.array(Qn)),bookingFinancialInfo:e.optional(or),bookingFileCode:e.optional(e.string()),groupingPaxPolicy:e.optional(ze),groupBookingFile:e.optional(U),typeDownloadFile:e.optional(Ve),setBookingFileCodeFromStartDate:e.optional(U)}),e.check(e=>!!(e.customerDetail||e.customerRecordCode),`customerDetail or customerRecordCode is required`),e.transform(_t)),nn),cr=ht(e.object({RsStatus:w,BookingFileDetail:e.optional(On),PrintableDocumentsList:e.optional(En),TotalAmountDetailAfterCancellation:e.optional(xn),Base64DocContent:e.optional(e.string())}),`bookingFileDetail`),lr=Ze,K={customerRecordCode:e.string(),bookingFileCode:e.string()},ur=cr,dr=e.object({reschedulingCode:e.string(),description:e.optional(e.string()),expireDate:e.optional(e.string())}),fr=e.object({cancelOperationType:Ee,serviceRefType:Oe,serviceRefValue:e.string()}),pr=T(e.pipe(e.object({...K,currencyCode:e.optional(e.string()),deadlineList:e.optional(e.array(dr)),selectedPackageDetail:e.optional(nr),selectedPackageList:e.optional(e.pipe(e.array(nr),e.maxLength(1))),selectedServiceList:e.pipe(e.array(tr),e.minLength(1)),cancellableBookedServiceList:e.optional(e.array(fr)),passengerList:e.optional(e.array(ar))}),e.transform(gt(`selectedPackageList`,`selectedPackageDetail`))),rn),mr=T(e.object({...K,bookingFileStartDate: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(ar)),statisticCodes:e.optional(G),bookingFinancialInfo:e.optional(or),financialDeadlineList:e.optional(e.array(e.object({reschedulingCode:e.string(),expireDate:e.string(),totalAmount:e.string()})))}),rn),hr=T(e.object({...K}),dn),gr=T(e.object({...K,fileStatus:k(me,{expiredDate:e.optional(e.string()),optionedFileExpireDatePolicy:e.optional(Ae)}),backOfficeRequest:e.optional(U),bookingFileDocument:e.optional(Jn),penalty:e.optional(e.object({apply:e.optional(U),specificCode:e.optional(e.string())})),simulateCancelAndGetPenaltyAmount:e.optional(U)}),un),_r=T(e.object({...K,bookingServiceRef:e.string(),bookingFileServiceStatus:e.literal(`NULLIFIED`),bookingFileServiceStatusDate:e.optional(e.string())}),dn),vr=e.object({paymentDate:e.string(),paymentNote:e.optional(e.string()),payerMasterCode:e.optional(e.string()),payerName:e.optional(e.string()),amount:e.string(),paymentType:be}),yr=T(e.pipe(e.object({bookingFileCode:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),paymentUser:e.optional(e.string()),enableMultiplePayments:U,operationType:Me,filePaymentList:e.pipe(e.array(vr),e.minLength(1))}),e.check(e=>!!(e.bookingFileCode||e.bookingFileRefCode),`bookingFileCode or bookingFileRefCode is required`)),an),br=k(m,{expireDate:e.optional(e.string())}),xr=e.object({code:e.optional(e.string()),number:e.optional(e.string())}),q={customerRecordCode:e.string(),customerPromoterCode:e.optional(e.string()),getSupplierInfo:e.optional(U),user:e.optional(e.string()),officeCode:e.optional(e.string())},Sr=e.object({...q,searchType:e.literal(v.FILE_CODE),bookingFileCode:e.string()}),Cr=e.object({...q,searchType:e.literal(v.PAX_NAME),firstPaxName:e.string()}),wr=e.object({...q,searchType:e.literal(v.PACKAGE_CODE),packageCode:e.string()}),Tr=e.object({...q,searchType:e.literal(v.OTHER),fileStatus:e.optional(br),startDate:e.optional(C),createdDate:e.optional(C),lastModificationDate:e.optional(C),insurance:e.optional(xr),isSearchForB2C:e.optional(U)}),Er=T(e.union([Sr,Cr,wr,Tr]),on),Dr=O(`BookingFileList`,E(`BookingFileDetail`,On)),J={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 Or(e,t){return{[e]:t}}const Y={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 kr=class{transport;constructor(e){this.transport=e}createBooking(e){return this.transport.invokeOp({op:`createBooking`,params:e,apiSchema:sr,endpoint:Y.createBooking,requestRoot:J.BOOKING_REQUEST,responseRoot:J.BOOKING_RESPONSE,responseSchema:cr})}modBookingServices(e){return this.transport.invokeOp({op:`modBookingServices`,params:e,apiSchema:pr,endpoint:Y.modBookingServices,requestRoot:J.MOD_FILE_SERVICES_REQUEST,responseRoot:J.BOOKING_RESPONSE,responseSchema:ur})}modBookingHeader(e){return this.transport.invokeOp({op:`modBookingHeader`,params:e,apiSchema:mr,endpoint:Y.modBookingHeader,requestRoot:J.MOD_FILE_HEADER_REQUEST,responseRoot:J.MOD_FILE_HEADER_RESPONSE,responseSchema:lr})}cancelBooking(e){return this.transport.invokeOp({op:`cancelBooking`,params:e,apiSchema:hr,endpoint:Y.cancelBooking,requestRoot:J.CANCEL_FILE_REQUEST,responseRoot:J.CANCEL_FILE_RESPONSE,responseSchema:lr})}setBookingStatus(e){return this.transport.invokeOp({op:`setBookingStatus`,params:e,apiSchema:gr,endpoint:Y.setBookingStatus,requestRoot:J.SET_STATUS_REQUEST,responseRoot:J.SET_STATUS_RESPONSE,responseSchema:ur})}setBookingServiceStatus(e){return this.transport.invokeOp({op:`setBookingServiceStatus`,params:e,apiSchema:_r,endpoint:Y.setBookingServiceStatus,requestRoot:J.SET_STATUS_SERVICE_REQUEST,responseRoot:J.SET_STATUS_SERVICE_RESPONSE,responseSchema:ur})}insertFilePaymentList(e){return this.transport.invokeOp({op:`insertFilePaymentList`,params:e,apiSchema:yr,endpoint:Y.insertFilePaymentList,requestRoot:J.FILE_PAYMENT_LIST_REQUEST,responseRoot:J.FILE_PAYMENT_LIST_RESPONSE,responseSchema:lr})}searchBookingFiles(e){return this.transport.invokeOp({op:`searchBookingFiles`,params:e,apiSchema:Er,endpoint:Y.searchBookingFile,requestRoot:J.SEARCH_BOOKING_FILE_REQUEST,responseRoot:J.SEARCH_BOOKING_FILE_RESPONSE,responseSchema:Dr})}};const Ar=C,X=b,jr=e.object({searchType:e.literal(d.CODE),recordCode:e.pipe(e.string(),e.minLength(5),e.maxLength(6)),languageCode:X}),Mr=e.object({searchType:e.literal(d.NAME),name:e.string(),city:e.optional(e.string()),languageCode:X}),Nr=e.object({searchType:e.literal(d.VATCODE),vatCode:e.string(),phoneNumber:e.optional(e.string()),languageCode:X}),Pr=e.object({searchType:e.literal(d.ZONE),zipCode:e.string(),countyCode:e.string(),city:e.optional(e.string()),languageCode:X}),Fr=e.object({searchType:e.literal(d.CATEGORY),categoryCode:e.string(),languageCode:X}),Ir=e.object({searchType:e.literal(d.EMAIL),email:e.string(),languageCode:X}),Lr=e.object({searchType:e.literal(d.LASTMODDATE),lastModificationDate:Ar,languageCode:X}),Rr=e.object({searchType:e.literal(d.SEARCH_FIELD),searchFieldValue:e.string(),languageCode:X}),zr=e.object({searchType:e.literal(d.EXTERNAL_REF_CODE),searchFieldValue:e.string(),languageCode:X}),Br=T(e.union([jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr]),jt);e.pipe(e.object({RqHeader:Ye,SearchMasterRecord:Br}),e.transform(e=>{let{SearchMasterRecord:t,RqHeader:n,...r}=e;return{RqHeader:n,...t,...r}}));const Vr=O(`MasterRecordList`,E(`MasterRecordDetail`,W));e.object({RqHeader:Ye,MasterRecordDetail:W});const Hr=ht(e.object({RsStatus:w,MasterRecordDetail:e.optional(W)}),`masterRecordDetail`);function Ur(e){return{success:!0,data:e}}function Z(e){return{success:!1,error:e}}var Wr=class{transport;constructor(e){this.transport=e}async search(e){let t=await this.transport.invokeOp({op:`search`,params:e,apiSchema:Br,endpoint:Y.search,requestRoot:J.SEARCH_REQUEST,responseRoot:J.SEARCH_RESPONSE,responseSchema:Vr});return t.success?Ur(t.data.masterRecordList??[]):t}upsertRecord(e){return this.transport.invokeOp({op:`upsertRecord`,params:e,apiSchema:Bn,bodyKey:`MasterRecordDetail`,endpoint:Y.upsert,requestRoot:J.UPSERT_REQUEST,responseRoot:J.UPSERT_RESPONSE,responseSchema:Hr})}};const Gr=E(`FeatureDetail`,e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),ValueCode:e.optional(e.string()),ValueName:e.optional(e.string())})),Kr=e.object({"@PackageCode":e.optional(e.string()),"@PackageReference":e.optional(e.string()),"@PackageServiceType":e.optional(e.string()),"@ServiceCodeForPackageDetail":e.optional(e.string())}),qr=E(`SubServiceDetail`,e.object({"@ssCode":e.optional(e.string()),FirstDescription:e.optional(e.string()),SubServiceType:e.optional(e.string()),SubServiceLevel:e.optional(S),StartDate:e.optional(e.string()),EndDate:e.optional(e.string())})),Jr=E(`ServiceDetail`,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(Kr),SubServiceList:e.optional(qr)})),Yr=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(S),BasePax:e.optional(S),CanCommitPack:e.optional(S),FeatureList:e.optional(Gr),ServiceList:e.optional(Jr)}),Xr=E(`PackageDetail`,Yr),Zr=e.object({code:e.string(),name:e.optional(e.string())}),Qr=e.object({getAllDeptDate:e.optional(U),getFlightPlan:e.optional(U),getAllAccomodation:e.optional(U),getRealAvailability:e.optional(U),minStay:e.optional(x),maxStay:e.optional(x)}),$r=e.object({compatibleAccomodation:e.optional(U),alternativeAccomodation:e.optional(U)}),ei=e.object({customerRecordCode:e.string(),languageCode:b,currencyCode:e.optional(e.string()),startDate:e.string(),endDate:e.string(),earlyBookingDate:e.optional(e.string()),passengerList:e.pipe(e.array(ir),e.minLength(1)),avesSearchType:e.optional(Ue),paxQty:e.optional(x),paxQtyCriteria:e.optional(Ge),discartNotAvailables:e.optional(U),discartNotAvailablesMinSales:e.optional(U),discartNotAvailablesDaysInOut:e.optional(U),discardPriceZero:e.optional(U),discardZeroPriceDays:e.optional(U),destination:e.optional(Hn),objectTypeCode:e.optional(e.string()),featureList:e.optional(e.array(Zr)),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(G),mergeBoardAndAccomodation:e.optional(U),packageParams:e.optional(Qr),topServiceParams:e.optional($r),getDocumentation:e.optional(U)}),ti=e.required(ei,[`languageCode`,`avesSearchType`]);function ni(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:ft({customerRecordCode:t,languageCode:n,currencyCode:r,startDate:i,endDate:a,earlyBookingDate:o,passengerList:s},cn),...ft({...ee,avesSearchType:u,paxQty:c??s.length,paxQtyCriteria:l??We.GREATER_OR_EQUAL},ln)}}const ri=e.pipe(ti,e.transform(ni)),ii=O(`PackageList`,Xr),ai=O(`ServiceList`,Jr),oi=e.object({serviceCode:e.string(),packageRow:e.string()}),si=T(e.object({customerRecordCode:e.string(),languageCode:b,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(G),selectedServiceList:e.pipe(e.array(oi),e.minLength(1)),passengerList:e.optional(e.array(ir))}),sn),ci=ht(e.object({RsStatus:w,PackageDetail:e.optional(Yr)}),`packageDetail`),li=T(e.object({packageCode:e.string()}),dn),ui=Ze;var di=class{transport;constructor(e){this.transport=e}#e(e,t){return{...this.transport.languageCode&&{languageCode:this.transport.languageCode},avesSearchType:t,...e}}searchPackages(e){return this.transport.invokeOp({op:`searchPackages`,params:this.#e(e,y.PACKAGE),apiSchema:ri,endpoint:Y.searchAvesPackages,requestRoot:J.AVES_SEARCH_REQUEST,responseRoot:J.SEARCH_PACKAGE_RESPONSE,responseSchema:ii})}searchTopServices(e){return this.transport.invokeOp({op:`searchTopServices`,params:this.#e(e,y.SERVICE),apiSchema:ri,endpoint:Y.searchTopServices,requestRoot:J.AVES_SEARCH_REQUEST,responseRoot:J.SEARCH_SERVICES_RESPONSE,responseSchema:ai})}getPackageDetail(e){return this.transport.invokeOp({op:`getPackageDetail`,params:e,apiSchema:si,endpoint:Y.getPackageDetail,requestRoot:J.PACKAGE_DETAIL_REQUEST,responseRoot:J.PACKAGE_DETAIL_RESPONSE,responseSchema:ci})}commitPackage(e){return this.transport.invokeOp({op:`commitPackage`,params:e,apiSchema:li,endpoint:Y.commitPackage,requestRoot:J.COMMIT_PACKAGE_REQUEST,responseRoot:J.COMMIT_PACKAGE_RESPONSE,responseSchema:ui})}};const fi={VALIDATION:`validation`,API:`api`,UNKNOWN:`unknown`};var Q=class extends Error{kind;status;code;constructor(e,t,n,r){super(t),this.kind=e,this.status=n,this.code=r,this.name=`AvesError`}};function $(e){return new Q(fi.VALIDATION,e)}function pi(e,t,n){return new Q(fi.API,e,t,n)}function mi(e){return new Q(fi.UNKNOWN,e)}function hi(e){return e.map(gi).join(`; `)}function gi(e){let t=_i(e.path),n=e.message??`Invalid value`;return t?`${t}: ${n}`:n}function _i(e){if(!e||e.length===0)return;let t=e.map(vi).filter(e=>e!==void 0);return t.length>0?t.join(`.`):void 0}function vi(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`key`in e)return String(e.key)}function yi(e){return e instanceof Error&&e.name===`AbortError`}function bi(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 xi(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 $(`Invalid baseURL: ${e instanceof Error?e.message:`Invalid URL format`}`)}}function Si(e,t){if(!t.startsWith(`/`))throw $(`Invalid endpoint: endpoint must start with '/' but got '${t}'`);let n=xi(e.replace(/\/$/,``),t);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw $(`Invalid protocol: baseURL must use http:// or https:// but got '${n.protocol}'`);return n.toString()}const Ci={ignoreAttributes:!1,attributeNamePrefix:`@`,parseAttributeValue:!1,trimValues:!0,ignoreNameSpace:!0,removeNSPrefix:!0,parseTagValue:!1},wi={ignoreAttributes:!1,attributeNamePrefix:`@`,suppressEmptyNode:!0},Ti=new o(Ci),Ei=new a(wi);function Di(e){try{return Ei.build(e)}catch(e){throw $(`Failed to convert JSON to XML: ${e instanceof Error?e.message:`Unknown error`}`)}}function Oi(e){try{return Ti.parse(e)}catch(e){throw $(`Failed to convert XML to JSON: ${e instanceof Error?e.message:`Unknown error`}`)}}var ki=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?$(`Validation error: ${hi(e.issues)}`):e instanceof Error?mi(e.message):mi(n)}handleApiStatus(e){let{rsStatus:t}=e;return t.status===`OK`?Ur(e):Z(pi(t.errorDescription??``,t.status,t.errorCode))}async request(e,t,n,a){let{signal:o,clear:s}=bi(this.options.timeoutMs??3e4);try{let s=await i(Si(this.options.baseURL,e),{method:`POST`,headers:{"Content-Type":`application/xml`},body:Di(t),signal:o}),c=await s.body.text();if(s.statusCode<200||s.statusCode>299)return Z(pi(c.slice(0,4096),`ERROR`,s.statusCode));let l=Oi(c)[n];if(!l)return Z($(`Invalid response structure: missing root element '${n}'`));let u=r(a,l);return u.success?this.handleApiStatus(u.output):Z($(`Invalid response format: ${hi(u.issues)}`))}catch(e){return yi(e)?Z(pi(`Request timed out`,`TIMEOUT`)):Z(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,Or(e.requestRoot,{RqHeader:this.createRqHeader(),...r}),e.responseRoot,e.responseSchema)}catch(t){return Z(this.toAvesError(t,`Validation error occurred during ${e.op}`))}}},Ai=class{transport;master;booking;packages;constructor(e,t={}){this.transport=t.transport??new ki(e),this.master=t.master??new Wr(this.transport),this.booking=t.booking??new kr(this.transport),this.packages=t.packages??new di(this.transport)}};export{Ai as AvesClient,Q as AvesError,y as AvesSearchType,Ue as AvesSearchTypeSchema,he as AvesServiceType,h as AvesServiceTypeSchema,ki as AvesTransport,_e as BookedServiceStatus,ve as BookedServiceStatusSchema,kr as BookingClient,de as BookingFileStatus,fe as BookingFileStatusSchema,p as BookingFileStatusWire,m as BookingFileStatusWireSchema,Te as CancelOperationType,Ee as CancelOperationTypeSchema,le as CarrierType,ue as CarrierTypeSchema,Le as CostPriceType,_ as CostPriceTypeSchema,xe as CustomerPaymentType,Se as CustomerPaymentTypeSchema,Ke as DestinationType,qe as DestinationTypeSchema,Ne as DocumentType,Pe as DocumentTypeSchema,je as FilePaymentOperationType,Me as FilePaymentOperationTypeSchema,c as Gender,l as GenderSchema,Re as GroupingPaxPolicy,ze as GroupingPaxPolicySchema,ae as InsertCriteria,oe as InsertCriteriaSchema,Fe as MakeDocumentTo,Ie as MakeDocumentToSchema,se as MasterPaymentType,ce as MasterPaymentTypeSchema,Wr as MasterRecordsClient,ke as OptionedExpirePolicy,Ae as OptionedExpirePolicySchema,di as PackageCatalogClient,Ce as PassengerCategory,we as PassengerCategorySchema,We as PaxQtyCriteria,Ge as PaxQtyCriteriaSchema,ye as PaymentType,be as PaymentTypeSchema,f as RecordStatus,ie as RecordStatusSchema,ne as RecordType,re as RecordTypeSchema,u as RsStatusValue,ee as RsStatusValueSchema,v as SearchBookingFileType,He as SearchBookingFileTypeSchema,d as SearchMasterType,te as SearchMasterTypeSchema,De as ServiceRefType,Oe as ServiceRefTypeSchema,pe as SetFileStatusValue,me as SetFileStatusValueSchema,ge as ToServiceType,g as ToServiceTypeSchema,Be as TypeDownloadFile,Ve as TypeDownloadFileSchema};
1
+ import*as e from"valibot";import{ValiError as t,parse as n,safeParse as r}from"valibot";import i from"fast-xml-builder";import{XMLParser as a}from"fast-xml-parser";import{request as o}from"undici";const s={rph:`RPH`,toServiceType:`TOServiceType`,text:`#text`},ee=Object.fromEntries(Object.entries(s).map(([e,t])=>[t,e]));function c(e){return typeof e!=`object`||!e?!1:e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error||e instanceof URL||ArrayBuffer.isView(e)||typeof Buffer<`u`&&Buffer.isBuffer(e)}function te(e){return s[e]??e.charAt(0).toUpperCase()+e.slice(1)}function ne(e){return ee[e]??e.charAt(0).toLowerCase()+e.slice(1)}function re(e,t){let n=t?.textContent===e?`#text`:t?.rename?.[e]??te(e);return n===`#text`||!t?.attrs?.includes(e)?n:t.preserveCamel?.includes(e)?`@${e}`:`@${n}`}const ie=new WeakMap,ae=new WeakMap;function oe(e){let t=ie.get(e);if(t)return t;let{listWrap:n,detailKey:r,...i}=e;return ie.set(e,i),i}function se(e,t){if(!t?.listWrap)return t;let n=ae.get(t);n||(n=new Map,ae.set(t,n));let r=n.get(e);if(r)return r;let i={children:{[t.detailKey??(e.endsWith(`List`)?`${e.slice(0,-4)}Detail`:`${e}Detail`)]:oe(t)}};return n.set(e,i),i}function ce(e){return le(e)}function le(e){if(typeof e!=`object`||!e||c(e))return e;if(Array.isArray(e)){for(let t=0;t<e.length;t++)e[t]=le(e[t]);return e}let t=e;for(let e of Object.keys(t)){let n=le(t[e]),r=ne(e.startsWith(`@`)?e.slice(1):e);r!==e&&delete t[e],t[r]=n}return t}const ue={rsStatus:`response`,customerRecordCode:`customerCode`,bookingFileCode:`bookingCode`,bookingFileRefCode:`bookingReference`,bookingFileStatus:`status`,bookingFileDescription:`description`,bookingFileStartDate:`startDate`,bookingFileReferenceName:`referenceName`,bookingFileServiceStatus:`serviceStatus`,bookingFileServiceStatusDate:`serviceStatusDate`,bookingServiceRef:`serviceReference`,newCustomerRecordCode:`newCustomerCode`,customerDetail:`customer`,bookingFileDocument:`documents`,bookingFinancialInfo:`financial`,financialDetail:`financial`,idDocumentDetail:`identityDocument`,idDocInfo:`identityDocument`,accountPolicies:`policies`,dynamicFields:`customFields`,supplierRefMasterRecords:`supplierReference`,selectedPackageDetail:`package`,selectedPackageList:`packages`,selectedServiceList:`services`,extraQuoteServiceList:`extraServices`,passengerList:`passengers`,noteList:`notes`,deadlineList:`deadlines`,financialDeadlineList:`financialDeadlines`,paymentList:`payments`,filePaymentList:`payments`,cancellableBookedServiceList:`cancellableServices`,bookedServiceList:`services`,serviceList:`services`,subServiceList:`subServices`,featureList:`features`,packageList:`packages`,pCode:`packageCode`,sCode:`serviceCode`,ssCode:`subServiceCode`,rph:`passengerRef`,roomRph:`roomRef`,avesSession:`session`,paxAssociated:`passengerRefs`,paxQty:`passengerCount`,paxQtyCriteria:`passengerCountRule`,qty:`quantity`,pax:`passengerCount`,eMail:`email`,sex:`gender`,nType:`noteType`,avesServiceType:`serviceType`,toServiceType:`targetType`,packageParams:`packageOptions`,topServiceParams:`serviceOptions`,servOrPackCode:`serviceOrPackageCode`,servOrPackDesc:`serviceOrPackageDescription`,getDocumentation:`includeDocumentation`,getServicesFromPackage:`includeServices`,mergeBoardAndAccomodation:`mergeBoardAndAccommodation`,discartNotAvailables:`discardUnavailable`,discartNotAvailablesMinSales:`discardUnavailableMinSales`,discartNotAvailablesDaysInOut:`discardUnavailableDaysInOut`,getAllDeptDate:`allDepartureDates`,getAllAccomodation:`allAccommodation`,compatibleAccomodation:`compatibleAccommodation`,alternativeAccomodation:`alternativeAccommodation`,fileStatus:`status`},de=new Set([`__proto__`,`prototype`,`constructor`]),l={};for(let[e,t]of Object.entries(ue))l[t]||(l[t]=[]),l[t].push(e);const fe=new WeakMap;function u(e){return typeof e==`string`&&de.has(e)}function d(e,t){if(typeof t!=`string`||Reflect.has(e,t))return t;let n=l[t];if(!n)return t;for(let t of n)if(Reflect.has(e,t))return t;return n[0]??t}function f(e){return typeof e!=`object`||!e||c(e)?e:fe.get(e)||(Array.isArray(e)?pe(e):me(e))}function pe(e){let t=new Proxy(e,{get(e,t,n){if(t===`length`)return e.length;if(typeof t==`string`&&/^\d+$/.test(t)){let n=Number(t);if(n<0||n>=e.length)return;let r=e[n];return typeof r==`function`?r.bind(e):f(r)}let r=Reflect.get(e,t,n);return typeof r==`function`?r.bind(e):r},set(e,t,n,r){return!u(t)&&Reflect.set(e,t,n,r)},defineProperty(e,t,n){return!u(t)&&Reflect.defineProperty(e,t,n)},deleteProperty(e,t){return!u(t)&&Reflect.deleteProperty(e,t)},setPrototypeOf(){return!1}});return fe.set(e,t),t}function me(e){let t=new Proxy(e,{get(e,t,n){let r=d(e,t);return f(Reflect.get(e,r,n))},set(e,t,n,r){return!u(t)&&Reflect.set(e,d(e,t),n,r)},has(e,t){return typeof t==`string`&&!Reflect.has(e,t)&&l[t]?.some(t=>Reflect.has(e,t))?!0:Reflect.has(e,d(e,t))},ownKeys(e){let t=Reflect.ownKeys(e),n=new Set(t),r=[];for(let e of t){if(typeof e!=`string`)continue;let t=ue[e];t&&!n.has(t)&&(n.add(t),r.push(t))}return[...t,...r]},getOwnPropertyDescriptor(e,t){let n=d(e,t),r=Reflect.getOwnPropertyDescriptor(e,n);if(r)return n===t?`value`in r?{...r,value:f(r.value)}:r:{configurable:!0,enumerable:!0,writable:!0,value:f(`value`in r?r.value:Reflect.get(e,n))}},defineProperty(e,t,n){return!u(t)&&Reflect.defineProperty(e,d(e,t),n)},deleteProperty(e,t){return!u(t)&&Reflect.deleteProperty(e,d(e,t))},getPrototypeOf(e){return Reflect.getPrototypeOf(e)},setPrototypeOf(){return!1}});return fe.set(e,t),t}function he(e){return f(e)}function p(e){return e.success?{success:!0,data:he(e.data)}:e}const m={customerCode:`customerRecordCode`,bookingCode:`bookingFileCode`,bookingReference:`bookingFileRefCode`},ge={noteType:`nType`},_e={passengerRef:`rph`,roomRef:`roomRph`,gender:`sex`,email:`eMail`,identityDocument:`idDocInfo`},ve={serviceCode:`sCode`,subServiceCode:`ssCode`,quantity:`qty`,passengerCount:`pax`,session:`avesSession`,passengerRefs:`paxAssociated`,serviceType:`avesServiceType`,targetType:`toServiceType`,notes:`noteList`},ye={packageCode:`pCode`,includeServices:`getServicesFromPackage`},be={...m,customer:`customerDetail`,status:`bookingFileStatus`,description:`bookingFileDescription`,referenceName:`bookingFileReferenceName`,financial:`bookingFinancialInfo`,package:`selectedPackageDetail`,packages:`selectedPackageList`,services:`selectedServiceList`,extraServices:`extraQuoteServiceList`,passengers:`passengerList`,payments:`paymentList`,documents:`bookingFileDocument`,deadlines:`deadlineList`,financialDeadlines:`financialDeadlineList`,notes:`noteList`},xe={...m,package:`selectedPackageDetail`,packages:`selectedPackageList`,services:`selectedServiceList`,passengers:`passengerList`,deadlines:`deadlineList`,cancellableServices:`cancellableBookedServiceList`},Se={...m,startDate:`bookingFileStartDate`,newCustomerCode:`newCustomerRecordCode`,referenceName:`bookingFileReferenceName`,passengers:`passengerList`,financial:`bookingFinancialInfo`,financialDeadlines:`financialDeadlineList`},Ce={...m,status:`fileStatus`,documents:`bookingFileDocument`},we={...m,serviceReference:`bookingServiceRef`,serviceStatus:`bookingFileServiceStatus`,serviceStatusDate:`bookingFileServiceStatusDate`},Te={...m,payments:`filePaymentList`},Ee={...m,status:`fileStatus`},De={financial:`financialDetail`,identityDocument:`idDocumentDetail`,policies:`accountPolicies`,customFields:`dynamicFields`,supplierReference:`supplierRefMasterRecords`},Oe={...m,searchType:`avesSearchType`,passengers:`passengerList`,packageOptions:`packageParams`,serviceOptions:`topServiceParams`,serviceOrPackageCode:`servOrPackCode`,serviceOrPackageDescription:`servOrPackDesc`,passengerCount:`paxQty`,passengerCountRule:`paxQtyCriteria`,features:`featureList`,includeDocumentation:`getDocumentation`,mergeBoardAndAccommodation:`mergeBoardAndAccomodation`,discardUnavailable:`discartNotAvailables`,discardUnavailableMinSales:`discartNotAvailablesMinSales`,discardUnavailableDaysInOut:`discartNotAvailablesDaysInOut`},ke={allDepartureDates:`getAllDeptDate`,allAccommodation:`getAllAccomodation`,compatibleAccommodation:`compatibleAccomodation`,alternativeAccommodation:`alternativeAccomodation`},Ae={...m,services:`selectedServiceList`,passengers:`passengerList`};function h(t){return e.picklist(Object.values(t))}const je={M:`M`,F:`F`},Me=h(je),Ne={OK:`OK`,ERROR:`ERROR`,WARNING:`WARNING`,TIMEOUT:`TIMEOUT`},Pe=h(Ne),Fe={MasterRecordDetail:`MasterRecordDetail`},Ie=h(Fe),g={CODE:`CODE`,NAME:`NAME`,VATCODE:`VATCODE`,ZONE:`ZONE`,CATEGORY:`CATEGORY`,EMAIL:`EMAIL`,LASTMODDATE:`LASTMODDATE`,SEARCH_FIELD:`SEARCH_FIELD`,EXTERNAL_REF_CODE:`EXTERNAL_REF_CODE`},Le=h(g),Re={CUSTOMER:`CUSTOMER`,SUPPLIER:`SUPPLIER`,VOUCHER:`VOUCHER`,SUPPLIER_VOUCHER:`SUPPLIER_VOUCHER`,GENERAL:`GENERAL`},ze=h(Re),Be={ENABLED:`ENABLED`,DISABLED:`DISABLED`,WARNING:`WARNING`,BLACKLISTED:`BLACKLISTED`},Ve=h(Be),He={S:`S`,N:`N`,T:`T`,M:`M`},Ue=h(He),We={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`},Ge=h(We),Ke={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`},qe=h(Ke),Je={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRMED:`CONFIRMED`,OPTIONED:`OPTIONED`,CANCELED:`CANCELED`},Ye=h(Je),Xe={...Je,NULLIFIED:`NULLIFIED`},Ze=h(Xe),_={QUOTATION:`QUOTATION`,WORK_IN_PROGRESS:`WORK_IN_PROGRESS`,CONFIRM:`CONFIRM`,CONFIRMED:`CONFIRMED`,OPTION:`OPTION`,OPTIONED:`OPTIONED`,REQUEST:`REQUEST`,REQUESTED:`REQUESTED`,NULLIFIED:`NULLIFIED`,CANCELED:`CANCELED`},Qe=h(_),$e={TOP:`TOP`,TOP_SS:`TOP_SS`,ADV:`ADV`,GRP:`GRP`,OTHER:`OTHER`},et=h($e),tt={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`,TOUR:`TOUR`},nt=h(tt),rt={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`},it=h(rt),at={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`},ot=h(at),st={CASH:`CASH`,BANK:`BANK`,RID:`RID`,RIBA:`RIBA`,SPECIFIC_CODE:`SPECIFIC_CODE`,NOT_SET:`NOT_SET`},ct=h(st),lt={AD:`AD`,CH:`CH`,IN:`IN`,OV:`OV`},ut=h(lt),dt={NULLIFY:`NULLIFY`,DELETE:`DELETE`},ft=h(dt),pt={RPH:`RPH`,FILE:`FILE`},mt=h(pt),ht={NOT_SET:`NOT_SET`,CONSIDER_HOLIDAY:`CONSIDER_HOLIDAY`,CONSIDER_HOLIDAY_AND_SATURDAY:`CONSIDER_HOLIDAY_AND_SATURDAY`},gt=h(ht),_t={AbsoluteAmountsInsertion:`AbsoluteAmountsInsertion`,FinalAmountToAchieve:`FinalAmountToAchieve`,FinalAmountToAchieveWithoutControls:`FinalAmountToAchieveWithoutControls`},vt=h(_t),yt={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`},bt=h(yt),xt={BOOKING_CUSTOMER:`BOOKING_CUSTOMER`,FIRST_PASSENGER:`FIRST_PASSENGER`},St=h(xt),Ct={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`},wt=h(Ct),Tt={GROUPED_PAX:`GROUPED_PAX`,NOT_GROUPED_PAX:`NOT_GROUPED_PAX`,ONE_PAX_ONLY:`ONE_PAX_ONLY`},Et=h(Tt),Dt={AVES2AVES:`AVES2AVES`,AVES2AVESVIA:`AVES2AVESVIA`,AVES2AVESITA:`AVES2AVESITA`},Ot=h(Dt),v={FILE_CODE:`FILE_CODE`,PAX_NAME:`PAX_NAME`,PACKAGE_CODE:`PACKAGE_CODE`,OTHER:`OTHER`},kt=h(v),y={SERVICE:`SERVICE`,PROGRAM:`PROGRAM`,PACKAGE:`PACKAGE`},At=h(y),jt={GREATER_THAN:`GREATER_THAN`,GREATER_OR_EQUAL:`GREATER_OR_EQUAL`,EQUAL_TO:`EQUAL_TO`,LESS_OR_EQUAL:`LESS_OR_EQUAL`,LESS_THAN:`LESS_THAN`},Mt=h(jt),Nt={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`},Pt=h(Nt),Ft=e.pipe(e.string(),e.minLength(2),e.maxLength(2)),b=e.optional(Ft),x=e.union([e.string(),e.number()]),S=e.union([e.string(),e.number(),e.boolean()]),C=e.object({minDate:e.string(),maxDate:e.string()}),It=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":b}),Lt=e.optional(e.string()),w=e.pipe(e.object({"@Status":Pe,ErrorCode:e.optional(e.pipe(x,e.transform(e=>Number(e)))),ErrorDescription:e.optional(e.string()),Warnings:Lt}),e.transform(e=>({status:e[`@Status`],errorCode:e.ErrorCode,errorDescription:e.ErrorDescription,warnings:e.Warnings}))),Rt=O(e.object({RsStatus:w})),zt={financialDeadlineList:`deadlineDetail`};function Bt(e,t){return t?.detailKey??zt[e]??(e.endsWith(`List`)?`${e.slice(0,-4)}Detail`:`${e}Detail`)}function Vt(e){return Array.isArray(e)?e.length?e.every(e=>typeof e==`string`)?e.map(e=>({pax:e})):e:``:e}function T(e,t){if(typeof e!=`object`||!e||c(e))return e;if(Array.isArray(e))return e.map(e=>T(e,t));let n={};for(let[r,i]of Object.entries(e)){let e=t?.children?.[r],a=r===`paxAssociated`?Vt(i):i;if(e?.listWrap&&Array.isArray(a)){let i=re(Bt(r,e)),o=a.map(t=>T(t,oe(e)));n[re(r,t)]=e.listWrap===`one`?o.map(e=>({[i]:e})):{[i]:o};continue}n[re(r,t)]=T(a,se(r,e))}return n}function Ht(e,t){return T(e,t)}function E(t,n){return e.pipe(t,e.transform(e=>Ht(e,n)))}function Ut(t){return e.pipe(e.union([e.array(t),t]),e.transform(e=>Array.isArray(e)?e:[e]))}function D(t,n){let r=e.optional(Ut(n));return e.pipe(e.object({[t]:r}),e.transform(e=>e[t]??[]))}function O(t){return e.pipe(t,e.transform(e=>ce(e)))}function k(t,n){let r={[t]:e.optional(n)};return O(e.object({RsStatus:w,...r}))}function Wt(e){return t=>{if(typeof t!=`object`||!t)return t;let n=t,r=n[e],{[e]:i,...a}=n;return!r||typeof r!=`object`||Array.isArray(r)?a:{...a,...r}}}function Gt(t,n){return e.pipe(O(t),e.transform(e=>Wt(n)(e)))}function Kt(t,n){let r=e.object({value:t,...n??{}});return e.pipe(e.union([t,r]),e.transform(e=>typeof e==`object`&&e?e:{value:e}))}function qt(e,t){return n=>{let r=Reflect.get(n,e),i=Reflect.get(n,t),a={...n};return Reflect.deleteProperty(a,e),Reflect.set(a,t,i??(Array.isArray(r)?r[0]:void 0)),a}}function Jt(e){let{customerRecordCode:t,customerDetail:n,...r}=e;return{...r,customerDetail:{...n,recordCode:n?.recordCode??t}}}function Yt(e){return t=>{let n={...t};for(let[t,r]of Object.entries(e)){let e=n[t];delete n[t],n[r]===void 0&&e!==void 0&&(n[r]=e)}return n}}function A(t,n){let r={...t},i={};for(let[a,o]of Object.entries(n)){let n=t[o];n!==void 0&&(i[a]=o,r[a]=Zt(n)?n:e.optional(n),Zt(n)||(r[o]=e.optional(n)))}return e.pipe(e.object(r),e.transform(Yt(i)),e.object(t))}function Xt(e){return e.type===`object`&&`entries`in e}function Zt(e){return e.type===`optional`&&`wrapped`in e}function Qt(e){return e.type===`array`&&`item`in e}function $t(t,n){if(Zt(t)){let r=$t(t.wrapped,n);return t.default===void 0?e.optional(r):e.optional(r,t.default)}return Qt(t)?Ut($t(t.item,n)):Xt(t)?en(t,n):t}function en(t,n,r){let i={};for(let e in t.entries){let r=n.children?.[e]??{};i[re(e,n)]=$t(t.entries[e],r)}return e.object({...i,...r})}function tn(e,t={},n){return en(e,t,n)}function j(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t;for(let e of r)if(n[e]!==void 0&&n[e]!==null){t=n[e];break}for(let t of r)t!==e&&delete n[t];t===void 0?delete n[e]:n[e]=t}return n}function M(e,t){return{api:E(e,t),validation:tn(e,t)}}function N(e){return e}function P(...e){return N({attrs:e})}function nn(...e){return N({attrs:e,preserveCamel:e})}function rn(e,t){return N({attrs:e,preserveCamel:t})}function F(e){return N({children:e})}function I(e,t){return N({attrs:e,children:t})}function L(e,t,n){return N(n?{...e,listWrap:t,detailKey:n}:{...e,listWrap:t})}function R(e,...t){return L(P(...t),e)}function an(e){return{one:L(e,`one`),many:L(e,`many`)}}P(`hostID`,`xtoken`,`interface`,`userName`,`status`,`languageCode`);const on=P(`currencyCode`,`creditLimit`,`c_PaymentType`,`c_SpecPaymentTypeCode`,`s_PaymentType`,`s_SpecPaymentTypeCode`,`enableElectronicInvoicing`,`electronicInvoicingType`),sn=P(`idType`,`idCode`,`idIssueLocation`,`idIssueCounty`,`idIssueDate`,`idExpireDate`),cn=P(`acceptProfilingPolicies`,`acceptPrivacyPolicies`,`acceptNewsletterPolicies`),ln=P(`key`,`value`),un=P(`supplierRefCode`,`companyMainBusinessType`,`carrierType`),dn=I([`recordCode`,`insertCriteria`],{financialDetail:on,idDocumentDetail:sn,accountPolicies:cn,dynamicFields:ln,supplierRefMasterRecords:un}),z=P(`minDate`,`maxDate`),fn=F({lastModificationDate:z}),pn=nn(`sCode1`,`sCode2`,`sCode3`,`sCode4`,`sCode5`,`sCode6`),mn=P(`code`,`iataCode`,`nationCode`,`type`),hn=P(`nType`,`title`),gn=L(hn,`many`),_n=I([`rph`,`roomRph`,`billingHolder`],{notes:L(hn,`many`,`noteDetail`),idDocInfo:sn}),vn=P(`currencyCode`,`exchangeRate`,`cost`,`costTax`,`costType`,`vatCostCurrencyCode`,`price`,`priceTax`,`priceType`),yn=rn([`pCode`,`startDate`,`endDate`,`getServicesFromPackage`],[`pCode`]),B=an(N({...rn([`sCode`,`ssCode`],[`sCode`,`ssCode`]),children:{serviceFare:vn,avesServiceInfo:F({serviceFare:vn}),noteList:gn}})),V=an(_n);V.one,V.many;const bn=L(yn,`many`),xn=R(`many`,`deadlineCode`,`description`,`expireDate`),Sn=R(`many`,`reschedulingCode`,`description`,`expireDate`),Cn=L(P(`reschedulingCode`,`expireDate`,`totalAmount`),`many`,`deadlineDetail`),wn=L(N({...P(`paymentDate`,`paymentNote`,`amount`,`paymentUser`,`paymentType`),rename:{paymentNote:`PaumentNote`}}),`many`),Tn=R(`many`,`paymentDate`,`paymentNote`,`payerMasterCode`,`payerName`,`amount`,`paymentType`),En=R(`many`,`cancelOperationType`,`serviceRefType`,`serviceRefValue`),Dn=I([`printDoc`,`sendDocViaEmail`],{infoDocumentsToPrint:F({documentCustomizablePrintParameters:P(`makeDocumentTo`,`fillInCode`)})}),On=P(`value`,`expiredDate`),kn=P(`recordCode`),An=P(`customer_PaymentType`,`customer_SpecPaymentTypeCode`),jn=P(`getAllDeptDate`,`getFlightPlan`,`getAllAccomodation`,`getRealAvailability`),Mn=P(`compatibleAccomodation`,`alternativeAccomodation`),Nn=R(`many`,`code`,`name`),Pn=P(`value`,`expiredDate`,`optionedFileExpireDatePolicy`),Fn=P(`apply`,`specificCode`),In={customerDetail:kn,bookingFileStatus:On,statisticCodes:pn,destination:mn,bookingFileDocument:Dn,bookingFinancialInfo:An,selectedPackageDetail:yn,selectedPackageList:bn,financialDeadlineList:Cn,paymentList:wn,cancellableBookedServiceList:En,noteList:gn},Ln=F({...In,deadlineList:xn,selectedServiceList:B.one,extraQuoteServiceList:B.one,passengerList:V.one}),Rn=F({...In,deadlineList:Sn,selectedServiceList:B.many,extraQuoteServiceList:B.many,passengerList:V.many}),zn=I([`paymentUser`],{filePaymentList:Tn}),Bn=F({fileStatus:P(`value`,`expireDate`),startDate:z,createdDate:z,lastModificationDate:z,insurance:P(`code`,`number`)}),Vn=F({statisticCodes:pn,selectedServiceList:L(P(`serviceCode`,`packageRow`),`many`),passengerList:V.many}),Hn=F({passengerList:V.many}),Un=F({destination:mn,statisticCodes:pn,packageParams:jn,topServiceParams:Mn,featureList:Nn}),Wn=F({fileStatus:Pn,penalty:Fn,bookingFileDocument:Dn}),Gn=N({}),H=e.union([e.literal(`true`),e.literal(`false`),e.boolean()]),Kn={[_.CONFIRM]:`CONFIRMED`,[_.OPTION]:`OPTIONED`,[_.REQUESTED]:`REQUEST`};function qn(e){return e in Kn?Kn[e]:e}const Jn=e.pipe(e.object({"@Value":Qe,"@ExpiredDate":e.optional(e.string()),"@ExpireDate":e.optional(e.string())}),e.transform(e=>({...j(e,{"@ExpiredDate":[`@ExpiredDate`,`@ExpireDate`]}),"@Value":qn(e[`@Value`])}))),Yn=D(`PricePerPaxDetail`,e.object({"@PaxRef":e.string(),"@Price":x})),Xn=e.object({"@CommissionCode":e.optional(e.string()),"@CommissionPercentage":e.optional(x),"@CommissionAmount":e.optional(x),"@PriceListCode":e.optional(e.string()),"@CostListCode":e.optional(e.string()),"@ServiceTotalPrice":e.optional(x),PaxPriceList:e.optional(Yn)}),Zn=e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),"@Email":e.optional(e.string()),"@LanguageCode":e.optional(e.string())}),Qn=e.object({"@Code":e.optional(e.string()),"@Description":e.optional(e.string())}),$n=e.object({"@RPH":e.string(),"@ServiceCode":e.optional(e.string()),"@FromExternalProvider":e.optional(x),"@isFromExternalProvider":e.optional(x),AvesServiceType:e.optional(et),TOServiceType:e.optional(nt),FirstDescription:e.optional(e.string()),SecondDescription:e.optional(e.string()),ThirdDescription:e.optional(e.string()),FourthDescription:e.optional(e.string()),ServiceStatus:e.optional(it),StartDate:e.optional(e.string()),EndDate:e.optional(e.string()),Qty:e.optional(x),Pax:e.optional(x),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(Qn),SupplierInfo:e.optional(Zn),ServiceTotalAmountDetail:e.optional(Xn)}),er=D(`BookedServiceDetail`,e.pipe($n,e.transform(e=>j(e,{"@FromExternalProvider":[`@FromExternalProvider`,`@isFromExternalProvider`]})))),tr=e.object({"@CurrencyCode":e.optional(e.string()),"@TotalAmountBeforeDiscount":e.optional(x),"@TotalAmountAfterDiscount":e.optional(x),"@TotalDiscount":e.optional(x),"@TotalAmountWithoutVat":e.optional(x),"@DueAmount":e.optional(x),"@PaiedAmount":e.optional(x),"@Balance":e.optional(x)}),nr=D(`PassengerDetail`,e.object({"@RPH":e.string(),"@RoomRPH":e.optional(e.string()),"@BillingHolder":e.optional(x),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())})),rr=e.object({"@ReschedulingCode":e.optional(e.string()),"@ExpireDate":e.optional(e.string()),"@TotalAmount":e.optional(x),ReschedulingCode:e.optional(e.string()),ExpireDate:e.optional(e.string()),TotalAmount:e.optional(x)}),ir=D(`DeadlineDetail`,e.pipe(rr,e.transform(e=>j(e,{"@ReschedulingCode":[`@ReschedulingCode`,`ReschedulingCode`],"@ExpireDate":[`@ExpireDate`,`ExpireDate`],"@TotalAmount":[`@TotalAmount`,`TotalAmount`]})))),ar=D(`StoredDocumentDetail`,e.object({DocumentRefCode:e.optional(e.string()),DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),ArchiviationDescription:e.optional(e.string())})),or=D(`PrintableDocumentDetail`,e.object({DocumentType:e.optional(e.string()),DocumentName:e.optional(e.string()),Enabled:e.optional(x)})),sr=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(Jn),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(er),TotalAmountDetail:e.optional(tr),PaxNumber:e.optional(x),PassengerList:e.optional(nr),Reference:e.optional(e.string()),ClerkName:e.optional(e.string()),StoredDocumentsList:e.optional(ar),PrintableDocumentsList:e.optional(or),FinancialDeadlineList:e.optional(ir)}),cr=e.pipe(sr,e.transform(e=>j(e,{"@BookingFileCode":[`@BookingFileCode`,`BookingFileCode`]}))),lr=e.object({currencyCode:e.optional(e.string()),creditLimit:e.optional(e.string()),c_PaymentType:e.optional(Ge),c_SpecPaymentTypeCode:e.optional(e.string()),s_PaymentType:e.optional(Ge),s_SpecPaymentTypeCode:e.optional(e.string()),enableElectronicInvoicing:e.optional(H),electronicInvoicingType:e.optional(e.string())}),ur=M(lr,on);ur.api,ur.validation;const dr=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())}),fr=M(dr,sn);fr.api,fr.validation;const pr=e.object({key:e.string(),value:e.string()});tn(pr,ln);const mr=e.object({supplierRefCode:e.optional(e.string()),companyMainBusinessType:e.optional(e.string()),carrierType:e.optional(qe)}),hr=M(mr,un);hr.api,hr.validation;const gr=e.union([e.literal(0),e.literal(1)]),_r=e.object({acceptProfilingPolicies:e.optional(gr),acceptPrivacyPolicies:e.optional(gr),acceptNewsletterPolicies:e.optional(gr)}),vr=M(_r,cn);vr.api,vr.validation;const yr={recordCode:e.optional(e.pipe(e.string(),e.minLength(6),e.maxLength(6))),insertCriteria:e.optional(Ue),createdDate:e.optional(e.string()),recordType:e.optional(ze,Re.CUSTOMER),recordStatus:e.optional(Ve,Be.ENABLED),moniker:e.optional(e.string()),name:e.optional(e.string()),extraInfo:e.optional(e.string()),languageCode:Ft,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(Me),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(dr),accountPolicies:e.optional(_r),financialDetail:e.optional(lr),dynamicFields:e.optional(e.array(pr)),supplierRefMasterRecords:e.optional(mr)},br=E(A(yr,De),dn),U=e.partial(tn(e.object(yr),dn,{ModifiedDate:e.optional(e.string()),LoginType:e.optional(e.string()),PromoterCode:e.optional(e.string()),EncryptedPassword:e.optional(H),NewsletterDisabled:e.optional(H)}));O(U);const xr=Kt(Ye,{expiredDate:e.optional(e.string())}),W=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)))}),Sr=e.object({code:e.optional(e.string()),iataCode:e.optional(e.string()),nationCode:e.optional(e.string()),type:e.optional(Pt)}),Cr=e.object({recordCode:e.optional(e.string())}),wr=e.object({makeDocumentTo:e.optional(St)}),Tr=e.object({fillInCode:e.optional(e.string())}),Er=e.union([wr,Tr]),Dr=e.object({documentType:bt,documentCustomizablePrintParameters:e.optional(Er)}),Or=e.object({printDoc:e.optional(H),sendDocViaEmail:e.optional(H),infoDocumentsToPrint:e.optional(e.array(Dr))}),kr=e.object({reschedulingCode:e.optional(e.string()),expireDate:e.optional(e.string()),totalAmount:e.optional(e.string())}),Ar=e.object({deadlineCode:e.optional(e.string()),description:e.optional(e.string()),expireDate:e.optional(e.string())}),jr=e.object({paymentDate:e.optional(e.string()),paymentNote:e.optional(e.string()),amount:e.optional(e.string()),paymentUser:e.optional(e.string()),paymentType:e.optional(ot)}),Mr=A({nType:e.optional(e.string()),title:e.optional(e.string()),text:e.optional(e.string())},ge),Nr=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(wt),vatCostCurrencyCode:e.optional(e.string()),price:e.optional(e.string()),priceTax:e.optional(e.string()),priceType:e.optional(wt)}),Pr=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(Nr)}),Fr=A({sCode:e.string(),ssCode:e.optional(e.string()),avesServiceType:et,toServiceType:e.optional(nt),subServiceDesc:e.optional(e.string()),startDate:e.string(),endDate:e.string(),qty:e.string(),pax:e.string(),paxAssociated:e.optional(e.union([e.array(e.string()),e.array(e.object({pax:e.string()}))])),avesSession:e.string(),avesServiceInfo:e.optional(Pr),serviceFare:e.optional(Nr),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.array(Mr)),voucherInfo:e.optional(e.string()),firstDescription:e.optional(e.string()),secondDescription:e.optional(e.string())},ve),Ir=A({pCode:e.string(),startDate:e.string(),endDate:e.string(),getServicesFromPackage:e.optional(H)},ye),Lr={rph:e.string(),roomRph:e.optional(e.string()),billingHolder:e.optional(H),masterRecordCode:e.optional(e.string()),name:e.string(),sex:Me,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(Mr)),flagStatus:e.optional(e.string()),offerCode:e.optional(e.string()),idDocInfo:e.optional(dr)},Rr=A({...Lr,categoryCode:ut},_e),zr=A({...Lr,categoryCode:e.optional(ut)},_e),Br=e.object({customer_PaymentType:e.optional(ct),customer_SpecPaymentTypeCode:e.optional(e.string())}),Vr=E(e.pipe(A({createDate:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),travelAgentCode:e.optional(e.string()),clerkName:e.optional(e.string()),customerDetail:e.optional(Cr),customerRecordCode:e.optional(e.string()),currencyCode:e.optional(e.string()),markupCode:e.optional(e.string()),bookingFileStatus:xr,statisticCodes:e.optional(W),destination:e.optional(Sr),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(Or),financialDeadlineList:e.optional(e.array(kr)),deadlineList:e.optional(e.array(Ar)),paymentList:e.optional(e.array(jr)),selectedPackageList:e.optional(e.array(Ir)),selectedServiceList:e.array(Fr),extraQuotaRefCode:e.optional(e.string()),extraQuoteServiceList:e.optional(e.array(Fr)),getExtraQuoteFromSystem:e.optional(H),passengerList:e.array(Rr),noteList:e.optional(e.array(Mr)),bookingFinancialInfo:e.optional(Br),bookingFileCode:e.optional(e.string()),groupingPaxPolicy:e.optional(Et),groupBookingFile:e.optional(H),typeDownloadFile:e.optional(Ot),setBookingFileCodeFromStartDate:e.optional(H)},be),e.check(e=>!!(e.customerDetail||e.customerRecordCode),`customerDetail or customerRecordCode is required`),e.transform(Jt)),Ln),Hr=Gt(e.object({RsStatus:w,BookingFileDetail:e.optional(cr),PrintableDocumentsList:e.optional(or),TotalAmountDetailAfterCancellation:e.optional(tr),Base64DocContent:e.optional(e.string())}),`bookingFileDetail`),Ur=Rt,G={customerRecordCode:e.string(),bookingFileCode:e.string()},Wr=Hr,Gr=e.object({reschedulingCode:e.string(),description:e.optional(e.string()),expireDate:e.optional(e.string())}),Kr=e.object({cancelOperationType:ft,serviceRefType:mt,serviceRefValue:e.string()}),qr=E(e.pipe(A({...G,currencyCode:e.optional(e.string()),deadlineList:e.optional(e.array(Gr)),selectedPackageDetail:e.optional(Ir),selectedPackageList:e.optional(e.pipe(e.array(Ir),e.maxLength(1))),selectedServiceList:e.pipe(e.array(Fr),e.minLength(1)),cancellableBookedServiceList:e.optional(e.array(Kr)),passengerList:e.optional(e.array(zr))},xe),e.transform(qt(`selectedPackageList`,`selectedPackageDetail`))),Rn),Jr=E(A({...G,bookingFileStartDate: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(zr)),statisticCodes:e.optional(W),bookingFinancialInfo:e.optional(Br),financialDeadlineList:e.optional(e.array(e.object({reschedulingCode:e.string(),expireDate:e.string(),totalAmount:e.string()})))},Se),Rn),Yr=E(A(G,m),Gn),Xr=E(A({...G,fileStatus:Kt(Ze,{expiredDate:e.optional(e.string()),optionedFileExpireDatePolicy:e.optional(gt)}),backOfficeRequest:e.optional(H),bookingFileDocument:e.optional(Or),penalty:e.optional(e.object({apply:e.optional(H),specificCode:e.optional(e.string())})),simulateCancelAndGetPenaltyAmount:e.optional(H)},Ce),Wn),Zr=E(A({...G,bookingServiceRef:e.string(),bookingFileServiceStatus:e.literal(`NULLIFIED`),bookingFileServiceStatusDate:e.optional(e.string())},we),Gn),Qr=e.object({paymentDate:e.string(),paymentNote:e.optional(e.string()),payerMasterCode:e.optional(e.string()),payerName:e.optional(e.string()),amount:e.string(),paymentType:ot}),$r=E(e.pipe(A({bookingFileCode:e.optional(e.string()),bookingFileRefCode:e.optional(e.string()),paymentUser:e.optional(e.string()),enableMultiplePayments:H,operationType:vt,filePaymentList:e.pipe(e.array(Qr),e.minLength(1))},Te),e.check(e=>!!(e.bookingFileCode||e.bookingFileRefCode),`bookingFileCode or bookingFileRefCode is required`)),zn),ei=D(`FeatureDetail`,e.object({"@Code":e.optional(e.string()),"@Name":e.optional(e.string()),ValueCode:e.optional(e.string()),ValueName:e.optional(e.string())})),ti=e.object({"@PackageCode":e.optional(e.string()),"@PackageReference":e.optional(e.string()),"@PackageServiceType":e.optional(e.string()),"@ServiceCodeForPackageDetail":e.optional(e.string())}),ni=D(`SubServiceDetail`,e.object({"@ssCode":e.optional(e.string()),FirstDescription:e.optional(e.string()),SubServiceType:e.optional(e.string()),SubServiceLevel:e.optional(S),StartDate:e.optional(e.string()),EndDate:e.optional(e.string())})),ri=D(`ServiceDetail`,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(ti),SubServiceList:e.optional(ni)})),ii=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(S),BasePax:e.optional(S),CanCommitPack:e.optional(S),FeatureList:e.optional(ei),ServiceList:e.optional(ri)}),ai=D(`PackageDetail`,ii),oi=e.object({code:e.string(),name:e.optional(e.string())}),si=A({getAllDeptDate:e.optional(H),getFlightPlan:e.optional(H),getAllAccomodation:e.optional(H),getRealAvailability:e.optional(H),minStay:e.optional(x),maxStay:e.optional(x)},ke),ci=A({compatibleAccomodation:e.optional(H),alternativeAccomodation:e.optional(H)},ke),li=A({customerRecordCode:e.string(),languageCode:b,currencyCode:e.optional(e.string()),startDate:e.string(),endDate:e.string(),earlyBookingDate:e.optional(e.string()),passengerList:e.pipe(e.array(Rr),e.minLength(1)),avesSearchType:e.optional(At),paxQty:e.optional(x),paxQtyCriteria:e.optional(Mt),discartNotAvailables:e.optional(H),discartNotAvailablesMinSales:e.optional(H),discartNotAvailablesDaysInOut:e.optional(H),discardPriceZero:e.optional(H),discardZeroPriceDays:e.optional(H),destination:e.optional(Sr),objectTypeCode:e.optional(e.string()),featureList:e.optional(e.array(oi)),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(W),mergeBoardAndAccomodation:e.optional(H),packageParams:e.optional(si),topServiceParams:e.optional(ci),getDocumentation:e.optional(H)},Oe),ui=e.pipe(li,e.check(e=>e.languageCode!=null&&e.avesSearchType!=null,`languageCode and avesSearchType required`));function di(e){let{customerRecordCode:t,languageCode:n,currencyCode:r,startDate:i,endDate:a,earlyBookingDate:o,passengerList:s,paxQty:ee,paxQtyCriteria:c,avesSearchType:te,...ne}=e;return{BaseSearch:Ht({customerRecordCode:t,languageCode:n,currencyCode:r,startDate:i,endDate:a,earlyBookingDate:o,passengerList:s},Hn),...Ht({...ne,avesSearchType:te,paxQty:ee??s.length,paxQtyCriteria:c??jt.GREATER_OR_EQUAL},Un)}}const fi=e.pipe(ui,e.transform(di)),pi=k(`PackageList`,ai),mi=k(`ServiceList`,ri),hi=e.object({serviceCode:e.string(),packageRow:e.string()}),gi=E(A({customerRecordCode:e.string(),languageCode:b,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(W),selectedServiceList:e.pipe(e.array(hi),e.minLength(1)),passengerList:e.optional(e.array(Rr))},Ae),Vn),_i=Gt(e.object({RsStatus:w,PackageDetail:e.optional(ii)}),`packageDetail`),vi=E(e.object({packageCode:e.string()}),Gn),yi=Rt,bi=C,K=b,xi=e.object({searchType:e.literal(g.CODE),recordCode:e.pipe(e.string(),e.minLength(5),e.maxLength(6)),languageCode:K}),Si=e.object({searchType:e.literal(g.NAME),name:e.string(),city:e.optional(e.string()),languageCode:K}),Ci=e.object({searchType:e.literal(g.VATCODE),vatCode:e.string(),phoneNumber:e.optional(e.string()),languageCode:K}),wi=e.object({searchType:e.literal(g.ZONE),zipCode:e.string(),countyCode:e.string(),city:e.optional(e.string()),languageCode:K}),Ti=e.object({searchType:e.literal(g.CATEGORY),categoryCode:e.string(),languageCode:K}),Ei=e.object({searchType:e.literal(g.EMAIL),email:e.string(),languageCode:K}),Di=e.object({searchType:e.literal(g.LASTMODDATE),lastModificationDate:bi,languageCode:K}),Oi=e.object({searchType:e.literal(g.SEARCH_FIELD),searchFieldValue:e.string(),languageCode:K}),ki=e.object({searchType:e.literal(g.EXTERNAL_REF_CODE),searchFieldValue:e.string(),languageCode:K}),Ai=E(e.union([xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki]),fn);e.pipe(e.object({RqHeader:It,SearchMasterRecord:Ai}),e.transform(e=>{let{SearchMasterRecord:t,RqHeader:n,...r}=e;return{RqHeader:n,...t,...r}}));const ji=k(`MasterRecordList`,D(`MasterRecordDetail`,U)),Mi=Kt(Qe,{expireDate:e.optional(e.string())}),Ni=e.object({code:e.optional(e.string()),number:e.optional(e.string())}),Pi={customerRecordCode:e.string(),customerPromoterCode:e.optional(e.string()),getSupplierInfo:e.optional(H),user:e.optional(e.string()),officeCode:e.optional(e.string())},Fi=A({...Pi,searchType:e.literal(v.FILE_CODE),bookingFileCode:e.string()},Ee),Ii=A({...Pi,searchType:e.literal(v.PAX_NAME),firstPaxName:e.string()},Ee),Li=A({...Pi,searchType:e.literal(v.PACKAGE_CODE),packageCode:e.string()},Ee),Ri=A({...Pi,searchType:e.literal(v.OTHER),fileStatus:e.optional(Mi),startDate:e.optional(C),createdDate:e.optional(C),lastModificationDate:e.optional(C),insurance:e.optional(Ni),isSearchForB2C:e.optional(H)},Ee),zi=E(e.union([Fi,Ii,Li,Ri]),Bn),Bi=k(`BookingFileList`,D(`BookingFileDetail`,cr));e.object({RqHeader:It,MasterRecordDetail:U});const Vi=Gt(e.object({RsStatus:w,MasterRecordDetail:e.optional(U)}),`masterRecordDetail`),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`,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 Hi(e,t){return{[e]:t}}const J={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`};function Y(e){return e}const X={search:`search`,upsert:`upsert`,create:`create`,updateServices:`updateServices`,updateHeader:`updateHeader`,cancel:`cancel`,setStatus:`setStatus`,setServiceStatus:`setServiceStatus`,addPayments:`addPayments`,searchBookings:`searchBookings`,searchPackages:`searchPackages`,searchServices:`searchServices`,get:`get`,commit:`commit`},Ui=h(X),Wi={[X.search]:Y({endpoint:J.search,requestRoot:q.SEARCH_REQUEST,responseRoot:q.SEARCH_RESPONSE,apiSchema:Ai,responseSchema:ji}),[X.upsert]:Y({endpoint:J.upsert,requestRoot:q.UPSERT_REQUEST,responseRoot:q.UPSERT_RESPONSE,apiSchema:br,responseSchema:Vi,bodyKey:Fe.MasterRecordDetail}),[X.create]:Y({endpoint:J.createBooking,requestRoot:q.BOOKING_REQUEST,responseRoot:q.BOOKING_RESPONSE,apiSchema:Vr,responseSchema:Hr}),[X.updateServices]:Y({endpoint:J.modBookingServices,requestRoot:q.MOD_FILE_SERVICES_REQUEST,responseRoot:q.BOOKING_RESPONSE,apiSchema:qr,responseSchema:Wr}),[X.updateHeader]:Y({endpoint:J.modBookingHeader,requestRoot:q.MOD_FILE_HEADER_REQUEST,responseRoot:q.MOD_FILE_HEADER_RESPONSE,apiSchema:Jr,responseSchema:Ur}),[X.cancel]:Y({endpoint:J.cancelBooking,requestRoot:q.CANCEL_FILE_REQUEST,responseRoot:q.CANCEL_FILE_RESPONSE,apiSchema:Yr,responseSchema:Ur}),[X.setStatus]:Y({endpoint:J.setBookingStatus,requestRoot:q.SET_STATUS_REQUEST,responseRoot:q.SET_STATUS_RESPONSE,apiSchema:Xr,responseSchema:Wr}),[X.setServiceStatus]:Y({endpoint:J.setBookingServiceStatus,requestRoot:q.SET_STATUS_SERVICE_REQUEST,responseRoot:q.SET_STATUS_SERVICE_RESPONSE,apiSchema:Zr,responseSchema:Wr}),[X.addPayments]:Y({endpoint:J.insertFilePaymentList,requestRoot:q.FILE_PAYMENT_LIST_REQUEST,responseRoot:q.FILE_PAYMENT_LIST_RESPONSE,apiSchema:$r,responseSchema:Ur}),[X.searchBookings]:Y({endpoint:J.searchBookingFile,requestRoot:q.SEARCH_BOOKING_FILE_REQUEST,responseRoot:q.SEARCH_BOOKING_FILE_RESPONSE,apiSchema:zi,responseSchema:Bi}),[X.searchPackages]:Y({endpoint:J.searchAvesPackages,requestRoot:q.AVES_SEARCH_REQUEST,responseRoot:q.SEARCH_PACKAGE_RESPONSE,apiSchema:fi,responseSchema:pi}),[X.searchServices]:Y({endpoint:J.searchTopServices,requestRoot:q.AVES_SEARCH_REQUEST,responseRoot:q.SEARCH_SERVICES_RESPONSE,apiSchema:fi,responseSchema:mi}),[X.get]:Y({endpoint:J.getPackageDetail,requestRoot:q.PACKAGE_DETAIL_REQUEST,responseRoot:q.PACKAGE_DETAIL_RESPONSE,apiSchema:gi,responseSchema:_i}),[X.commit]:Y({endpoint:J.commitPackage,requestRoot:q.COMMIT_PACKAGE_REQUEST,responseRoot:q.COMMIT_PACKAGE_RESPONSE,apiSchema:vi,responseSchema:yi})};var Gi=class{transport;constructor(e){this.transport=e}async create(e){return p(await this.transport.invokeOp(X.create,e))}async updateServices(e){return p(await this.transport.invokeOp(X.updateServices,e))}async updateHeader(e){return p(await this.transport.invokeOp(X.updateHeader,e))}async cancel(e){return p(await this.transport.invokeOp(X.cancel,e))}async setStatus(e){return p(await this.transport.invokeOp(X.setStatus,e))}async setServiceStatus(e){return p(await this.transport.invokeOp(X.setServiceStatus,e))}async addPayments(e){return p(await this.transport.invokeOp(X.addPayments,e))}async search(e){return p(await this.transport.invokeOp(X.searchBookings,e))}};function Ki(e){return{success:!0,data:e}}function Z(e){return{success:!1,error:e}}var qi=class{transport;constructor(e){this.transport=e}async search(e){let t=await this.transport.invokeOp(X.search,e);return t.success?Ki(he(t.data.masterRecordList??[])):t}async upsert(e){return p(await this.transport.invokeOp(X.upsert,e))}},Ji=class{transport;constructor(e){this.transport=e}#e(e,t){return{...this.transport.languageCode&&{languageCode:this.transport.languageCode},...e,avesSearchType:e.avesSearchType??e.searchType??t}}async search(e){return p(await this.transport.invokeOp(X.searchPackages,this.#e(e,y.PACKAGE)))}async searchServices(e){return p(await this.transport.invokeOp(X.searchServices,this.#e(e,y.SERVICE)))}async get(e){return p(await this.transport.invokeOp(X.get,e))}async commit(e){return p(await this.transport.invokeOp(X.commit,e))}};const Yi={VALIDATION:`validation`,API:`api`,UNKNOWN:`unknown`};var Q=class extends Error{kind;status;code;constructor(e,t,n,r){super(t),this.kind=e,this.status=n,this.code=r,this.name=`AvesError`}};function $(e){return new Q(Yi.VALIDATION,e)}function Xi(e,t,n){return new Q(Yi.API,e,t,n)}function Zi(e){return new Q(Yi.UNKNOWN,e)}function Qi(e,n){return e instanceof Q?e:e instanceof t?$(`Validation error: ${$i(e.issues)}`):e instanceof Error?Zi(e.message):Zi(n)}function $i(e){return e.map(ea).join(`; `)}function ea(e){let t=ta(e.path),n=e.message??`Invalid value`;return t?`${t}: ${n}`:n}function ta(e){if(!e||e.length===0)return;let t=e.map(na).filter(e=>e!==void 0);return t.length>0?t.join(`.`):void 0}function na(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`key`in e)return String(e.key)}function ra(e){return e instanceof Error&&e.name===`AbortError`}const ia=e=>e<200||e>299,aa={ignoreAttributes:!1,attributeNamePrefix:`@`,parseAttributeValue:!1,trimValues:!0,ignoreNameSpace:!0,removeNSPrefix:!0,parseTagValue:!1},oa={ignoreAttributes:!1,attributeNamePrefix:`@`,suppressEmptyNode:!0},sa=new a(aa),ca=new i(oa);function la(e){try{return ca.build(e)}catch(e){throw $(`Failed to convert JSON to XML: ${e instanceof Error?e.message:`Unknown error`}`)}}function ua(e){try{return sa.parse(e)}catch(e){throw $(`Failed to convert XML to JSON: ${e instanceof Error?e.message:`Unknown error`}`)}}function da(e,t,n){let r=e.bodyKey?{[e.bodyKey]:t}:t;return Hi(e.requestRoot,{RqHeader:n,...r})}function fa(e){return typeof e==`string`?e:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString(`utf8`):String(e)}async function pa(e,t){let n=``;for await(let r of e){if(n.length>=t)continue;let e=fa(r),i=t-n.length;n+=e.length<=i?e:e.slice(0,i)}return n}function ma(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 ha(e,t){if(!t.startsWith(`/`))throw $(`Invalid endpoint: endpoint must start with '/' but got '${t}'`);let n;try{n=new URL(e)}catch(e){throw $(`Invalid baseURL: ${e instanceof Error?e.message:`Invalid URL format`}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw $(`Invalid protocol: baseURL must use http:// or https:// but got '${n.protocol}'`);let{pathname:r}=n;if(r===`/`||r===``)return new URL(t,n).href;let i=(r.endsWith(`/`)?r.slice(0,-1):r)+t;return new URL(i,n).href}const ga={"Content-Type":`application/xml`};var _a=class{options;urlByEndpoint=new Map;constructor(e){this.options=e}async postXml(e,t){let{signal:n,clear:r}=ma(this.options.timeoutMs??3e4);try{let r=await o(this.resolveUrl(e),{method:`POST`,headers:ga,body:t,signal:n}),i=ia(r.statusCode),a=i?await pa(r.body,4096):await r.body.text();return i?Z(Xi(a,`ERROR`,r.statusCode)):Ki({statusCode:r.statusCode,body:a})}catch(e){return ra(e)?Z(Xi(`Request timed out`,`TIMEOUT`)):Z(Qi(e,`Unknown error occurred`))}finally{r?.()}}resolveUrl(e){let t=this.urlByEndpoint.get(e);if(t)return t;let n=ha(this.options.baseURL,e);return this.urlByEndpoint.set(e,n),n}};function va(e,t,n){let i=ua(e)[t];if(!i)return Z($(`Invalid response structure: missing root element '${t}'`));let a=r(n,i);return a.success?ya(a.output):Z($(`Invalid response format: ${$i(a.issues)}`))}function ya(e){let{rsStatus:t}=e;return t.status===`OK`?Ki(e):Z(Xi(t.errorDescription??``,t.status,t.errorCode))}function ba(e){return{"@HostID":e.hostID,"@Xtoken":e.xtoken,"@Interface":`WEB`,"@UserName":`WEB`,...e.languageCode&&{"@LanguageCode":e.languageCode}}}var xa=class{options;http;rqHeader;constructor(e){this.options=e,this.http=new _a({baseURL:e.baseURL,timeoutMs:e.timeoutMs}),this.rqHeader=Object.freeze(ba(e))}get languageCode(){return this.options.languageCode}createRqHeader(){return this.rqHeader}async invokeOp(e,t){let r=Wi[e];try{let e=da(r,n(r.apiSchema,t),this.rqHeader),i=await this.http.postXml(r.endpoint,la(e));return i.success?va(i.data.body,r.responseRoot,r.responseSchema):i}catch(t){return Z(Qi(t,`Validation error occurred during ${e}`))}}},Sa=class{transport;master;booking;packages;constructor(e,t={}){this.transport=t.transport??new xa(e),this.master=t.master??new qi(this.transport),this.booking=t.booking??new Gi(this.transport),this.packages=t.packages??new Ji(this.transport)}};export{Sa as AvesClient,Q as AvesError,X as AvesOp,Ui as AvesOpSchema,y as AvesSearchType,At as AvesSearchTypeSchema,$e as AvesServiceType,et as AvesServiceTypeSchema,xa as AvesTransport,rt as BookedServiceStatus,it as BookedServiceStatusSchema,Gi as BookingClient,Je as BookingFileStatus,Ye as BookingFileStatusSchema,_ as BookingFileStatusWire,Qe as BookingFileStatusWireSchema,dt as CancelOperationType,ft as CancelOperationTypeSchema,Ke as CarrierType,qe as CarrierTypeSchema,Ct as CostPriceType,wt as CostPriceTypeSchema,st as CustomerPaymentType,ct as CustomerPaymentTypeSchema,Nt as DestinationType,Pt as DestinationTypeSchema,yt as DocumentType,bt as DocumentTypeSchema,_t as FilePaymentOperationType,vt as FilePaymentOperationTypeSchema,je as Gender,Me as GenderSchema,Tt as GroupingPaxPolicy,Et as GroupingPaxPolicySchema,He as InsertCriteria,Ue as InsertCriteriaSchema,xt as MakeDocumentTo,St as MakeDocumentToSchema,We as MasterPaymentType,Ge as MasterPaymentTypeSchema,qi as MasterRecordsClient,Fe as OpBodyKey,Ie as OpBodyKeySchema,ht as OptionedExpirePolicy,gt as OptionedExpirePolicySchema,Ji as PackageCatalogClient,lt as PassengerCategory,ut as PassengerCategorySchema,jt as PaxQtyCriteria,Mt as PaxQtyCriteriaSchema,at as PaymentType,ot as PaymentTypeSchema,Be as RecordStatus,Ve as RecordStatusSchema,Re as RecordType,ze as RecordTypeSchema,Ne as RsStatusValue,Pe as RsStatusValueSchema,v as SearchBookingFileType,kt as SearchBookingFileTypeSchema,g as SearchMasterType,Le as SearchMasterTypeSchema,pt as ServiceRefType,mt as ServiceRefTypeSchema,Xe as SetFileStatusValue,Ze as SetFileStatusValueSchema,tt as ToServiceType,nt as ToServiceTypeSchema,Dt as TypeDownloadFile,Ot as TypeDownloadFileSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aves-sdk",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "TypeScript SDK for AVES XML REST",
5
5
  "homepage": "https://github.com/simoneguglielmi/aves-sdk#readme",
6
6
  "repository": [
@@ -51,6 +51,8 @@
51
51
  "prepare": "yarn build",
52
52
  "test": "vitest run",
53
53
  "test:types": "vitest run --typecheck.only",
54
+ "test:bench": "vitest bench",
55
+ "test:perf": "AVES_PERF=1 vitest run src/utils/hot-path.perf.test.ts",
54
56
  "publish": "npm publish",
55
57
  "lint": "biome check src",
56
58
  "check": "biome check --write src",