@final-commerce/common 2.12.0-staging.3 → 2.12.0-staging.5

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;
@@ -1835,6 +1841,10 @@ interface PlanCourseInput {
1835
1841
  now: Date;
1836
1842
  }
1837
1843
  declare function courseSessions(rule: BookingRulesInput, timeZone: string): GridSlot[];
1844
+ declare function courseSpan(rule: BookingRulesInput, timeZone: string): {
1845
+ from: Date;
1846
+ to: Date;
1847
+ };
1838
1848
  declare const courseStarted: (rule: BookingRulesInput, sessions: GridSlot[], now: Date) => boolean;
1839
1849
  declare function courseStartedInZone(rule: BookingRulesInput, sessions: GridSlot[], now: Date, timeZone: string): boolean;
1840
1850
  declare function planCourse({ rule, timeZone, presence, now }: PlanCourseInput): GridSlot[];
@@ -1940,6 +1950,7 @@ declare function buildAvailability({ productId, bookingRulesId, rule, resources,
1940
1950
  course: ({
1941
1951
  sessions: number;
1942
1952
  alreadyStarted: boolean;
1953
+ beyondWindow: boolean;
1943
1954
  sessionTimes: {
1944
1955
  startAt: Date;
1945
1956
  endAt: Date;
@@ -2179,4 +2190,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2179
2190
  }];
2180
2191
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2181
2192
 
2182
- 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, 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 };
2193
+ 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, 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, 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;
@@ -1835,6 +1841,10 @@ interface PlanCourseInput {
1835
1841
  now: Date;
1836
1842
  }
1837
1843
  declare function courseSessions(rule: BookingRulesInput, timeZone: string): GridSlot[];
1844
+ declare function courseSpan(rule: BookingRulesInput, timeZone: string): {
1845
+ from: Date;
1846
+ to: Date;
1847
+ };
1838
1848
  declare const courseStarted: (rule: BookingRulesInput, sessions: GridSlot[], now: Date) => boolean;
1839
1849
  declare function courseStartedInZone(rule: BookingRulesInput, sessions: GridSlot[], now: Date, timeZone: string): boolean;
1840
1850
  declare function planCourse({ rule, timeZone, presence, now }: PlanCourseInput): GridSlot[];
@@ -1940,6 +1950,7 @@ declare function buildAvailability({ productId, bookingRulesId, rule, resources,
1940
1950
  course: ({
1941
1951
  sessions: number;
1942
1952
  alreadyStarted: boolean;
1953
+ beyondWindow: boolean;
1943
1954
  sessionTimes: {
1944
1955
  startAt: Date;
1945
1956
  endAt: Date;
@@ -2179,4 +2190,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2179
2190
  }];
2180
2191
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2181
2192
 
2182
- 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, 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 };
2193
+ 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, 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, 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,
@@ -169,6 +170,7 @@ __export(index_exports, {
169
170
  conditionSummary: () => conditionSummary,
170
171
  convertFixedFeeToLocalCurrency: () => convertFixedFeeToLocalCurrency,
171
172
  courseSessions: () => courseSessions,
173
+ courseSpan: () => courseSpan,
172
174
  courseStarted: () => courseStarted,
173
175
  courseStartedInZone: () => courseStartedInZone,
174
176
  createAmount: () => createAmount,
@@ -279,6 +281,7 @@ __export(index_exports, {
279
281
  signReportForDisplay: () => signReportForDisplay,
280
282
  slotsForWindow: () => slotsForWindow,
281
283
  soldAsCourse: () => soldAsCourse,
284
+ startsPastMaxAdvance: () => startsPastMaxAdvance,
282
285
  stringifyMinorUnits: () => stringifyMinorUnits,
283
286
  subtractAmounts: () => subtractAmounts,
284
287
  toBase: () => toBase,
@@ -782,6 +785,11 @@ var BookingSessionSale = /* @__PURE__ */ ((BookingSessionSale2) => {
782
785
  BookingSessionSale2["COURSE"] = "course";
783
786
  return BookingSessionSale2;
784
787
  })(BookingSessionSale || {});
788
+ var BookingArriveLeave = /* @__PURE__ */ ((BookingArriveLeave2) => {
789
+ BookingArriveLeave2["SET_TIMES"] = "set-times";
790
+ BookingArriveLeave2["OPENING_HOURS"] = "opening-hours";
791
+ return BookingArriveLeave2;
792
+ })(BookingArriveLeave || {});
785
793
  var BookingResourceKind = /* @__PURE__ */ ((BookingResourceKind2) => {
786
794
  BookingResourceKind2["ASSET"] = "asset";
787
795
  BookingResourceKind2["ROOM"] = "room";
@@ -3824,7 +3832,7 @@ function buildAvailability({
3824
3832
  // The per-booking limits, so a stepper is bounded by the rules (G7) instead of a number in the flow.
3825
3833
  maxQtyPerBooking: rule.slot.maxQtyPerBooking,
3826
3834
  maxPartySize: rule.slot.maxPartySize,
3827
- // Why a day can come back empty. Past this instant the rule refuses everything, so the UI
3835
+ // Why a day can come back empty. Past this instant the rule refuses every start, so the UI
3828
3836
  // can say "beyond the booking window" where it would otherwise claim "nothing free".
3829
3837
  bookableUntil,
3830
3838
  // The comparison itself, not just the boundary: deciding whether a day lies past the
@@ -3907,6 +3915,7 @@ function courseAvailability(rule, resources, byResource, productId, shared, now)
3907
3915
  if (resources.length === 0) return void 0;
3908
3916
  const sessions = courseSessions(rule, resources[0].timeZone);
3909
3917
  const alreadyStarted = courseStartedInZone(rule, sessions, now, resources[0].timeZone);
3918
+ const beyondWindow = startsPastMaxAdvance(rule, sessions[0].startAt, now, resources[0].timeZone);
3910
3919
  const free = resources.map((resource) => {
3911
3920
  const mine = byResource.get(resource.id) ?? [];
3912
3921
  const everySession = sessions.every((session) => withinPresence(session, resource.timeZone, resource.presence));
@@ -3914,13 +3923,14 @@ function courseAvailability(rule, resources, byResource, productId, shared, now)
3914
3923
  const { taken, foreignProductId } = occupancyIn(mine, productId, session.startAt, session.bufferEndAt, shared);
3915
3924
  return foreignProductId ? 0 : Math.max(capacityOf(rule, resource) - taken, 0);
3916
3925
  });
3917
- const fewest = everySession && !alreadyStarted ? Math.min(...freePerSession) : 0;
3926
+ const fewest = everySession && !alreadyStarted && !beyondWindow ? Math.min(...freePerSession) : 0;
3918
3927
  return Number.isFinite(fewest) ? { resourceId: resource.id, free: fewest } : { resourceId: resource.id, free: UNLIMITED_PLACES, unlimited: true };
3919
3928
  });
3920
3929
  return withMaxQtyNow(
3921
3930
  {
3922
3931
  sessions: sessions.length,
3923
3932
  alreadyStarted,
3933
+ beyondWindow,
3924
3934
  sessionTimes: sessions.map(({ startAt, endAt }) => ({ startAt, endAt })),
3925
3935
  startAt: sessions[0].startAt,
3926
3936
  endAt: sessions[sessions.length - 1].endAt,
@@ -4065,6 +4075,7 @@ function noticeAboveAdvance({
4065
4075
  // booking/plan.ts
4066
4076
  var DEFAULT_HOLD_MINUTES = 10;
4067
4077
  function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }) {
4078
+ if (!soldAsCourse(rule)) checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4068
4079
  const grid = buildGrid(rule, timeZone, startAt, endAt, now, busy).filter(
4069
4080
  (slot) => withinPresence(slot, timeZone, presence)
4070
4081
  );
@@ -4078,6 +4089,11 @@ function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }
4078
4089
  const bufferEndAt = rule.ratePeriod === "hour" /* HOUR */ || wholePeriods ? buffer ? addDuration(last.endAt, buffer, timeZone) : new Date(last.endAt.getTime()) : last.bufferEndAt;
4079
4090
  return { slots, periods, endAt: last.endAt, bufferEndAt };
4080
4091
  }
4092
+ function checkStartWithinMaxAdvance(rule, timeZone, startAt, now) {
4093
+ if (startsPastMaxAdvance(rule, startAt, now, timeZone)) {
4094
+ throw new BookingRulesError(`${startAt.toISOString()} is past the booking window of these rules`);
4095
+ }
4096
+ }
4081
4097
  function checkStay(parts, timeZone, startAt, periods) {
4082
4098
  if (parts.method !== "date-ranges") return;
4083
4099
  const stay = { count: periods, unit: periodUnitOf(parts) };
@@ -4110,6 +4126,7 @@ function windowForPeriods({ rule, timeZone, startAt, periods, now }) {
4110
4126
  if (!Number.isInteger(periods) || periods < 1) {
4111
4127
  throw new BookingRulesError(`periods must be a whole number of at least 1, got ${String(periods)}`);
4112
4128
  }
4129
+ checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4113
4130
  const parts = bookingRuleParts(rule);
4114
4131
  checkStay(parts, timeZone, startAt, periods);
4115
4132
  const wholePeriods = parts.method === "date-ranges" && parts.wholePeriods;
@@ -4136,6 +4153,7 @@ function rentalEnds(input) {
4136
4153
  const { rule, timeZone, startAt, now, untilDay } = input;
4137
4154
  const parts = bookingRuleParts(rule);
4138
4155
  if (parts.method !== "date-ranges") throw new BookingRulesError("Only date-range rules book a stay");
4156
+ checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
4139
4157
  const horizon = shopDayRange(untilDay, 1, timeZone).to;
4140
4158
  if (horizon <= startAt) throw new BookingRulesError(`untilDay ${untilDay} is before the stay starts`);
4141
4159
  const gridUntil = (end) => buildGrid(rule, timeZone, startAt, new Date(Math.min(end, startAt.getTime() + 366 * 1440 * 6e4)), now);
@@ -4218,14 +4236,30 @@ function wholePeriodsIn(ratePeriod, timeZone, startAt, endAt, days) {
4218
4236
  return months;
4219
4237
  }
4220
4238
  function courseSessions(rule, timeZone) {
4221
- const { bookableFrom, bookableTo } = rule.window;
4222
- if (!bookableFrom || !bookableTo) throw new BookingRulesError("A course needs both course dates");
4223
- const sessions = sessionCells(rule, timeZone, new Date(bookableFrom), new Date(bookableTo)).sort(
4224
- (first, second) => +first.startAt - +second.startAt
4225
- );
4239
+ const [from, to] = rule.sessions?.weekly?.length ? weeklyCourseRange(rule) : datesCourseRange(rule.sessions?.dates ?? [], timeZone);
4240
+ const sessions = sessionCells(rule, timeZone, from, to).sort((first, second) => +first.startAt - +second.startAt);
4226
4241
  if (sessions.length === 0) throw new BookingRulesError("These course dates hold no session");
4227
4242
  return sessions;
4228
4243
  }
4244
+ function courseSpan(rule, timeZone) {
4245
+ const sessions = courseSessions(rule, timeZone);
4246
+ return { from: sessions[0].startAt, to: sessions[sessions.length - 1].bufferEndAt };
4247
+ }
4248
+ function weeklyCourseRange(rule) {
4249
+ const { bookableFrom, bookableTo } = rule.window;
4250
+ if (!bookableFrom || !bookableTo) throw new BookingRulesError("A course needs both course dates");
4251
+ return [new Date(bookableFrom), new Date(bookableTo)];
4252
+ }
4253
+ function datesCourseRange(dates, timeZone) {
4254
+ if (dates.length === 0) throw new BookingRulesError("A course needs its sessions");
4255
+ const days = dates.map(({ date }) => date).sort();
4256
+ const [firstYear, firstMonth, firstDay] = calendarDate(days[0]);
4257
+ const [lastYear, lastMonth, lastDay] = calendarDate(days[days.length - 1]);
4258
+ return [
4259
+ instantFromLocal(firstYear, firstMonth, firstDay, 0, timeZone),
4260
+ instantFromLocal(lastYear, lastMonth, lastDay + 1, 0, timeZone)
4261
+ ];
4262
+ }
4229
4263
  var courseStarted = (rule, sessions, now) => sessions[0].startAt.getTime() < now.getTime() + (rule.window.minNoticeMinutes ?? 0) * 6e4;
4230
4264
  function courseStartedInZone(rule, sessions, now, timeZone) {
4231
4265
  const { minNotice } = ruleDurationsOf(rule);
@@ -4238,6 +4272,9 @@ function planCourse({ rule, timeZone, presence, now }) {
4238
4272
  }
4239
4273
  if (courseStartedInZone(rule, sessions, now, timeZone))
4240
4274
  throw new BookingRulesError("This course has already started");
4275
+ if (startsPastMaxAdvance(rule, sessions[0].startAt, now, timeZone)) {
4276
+ throw new BookingRulesError("This course starts past the booking window of these rules");
4277
+ }
4241
4278
  return sessions;
4242
4279
  }
4243
4280
  function holdExpiresAt(rule, now) {
@@ -4395,12 +4432,21 @@ var OLD_FIELDS = [
4395
4432
  "date-ranges": "dateRanges.weeklyHours"
4396
4433
  }
4397
4434
  },
4398
- ...["availability.arrivalDays", "checkInTime", "checkOutTime", "checkTimesByWeekday"].map((path) => ({
4435
+ {
4436
+ path: "availability.arrivalDays",
4437
+ home: {
4438
+ "time-slots": { unread: "date ranges only" },
4439
+ sessions: { unread: "date ranges only" },
4440
+ "date-ranges": "dateRanges.arrivalDays"
4441
+ }
4442
+ },
4443
+ // An `opening-hours` night has no check times (FC-1503): switching to it drops the old ones, said in a note.
4444
+ ...["checkInTime", "checkOutTime", "checkTimesByWeekday"].map((path) => ({
4399
4445
  path,
4400
4446
  home: {
4401
4447
  "time-slots": { unread: "date ranges only" },
4402
4448
  sessions: { unread: "date ranges only" },
4403
- "date-ranges": `dateRanges.${path.replace("availability.", "")}`
4449
+ "date-ranges": ({ dateRanges }) => dateRanges?.arriveLeave === "opening-hours" /* OPENING_HOURS */ ? { dropped: "opening-hours nights have no check times" } : `dateRanges.${path}`
4404
4450
  }
4405
4451
  }))
4406
4452
  ];
@@ -4513,13 +4559,23 @@ function windowEndsAt(rule, now) {
4513
4559
  return Number.isFinite(ends) ? new Date(ends) : null;
4514
4560
  }
4515
4561
  function windowEndsAtInZone(rule, now, timeZone) {
4516
- const { maxAdvance } = ruleDurationsOf(rule);
4517
4562
  const ends = Math.min(
4518
- maxAdvance ? addInZone(now, maxAdvance, timeZone, "window.maxAdvance").getTime() : Number.POSITIVE_INFINITY,
4563
+ lastStartOf(rule, now, timeZone),
4519
4564
  asTime(rule.window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY
4520
4565
  );
4521
4566
  return Number.isFinite(ends) ? new Date(ends) : null;
4522
4567
  }
4568
+ function lastStartOf(rule, now, timeZone) {
4569
+ const { maxAdvance } = ruleDurationsOf(rule);
4570
+ if (!maxAdvance) return Number.POSITIVE_INFINITY;
4571
+ const reached = addInZone(now, maxAdvance, timeZone, "window.maxAdvance");
4572
+ if (maxAdvance.unit === "minute" /* MINUTE */ || maxAdvance.unit === "hour" /* HOUR */) {
4573
+ return reached.getTime();
4574
+ }
4575
+ const zone = timeZone;
4576
+ return nextZonedDay(startOfZonedDay(reached, zone), zone).getTime() - 1;
4577
+ }
4578
+ var startsPastMaxAdvance = (rule, startAt, now, timeZone) => startAt.getTime() > lastStartOf(rule, now, timeZone);
4523
4579
  function addInZone(from, duration, timeZone, field) {
4524
4580
  if (timeZone) return addDuration(from, duration, timeZone);
4525
4581
  if (duration.unit === "minute" /* MINUTE */ || duration.unit === "hour" /* HOUR */) {
@@ -4567,7 +4623,7 @@ function oldMaxAdvanceOf({
4567
4623
  function periodSlot(dayStart, timeZone, parts, buffer, openMinute, closeMinute) {
4568
4624
  const { ratePeriod } = parts;
4569
4625
  const at = (minutes) => atZonedMinute(dayStart, minutes, timeZone);
4570
- if (ratePeriod === "night" /* NIGHT */) {
4626
+ if (ratePeriod === "night" /* NIGHT */ && parts.arriveLeave !== "opening-hours" /* OPENING_HOURS */) {
4571
4627
  const arrival = zonedParts(dayStart, timeZone).weekday;
4572
4628
  const departure = (arrival + 1) % 7;
4573
4629
  return {
@@ -4580,7 +4636,7 @@ function periodSlot(dayStart, timeZone, parts, buffer, openMinute, closeMinute)
4580
4636
  }
4581
4637
  const from = ratePeriod === "day" /* DAY */ ? openMinute ?? 0 : 0;
4582
4638
  const to = ratePeriod === "day" /* DAY */ ? closeMinute ?? 1440 : 1440;
4583
- const turnaround = parts.wholePeriods ? void 0 : buffer;
4639
+ const turnaround = parts.wholePeriods || ratePeriod === "night" /* NIGHT */ ? void 0 : buffer;
4584
4640
  return {
4585
4641
  startAt: at(from),
4586
4642
  endAt: at(to),
@@ -4717,7 +4773,8 @@ function buildGrid(rule, timeZone, from, to, now, busy = []) {
4717
4773
  asTime(window.bookableFrom, "window.bookableFrom") ?? 0,
4718
4774
  asTime(availability.availableFrom, "availability.availableFrom") ?? 0
4719
4775
  );
4720
- const notAfter = windowEndsAtInZone(rule, now, timeZone)?.getTime() ?? Number.POSITIVE_INFINITY;
4776
+ const notAfter = asTime(window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY;
4777
+ const lastStart = lastStartOf(rule, now, timeZone);
4721
4778
  const blocked = offMarketOf(rule);
4722
4779
  const slots = cellsOf(rule, bookingRuleParts(rule), timeZone, from, to, busy);
4723
4780
  const askedFrom = from.getTime();
@@ -4727,7 +4784,11 @@ function buildGrid(rule, timeZone, from, to, now, busy = []) {
4727
4784
  if (start < askedFrom || start >= askedTo) return false;
4728
4785
  if (start < notBefore || start > notAfter) return false;
4729
4786
  return !isBlocked(blocked, start, bufferEndAt.getTime());
4730
- }).sort((first, second) => +first.startAt - +second.startAt);
4787
+ }).flatMap((cell) => cell.startAt.getTime() > lastStart ? pastMaxAdvance(cell, rule) : [cell]).sort((first, second) => +first.startAt - +second.startAt);
4788
+ }
4789
+ function pastMaxAdvance(cell, rule) {
4790
+ if (soldAsCourse(rule)) return [cell];
4791
+ return bookingMethodOf(rule) === "date-ranges" ? [{ ...cell, canStart: false }] : [];
4731
4792
  }
4732
4793
  function slotsForWindow(grid, startAt, endAt) {
4733
4794
  const startIndex = grid.findIndex((entry) => entry.startAt.getTime() === startAt.getTime());
@@ -5186,6 +5247,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5186
5247
  AttributeType,
5187
5248
  BNPL_METHOD_STATUS,
5188
5249
  BNPL_SKIP_REASON,
5250
+ BookingArriveLeave,
5189
5251
  BookingDurationUnit,
5190
5252
  BookingRatePeriod,
5191
5253
  BookingResourceKind,
@@ -5324,6 +5386,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5324
5386
  conditionSummary,
5325
5387
  convertFixedFeeToLocalCurrency,
5326
5388
  courseSessions,
5389
+ courseSpan,
5327
5390
  courseStarted,
5328
5391
  courseStartedInZone,
5329
5392
  createAmount,
@@ -5434,6 +5497,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
5434
5497
  signReportForDisplay,
5435
5498
  slotsForWindow,
5436
5499
  soldAsCourse,
5500
+ startsPastMaxAdvance,
5437
5501
  stringifyMinorUnits,
5438
5502
  subtractAmounts,
5439
5503
  toBase,