@roomstay/core 0.1.52 → 0.1.53-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node.js +1 -1
- package/dist/node.js.LICENSE.txt +7 -0
- package/dist/types/Booking/IBookingCreateErrorResponse.d.ts +11 -0
- package/dist/types/Booking/IBookingStatus.type.d.ts +5 -0
- package/dist/types/Booking/ICheckoutBrowserSession.type.d.ts +14 -0
- package/dist/types/Booking/IPrice.type.d.ts +7 -0
- package/dist/types/Company/IAdminCompany.type.d.ts +0 -2
- package/dist/types/Fees/IFee.type.d.ts +5 -0
- package/dist/types/General/IJsonString.type.d.ts +6 -0
- package/dist/types/RMS/IRMSPropertyDiscount.type.d.ts +1 -1
- package/dist/types/index.d.ts +13 -1
- package/dist/utils/index.d.ts +9 -8
- package/dist/utils/roundMoney.d.ts +11 -1
- package/dist/web.js +1 -1
- package/dist/web.js.LICENSE.txt +7 -0
- package/package.json +1 -1
- package/dist/types/General/Format.types.d.ts +0 -1
- package/dist/types/General/Pagination.types.d.ts +0 -19
- package/dist/types/GiftCards/GiftCard.types.d.ts +0 -32
- package/dist/types/GiftCards/GiftCardAuth.types.d.ts +0 -31
- package/dist/utils/zodUtils.d.ts +0 -19
package/dist/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={n:t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let i,o,n,r,a,s;e.r(t),e.d(t,{EAddonPricingType:()=>i,EBookingFlow:()=>n,EBookingPaymentMethod:()=>r,EBookingStatus:()=>o,ECompanyProvider:()=>P,EDistanceUnitType:()=>p,EFeeType:()=>O,EGuarantyPolicyPrepaymentType:()=>C,EHotelCardProcessor:()=>a,EHotelPriceModel:()=>h,EHotelStateFieldConfiguration:()=>g,EHotelWeekdayStartsOn:()=>y,EIntegration:()=>m,EPlanpayBookingStatus:()=>s,ERMSDiscountType:()=>f,ERoomstayEventSource:()=>E,ERoomstayImageSize:()=>R,GuestProfile:()=>l,HttpMethod:()=>T,IAuxiliaryFilterType:()=>v,ItineraryResponse:()=>c,PCIBookingCardProcessorTypes:()=>d,Package:()=>N,Reservation:()=>u,ReservedPackage:()=>S,calculateFeeAmount:()=>x,calculateTotalForMemberBooking:()=>k,getFeeOptionValidity:()=>Q,getFilteredBookingAddonFees:()=>j,getFilteredBookingFees:()=>G,getFilteredBookingRateFees:()=>U,nameof:()=>I,resizeRoomstayImageUrl:()=>_,roundMoney:()=>b,subset:()=>F,uppercaseString:()=>A}),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(i||(i={})),function(e){e.Pending="Pending",e.Processing="Processing",e.Committed="Committed",e.Cancelled="Cancelled",e.Reverted="Reverted"}(o||(o={})),function(e){e.Default="Default",e.PreCheckoutPencil="PreCheckoutPencil",e.PostCheckoutPencil="PostCheckoutPencil"}(n||(n={})),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(r||(r={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(a||(a={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(s||(s={}));const d=[];class c{constructor(){this.roomstayId=void 0,this.itineraryNumber=void 0,this.total=void 0,this.hotelFrontendId=void 0,this.reservations=[],this.payment=void 0,this.feesSummary=void 0,this.itemisedFees=void 0,this.warnings=void 0}}class u{constructor(){this.reservationNumber=void 0,this.roomType=void 0,this.roomCode=void 0,this.rate=void 0,this.rateCode=void 0,this.images=void 0,this.guaranteePolicy=void 0,this.cancellationPolicy=void 0,this.checkInDate=void 0,this.checkOutDate=void 0,this.nights={},this.guestCounts={adults:1,children:0},this.guest=new l,this.paymentCard=void 0,this.paymentMethod=void 0,this.total=void 0,this.status=void 0,this.isCancelable=void 0,this.addons=void 0,this.comments=void 0,this.specialRequests=void 0,this.promoCode=void 0,this.guaranteePolicyLongDescription=void 0,this.cancellationPolicyLongDescription=void 0,this.itemisedFees=void 0}}class l{constructor(){this.title=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.nameSuffix=void 0,this.phone=void 0,this.email=void 0,this.address={},this.marketingOptIn=void 0,this.country=void 0}}let P,h,g,y,m,v,p,f,R,C,E,T,O;!function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(P||(P={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(h||(h={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(g||(g={})),function(e){e.Monday="monday",e.Sunday="sunday"}(y||(y={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(m||(m={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(v||(v={})),function(e){e.Metric="metric",e.Imperial="imperial"}(p||(p={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(f||(f={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(R||(R={}));class N{constructor(){this.ratePlanCode=void 0,this.name=void 0,this.description=void 0,this.inclusive=void 0,this.image=void 0,this.url=void 0,this.pricingType=void 0,this.quantity=void 0,this.category=void 0,this.cancelPenalty=void 0,this.guaranteeDescription=void 0,this.availability={}}}class S extends N{constructor(...e){super(...e),this.code=void 0,this.price=void 0,this.fees=void 0,this.itemisedFees=void 0,this.adultQuantity=void 0,this.childQuantity=void 0,this.adultPrice=void 0,this.childPrice=void 0,this.startDate=void 0,this.startTime=void 0,this.hideDatePicker=!1,this.order=void 0}}function A(e){return e.toUpperCase()}!function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(C||(C={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(E||(E={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(T||(T={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(O||(O={}));const k=e=>{let t=0;const i=Object.values(e.itinerary);for(const e of i){const i=Object.keys(e.nights);for(const o of i)t+=e.nights[o].total}return t},_=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e,I=e=>e,F=(e,t)=>{const i={};return t.forEach((t=>{t in e&&(i[t]=e[t])})),i},B=require("decimal.js");var D=e.n(B);const b=e=>new(D())(e).toDecimalPlaces(2).toNumber();function x(e,t={}){const{baseAmount:i=0,numberOfNights:o=1,feeIncludedInBaseAmount:n=!1,extractedFromRates:r=!1,removedPercentages:a=[]}=t,s=b(i);switch(e.feeType){case O.PercentageOfBooking:if(n)return b(s*e.amount/(100+e.amount));if(r){const t=a.reduce(((e,t)=>e+t/(100+t)),0);return b(s/(1-t)*e.amount/(100+e.amount))}return b(s*(e.amount/100));case O.FixedChargePerRoom:case O.FixedChargePerBooking:return e.amount;case O.NightlyChargePerRoom:return b(e.amount*o);default:return 0}}const M=[O.FixedChargePerBooking],H=[O.PercentageOfBooking,O.FixedChargePerRoom,O.NightlyChargePerRoom],L=[O.PercentageOfBooking];function w(e,t){return e.filter((e=>t.includes(e.feeType)))}function G(e){return w(e,M)}function U(e){return w(e,H)}function j(e){return w(e,L)}function Q(e){return{includeInRates:[O.PercentageOfBooking,O.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===O.PercentageOfBooking,appliesToAddons:e===O.PercentageOfBooking,includePreviousFeesInCalculation:e===O.PercentageOfBooking}}module.exports=t})();
|
|
1
|
+
(()=>{"use strict";var e={n:t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let i,o,n,r,a,d;e.r(t),e.d(t,{ADDON_PER_NIGHT_TYPES:()=>I,AddonPricingType:()=>f,EAddonPricingType:()=>i,EBookingFlow:()=>n,EBookingPaymentMethod:()=>r,EBookingStatus:()=>o,ECompanyProvider:()=>u,EDistanceUnitType:()=>E,EFeeType:()=>C,EGuarantyPolicyPrepaymentType:()=>T,EHotelCardProcessor:()=>a,EHotelPriceModel:()=>h,EHotelStateFieldConfiguration:()=>g,EHotelWeekdayStartsOn:()=>y,EIntegration:()=>R,EPlanpayBookingStatus:()=>d,ERMSDiscountType:()=>N,ERoomstayEventSource:()=>v,ERoomstayImageSize:()=>p,GuestProfile:()=>P,HttpMethod:()=>O,IAuxiliaryFilterType:()=>_,IMaintenanceStatusService:()=>m,ItineraryResponse:()=>s,PCIBookingCardProcessorTypes:()=>c,Package:()=>A,Reservation:()=>l,ReservedPackage:()=>F,RoundingType:()=>L,TotalCalculator:()=>V,calculateFeeAmount:()=>k,calculateTotalForMemberBooking:()=>S,getFeeOptionValidity:()=>w,getFilteredBookingAddonFees:()=>Y,getFilteredBookingFees:()=>M,getFilteredBookingRateFees:()=>x,nameof:()=>j,resizeRoomstayImageUrl:()=>W,roundMoney:()=>U,subset:()=>q,uppercaseString:()=>z}),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(i||(i={})),function(e){e.Pending="Pending",e.Processing="Processing",e.Committed="Committed",e.Cancelled="Cancelled",e.Reverted="Reverted"}(o||(o={})),function(e){e.Default="Default",e.PreCheckoutPencil="PreCheckoutPencil",e.PostCheckoutPencil="PostCheckoutPencil"}(n||(n={})),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(r||(r={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(a||(a={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(d||(d={}));const c=[];class s{constructor(){this.roomstayId=void 0,this.itineraryNumber=void 0,this.total=void 0,this.hotelFrontendId=void 0,this.reservations=[],this.payment=void 0,this.feesSummary=void 0,this.itemisedFees=void 0,this.warnings=void 0}}class l{constructor(){this.reservationNumber=void 0,this.roomType=void 0,this.roomCode=void 0,this.rate=void 0,this.rateCode=void 0,this.images=void 0,this.guaranteePolicy=void 0,this.cancellationPolicy=void 0,this.checkInDate=void 0,this.checkOutDate=void 0,this.nights={},this.guestCounts={adults:1,children:0},this.guest=new P,this.paymentCard=void 0,this.paymentMethod=void 0,this.total=void 0,this.status=void 0,this.isCancelable=void 0,this.addons=void 0,this.comments=void 0,this.specialRequests=void 0,this.promoCode=void 0,this.guaranteePolicyLongDescription=void 0,this.cancellationPolicyLongDescription=void 0,this.itemisedFees=void 0}}class P{constructor(){this.title=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.nameSuffix=void 0,this.phone=void 0,this.email=void 0,this.address={},this.marketingOptIn=void 0,this.country=void 0}}let u,h,g,y,R,_,E,N,p,m,T,v,O,C,f;!function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(u||(u={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(h||(h={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(g||(g={})),function(e){e.Monday="monday",e.Sunday="sunday"}(y||(y={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(R||(R={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(_||(_={})),function(e){e.Metric="metric",e.Imperial="imperial"}(E||(E={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(N||(N={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(p||(p={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(m||(m={}));class A{constructor(){this.ratePlanCode=void 0,this.name=void 0,this.description=void 0,this.inclusive=void 0,this.image=void 0,this.url=void 0,this.pricingType=void 0,this.quantity=void 0,this.category=void 0,this.cancelPenalty=void 0,this.guaranteeDescription=void 0,this.availability={}}}class F extends A{constructor(...e){super(...e),this.code=void 0,this.price=void 0,this.fees=void 0,this.itemisedFees=void 0,this.adultQuantity=void 0,this.childQuantity=void 0,this.adultPrice=void 0,this.childPrice=void 0,this.startDate=void 0,this.startTime=void 0,this.hideDatePicker=!1,this.order=void 0}}!function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(T||(T={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(v||(v={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(O||(O={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(C||(C={})),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(f||(f={}));const I=[f.PER_NIGHT,f.PER_PERSON_PER_NIGHT,f.PER_QUANTITY_NAME_PER_NIGHT,f.PER_ROOM_QUANTITY_PER_NIGHT,f.PER_PERSON_OCCUPANCY_PER_NIGHT,f.PER_ADULT_OCCUPANCY_PER_NIGHT,f.PER_CHILD_OCCUPANCY_PER_NIGHT,f.PER_ALL_PERSONS_PER_NIGHT],S=e=>{let t=0;const i=Object.values(e.itinerary);for(const e of i){const i=Object.keys(e.nights);for(const o of i)t+=e.nights[o].total}return t},H=require("decimal.js");var D=e.n(H);const L={UP:D().ROUND_UP,DOWN:D().ROUND_DOWN,CEIL:D().ROUND_CEIL,FLOOR:D().ROUND_FLOOR,HALF_UP:D().ROUND_HALF_UP,HALF_DOWN:D().ROUND_HALF_DOWN,HALF_EVEN:D().ROUND_HALF_EVEN,HALF_CEIL:D().ROUND_HALF_CEIL,HALF_FLOOR:D().ROUND_HALF_FLOOR},U=(e,t)=>{const{precision:i=2,rounding:o=L.HALF_UP}=t||{};return new(D())(e).toDecimalPlaces(i,o).toNumber()};function k(e,t={}){const{baseAmount:i=0,numberOfNights:o=1,feeIncludedInBaseAmount:n=!1,extractedFromRates:r=!1,removedPercentages:a=[]}=t,d=U(i);switch(e.feeType){case C.PercentageOfBooking:if(n)return U(d*e.amount/(100+e.amount));if(r){const t=a.reduce(((e,t)=>e+t/(100+t)),0);return U(d/(1-t)*e.amount/(100+e.amount))}return U(d*(e.amount/100));case C.FixedChargePerRoom:case C.FixedChargePerBooking:return e.amount;case C.NightlyChargePerRoom:return U(e.amount*o);default:return 0}}const G=[C.FixedChargePerBooking],B=[C.PercentageOfBooking,C.FixedChargePerRoom,C.NightlyChargePerRoom],b=[C.PercentageOfBooking];function Q(e,t){return e.filter((e=>t.includes(e.feeType)))}function M(e){return Q(e,G)}function x(e){return Q(e,B)}function Y(e){return Q(e,b)}function w(e){return{includeInRates:[C.PercentageOfBooking,C.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===C.PercentageOfBooking,appliesToAddons:e===C.PercentageOfBooking,includePreviousFeesInCalculation:e===C.PercentageOfBooking}}const j=e=>e,q=(e,t)=>{const i={};return t.forEach((t=>{t in e&&(i[t]=e[t])})),i},W=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e;class V{}function z(e){return e.toUpperCase()}V.calculateBaseAddonTotal=(e,t)=>{let i=0,o=0,n=0;e.price&&e.quantity&&(i=e.quantity*Number(e.price)),e.pricingType===f.PER_ADULT_OCCUPANCY_PER_NIGHT&&e.adultQuantity?i*=e.adultQuantity:e.pricingType===f.PER_CHILD_OCCUPANCY_PER_NIGHT&&e.childQuantity&&(i*=e.childQuantity),e.adultPrice&&e.adultQuantity&&(o=e.adultQuantity*Number(e.adultPrice)),e.childPrice&&e.childQuantity&&(n=e.childQuantity*Number(e.childPrice));let r=i+o+n;return I.includes(e.pricingType)&&e.nights&&!t&&(r*=e.nights),{indPrice:i,indAdultPrice:o,indChildPrice:n,addonTotal:r}},V.calculateBasketAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,i)=>{const o=V.calculateBaseAddonTotal(i,t);let n=0;return(i.fee||i.fees?.length)&&i.quantity?i.fees?.length?i.fees.forEach((e=>{n+=i.quantity*e.amount})):n=i.quantity*Number(i.fee):((i.adultFee||i.adultFees?.length)&&i.adultQuantity&&(i.adultFees?.length?i.adultFees.forEach((e=>{n+=i.adultQuantity*e.amount})):n+=i.adultQuantity??1*Number(i.adultFee)),(i.childFee||i.childFees?.length)&&i.childQuantity&&(i.childFees?.length?i.childFees.forEach((e=>{n+=i.childQuantity??1*e.amount})):n+=i.childQuantity*Number(i.childFee))),I.includes(i.pricingType)&&i.nights&&!t&&(n*=i.nights),{price:e.price+o.indPrice,adultPrice:e.adultPrice+o.indAdultPrice,childPrice:e.childPrice+o.indChildPrice,totalFees:e.totalFees+n,total:e.total+o.addonTotal+n}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0})),V.calculateReservationAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,i)=>{const o=V.calculateBaseAddonTotal(i,t);let n=i.fees||0;i.itemisedFees?.length&&(n=i.itemisedFees.reduce(((e,t)=>e+t.amount),0));const r=i.itemisedFees?.length?o.addonTotal:o.addonTotal+n;return{price:e.price+o.indPrice,adultPrice:e.adultPrice+o.indAdultPrice,childPrice:e.childPrice+o.indChildPrice,totalFees:e.totalFees+n,total:e.total+o.addonTotal+n,displayPrice:e.displayPrice+r}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0,displayPrice:0})),V.calculateTotalForReservation=(e,t=!1)=>{let i=0;return e.itemisedFees?.forEach((e=>{i+=e.amount})),e.reservations.forEach((e=>{i+=e.total.afterTax;const o=Object.keys(e.nights)?.length??0;if(e.addons?.length){const n=(e.addons??[]).map((e=>({...e,nights:o})));i+=V.calculateReservationAddonTotal(n,t)?.total}})),U(i)},module.exports=t})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the response body that comes down if a booking fails anywhere in the booking flow.
|
|
3
|
+
*
|
|
4
|
+
* Object will contain a public message only, with partial reservation data to be able to attempt to "resume" the booking
|
|
5
|
+
*/
|
|
6
|
+
export type IBookingCreateErrorResponse = {
|
|
7
|
+
canRetryPayment: boolean;
|
|
8
|
+
isPaymentTaken: boolean;
|
|
9
|
+
publicMessage: string;
|
|
10
|
+
roomstayId: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EHotelCardProcessor, EHotelCardProcessorInitData } from './IBookingPayment.type';
|
|
2
|
+
export type ICheckoutBrowserSession<T extends EHotelCardProcessor | undefined = EHotelCardProcessor> = {
|
|
3
|
+
browserSessionId: string;
|
|
4
|
+
checkoutSessionId: string;
|
|
5
|
+
rows: {}[];
|
|
6
|
+
/**
|
|
7
|
+
* ISO 8601 date string
|
|
8
|
+
*/
|
|
9
|
+
expiry: string;
|
|
10
|
+
payment: {
|
|
11
|
+
processor: T;
|
|
12
|
+
data: EHotelCardProcessorInitData[T];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -10,7 +10,6 @@ export interface IAdminCompany {
|
|
|
10
10
|
isGiftCardsEnabled: boolean;
|
|
11
11
|
isEventsEnabled: boolean;
|
|
12
12
|
isAnalyticsEnabled: boolean;
|
|
13
|
-
preventMemberPortalWelcomeEmails: boolean;
|
|
14
13
|
hotels: {
|
|
15
14
|
name: string;
|
|
16
15
|
label: string;
|
|
@@ -21,7 +20,6 @@ export interface IAdminCompany {
|
|
|
21
20
|
clientPassword: string;
|
|
22
21
|
useTrainingDb: boolean;
|
|
23
22
|
apiUrl: string;
|
|
24
|
-
pencilGuestId?: number;
|
|
25
23
|
};
|
|
26
24
|
}[];
|
|
27
25
|
enableLighthouseAvailability: boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export * from './RMS/IRMSRequirement.type';
|
|
|
47
47
|
* Image
|
|
48
48
|
*/
|
|
49
49
|
export * from './Image/IRoomstayImage.type';
|
|
50
|
+
/** Maintenance */
|
|
51
|
+
export * from './Maintenance/IMaintenanceStatus.type';
|
|
50
52
|
/**
|
|
51
53
|
* Member Details
|
|
52
54
|
*/
|
|
@@ -89,7 +91,17 @@ export * from './Media/IMedia.type';
|
|
|
89
91
|
export * from './Fees/EFeeType.enum';
|
|
90
92
|
export * from './Fees/IFee.type';
|
|
91
93
|
export * from './Fees/IFeeConfigurationOptions.type';
|
|
94
|
+
/**
|
|
95
|
+
* Addon
|
|
96
|
+
*/
|
|
97
|
+
export * from './Addon/Addon.enum';
|
|
98
|
+
export * from './Addon/Addon.type';
|
|
99
|
+
/**
|
|
100
|
+
* Api
|
|
101
|
+
*/
|
|
102
|
+
export * from './Api/Reservations.type';
|
|
103
|
+
export * from './Api/RoomNightRate.type';
|
|
92
104
|
/**
|
|
93
105
|
* Analytics
|
|
94
106
|
*/
|
|
95
|
-
export * from
|
|
107
|
+
export * from "./Analytics/IBigQueryResults.type";
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
1
|
+
export * from "./bookingTotal";
|
|
2
|
+
export * from "./calculateFee";
|
|
3
|
+
export * from "./feeTypes";
|
|
4
|
+
export * from "./reflection";
|
|
5
|
+
export * from "./roomstayImageResize";
|
|
6
|
+
export * from "./roundMoney";
|
|
7
|
+
export * from "./TotalCalculator";
|
|
8
|
+
export * from "./typeUtils";
|
|
9
|
+
export * from "./uppercaseString";
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
export declare const RoundingType: {
|
|
3
|
+
[key: string]: Decimal.Rounding;
|
|
4
|
+
};
|
|
5
|
+
interface RoundMoneyOptions {
|
|
6
|
+
precision?: number;
|
|
7
|
+
rounding?: Decimal.Rounding;
|
|
8
|
+
}
|
|
1
9
|
/**
|
|
2
10
|
* Rounds a monetary amount to two decimal places.
|
|
3
11
|
*
|
|
@@ -5,6 +13,8 @@
|
|
|
5
13
|
* with some systems, such as RMS.
|
|
6
14
|
*
|
|
7
15
|
* @param amount a string or number to be rounded
|
|
16
|
+
* @param options an object containing precision and rounding options
|
|
8
17
|
* @returns the rounded amount as a number
|
|
9
18
|
*/
|
|
10
|
-
export declare const roundMoney: (amount: string | number) => number;
|
|
19
|
+
export declare const roundMoney: (amount: string | number, options?: RoundMoneyOptions) => number;
|
|
20
|
+
export {};
|
package/dist/web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
define("@roomstay/core",["decimal.js"],(e=>(()=>{"use strict";var t={60:t=>{t.exports=e}},i={};function o(e){var n=i[e];if(void 0!==n)return n.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{let e,t,i,r,a,s;o.r(n),o.d(n,{EAddonPricingType:()=>e,EBookingFlow:()=>i,EBookingPaymentMethod:()=>r,EBookingStatus:()=>t,ECompanyProvider:()=>P,EDistanceUnitType:()=>p,EFeeType:()=>O,EGuarantyPolicyPrepaymentType:()=>C,EHotelCardProcessor:()=>a,EHotelPriceModel:()=>h,EHotelStateFieldConfiguration:()=>g,EHotelWeekdayStartsOn:()=>y,EIntegration:()=>v,EPlanpayBookingStatus:()=>s,ERMSDiscountType:()=>f,ERoomstayEventSource:()=>E,ERoomstayImageSize:()=>R,GuestProfile:()=>l,HttpMethod:()=>T,IAuxiliaryFilterType:()=>m,ItineraryResponse:()=>c,PCIBookingCardProcessorTypes:()=>d,Package:()=>N,Reservation:()=>u,ReservedPackage:()=>S,calculateFeeAmount:()=>b,calculateTotalForMemberBooking:()=>k,getFeeOptionValidity:()=>Q,getFilteredBookingAddonFees:()=>j,getFilteredBookingFees:()=>G,getFilteredBookingRateFees:()=>U,nameof:()=>I,resizeRoomstayImageUrl:()=>_,roundMoney:()=>x,subset:()=>F,uppercaseString:()=>A}),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(e||(e={})),function(e){e.Pending="Pending",e.Processing="Processing",e.Committed="Committed",e.Cancelled="Cancelled",e.Reverted="Reverted"}(t||(t={})),function(e){e.Default="Default",e.PreCheckoutPencil="PreCheckoutPencil",e.PostCheckoutPencil="PostCheckoutPencil"}(i||(i={})),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(r||(r={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(a||(a={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(s||(s={}));const d=[];class c{constructor(){this.roomstayId=void 0,this.itineraryNumber=void 0,this.total=void 0,this.hotelFrontendId=void 0,this.reservations=[],this.payment=void 0,this.feesSummary=void 0,this.itemisedFees=void 0,this.warnings=void 0}}class u{constructor(){this.reservationNumber=void 0,this.roomType=void 0,this.roomCode=void 0,this.rate=void 0,this.rateCode=void 0,this.images=void 0,this.guaranteePolicy=void 0,this.cancellationPolicy=void 0,this.checkInDate=void 0,this.checkOutDate=void 0,this.nights={},this.guestCounts={adults:1,children:0},this.guest=new l,this.paymentCard=void 0,this.paymentMethod=void 0,this.total=void 0,this.status=void 0,this.isCancelable=void 0,this.addons=void 0,this.comments=void 0,this.specialRequests=void 0,this.promoCode=void 0,this.guaranteePolicyLongDescription=void 0,this.cancellationPolicyLongDescription=void 0,this.itemisedFees=void 0}}class l{constructor(){this.title=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.nameSuffix=void 0,this.phone=void 0,this.email=void 0,this.address={},this.marketingOptIn=void 0,this.country=void 0}}let P,h,g,y,v,m,p,f,R,C,E,T,O;!function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(P||(P={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(h||(h={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(g||(g={})),function(e){e.Monday="monday",e.Sunday="sunday"}(y||(y={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(v||(v={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(m||(m={})),function(e){e.Metric="metric",e.Imperial="imperial"}(p||(p={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(f||(f={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(R||(R={}));class N{constructor(){this.ratePlanCode=void 0,this.name=void 0,this.description=void 0,this.inclusive=void 0,this.image=void 0,this.url=void 0,this.pricingType=void 0,this.quantity=void 0,this.category=void 0,this.cancelPenalty=void 0,this.guaranteeDescription=void 0,this.availability={}}}class S extends N{constructor(...e){super(...e),this.code=void 0,this.price=void 0,this.fees=void 0,this.itemisedFees=void 0,this.adultQuantity=void 0,this.childQuantity=void 0,this.adultPrice=void 0,this.childPrice=void 0,this.startDate=void 0,this.startTime=void 0,this.hideDatePicker=!1,this.order=void 0}}function A(e){return e.toUpperCase()}!function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(C||(C={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(E||(E={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(T||(T={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(O||(O={}));const k=e=>{let t=0;const i=Object.values(e.itinerary);for(const e of i){const i=Object.keys(e.nights);for(const o of i)t+=e.nights[o].total}return t},_=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e,I=e=>e,F=(e,t)=>{const i={};return t.forEach((t=>{t in e&&(i[t]=e[t])})),i};var B=o(60),D=o.n(B);const x=e=>new(D())(e).toDecimalPlaces(2).toNumber();function b(e,t={}){const{baseAmount:i=0,numberOfNights:o=1,feeIncludedInBaseAmount:n=!1,extractedFromRates:r=!1,removedPercentages:a=[]}=t,s=x(i);switch(e.feeType){case O.PercentageOfBooking:if(n)return x(s*e.amount/(100+e.amount));if(r){const t=a.reduce(((e,t)=>e+t/(100+t)),0);return x(s/(1-t)*e.amount/(100+e.amount))}return x(s*(e.amount/100));case O.FixedChargePerRoom:case O.FixedChargePerBooking:return e.amount;case O.NightlyChargePerRoom:return x(e.amount*o);default:return 0}}const M=[O.FixedChargePerBooking],H=[O.PercentageOfBooking,O.FixedChargePerRoom,O.NightlyChargePerRoom],L=[O.PercentageOfBooking];function w(e,t){return e.filter((e=>t.includes(e.feeType)))}function G(e){return w(e,M)}function U(e){return w(e,H)}function j(e){return w(e,L)}function Q(e){return{includeInRates:[O.PercentageOfBooking,O.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===O.PercentageOfBooking,appliesToAddons:e===O.PercentageOfBooking,includePreviousFeesInCalculation:e===O.PercentageOfBooking}}})(),n})()));
|
|
1
|
+
define("@roomstay/core",["decimal.js"],(e=>(()=>{"use strict";var t={60:t=>{t.exports=e}},i={};function o(e){var n=i[e];if(void 0!==n)return n.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{let e,t,i,r,a,d;o.r(n),o.d(n,{ADDON_PER_NIGHT_TYPES:()=>I,AddonPricingType:()=>f,EAddonPricingType:()=>e,EBookingFlow:()=>i,EBookingPaymentMethod:()=>r,EBookingStatus:()=>t,ECompanyProvider:()=>u,EDistanceUnitType:()=>E,EFeeType:()=>C,EGuarantyPolicyPrepaymentType:()=>T,EHotelCardProcessor:()=>a,EHotelPriceModel:()=>h,EHotelStateFieldConfiguration:()=>g,EHotelWeekdayStartsOn:()=>y,EIntegration:()=>R,EPlanpayBookingStatus:()=>d,ERMSDiscountType:()=>p,ERoomstayEventSource:()=>v,ERoomstayImageSize:()=>N,GuestProfile:()=>P,HttpMethod:()=>O,IAuxiliaryFilterType:()=>_,IMaintenanceStatusService:()=>m,ItineraryResponse:()=>s,PCIBookingCardProcessorTypes:()=>c,Package:()=>A,Reservation:()=>l,ReservedPackage:()=>F,RoundingType:()=>L,TotalCalculator:()=>V,calculateFeeAmount:()=>k,calculateTotalForMemberBooking:()=>S,getFeeOptionValidity:()=>w,getFilteredBookingAddonFees:()=>Y,getFilteredBookingFees:()=>x,getFilteredBookingRateFees:()=>M,nameof:()=>j,resizeRoomstayImageUrl:()=>W,roundMoney:()=>U,subset:()=>q,uppercaseString:()=>z}),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(e||(e={})),function(e){e.Pending="Pending",e.Processing="Processing",e.Committed="Committed",e.Cancelled="Cancelled",e.Reverted="Reverted"}(t||(t={})),function(e){e.Default="Default",e.PreCheckoutPencil="PreCheckoutPencil",e.PostCheckoutPencil="PostCheckoutPencil"}(i||(i={})),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(r||(r={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(a||(a={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(d||(d={}));const c=[];class s{constructor(){this.roomstayId=void 0,this.itineraryNumber=void 0,this.total=void 0,this.hotelFrontendId=void 0,this.reservations=[],this.payment=void 0,this.feesSummary=void 0,this.itemisedFees=void 0,this.warnings=void 0}}class l{constructor(){this.reservationNumber=void 0,this.roomType=void 0,this.roomCode=void 0,this.rate=void 0,this.rateCode=void 0,this.images=void 0,this.guaranteePolicy=void 0,this.cancellationPolicy=void 0,this.checkInDate=void 0,this.checkOutDate=void 0,this.nights={},this.guestCounts={adults:1,children:0},this.guest=new P,this.paymentCard=void 0,this.paymentMethod=void 0,this.total=void 0,this.status=void 0,this.isCancelable=void 0,this.addons=void 0,this.comments=void 0,this.specialRequests=void 0,this.promoCode=void 0,this.guaranteePolicyLongDescription=void 0,this.cancellationPolicyLongDescription=void 0,this.itemisedFees=void 0}}class P{constructor(){this.title=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.nameSuffix=void 0,this.phone=void 0,this.email=void 0,this.address={},this.marketingOptIn=void 0,this.country=void 0}}let u,h,g,y,R,_,E,p,N,m,T,v,O,C,f;!function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(u||(u={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(h||(h={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(g||(g={})),function(e){e.Monday="monday",e.Sunday="sunday"}(y||(y={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(R||(R={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(_||(_={})),function(e){e.Metric="metric",e.Imperial="imperial"}(E||(E={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(p||(p={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(N||(N={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(m||(m={}));class A{constructor(){this.ratePlanCode=void 0,this.name=void 0,this.description=void 0,this.inclusive=void 0,this.image=void 0,this.url=void 0,this.pricingType=void 0,this.quantity=void 0,this.category=void 0,this.cancelPenalty=void 0,this.guaranteeDescription=void 0,this.availability={}}}class F extends A{constructor(...e){super(...e),this.code=void 0,this.price=void 0,this.fees=void 0,this.itemisedFees=void 0,this.adultQuantity=void 0,this.childQuantity=void 0,this.adultPrice=void 0,this.childPrice=void 0,this.startDate=void 0,this.startTime=void 0,this.hideDatePicker=!1,this.order=void 0}}!function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(T||(T={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(v||(v={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(O||(O={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(C||(C={})),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(f||(f={}));const I=[f.PER_NIGHT,f.PER_PERSON_PER_NIGHT,f.PER_QUANTITY_NAME_PER_NIGHT,f.PER_ROOM_QUANTITY_PER_NIGHT,f.PER_PERSON_OCCUPANCY_PER_NIGHT,f.PER_ADULT_OCCUPANCY_PER_NIGHT,f.PER_CHILD_OCCUPANCY_PER_NIGHT,f.PER_ALL_PERSONS_PER_NIGHT],S=e=>{let t=0;const i=Object.values(e.itinerary);for(const e of i){const i=Object.keys(e.nights);for(const o of i)t+=e.nights[o].total}return t};var H=o(60),D=o.n(H);const L={UP:D().ROUND_UP,DOWN:D().ROUND_DOWN,CEIL:D().ROUND_CEIL,FLOOR:D().ROUND_FLOOR,HALF_UP:D().ROUND_HALF_UP,HALF_DOWN:D().ROUND_HALF_DOWN,HALF_EVEN:D().ROUND_HALF_EVEN,HALF_CEIL:D().ROUND_HALF_CEIL,HALF_FLOOR:D().ROUND_HALF_FLOOR},U=(e,t)=>{const{precision:i=2,rounding:o=L.HALF_UP}=t||{};return new(D())(e).toDecimalPlaces(i,o).toNumber()};function k(e,t={}){const{baseAmount:i=0,numberOfNights:o=1,feeIncludedInBaseAmount:n=!1,extractedFromRates:r=!1,removedPercentages:a=[]}=t,d=U(i);switch(e.feeType){case C.PercentageOfBooking:if(n)return U(d*e.amount/(100+e.amount));if(r){const t=a.reduce(((e,t)=>e+t/(100+t)),0);return U(d/(1-t)*e.amount/(100+e.amount))}return U(d*(e.amount/100));case C.FixedChargePerRoom:case C.FixedChargePerBooking:return e.amount;case C.NightlyChargePerRoom:return U(e.amount*o);default:return 0}}const G=[C.FixedChargePerBooking],B=[C.PercentageOfBooking,C.FixedChargePerRoom,C.NightlyChargePerRoom],b=[C.PercentageOfBooking];function Q(e,t){return e.filter((e=>t.includes(e.feeType)))}function x(e){return Q(e,G)}function M(e){return Q(e,B)}function Y(e){return Q(e,b)}function w(e){return{includeInRates:[C.PercentageOfBooking,C.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===C.PercentageOfBooking,appliesToAddons:e===C.PercentageOfBooking,includePreviousFeesInCalculation:e===C.PercentageOfBooking}}const j=e=>e,q=(e,t)=>{const i={};return t.forEach((t=>{t in e&&(i[t]=e[t])})),i},W=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e;class V{}function z(e){return e.toUpperCase()}V.calculateBaseAddonTotal=(e,t)=>{let i=0,o=0,n=0;e.price&&e.quantity&&(i=e.quantity*Number(e.price)),e.pricingType===f.PER_ADULT_OCCUPANCY_PER_NIGHT&&e.adultQuantity?i*=e.adultQuantity:e.pricingType===f.PER_CHILD_OCCUPANCY_PER_NIGHT&&e.childQuantity&&(i*=e.childQuantity),e.adultPrice&&e.adultQuantity&&(o=e.adultQuantity*Number(e.adultPrice)),e.childPrice&&e.childQuantity&&(n=e.childQuantity*Number(e.childPrice));let r=i+o+n;return I.includes(e.pricingType)&&e.nights&&!t&&(r*=e.nights),{indPrice:i,indAdultPrice:o,indChildPrice:n,addonTotal:r}},V.calculateBasketAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,i)=>{const o=V.calculateBaseAddonTotal(i,t);let n=0;return(i.fee||i.fees?.length)&&i.quantity?i.fees?.length?i.fees.forEach((e=>{n+=i.quantity*e.amount})):n=i.quantity*Number(i.fee):((i.adultFee||i.adultFees?.length)&&i.adultQuantity&&(i.adultFees?.length?i.adultFees.forEach((e=>{n+=i.adultQuantity*e.amount})):n+=i.adultQuantity??1*Number(i.adultFee)),(i.childFee||i.childFees?.length)&&i.childQuantity&&(i.childFees?.length?i.childFees.forEach((e=>{n+=i.childQuantity??1*e.amount})):n+=i.childQuantity*Number(i.childFee))),I.includes(i.pricingType)&&i.nights&&!t&&(n*=i.nights),{price:e.price+o.indPrice,adultPrice:e.adultPrice+o.indAdultPrice,childPrice:e.childPrice+o.indChildPrice,totalFees:e.totalFees+n,total:e.total+o.addonTotal+n}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0})),V.calculateReservationAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,i)=>{const o=V.calculateBaseAddonTotal(i,t);let n=i.fees||0;i.itemisedFees?.length&&(n=i.itemisedFees.reduce(((e,t)=>e+t.amount),0));const r=i.itemisedFees?.length?o.addonTotal:o.addonTotal+n;return{price:e.price+o.indPrice,adultPrice:e.adultPrice+o.indAdultPrice,childPrice:e.childPrice+o.indChildPrice,totalFees:e.totalFees+n,total:e.total+o.addonTotal+n,displayPrice:e.displayPrice+r}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0,displayPrice:0})),V.calculateTotalForReservation=(e,t=!1)=>{let i=0;return e.itemisedFees?.forEach((e=>{i+=e.amount})),e.reservations.forEach((e=>{i+=e.total.afterTax;const o=Object.keys(e.nights)?.length??0;if(e.addons?.length){const n=(e.addons??[]).map((e=>({...e,nights:o})));i+=V.calculateReservationAddonTotal(n,t)?.total}})),U(i)}})(),n})()));
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DATE_FORMAT = "DD/MM/YYYY";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type IPaginatedRequest = {
|
|
2
|
-
pageSize?: number;
|
|
3
|
-
currentPage?: number;
|
|
4
|
-
};
|
|
5
|
-
export type IPagination = {
|
|
6
|
-
pageSize: number;
|
|
7
|
-
currentPage: number;
|
|
8
|
-
skip: number;
|
|
9
|
-
};
|
|
10
|
-
export type IPaginatedResponse<T> = {
|
|
11
|
-
pageSize: number;
|
|
12
|
-
currentPage: number;
|
|
13
|
-
totalPages: number;
|
|
14
|
-
totalItems: number;
|
|
15
|
-
data: T[];
|
|
16
|
-
};
|
|
17
|
-
export type IPaginatedSearchRequest = IPaginatedRequest & {
|
|
18
|
-
search?: string;
|
|
19
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
export declare const AddGiftCardSchema: z.ZodObject<{
|
|
3
|
-
amount: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>>;
|
|
4
|
-
expiry: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<Date, unknown, z.core.$ZodTypeInternals<Date, unknown>>>;
|
|
5
|
-
giverFirstName: z.ZodString;
|
|
6
|
-
giverLastName: z.ZodString;
|
|
7
|
-
giverEmail: z.ZodEmail;
|
|
8
|
-
giverPhone: z.ZodString;
|
|
9
|
-
cardHolder: z.ZodString;
|
|
10
|
-
recipientEmail: z.ZodEmail;
|
|
11
|
-
recipientPhone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
-
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export type IAddGiftCardRequest = z.infer<typeof AddGiftCardSchema>;
|
|
15
|
-
export type IAddGiftCardResponse = IGiftCardDTO & {
|
|
16
|
-
password: string;
|
|
17
|
-
};
|
|
18
|
-
export type IGiftCardDTO = {
|
|
19
|
-
code: string;
|
|
20
|
-
createdBy?: string | null;
|
|
21
|
-
amount: number;
|
|
22
|
-
balance: number;
|
|
23
|
-
expiry: Date;
|
|
24
|
-
giverFirstName: string;
|
|
25
|
-
giverLastName: string;
|
|
26
|
-
giverEmail: string;
|
|
27
|
-
giverPhone: string;
|
|
28
|
-
cardHolder: string;
|
|
29
|
-
recipientEmail: string;
|
|
30
|
-
recipientPhone?: string | null;
|
|
31
|
-
notes?: string | null;
|
|
32
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
export declare const RefreshGiftCardTokenSchema: z.ZodObject<{
|
|
3
|
-
grant_type: z.ZodDefault<z.ZodReadonly<z.ZodString>>;
|
|
4
|
-
client_id: z.ZodUUID;
|
|
5
|
-
client_secret: z.ZodString;
|
|
6
|
-
refresh_token: z.ZodString;
|
|
7
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export type IRefreshGiftCardTokenRequest = z.infer<typeof RefreshGiftCardTokenSchema>;
|
|
10
|
-
/**
|
|
11
|
-
* Response from the Gift Card Engine when refreshing a token.
|
|
12
|
-
*/
|
|
13
|
-
export type IGiftCardTokenResponse = {
|
|
14
|
-
token_type: string;
|
|
15
|
-
access_token: string;
|
|
16
|
-
refresh_token?: string;
|
|
17
|
-
expires_in: number;
|
|
18
|
-
scope: string;
|
|
19
|
-
user?: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Request to register a new user on the gift card admin.
|
|
23
|
-
*/
|
|
24
|
-
export declare const RegisterGiftCardAdminSchema: z.ZodObject<{
|
|
25
|
-
email: z.ZodEmail;
|
|
26
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
27
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
28
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
29
|
-
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
export type IRegisterGiftCardAdminRequest = z.infer<typeof RegisterGiftCardAdminSchema>;
|
package/dist/utils/zodUtils.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
/**
|
|
4
|
-
* Processes a form submission using Zod for validation.
|
|
5
|
-
*/
|
|
6
|
-
export declare function validateFormWithZod<T extends FieldValues>(formMethods: UseFormReturn<T>, schema: z.ZodSchema<T>, data: any): T;
|
|
7
|
-
/**
|
|
8
|
-
* Preprocesses a form input to convert string values to numbers.
|
|
9
|
-
*/
|
|
10
|
-
export declare const preprocessNumber: (schema: z.ZodType<number>) => z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>>;
|
|
11
|
-
/**
|
|
12
|
-
* Preprocesses a form input to convert string values to dates.
|
|
13
|
-
*/
|
|
14
|
-
export declare const preprocessDate: (schema: z.ZodType<Date>) => z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<Date, unknown, z.core.$ZodTypeInternals<Date, unknown>>>;
|
|
15
|
-
export declare const requireString: (max: number) => z.ZodString;
|
|
16
|
-
export declare const requireEmail: () => z.ZodEmail;
|
|
17
|
-
export declare const requirePositiveAmount: () => z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>>;
|
|
18
|
-
export declare const requireFutureDate: () => z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodType<Date, unknown, z.core.$ZodTypeInternals<Date, unknown>>>;
|
|
19
|
-
export declare const maxString: (max: number) => z.ZodString;
|