@final-commerce/common 2.5.1-online.1 → 2.5.1-online.2

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,43 @@ declare enum ResourceAvailabilityState {
443
443
  NO_HOURS_IN_RANGE = "noHoursInRange"
444
444
  }
445
445
 
446
+ declare enum ShippingZoneKind {
447
+ COUNTRY = "country",
448
+ PROVINCE = "province",
449
+ CITY = "city",
450
+ EVERYWHERE = "everywhere"
451
+ }
452
+ declare enum ShippingOptionType {
453
+ SHIP = "ship",
454
+ PICKUP = "pickup"
455
+ }
456
+ declare enum ShippingRateType {
457
+ FLAT = "flat"
458
+ }
459
+ declare enum ShippingChannel {
460
+ WEB = "web",
461
+ POS = "pos"
462
+ }
463
+ declare enum ShippingNoOptionReason {
464
+ INCOMPLETE = "INCOMPLETE",
465
+ ADDRESS_MISMATCH = "ADDRESS_MISMATCH",
466
+ NO_COVERAGE = "NO_COVERAGE",
467
+ BLOCKED = "BLOCKED",
468
+ NO_OPTION = "NO_OPTION"
469
+ }
470
+ declare enum ShippingZoneError {
471
+ NO_PLACES = "NO_PLACES",
472
+ INVALID_PLACE = "INVALID_PLACE",
473
+ DUPLICATE_PLACE = "DUPLICATE_PLACE",
474
+ NO_WEBSITE_OPTION = "NO_WEBSITE_OPTION",
475
+ INVALID_PRICE = "INVALID_PRICE",
476
+ INVALID_DAYS = "INVALID_DAYS",
477
+ INVALID_TIERS = "INVALID_TIERS",
478
+ NO_CHANNEL = "NO_CHANNEL",
479
+ PICKUP_WITHOUT_STORE = "PICKUP_WITHOUT_STORE",
480
+ MISSING_NAME = "MISSING_NAME"
481
+ }
482
+
446
483
  interface CurrencyConfig {
447
484
  minorUnits: number;
448
485
  symbol: string;
@@ -1438,6 +1475,112 @@ declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, bus
1438
1475
  };
1439
1476
  declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
1440
1477
 
1478
+ interface ShippingPlace {
1479
+ country: string;
1480
+ province?: string | null;
1481
+ city?: string | null;
1482
+ }
1483
+ interface ShippingPriceTier {
1484
+ from: number;
1485
+ price: number;
1486
+ }
1487
+ interface ShippingOptionRule {
1488
+ id: string;
1489
+ type: ShippingOptionType | `${ShippingOptionType}`;
1490
+ rate?: ShippingRateType | `${ShippingRateType}`;
1491
+ name?: string | null;
1492
+ price: number;
1493
+ priceByTotal?: ShippingPriceTier[] | null;
1494
+ freeOver?: number | null;
1495
+ minDays?: number | null;
1496
+ maxDays?: number | null;
1497
+ channels: (ShippingChannel | `${ShippingChannel}`)[];
1498
+ outletId?: string | null;
1499
+ }
1500
+ interface ShippingZoneRule {
1501
+ id: string;
1502
+ kind: ShippingZoneKind | `${ShippingZoneKind}`;
1503
+ places: ShippingPlace[];
1504
+ ships: boolean;
1505
+ message?: string | null;
1506
+ options: ShippingOptionRule[];
1507
+ }
1508
+ interface AddressLike {
1509
+ country?: string | null;
1510
+ state?: string | null;
1511
+ province?: string | null;
1512
+ city?: string | null;
1513
+ postCode?: string | null;
1514
+ postalCode?: string | null;
1515
+ zip?: string | null;
1516
+ }
1517
+ interface NormalizedAddress {
1518
+ country?: string;
1519
+ province?: string;
1520
+ cityKey?: string;
1521
+ postCode?: string;
1522
+ }
1523
+ interface ShippingQuoteOption {
1524
+ optionId: string;
1525
+ zoneId: string;
1526
+ type: ShippingOptionType | `${ShippingOptionType}`;
1527
+ name: string | null;
1528
+ amount: number;
1529
+ amountToFree: number | null;
1530
+ minDays: number | null;
1531
+ maxDays: number | null;
1532
+ outletId: string | null;
1533
+ }
1534
+ interface ShippingResolution {
1535
+ zoneId: string | null;
1536
+ options: ShippingQuoteOption[];
1537
+ reason: ShippingNoOptionReason | null;
1538
+ message: string | null;
1539
+ shipsToCountries: string[];
1540
+ }
1541
+ interface ResolveShippingInput {
1542
+ zones: ShippingZoneRule[];
1543
+ address: AddressLike | null | undefined;
1544
+ itemsTotal: number;
1545
+ channel: ShippingChannel | `${ShippingChannel}`;
1546
+ }
1547
+
1548
+ declare function normalizeCountry(value: string | null | undefined): string | undefined;
1549
+ interface CountryOption {
1550
+ code: string;
1551
+ name: string;
1552
+ }
1553
+ declare function listCountries(locale?: string): CountryOption[];
1554
+
1555
+ interface Province {
1556
+ code: string;
1557
+ name: string;
1558
+ nameFr: string;
1559
+ postalLetters: string[];
1560
+ aliases?: string[];
1561
+ }
1562
+ declare const CANADA_PROVINCES: readonly Province[];
1563
+ declare function normalizeProvince(country: string | undefined, value: string | null | undefined): string | undefined;
1564
+ declare function listProvinces(country: string): readonly Province[];
1565
+ declare function provincesForPostCode(country: string | undefined, postCode: string | undefined): string[];
1566
+
1567
+ declare const EVERYWHERE_KEY = "*";
1568
+ declare function normalizeCityKey(value: string | null | undefined): string | undefined;
1569
+ declare function normalizePostCode(value: string | null | undefined): string | undefined;
1570
+ declare function normalizeAddress(address: AddressLike | null | undefined): NormalizedAddress;
1571
+ declare function postCodeMatchesProvince(address: NormalizedAddress): boolean;
1572
+ declare function placeKey(place: ShippingPlace): string | undefined;
1573
+ declare function addressPlaceKeys(address: NormalizedAddress): string[];
1574
+
1575
+ declare function resolveShipping({ zones, address, itemsTotal, channel }: ResolveShippingInput): ShippingResolution;
1576
+ declare function priceForTotal(option: ShippingOptionRule, itemsTotal: number): number;
1577
+
1578
+ interface ShippingZoneProblem {
1579
+ code: ShippingZoneError;
1580
+ optionId?: string;
1581
+ }
1582
+ declare function validateShippingZone(zone: ShippingZoneRule): ShippingZoneProblem[];
1583
+
1441
1584
  interface CurrencyRate {
1442
1585
  rate: number;
1443
1586
  country: string;
@@ -1467,4 +1610,4 @@ declare enum ProcessorType {
1467
1610
  declare const PAYMENT_CHANNELS: readonly ["inPerson", "online"];
1468
1611
  type PaymentChannel = (typeof PAYMENT_CHANNELS)[number];
1469
1612
 
1470
- export { ADYEN_ROLLOUT_COUNTRY_CODES, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, 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, type ModifiersBreakdown, type ModifiersTuple, 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_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, 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, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, 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, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };
1613
+ export { ADYEN_ROLLOUT_COUNTRY_CODES, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, 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 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, 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, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, 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_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveShippingInput, 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, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, 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 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, addressPlaceKeys, 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, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -443,6 +443,43 @@ declare enum ResourceAvailabilityState {
443
443
  NO_HOURS_IN_RANGE = "noHoursInRange"
444
444
  }
445
445
 
446
+ declare enum ShippingZoneKind {
447
+ COUNTRY = "country",
448
+ PROVINCE = "province",
449
+ CITY = "city",
450
+ EVERYWHERE = "everywhere"
451
+ }
452
+ declare enum ShippingOptionType {
453
+ SHIP = "ship",
454
+ PICKUP = "pickup"
455
+ }
456
+ declare enum ShippingRateType {
457
+ FLAT = "flat"
458
+ }
459
+ declare enum ShippingChannel {
460
+ WEB = "web",
461
+ POS = "pos"
462
+ }
463
+ declare enum ShippingNoOptionReason {
464
+ INCOMPLETE = "INCOMPLETE",
465
+ ADDRESS_MISMATCH = "ADDRESS_MISMATCH",
466
+ NO_COVERAGE = "NO_COVERAGE",
467
+ BLOCKED = "BLOCKED",
468
+ NO_OPTION = "NO_OPTION"
469
+ }
470
+ declare enum ShippingZoneError {
471
+ NO_PLACES = "NO_PLACES",
472
+ INVALID_PLACE = "INVALID_PLACE",
473
+ DUPLICATE_PLACE = "DUPLICATE_PLACE",
474
+ NO_WEBSITE_OPTION = "NO_WEBSITE_OPTION",
475
+ INVALID_PRICE = "INVALID_PRICE",
476
+ INVALID_DAYS = "INVALID_DAYS",
477
+ INVALID_TIERS = "INVALID_TIERS",
478
+ NO_CHANNEL = "NO_CHANNEL",
479
+ PICKUP_WITHOUT_STORE = "PICKUP_WITHOUT_STORE",
480
+ MISSING_NAME = "MISSING_NAME"
481
+ }
482
+
446
483
  interface CurrencyConfig {
447
484
  minorUnits: number;
448
485
  symbol: string;
@@ -1438,6 +1475,112 @@ declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, bus
1438
1475
  };
1439
1476
  declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
1440
1477
 
1478
+ interface ShippingPlace {
1479
+ country: string;
1480
+ province?: string | null;
1481
+ city?: string | null;
1482
+ }
1483
+ interface ShippingPriceTier {
1484
+ from: number;
1485
+ price: number;
1486
+ }
1487
+ interface ShippingOptionRule {
1488
+ id: string;
1489
+ type: ShippingOptionType | `${ShippingOptionType}`;
1490
+ rate?: ShippingRateType | `${ShippingRateType}`;
1491
+ name?: string | null;
1492
+ price: number;
1493
+ priceByTotal?: ShippingPriceTier[] | null;
1494
+ freeOver?: number | null;
1495
+ minDays?: number | null;
1496
+ maxDays?: number | null;
1497
+ channels: (ShippingChannel | `${ShippingChannel}`)[];
1498
+ outletId?: string | null;
1499
+ }
1500
+ interface ShippingZoneRule {
1501
+ id: string;
1502
+ kind: ShippingZoneKind | `${ShippingZoneKind}`;
1503
+ places: ShippingPlace[];
1504
+ ships: boolean;
1505
+ message?: string | null;
1506
+ options: ShippingOptionRule[];
1507
+ }
1508
+ interface AddressLike {
1509
+ country?: string | null;
1510
+ state?: string | null;
1511
+ province?: string | null;
1512
+ city?: string | null;
1513
+ postCode?: string | null;
1514
+ postalCode?: string | null;
1515
+ zip?: string | null;
1516
+ }
1517
+ interface NormalizedAddress {
1518
+ country?: string;
1519
+ province?: string;
1520
+ cityKey?: string;
1521
+ postCode?: string;
1522
+ }
1523
+ interface ShippingQuoteOption {
1524
+ optionId: string;
1525
+ zoneId: string;
1526
+ type: ShippingOptionType | `${ShippingOptionType}`;
1527
+ name: string | null;
1528
+ amount: number;
1529
+ amountToFree: number | null;
1530
+ minDays: number | null;
1531
+ maxDays: number | null;
1532
+ outletId: string | null;
1533
+ }
1534
+ interface ShippingResolution {
1535
+ zoneId: string | null;
1536
+ options: ShippingQuoteOption[];
1537
+ reason: ShippingNoOptionReason | null;
1538
+ message: string | null;
1539
+ shipsToCountries: string[];
1540
+ }
1541
+ interface ResolveShippingInput {
1542
+ zones: ShippingZoneRule[];
1543
+ address: AddressLike | null | undefined;
1544
+ itemsTotal: number;
1545
+ channel: ShippingChannel | `${ShippingChannel}`;
1546
+ }
1547
+
1548
+ declare function normalizeCountry(value: string | null | undefined): string | undefined;
1549
+ interface CountryOption {
1550
+ code: string;
1551
+ name: string;
1552
+ }
1553
+ declare function listCountries(locale?: string): CountryOption[];
1554
+
1555
+ interface Province {
1556
+ code: string;
1557
+ name: string;
1558
+ nameFr: string;
1559
+ postalLetters: string[];
1560
+ aliases?: string[];
1561
+ }
1562
+ declare const CANADA_PROVINCES: readonly Province[];
1563
+ declare function normalizeProvince(country: string | undefined, value: string | null | undefined): string | undefined;
1564
+ declare function listProvinces(country: string): readonly Province[];
1565
+ declare function provincesForPostCode(country: string | undefined, postCode: string | undefined): string[];
1566
+
1567
+ declare const EVERYWHERE_KEY = "*";
1568
+ declare function normalizeCityKey(value: string | null | undefined): string | undefined;
1569
+ declare function normalizePostCode(value: string | null | undefined): string | undefined;
1570
+ declare function normalizeAddress(address: AddressLike | null | undefined): NormalizedAddress;
1571
+ declare function postCodeMatchesProvince(address: NormalizedAddress): boolean;
1572
+ declare function placeKey(place: ShippingPlace): string | undefined;
1573
+ declare function addressPlaceKeys(address: NormalizedAddress): string[];
1574
+
1575
+ declare function resolveShipping({ zones, address, itemsTotal, channel }: ResolveShippingInput): ShippingResolution;
1576
+ declare function priceForTotal(option: ShippingOptionRule, itemsTotal: number): number;
1577
+
1578
+ interface ShippingZoneProblem {
1579
+ code: ShippingZoneError;
1580
+ optionId?: string;
1581
+ }
1582
+ declare function validateShippingZone(zone: ShippingZoneRule): ShippingZoneProblem[];
1583
+
1441
1584
  interface CurrencyRate {
1442
1585
  rate: number;
1443
1586
  country: string;
@@ -1467,4 +1610,4 @@ declare enum ProcessorType {
1467
1610
  declare const PAYMENT_CHANNELS: readonly ["inPerson", "online"];
1468
1611
  type PaymentChannel = (typeof PAYMENT_CHANNELS)[number];
1469
1612
 
1470
- export { ADYEN_ROLLOUT_COUNTRY_CODES, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, 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, type ModifiersBreakdown, type ModifiersTuple, 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_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, 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, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, 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, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };
1613
+ export { ADYEN_ROLLOUT_COUNTRY_CODES, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, 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 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, 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, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, 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_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveShippingInput, 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, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, 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 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, addressPlaceKeys, 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, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };