@final-commerce/common 2.12.0-staging.4 → 2.12.0-staging.6

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.d.mts CHANGED
@@ -443,6 +443,10 @@ declare enum BookingSessionSale {
443
443
  SESSION = "session",
444
444
  COURSE = "course"
445
445
  }
446
+ declare enum BookingArriveLeave {
447
+ SET_TIMES = "set-times",
448
+ OPENING_HOURS = "opening-hours"
449
+ }
446
450
  declare enum BookingResourceKind {
447
451
  ASSET = "asset",
448
452
  ROOM = "room",
@@ -1667,6 +1671,7 @@ interface BookingTimeSlots {
1667
1671
  interface BookingDateRanges {
1668
1672
  weeklyHours?: WeeklyHours[];
1669
1673
  arrivalDays?: number[];
1674
+ arriveLeave?: BookingArriveLeave | `${BookingArriveLeave}`;
1670
1675
  checkInTime?: string | null;
1671
1676
  checkOutTime?: string | null;
1672
1677
  checkTimesByWeekday?: {
@@ -1752,6 +1757,7 @@ declare class BookingRulesError extends Error {
1752
1757
 
1753
1758
  declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
1754
1759
  declare function windowEndsAtInZone(rule: BookingRulesInput, now: Date, timeZone: string | null): Date | null;
1760
+ declare const startsPastMaxAdvance: (rule: BookingRulesInput, startAt: Date, now: Date, timeZone: string) => boolean;
1755
1761
  declare function maxAdvanceMinutesOf(rule: Pick<BookingRulesInput, 'window'>): number;
1756
1762
  interface BookingRuleDurations {
1757
1763
  buffer?: BookingDuration;
@@ -1764,7 +1770,9 @@ declare function oldMaxAdvanceOf({ maxAdvanceMinutes, maxAdvanceDays, }: Booking
1764
1770
  declare function sessionCells(rule: BookingRulesInput, timeZone: string, from: Date, to: Date): GridSlot[];
1765
1771
  declare function calendarDate(value: string): [number, number, number];
1766
1772
  declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
1767
- declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
1773
+ type CellChain = (previous: GridSlot, next: GridSlot) => boolean;
1774
+ declare function cellChainOf(rule: Pick<BookingRulesInput, 'ratePeriod'>, timeZone: string): CellChain;
1775
+ declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date, chain?: CellChain): GridSlot[];
1768
1776
 
1769
1777
  type BookingDurationField = 'timeSlots.length' | 'slot.buffer' | 'window.hold' | 'window.minNotice' | 'window.maxAdvance' | 'dateRanges.minStay' | 'dateRanges.maxStay';
1770
1778
  type Units = readonly BookingDurationUnit[];
@@ -1944,6 +1952,7 @@ declare function buildAvailability({ productId, bookingRulesId, rule, resources,
1944
1952
  course: ({
1945
1953
  sessions: number;
1946
1954
  alreadyStarted: boolean;
1955
+ beyondWindow: boolean;
1947
1956
  sessionTimes: {
1948
1957
  startAt: Date;
1949
1958
  endAt: Date;
@@ -2183,4 +2192,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2183
2192
  }];
2184
2193
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2185
2194
 
2186
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingDateRanges, type BookingDuration, type BookingDurationField, type BookingDurationProblem, type BookingDurationProblemKind, BookingDurationUnit, type BookingMethod, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, type BookingRuleDurations, type BookingRuleInNewShape, type BookingRuleNewFields, type BookingRuleParts, BookingRulesError, type BookingRulesInput, BookingSessionSale, type BookingTimeSlots, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanCourseInput, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, type RentalEndsInput, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UNLIMITED_PLACES, UserTypes, type WeeklyHours, type WindowForPeriodsInput, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, allowedDurationUnits, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, bookingMethodOf, bookingRuleParts, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, calendarDate, canTransition, capacityOf, cheapestCompositeItem, cheapestCompositePrice, checkPartySize, checkQtyPerBooking, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, courseSessions, courseSpan, courseStarted, courseStartedInZone, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, durationProblems, durationText, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, fewestFreeOver, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, longestMinutesOf, mapToLegacyStatus, maxAdvanceMinutesOf, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, occupiedAtOutlet, oldMaxAdvanceOf, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, pickFreeResource, placeKey, planCourse, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, rentalEnds, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, ruleDurationsOf, ruleInNewShape, sameFamily, sessionCells, setOrderState, shipsToCountry, shopDayKey, shopDayRange, shortestMinutesOf, signReportForDisplay, slotsForWindow, soldAsCourse, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, windowEndsAtInZone, windowForPeriods, withinPresence };
2195
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, BookingArriveLeave, type BookingDateRanges, type BookingDuration, type BookingDurationField, type BookingDurationProblem, type BookingDurationProblemKind, BookingDurationUnit, type BookingMethod, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, type BookingRuleDurations, type BookingRuleInNewShape, type BookingRuleNewFields, type BookingRuleParts, BookingRulesError, type BookingRulesInput, BookingSessionSale, type BookingTimeSlots, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, type CellChain, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanCourseInput, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, type RentalEndsInput, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UNLIMITED_PLACES, UserTypes, type WeeklyHours, type WindowForPeriodsInput, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, allowedDurationUnits, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, bookingMethodOf, bookingRuleParts, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, calendarDate, canTransition, capacityOf, cellChainOf, cheapestCompositeItem, cheapestCompositePrice, checkPartySize, checkQtyPerBooking, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, courseSessions, courseSpan, courseStarted, courseStartedInZone, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, durationProblems, durationText, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, fewestFreeOver, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, longestMinutesOf, mapToLegacyStatus, maxAdvanceMinutesOf, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, occupiedAtOutlet, oldMaxAdvanceOf, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, pickFreeResource, placeKey, planCourse, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, rentalEnds, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, ruleDurationsOf, ruleInNewShape, sameFamily, sessionCells, setOrderState, shipsToCountry, shopDayKey, shopDayRange, shortestMinutesOf, signReportForDisplay, slotsForWindow, soldAsCourse, startsPastMaxAdvance, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, windowEndsAtInZone, windowForPeriods, withinPresence };
package/dist/index.d.ts CHANGED
@@ -443,6 +443,10 @@ declare enum BookingSessionSale {
443
443
  SESSION = "session",
444
444
  COURSE = "course"
445
445
  }
446
+ declare enum BookingArriveLeave {
447
+ SET_TIMES = "set-times",
448
+ OPENING_HOURS = "opening-hours"
449
+ }
446
450
  declare enum BookingResourceKind {
447
451
  ASSET = "asset",
448
452
  ROOM = "room",
@@ -1667,6 +1671,7 @@ interface BookingTimeSlots {
1667
1671
  interface BookingDateRanges {
1668
1672
  weeklyHours?: WeeklyHours[];
1669
1673
  arrivalDays?: number[];
1674
+ arriveLeave?: BookingArriveLeave | `${BookingArriveLeave}`;
1670
1675
  checkInTime?: string | null;
1671
1676
  checkOutTime?: string | null;
1672
1677
  checkTimesByWeekday?: {
@@ -1752,6 +1757,7 @@ declare class BookingRulesError extends Error {
1752
1757
 
1753
1758
  declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
1754
1759
  declare function windowEndsAtInZone(rule: BookingRulesInput, now: Date, timeZone: string | null): Date | null;
1760
+ declare const startsPastMaxAdvance: (rule: BookingRulesInput, startAt: Date, now: Date, timeZone: string) => boolean;
1755
1761
  declare function maxAdvanceMinutesOf(rule: Pick<BookingRulesInput, 'window'>): number;
1756
1762
  interface BookingRuleDurations {
1757
1763
  buffer?: BookingDuration;
@@ -1764,7 +1770,9 @@ declare function oldMaxAdvanceOf({ maxAdvanceMinutes, maxAdvanceDays, }: Booking
1764
1770
  declare function sessionCells(rule: BookingRulesInput, timeZone: string, from: Date, to: Date): GridSlot[];
1765
1771
  declare function calendarDate(value: string): [number, number, number];
1766
1772
  declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
1767
- declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
1773
+ type CellChain = (previous: GridSlot, next: GridSlot) => boolean;
1774
+ declare function cellChainOf(rule: Pick<BookingRulesInput, 'ratePeriod'>, timeZone: string): CellChain;
1775
+ declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date, chain?: CellChain): GridSlot[];
1768
1776
 
1769
1777
  type BookingDurationField = 'timeSlots.length' | 'slot.buffer' | 'window.hold' | 'window.minNotice' | 'window.maxAdvance' | 'dateRanges.minStay' | 'dateRanges.maxStay';
1770
1778
  type Units = readonly BookingDurationUnit[];
@@ -1944,6 +1952,7 @@ declare function buildAvailability({ productId, bookingRulesId, rule, resources,
1944
1952
  course: ({
1945
1953
  sessions: number;
1946
1954
  alreadyStarted: boolean;
1955
+ beyondWindow: boolean;
1947
1956
  sessionTimes: {
1948
1957
  startAt: Date;
1949
1958
  endAt: Date;
@@ -2183,4 +2192,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2183
2192
  }];
2184
2193
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2185
2194
 
2186
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingDateRanges, type BookingDuration, type BookingDurationField, type BookingDurationProblem, type BookingDurationProblemKind, BookingDurationUnit, type BookingMethod, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, type BookingRuleDurations, type BookingRuleInNewShape, type BookingRuleNewFields, type BookingRuleParts, BookingRulesError, type BookingRulesInput, BookingSessionSale, type BookingTimeSlots, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanCourseInput, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, type RentalEndsInput, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UNLIMITED_PLACES, UserTypes, type WeeklyHours, type WindowForPeriodsInput, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, allowedDurationUnits, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, bookingMethodOf, bookingRuleParts, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, calendarDate, canTransition, capacityOf, cheapestCompositeItem, cheapestCompositePrice, checkPartySize, checkQtyPerBooking, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, courseSessions, courseSpan, courseStarted, courseStartedInZone, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, durationProblems, durationText, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, fewestFreeOver, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, longestMinutesOf, mapToLegacyStatus, maxAdvanceMinutesOf, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, occupiedAtOutlet, oldMaxAdvanceOf, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, pickFreeResource, placeKey, planCourse, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, rentalEnds, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, ruleDurationsOf, ruleInNewShape, sameFamily, sessionCells, setOrderState, shipsToCountry, shopDayKey, shopDayRange, shortestMinutesOf, signReportForDisplay, slotsForWindow, soldAsCourse, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, windowEndsAtInZone, windowForPeriods, withinPresence };
2195
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, BookingArriveLeave, type BookingDateRanges, type BookingDuration, type BookingDurationField, type BookingDurationProblem, type BookingDurationProblemKind, BookingDurationUnit, type BookingMethod, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, type BookingRuleDurations, type BookingRuleInNewShape, type BookingRuleNewFields, type BookingRuleParts, BookingRulesError, type BookingRulesInput, BookingSessionSale, type BookingTimeSlots, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, type CellChain, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanCourseInput, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, type RentalEndsInput, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UNLIMITED_PLACES, UserTypes, type WeeklyHours, type WindowForPeriodsInput, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, allowedDurationUnits, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, bookingMethodOf, bookingRuleParts, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, calendarDate, canTransition, capacityOf, cellChainOf, cheapestCompositeItem, cheapestCompositePrice, checkPartySize, checkQtyPerBooking, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, courseSessions, courseSpan, courseStarted, courseStartedInZone, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, durationProblems, durationText, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, fewestFreeOver, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, longestMinutesOf, mapToLegacyStatus, maxAdvanceMinutesOf, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, occupiedAtOutlet, oldMaxAdvanceOf, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, pickFreeResource, placeKey, planCourse, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, rentalEnds, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, ruleDurationsOf, ruleInNewShape, sameFamily, sessionCells, setOrderState, shipsToCountry, shopDayKey, shopDayRange, shortestMinutesOf, signReportForDisplay, slotsForWindow, soldAsCourse, startsPastMaxAdvance, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, windowEndsAtInZone, windowForPeriods, withinPresence };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  AttributeType: () => AttributeType,
32
32
  BNPL_METHOD_STATUS: () => BNPL_METHOD_STATUS,
33
33
  BNPL_SKIP_REASON: () => BNPL_SKIP_REASON,
34
+ BookingArriveLeave: () => BookingArriveLeave,
34
35
  BookingDurationUnit: () => BookingDurationUnit,
35
36
  BookingRatePeriod: () => BookingRatePeriod,
36
37
  BookingResourceKind: () => BookingResourceKind,
@@ -156,6 +157,7 @@ __export(index_exports, {
156
157
  calendarDate: () => calendarDate,
157
158
  canTransition: () => canTransition,
158
159
  capacityOf: () => capacityOf,
160
+ cellChainOf: () => cellChainOf,
159
161
  cheapestCompositeItem: () => cheapestCompositeItem,
160
162
  cheapestCompositePrice: () => cheapestCompositePrice,
161
163
  checkPartySize: () => checkPartySize,
@@ -280,6 +282,7 @@ __export(index_exports, {
280
282
  signReportForDisplay: () => signReportForDisplay,
281
283
  slotsForWindow: () => slotsForWindow,
282
284
  soldAsCourse: () => soldAsCourse,
285
+ startsPastMaxAdvance: () => startsPastMaxAdvance,
283
286
  stringifyMinorUnits: () => stringifyMinorUnits,
284
287
  subtractAmounts: () => subtractAmounts,
285
288
  toBase: () => toBase,
@@ -783,6 +786,11 @@ var BookingSessionSale = /* @__PURE__ */ ((BookingSessionSale2) => {
783
786
  BookingSessionSale2["COURSE"] = "course";
784
787
  return BookingSessionSale2;
785
788
  })(BookingSessionSale || {});
789
+ var BookingArriveLeave = /* @__PURE__ */ ((BookingArriveLeave2) => {
790
+ BookingArriveLeave2["SET_TIMES"] = "set-times";
791
+ BookingArriveLeave2["OPENING_HOURS"] = "opening-hours";
792
+ return BookingArriveLeave2;
793
+ })(BookingArriveLeave || {});
786
794
  var BookingResourceKind = /* @__PURE__ */ ((BookingResourceKind2) => {
787
795
  BookingResourceKind2["ASSET"] = "asset";
788
796
  BookingResourceKind2["ROOM"] = "room";
@@ -3825,7 +3833,7 @@ function buildAvailability({
3825
3833
  // The per-booking limits, so a stepper is bounded by the rules (G7) instead of a number in the flow.
3826
3834
  maxQtyPerBooking: rule.slot.maxQtyPerBooking,
3827
3835
  maxPartySize: rule.slot.maxPartySize,
3828
- // Why a day can come back empty. Past this instant the rule refuses everything, so the UI
3836
+ // Why a day can come back empty. Past this instant the rule refuses every start, so the UI
3829
3837
  // can say "beyond the booking window" where it would otherwise claim "nothing free".
3830
3838
  bookableUntil,
3831
3839
  // The comparison itself, not just the boundary: deciding whether a day lies past the
@@ -3908,6 +3916,7 @@ function courseAvailability(rule, resources, byResource, productId, shared, now)
3908
3916
  if (resources.length === 0) return void 0;
3909
3917
  const sessions = courseSessions(rule, resources[0].timeZone);
3910
3918
  const alreadyStarted = courseStartedInZone(rule, sessions, now, resources[0].timeZone);
3919
+ const beyondWindow = startsPastMaxAdvance(rule, sessions[0].startAt, now, resources[0].timeZone);
3911
3920
  const free = resources.map((resource) => {
3912
3921
  const mine = byResource.get(resource.id) ?? [];
3913
3922
  const everySession = sessions.every((session) => withinPresence(session, resource.timeZone, resource.presence));
@@ -3915,13 +3924,14 @@ function courseAvailability(rule, resources, byResource, productId, shared, now)
3915
3924
  const { taken, foreignProductId } = occupancyIn(mine, productId, session.startAt, session.bufferEndAt, shared);
3916
3925
  return foreignProductId ? 0 : Math.max(capacityOf(rule, resource) - taken, 0);
3917
3926
  });
3918
- const fewest = everySession && !alreadyStarted ? Math.min(...freePerSession) : 0;
3927
+ const fewest = everySession && !alreadyStarted && !beyondWindow ? Math.min(...freePerSession) : 0;
3919
3928
  return Number.isFinite(fewest) ? { resourceId: resource.id, free: fewest } : { resourceId: resource.id, free: UNLIMITED_PLACES, unlimited: true };
3920
3929
  });
3921
3930
  return withMaxQtyNow(
3922
3931
  {
3923
3932
  sessions: sessions.length,
3924
3933
  alreadyStarted,
3934
+ beyondWindow,
3925
3935
  sessionTimes: sessions.map(({ startAt, endAt }) => ({ startAt, endAt })),
3926
3936
  startAt: sessions[0].startAt,
3927
3937
  endAt: sessions[sessions.length - 1].endAt,
@@ -4066,10 +4076,11 @@ function noticeAboveAdvance({
4066
4076
  // booking/plan.ts
4067
4077
  var DEFAULT_HOLD_MINUTES = 10;
4068
4078
  function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }) {
4079
+ if (!soldAsCourse(rule)) checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4069
4080
  const grid = buildGrid(rule, timeZone, startAt, endAt, now, busy).filter(
4070
4081
  (slot) => withinPresence(slot, timeZone, presence)
4071
4082
  );
4072
- const slots = slotsForWindow(grid, startAt, endAt);
4083
+ const slots = slotsForWindow(grid, startAt, endAt, cellChainOf(rule, timeZone));
4073
4084
  const last = slots[slots.length - 1];
4074
4085
  const parts = bookingRuleParts(rule);
4075
4086
  const wholePeriods = parts.method === "date-ranges" && parts.wholePeriods;
@@ -4079,6 +4090,11 @@ function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }
4079
4090
  const bufferEndAt = rule.ratePeriod === "hour" /* HOUR */ || wholePeriods ? buffer ? addDuration(last.endAt, buffer, timeZone) : new Date(last.endAt.getTime()) : last.bufferEndAt;
4080
4091
  return { slots, periods, endAt: last.endAt, bufferEndAt };
4081
4092
  }
4093
+ function checkStartWithinMaxAdvance(rule, timeZone, startAt, now) {
4094
+ if (startsPastMaxAdvance(rule, startAt, now, timeZone)) {
4095
+ throw new BookingRulesError(`${startAt.toISOString()} is past the booking window of these rules`);
4096
+ }
4097
+ }
4082
4098
  function checkStay(parts, timeZone, startAt, periods) {
4083
4099
  if (parts.method !== "date-ranges") return;
4084
4100
  const stay = { count: periods, unit: periodUnitOf(parts) };
@@ -4111,6 +4127,7 @@ function windowForPeriods({ rule, timeZone, startAt, periods, now }) {
4111
4127
  if (!Number.isInteger(periods) || periods < 1) {
4112
4128
  throw new BookingRulesError(`periods must be a whole number of at least 1, got ${String(periods)}`);
4113
4129
  }
4130
+ checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4114
4131
  const parts = bookingRuleParts(rule);
4115
4132
  checkStay(parts, timeZone, startAt, periods);
4116
4133
  const wholePeriods = parts.method === "date-ranges" && parts.wholePeriods;
@@ -4130,13 +4147,14 @@ function windowForPeriods({ rule, timeZone, startAt, periods, now }) {
4130
4147
  const endAt = monthsEnd ?? grid[startIndex + cells - 1]?.endAt;
4131
4148
  if (!endAt)
4132
4149
  throw new BookingRulesError(`${periods} period(s) from ${startAt.toISOString()} run past the bookable grid`);
4133
- slotsForWindow(grid, startAt, endAt);
4150
+ slotsForWindow(grid, startAt, endAt, cellChainOf(rule, timeZone));
4134
4151
  return { startAt, endAt };
4135
4152
  }
4136
4153
  function rentalEnds(input) {
4137
4154
  const { rule, timeZone, startAt, now, untilDay } = input;
4138
4155
  const parts = bookingRuleParts(rule);
4139
4156
  if (parts.method !== "date-ranges") throw new BookingRulesError("Only date-range rules book a stay");
4157
+ checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4140
4158
  const horizon = shopDayRange(untilDay, 1, timeZone).to;
4141
4159
  if (horizon <= startAt) throw new BookingRulesError(`untilDay ${untilDay} is before the stay starts`);
4142
4160
  const gridUntil = (end) => buildGrid(rule, timeZone, startAt, new Date(Math.min(end, startAt.getTime() + 366 * 1440 * 6e4)), now);
@@ -4161,7 +4179,7 @@ function walkRentalEnds(grid, { rule, timeZone, startAt, untilDay }, parts, hori
4161
4179
  refusal ??= new BookingRulesError(`No stay from ${startAt.toISOString()} ends on or before ${untilDay}`);
4162
4180
  return { ends, refusal, ranOut: false };
4163
4181
  }
4164
- const slots = refusalOr(() => slotsForWindow(grid, startAt, cell.endAt));
4182
+ const slots = refusalOr(() => slotsForWindow(grid, startAt, cell.endAt, cellChainOf(rule, timeZone)));
4165
4183
  if (slots instanceof BookingRulesError) return { ends, refusal, ranOut: false };
4166
4184
  const periods = refusalOr(
4167
4185
  () => parts.wholePeriods ? wholePeriodsIn(rule.ratePeriod, timeZone, startAt, cell.endAt, slots.length) : slots.length
@@ -4255,6 +4273,9 @@ function planCourse({ rule, timeZone, presence, now }) {
4255
4273
  }
4256
4274
  if (courseStartedInZone(rule, sessions, now, timeZone))
4257
4275
  throw new BookingRulesError("This course has already started");
4276
+ if (startsPastMaxAdvance(rule, sessions[0].startAt, now, timeZone)) {
4277
+ throw new BookingRulesError("This course starts past the booking window of these rules");
4278
+ }
4258
4279
  return sessions;
4259
4280
  }
4260
4281
  function holdExpiresAt(rule, now) {
@@ -4412,12 +4433,21 @@ var OLD_FIELDS = [
4412
4433
  "date-ranges": "dateRanges.weeklyHours"
4413
4434
  }
4414
4435
  },
4415
- ...["availability.arrivalDays", "checkInTime", "checkOutTime", "checkTimesByWeekday"].map((path) => ({
4436
+ {
4437
+ path: "availability.arrivalDays",
4438
+ home: {
4439
+ "time-slots": { unread: "date ranges only" },
4440
+ sessions: { unread: "date ranges only" },
4441
+ "date-ranges": "dateRanges.arrivalDays"
4442
+ }
4443
+ },
4444
+ // An `opening-hours` night has no check times (FC-1503): switching to it drops the old ones, said in a note.
4445
+ ...["checkInTime", "checkOutTime", "checkTimesByWeekday"].map((path) => ({
4416
4446
  path,
4417
4447
  home: {
4418
4448
  "time-slots": { unread: "date ranges only" },
4419
4449
  sessions: { unread: "date ranges only" },
4420
- "date-ranges": `dateRanges.${path.replace("availability.", "")}`
4450
+ "date-ranges": ({ dateRanges }) => dateRanges?.arriveLeave === "opening-hours" /* OPENING_HOURS */ ? { dropped: "opening-hours nights have no check times" } : `dateRanges.${path}`
4421
4451
  }
4422
4452
  }))
4423
4453
  ];
@@ -4530,13 +4560,23 @@ function windowEndsAt(rule, now) {
4530
4560
  return Number.isFinite(ends) ? new Date(ends) : null;
4531
4561
  }
4532
4562
  function windowEndsAtInZone(rule, now, timeZone) {
4533
- const { maxAdvance } = ruleDurationsOf(rule);
4534
4563
  const ends = Math.min(
4535
- maxAdvance ? addInZone(now, maxAdvance, timeZone, "window.maxAdvance").getTime() : Number.POSITIVE_INFINITY,
4564
+ lastStartOf(rule, now, timeZone),
4536
4565
  asTime(rule.window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY
4537
4566
  );
4538
4567
  return Number.isFinite(ends) ? new Date(ends) : null;
4539
4568
  }
4569
+ function lastStartOf(rule, now, timeZone) {
4570
+ const { maxAdvance } = ruleDurationsOf(rule);
4571
+ if (!maxAdvance) return Number.POSITIVE_INFINITY;
4572
+ const reached = addInZone(now, maxAdvance, timeZone, "window.maxAdvance");
4573
+ if (maxAdvance.unit === "minute" /* MINUTE */ || maxAdvance.unit === "hour" /* HOUR */) {
4574
+ return reached.getTime();
4575
+ }
4576
+ const zone = timeZone;
4577
+ return nextZonedDay(startOfZonedDay(reached, zone), zone).getTime() - 1;
4578
+ }
4579
+ var startsPastMaxAdvance = (rule, startAt, now, timeZone) => startAt.getTime() > lastStartOf(rule, now, timeZone);
4540
4580
  function addInZone(from, duration, timeZone, field) {
4541
4581
  if (timeZone) return addDuration(from, duration, timeZone);
4542
4582
  if (duration.unit === "minute" /* MINUTE */ || duration.unit === "hour" /* HOUR */) {
@@ -4584,7 +4624,7 @@ function oldMaxAdvanceOf({
4584
4624
  function periodSlot(dayStart, timeZone, parts, buffer, openMinute, closeMinute) {
4585
4625
  const { ratePeriod } = parts;
4586
4626
  const at = (minutes) => atZonedMinute(dayStart, minutes, timeZone);
4587
- if (ratePeriod === "night" /* NIGHT */) {
4627
+ if (ratePeriod === "night" /* NIGHT */ && parts.arriveLeave !== "opening-hours" /* OPENING_HOURS */) {
4588
4628
  const arrival = zonedParts(dayStart, timeZone).weekday;
4589
4629
  const departure = (arrival + 1) % 7;
4590
4630
  return {
@@ -4597,7 +4637,7 @@ function periodSlot(dayStart, timeZone, parts, buffer, openMinute, closeMinute)
4597
4637
  }
4598
4638
  const from = ratePeriod === "day" /* DAY */ ? openMinute ?? 0 : 0;
4599
4639
  const to = ratePeriod === "day" /* DAY */ ? closeMinute ?? 1440 : 1440;
4600
- const turnaround = parts.wholePeriods ? void 0 : buffer;
4640
+ const turnaround = parts.wholePeriods || ratePeriod === "night" /* NIGHT */ ? void 0 : buffer;
4601
4641
  return {
4602
4642
  startAt: at(from),
4603
4643
  endAt: at(to),
@@ -4734,7 +4774,8 @@ function buildGrid(rule, timeZone, from, to, now, busy = []) {
4734
4774
  asTime(window.bookableFrom, "window.bookableFrom") ?? 0,
4735
4775
  asTime(availability.availableFrom, "availability.availableFrom") ?? 0
4736
4776
  );
4737
- const notAfter = windowEndsAtInZone(rule, now, timeZone)?.getTime() ?? Number.POSITIVE_INFINITY;
4777
+ const notAfter = asTime(window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY;
4778
+ const lastStart = lastStartOf(rule, now, timeZone);
4738
4779
  const blocked = offMarketOf(rule);
4739
4780
  const slots = cellsOf(rule, bookingRuleParts(rule), timeZone, from, to, busy);
4740
4781
  const askedFrom = from.getTime();
@@ -4744,9 +4785,19 @@ function buildGrid(rule, timeZone, from, to, now, busy = []) {
4744
4785
  if (start < askedFrom || start >= askedTo) return false;
4745
4786
  if (start < notBefore || start > notAfter) return false;
4746
4787
  return !isBlocked(blocked, start, bufferEndAt.getTime());
4747
- }).sort((first, second) => +first.startAt - +second.startAt);
4788
+ }).flatMap((cell) => cell.startAt.getTime() > lastStart ? pastMaxAdvance(cell, rule) : [cell]).sort((first, second) => +first.startAt - +second.startAt);
4789
+ }
4790
+ function pastMaxAdvance(cell, rule) {
4791
+ if (soldAsCourse(rule)) return [cell];
4792
+ return bookingMethodOf(rule) === "date-ranges" ? [{ ...cell, canStart: false }] : [];
4793
+ }
4794
+ var endToStart = (previous, next) => next.startAt.getTime() === previous.bufferEndAt.getTime();
4795
+ function cellChainOf(rule, timeZone) {
4796
+ if (rule.ratePeriod !== "day" /* DAY */) return endToStart;
4797
+ const dayOf = (slot) => startOfZonedDay(slot.startAt, timeZone);
4798
+ return (previous, next) => +dayOf(next) === +nextZonedDay(dayOf(previous), timeZone);
4748
4799
  }
4749
- function slotsForWindow(grid, startAt, endAt) {
4800
+ function slotsForWindow(grid, startAt, endAt, chain = endToStart) {
4750
4801
  const startIndex = grid.findIndex((entry) => entry.startAt.getTime() === startAt.getTime());
4751
4802
  if (startIndex < 0) {
4752
4803
  throw new BookingRulesError(`${startAt.toISOString()} is not a bookable slot start for these rules`);
@@ -4758,7 +4809,7 @@ function slotsForWindow(grid, startAt, endAt) {
4758
4809
  for (let index = startIndex; index < grid.length; index++) {
4759
4810
  const entry = grid[index];
4760
4811
  const previous = covered[covered.length - 1];
4761
- if (previous && entry.startAt.getTime() !== previous.bufferEndAt.getTime()) break;
4812
+ if (previous && !chain(previous, entry)) break;
4762
4813
  covered.push(entry);
4763
4814
  if (entry.endAt.getTime() === endAt.getTime()) return covered;
4764
4815
  if (entry.endAt.getTime() > endAt.getTime()) break;
@@ -5203,6 +5254,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5203
5254
  AttributeType,
5204
5255
  BNPL_METHOD_STATUS,
5205
5256
  BNPL_SKIP_REASON,
5257
+ BookingArriveLeave,
5206
5258
  BookingDurationUnit,
5207
5259
  BookingRatePeriod,
5208
5260
  BookingResourceKind,
@@ -5328,6 +5380,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5328
5380
  calendarDate,
5329
5381
  canTransition,
5330
5382
  capacityOf,
5383
+ cellChainOf,
5331
5384
  cheapestCompositeItem,
5332
5385
  cheapestCompositePrice,
5333
5386
  checkPartySize,
@@ -5452,6 +5505,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5452
5505
  signReportForDisplay,
5453
5506
  slotsForWindow,
5454
5507
  soldAsCourse,
5508
+ startsPastMaxAdvance,
5455
5509
  stringifyMinorUnits,
5456
5510
  subtractAmounts,
5457
5511
  toBase,