@final-commerce/common 2.2.3-staging3.2 → 2.3.0-staging.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -387,7 +387,8 @@ declare enum StripeCurrencyCode {
387
387
 
388
388
  declare enum ProductType {
389
389
  SIMPLE = "simple",
390
- VARIABLE = "variable"
390
+ VARIABLE = "variable",
391
+ BOOKING = "booking"
391
392
  }
392
393
  declare enum ProductStatus {
393
394
  ACTIVE = "active",
@@ -401,6 +402,43 @@ declare enum PaymentProcessor {
401
402
  EXTERNAL = "external"
402
403
  }
403
404
 
405
+ declare enum BookingType {
406
+ RENTAL = "rental",
407
+ APPOINTMENT = "appointment",
408
+ OVERNIGHT = "overnight",
409
+ GROUP = "group"
410
+ }
411
+ declare enum BookingRatePeriod {
412
+ SLOT = "slot",
413
+ DAY = "day",
414
+ NIGHT = "night",
415
+ WEEK = "week",
416
+ MONTH = "month"
417
+ }
418
+ declare enum BookingResourceKind {
419
+ ASSET = "asset",
420
+ ROOM = "room",
421
+ PROPERTY = "property",
422
+ SPACE = "space",
423
+ STAFF = "staff",
424
+ TABLE = "table"
425
+ }
426
+ declare enum ReservationStatus {
427
+ HELD = "held",
428
+ CONFIRMED = "confirmed",
429
+ CANCELLED = "cancelled",
430
+ EXPIRED = "expired"
431
+ }
432
+ declare enum BookingResourceStatus {
433
+ ACTIVE = "active",
434
+ INACTIVE = "inactive"
435
+ }
436
+ declare enum ResourceAvailabilityState {
437
+ AVAILABLE = "available",
438
+ FULLY_BOOKED = "fullyBooked",
439
+ NO_HOURS_IN_RANGE = "noHoursInRange"
440
+ }
441
+
404
442
  interface CurrencyConfig {
405
443
  minorUnits: number;
406
444
  symbol: string;
@@ -764,6 +802,13 @@ interface OrderLineItem {
764
802
  returnedQuantity?: number;
765
803
  [key: string]: unknown;
766
804
  }
805
+ interface OrderReservationForContext {
806
+ internalId?: string;
807
+ quantity?: number;
808
+ fulfilledQuantity?: number;
809
+ returnedQuantity?: number;
810
+ [key: string]: unknown;
811
+ }
767
812
  interface SplitPaymentPayment {
768
813
  amount?: number;
769
814
  [key: string]: unknown;
@@ -779,6 +824,7 @@ interface OrderContext {
779
824
  paymentMethods: OrderPaymentMethod[];
780
825
  refunds: OrderRefund[];
781
826
  lineItems: OrderLineItem[];
827
+ reservations: OrderReservationForContext[];
782
828
  };
783
829
  computed: {
784
830
  balance: number;
@@ -892,6 +938,7 @@ interface OrderLikeForContext {
892
938
  refunds?: OrderRefund[];
893
939
  refund?: OrderRefund[];
894
940
  lineItems?: OrderLineItem[];
941
+ reservations?: OrderReservationForContext[];
895
942
  }
896
943
  interface OrderLikeForLegacyInference extends OrderLikeForContext {
897
944
  status?: string;
@@ -1181,8 +1228,149 @@ interface ConfigUpdatedPayload {
1181
1228
  }
1182
1229
  type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
1183
1230
 
1184
- declare const ADYEN_ROLLOUT_COUNTRY_CODES: Set<string>;
1185
- declare function isAdyenRolloutCountry(alpha2: string): boolean;
1231
+ interface WeeklyHours {
1232
+ weekday: number;
1233
+ openMinute: number;
1234
+ closeMinute: number;
1235
+ }
1236
+ interface BookingRulesInput {
1237
+ ratePeriod: BookingRatePeriod | `${BookingRatePeriod}`;
1238
+ slot: {
1239
+ lengthMinutes: number;
1240
+ bufferMinutes?: number;
1241
+ minimumToRun?: number;
1242
+ minStay?: number;
1243
+ maxStay?: number;
1244
+ sharedAcrossProducts?: boolean;
1245
+ };
1246
+ window: {
1247
+ maxAdvanceDays?: number;
1248
+ minNoticeMinutes?: number;
1249
+ holdMinutes?: number;
1250
+ bookableFrom?: Date | string | null;
1251
+ bookableTo?: Date | string | null;
1252
+ };
1253
+ availability: {
1254
+ weeklyHours?: WeeklyHours[];
1255
+ offMarket?: {
1256
+ from: Date | string;
1257
+ to: Date | string;
1258
+ }[];
1259
+ arrivalDays?: number[];
1260
+ availableFrom?: Date | string | null;
1261
+ };
1262
+ checkInTime?: string | null;
1263
+ checkOutTime?: string | null;
1264
+ }
1265
+ interface BusyWindow {
1266
+ startAt: Date;
1267
+ bufferEndAt: Date;
1268
+ }
1269
+ interface GridSlot {
1270
+ startAt: Date;
1271
+ endAt: Date;
1272
+ bufferEndAt: Date;
1273
+ canStart: boolean;
1274
+ }
1275
+ declare class BookingRulesError extends Error {
1276
+ constructor(message: string);
1277
+ }
1278
+
1279
+ declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
1280
+ declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
1281
+ declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
1282
+
1283
+ interface BookingOccupancy {
1284
+ resourceId: string;
1285
+ productId: string;
1286
+ qty: number;
1287
+ startAt: Date;
1288
+ bufferEndAt: Date;
1289
+ }
1290
+ interface BookingResourceInput {
1291
+ id: string;
1292
+ name: string;
1293
+ seats?: number | null;
1294
+ timeZone: string;
1295
+ presence?: WeeklyHours[] | null;
1296
+ }
1297
+ interface ResourceAvailability {
1298
+ resourceId: string;
1299
+ name: string;
1300
+ capacity: number;
1301
+ booked: number;
1302
+ free: number;
1303
+ }
1304
+ interface AvailabilitySlot extends GridSlot {
1305
+ capacity: number;
1306
+ booked: number;
1307
+ free: number;
1308
+ resources: ResourceAvailability[];
1309
+ }
1310
+ interface ResourceInWindow {
1311
+ resourceId: string;
1312
+ name: string;
1313
+ slots: number;
1314
+ free: number;
1315
+ state: ResourceAvailabilityState;
1316
+ }
1317
+ interface AvailabilityInput {
1318
+ productId: string;
1319
+ bookingRulesId?: string;
1320
+ bookingType?: BookingType;
1321
+ rule: BookingRulesInput;
1322
+ resources: BookingResourceInput[];
1323
+ occupied: BookingOccupancy[];
1324
+ from: Date;
1325
+ to: Date;
1326
+ now: Date;
1327
+ }
1328
+ declare const withinPresence: (slot: GridSlot, timeZone: string, presence?: WeeklyHours[] | null) => boolean;
1329
+ declare function occupancyIn(occupied: BookingOccupancy[], productId: string, startAt: Date, bufferEndAt: Date, shared: boolean): {
1330
+ taken: number;
1331
+ foreignProductId?: string;
1332
+ };
1333
+ declare function buildAvailability({ productId, bookingRulesId, bookingType, rule, resources, occupied, from, to, now, }: AvailabilityInput): {
1334
+ resources: ResourceInWindow[];
1335
+ slots: AvailabilitySlot[];
1336
+ productId: string;
1337
+ bookingRulesId: string | undefined;
1338
+ bookingType: BookingType | undefined;
1339
+ ratePeriod: "slot" | "day" | "night" | "week" | "month" | BookingRatePeriod;
1340
+ minimumToRun: number | undefined;
1341
+ minStay: number | undefined;
1342
+ maxStay: number | undefined;
1343
+ bookableUntil: Date | null;
1344
+ beyondWindow: boolean;
1345
+ };
1346
+ interface ResourcePresenceRow {
1347
+ resourceId: string;
1348
+ outletId: string;
1349
+ weeklyHours?: WeeklyHours[] | null;
1350
+ }
1351
+ declare function presentAt<T extends {
1352
+ id: string;
1353
+ }>(resources: T[], rows: ResourcePresenceRow[], outletId?: string): {
1354
+ resource: T;
1355
+ presence?: WeeklyHours[] | null;
1356
+ }[];
1357
+
1358
+ declare const DEFAULT_HOLD_MINUTES = 10;
1359
+ interface PlanWindowInput {
1360
+ rule: BookingRulesInput;
1361
+ timeZone: string;
1362
+ presence?: WeeklyHours[] | null;
1363
+ startAt: Date;
1364
+ endAt: Date;
1365
+ now: Date;
1366
+ busy?: BusyWindow[];
1367
+ }
1368
+ declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy }: PlanWindowInput): {
1369
+ slots: GridSlot[];
1370
+ endAt: Date;
1371
+ bufferEndAt: Date;
1372
+ };
1373
+ declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
1186
1374
 
1187
1375
  interface CurrencyRate {
1188
1376
  rate: number;
@@ -1195,4 +1383,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
1195
1383
  declare const OtherFixedRates: Record<string, CurrencyRate>;
1196
1384
  declare const COUNTRY_CURRENCIES: Record<string, string>;
1197
1385
 
1198
- export { ADYEN_ROLLOUT_COUNTRY_CODES, type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, 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, UserTypes, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
1386
+ export { type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, 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, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, 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, UserTypes, type WeeklyHours, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, holdExpiresAt, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, planWindow, presentAt, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -387,7 +387,8 @@ declare enum StripeCurrencyCode {
387
387
 
388
388
  declare enum ProductType {
389
389
  SIMPLE = "simple",
390
- VARIABLE = "variable"
390
+ VARIABLE = "variable",
391
+ BOOKING = "booking"
391
392
  }
392
393
  declare enum ProductStatus {
393
394
  ACTIVE = "active",
@@ -401,6 +402,43 @@ declare enum PaymentProcessor {
401
402
  EXTERNAL = "external"
402
403
  }
403
404
 
405
+ declare enum BookingType {
406
+ RENTAL = "rental",
407
+ APPOINTMENT = "appointment",
408
+ OVERNIGHT = "overnight",
409
+ GROUP = "group"
410
+ }
411
+ declare enum BookingRatePeriod {
412
+ SLOT = "slot",
413
+ DAY = "day",
414
+ NIGHT = "night",
415
+ WEEK = "week",
416
+ MONTH = "month"
417
+ }
418
+ declare enum BookingResourceKind {
419
+ ASSET = "asset",
420
+ ROOM = "room",
421
+ PROPERTY = "property",
422
+ SPACE = "space",
423
+ STAFF = "staff",
424
+ TABLE = "table"
425
+ }
426
+ declare enum ReservationStatus {
427
+ HELD = "held",
428
+ CONFIRMED = "confirmed",
429
+ CANCELLED = "cancelled",
430
+ EXPIRED = "expired"
431
+ }
432
+ declare enum BookingResourceStatus {
433
+ ACTIVE = "active",
434
+ INACTIVE = "inactive"
435
+ }
436
+ declare enum ResourceAvailabilityState {
437
+ AVAILABLE = "available",
438
+ FULLY_BOOKED = "fullyBooked",
439
+ NO_HOURS_IN_RANGE = "noHoursInRange"
440
+ }
441
+
404
442
  interface CurrencyConfig {
405
443
  minorUnits: number;
406
444
  symbol: string;
@@ -764,6 +802,13 @@ interface OrderLineItem {
764
802
  returnedQuantity?: number;
765
803
  [key: string]: unknown;
766
804
  }
805
+ interface OrderReservationForContext {
806
+ internalId?: string;
807
+ quantity?: number;
808
+ fulfilledQuantity?: number;
809
+ returnedQuantity?: number;
810
+ [key: string]: unknown;
811
+ }
767
812
  interface SplitPaymentPayment {
768
813
  amount?: number;
769
814
  [key: string]: unknown;
@@ -779,6 +824,7 @@ interface OrderContext {
779
824
  paymentMethods: OrderPaymentMethod[];
780
825
  refunds: OrderRefund[];
781
826
  lineItems: OrderLineItem[];
827
+ reservations: OrderReservationForContext[];
782
828
  };
783
829
  computed: {
784
830
  balance: number;
@@ -892,6 +938,7 @@ interface OrderLikeForContext {
892
938
  refunds?: OrderRefund[];
893
939
  refund?: OrderRefund[];
894
940
  lineItems?: OrderLineItem[];
941
+ reservations?: OrderReservationForContext[];
895
942
  }
896
943
  interface OrderLikeForLegacyInference extends OrderLikeForContext {
897
944
  status?: string;
@@ -1181,8 +1228,149 @@ interface ConfigUpdatedPayload {
1181
1228
  }
1182
1229
  type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
1183
1230
 
1184
- declare const ADYEN_ROLLOUT_COUNTRY_CODES: Set<string>;
1185
- declare function isAdyenRolloutCountry(alpha2: string): boolean;
1231
+ interface WeeklyHours {
1232
+ weekday: number;
1233
+ openMinute: number;
1234
+ closeMinute: number;
1235
+ }
1236
+ interface BookingRulesInput {
1237
+ ratePeriod: BookingRatePeriod | `${BookingRatePeriod}`;
1238
+ slot: {
1239
+ lengthMinutes: number;
1240
+ bufferMinutes?: number;
1241
+ minimumToRun?: number;
1242
+ minStay?: number;
1243
+ maxStay?: number;
1244
+ sharedAcrossProducts?: boolean;
1245
+ };
1246
+ window: {
1247
+ maxAdvanceDays?: number;
1248
+ minNoticeMinutes?: number;
1249
+ holdMinutes?: number;
1250
+ bookableFrom?: Date | string | null;
1251
+ bookableTo?: Date | string | null;
1252
+ };
1253
+ availability: {
1254
+ weeklyHours?: WeeklyHours[];
1255
+ offMarket?: {
1256
+ from: Date | string;
1257
+ to: Date | string;
1258
+ }[];
1259
+ arrivalDays?: number[];
1260
+ availableFrom?: Date | string | null;
1261
+ };
1262
+ checkInTime?: string | null;
1263
+ checkOutTime?: string | null;
1264
+ }
1265
+ interface BusyWindow {
1266
+ startAt: Date;
1267
+ bufferEndAt: Date;
1268
+ }
1269
+ interface GridSlot {
1270
+ startAt: Date;
1271
+ endAt: Date;
1272
+ bufferEndAt: Date;
1273
+ canStart: boolean;
1274
+ }
1275
+ declare class BookingRulesError extends Error {
1276
+ constructor(message: string);
1277
+ }
1278
+
1279
+ declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
1280
+ declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
1281
+ declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
1282
+
1283
+ interface BookingOccupancy {
1284
+ resourceId: string;
1285
+ productId: string;
1286
+ qty: number;
1287
+ startAt: Date;
1288
+ bufferEndAt: Date;
1289
+ }
1290
+ interface BookingResourceInput {
1291
+ id: string;
1292
+ name: string;
1293
+ seats?: number | null;
1294
+ timeZone: string;
1295
+ presence?: WeeklyHours[] | null;
1296
+ }
1297
+ interface ResourceAvailability {
1298
+ resourceId: string;
1299
+ name: string;
1300
+ capacity: number;
1301
+ booked: number;
1302
+ free: number;
1303
+ }
1304
+ interface AvailabilitySlot extends GridSlot {
1305
+ capacity: number;
1306
+ booked: number;
1307
+ free: number;
1308
+ resources: ResourceAvailability[];
1309
+ }
1310
+ interface ResourceInWindow {
1311
+ resourceId: string;
1312
+ name: string;
1313
+ slots: number;
1314
+ free: number;
1315
+ state: ResourceAvailabilityState;
1316
+ }
1317
+ interface AvailabilityInput {
1318
+ productId: string;
1319
+ bookingRulesId?: string;
1320
+ bookingType?: BookingType;
1321
+ rule: BookingRulesInput;
1322
+ resources: BookingResourceInput[];
1323
+ occupied: BookingOccupancy[];
1324
+ from: Date;
1325
+ to: Date;
1326
+ now: Date;
1327
+ }
1328
+ declare const withinPresence: (slot: GridSlot, timeZone: string, presence?: WeeklyHours[] | null) => boolean;
1329
+ declare function occupancyIn(occupied: BookingOccupancy[], productId: string, startAt: Date, bufferEndAt: Date, shared: boolean): {
1330
+ taken: number;
1331
+ foreignProductId?: string;
1332
+ };
1333
+ declare function buildAvailability({ productId, bookingRulesId, bookingType, rule, resources, occupied, from, to, now, }: AvailabilityInput): {
1334
+ resources: ResourceInWindow[];
1335
+ slots: AvailabilitySlot[];
1336
+ productId: string;
1337
+ bookingRulesId: string | undefined;
1338
+ bookingType: BookingType | undefined;
1339
+ ratePeriod: "slot" | "day" | "night" | "week" | "month" | BookingRatePeriod;
1340
+ minimumToRun: number | undefined;
1341
+ minStay: number | undefined;
1342
+ maxStay: number | undefined;
1343
+ bookableUntil: Date | null;
1344
+ beyondWindow: boolean;
1345
+ };
1346
+ interface ResourcePresenceRow {
1347
+ resourceId: string;
1348
+ outletId: string;
1349
+ weeklyHours?: WeeklyHours[] | null;
1350
+ }
1351
+ declare function presentAt<T extends {
1352
+ id: string;
1353
+ }>(resources: T[], rows: ResourcePresenceRow[], outletId?: string): {
1354
+ resource: T;
1355
+ presence?: WeeklyHours[] | null;
1356
+ }[];
1357
+
1358
+ declare const DEFAULT_HOLD_MINUTES = 10;
1359
+ interface PlanWindowInput {
1360
+ rule: BookingRulesInput;
1361
+ timeZone: string;
1362
+ presence?: WeeklyHours[] | null;
1363
+ startAt: Date;
1364
+ endAt: Date;
1365
+ now: Date;
1366
+ busy?: BusyWindow[];
1367
+ }
1368
+ declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy }: PlanWindowInput): {
1369
+ slots: GridSlot[];
1370
+ endAt: Date;
1371
+ bufferEndAt: Date;
1372
+ };
1373
+ declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
1186
1374
 
1187
1375
  interface CurrencyRate {
1188
1376
  rate: number;
@@ -1195,4 +1383,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
1195
1383
  declare const OtherFixedRates: Record<string, CurrencyRate>;
1196
1384
  declare const COUNTRY_CURRENCIES: Record<string, string>;
1197
1385
 
1198
- export { ADYEN_ROLLOUT_COUNTRY_CODES, type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, 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, UserTypes, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
1386
+ export { type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, 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, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, 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, UserTypes, type WeeklyHours, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, holdExpiresAt, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, planWindow, presentAt, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };