@final-commerce/common 2.9.2-preprod.2 → 2.9.2-preprod.4

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
@@ -572,6 +572,11 @@ interface FeesTuple {
572
572
  refundedFees: number;
573
573
  netFees: number;
574
574
  }
575
+ interface ShippingTuple {
576
+ grossShipping: number;
577
+ refundedShipping: number;
578
+ netShipping: number;
579
+ }
575
580
  interface ModifiersTuple {
576
581
  grossModifiers: number;
577
582
  refundedModifiers: number;
@@ -602,6 +607,7 @@ interface SalesSummary {
602
607
  discounts: DiscountsTuple;
603
608
  refundsItems: number;
604
609
  fees: FeesTuple;
610
+ shipping?: ShippingTuple;
605
611
  modifiers?: ModifiersTuple;
606
612
  taxes?: TaxesTuple;
607
613
  totalSales: number;
@@ -1081,6 +1087,78 @@ interface LineStockMove {
1081
1087
  }
1082
1088
  declare function lineStockMoves(item: StockLine, quantity: number, reservations?: readonly StockReservationLink[]): LineStockMove[];
1083
1089
 
1090
+ interface ShellTipOption {
1091
+ label: string;
1092
+ value: number;
1093
+ }
1094
+ interface ShellTipSettings {
1095
+ enabled?: boolean;
1096
+ tip1?: ShellTipOption;
1097
+ tip2?: ShellTipOption;
1098
+ tip3?: ShellTipOption;
1099
+ customTipLabel?: string;
1100
+ noTipLabel?: string;
1101
+ }
1102
+ interface ShellSettings {
1103
+ pinSwitchUser?: boolean;
1104
+ pinSession?: boolean;
1105
+ stationLock?: number;
1106
+ buildTimeout?: number;
1107
+ lockedAccess?: boolean;
1108
+ cashManagement?: boolean;
1109
+ tips?: ShellTipSettings;
1110
+ }
1111
+ type ShellTipsLevel = Pick<ShellSettings, 'tips'>;
1112
+
1113
+ type ShellSettingsSource = 'station' | 'outlet' | 'flow' | 'company' | 'default';
1114
+ interface ShellSettingsLevels {
1115
+ station?: ShellSettings | null;
1116
+ outlet?: ShellTipsLevel | null;
1117
+ flow?: ShellTipsLevel | null;
1118
+ company?: ShellTipsLevel | null;
1119
+ }
1120
+ type ResolvedShellTipSettings = Required<ShellTipSettings>;
1121
+ interface ResolvedShellSettings {
1122
+ pinSwitchUser: boolean;
1123
+ pinSession: boolean;
1124
+ stationLock: number;
1125
+ buildTimeout: number;
1126
+ lockedAccess: boolean;
1127
+ cashManagement: boolean;
1128
+ tips: ResolvedShellTipSettings;
1129
+ }
1130
+ type TopField = Exclude<keyof ShellSettings, 'tips'>;
1131
+ type TipField = keyof ShellTipSettings;
1132
+ type ShellStationField = TopField;
1133
+ type ShellTipField = TipField;
1134
+ interface ShellSettingsSources {
1135
+ fields: Record<TopField, ShellSettingsSource>;
1136
+ tips: Record<TipField, ShellSettingsSource>;
1137
+ }
1138
+ declare const DEFAULT_SHELL_SETTINGS: ResolvedShellSettings;
1139
+ declare function resolveShellSettingsWithSources(levels: ShellSettingsLevels): {
1140
+ settings: ResolvedShellSettings;
1141
+ sources: ShellSettingsSources;
1142
+ };
1143
+ declare function resolveShellSettings(levels: ShellSettingsLevels): ResolvedShellSettings;
1144
+ declare const SHELL_TIP_PERCENT_MIN = 1;
1145
+ declare const SHELL_TIP_PERCENT_MAX = 100;
1146
+ declare const SHELL_TIP_LABEL_MAX_LENGTH = 20;
1147
+ type ShellSettingsProblemCode = 'boolean' | 'timeout' | 'percent' | 'label' | 'preset';
1148
+ interface ShellSettingsProblem {
1149
+ field: string;
1150
+ code: ShellSettingsProblemCode;
1151
+ }
1152
+ declare const isShellTipPercent: (raw: unknown) => boolean;
1153
+ declare function shellTipSettingsProblems(tips: ShellTipSettings | null | undefined): ShellSettingsProblem[];
1154
+ declare function shellSettingsProblems(settings: ShellSettings | null | undefined): ShellSettingsProblem[];
1155
+ declare const SHELL_FLOW_SETTINGS_PREFIX = "flowSettingsKey";
1156
+ declare const SHELL_FLOW_TIPS_KEY = "flowSettingsKey.tips";
1157
+ declare function readShellTipSettings(raw: unknown): ShellTipSettings | undefined;
1158
+ declare function shellSettingsFromFlowSettings(dict: Record<string, string> | null | undefined): ShellTipsLevel;
1159
+ declare function flowSettingsFromShellSettings(settings: ShellTipsLevel): Record<string, string>;
1160
+ declare function shellSettingsFromCompanyTips(enabled: unknown, options: unknown): ShellTipsLevel;
1161
+
1084
1162
  declare const SYSTEM_FAMILY_IDS: {
1085
1163
  readonly COUNT: "count";
1086
1164
  readonly WEIGHT: "weight-metric";
@@ -1960,4 +2038,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1960
2038
  }];
1961
2039
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1962
2040
 
1963
- 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 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, 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 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, 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, 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, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, 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, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
2041
+ 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 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, 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_SHELL_SETTINGS, 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 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, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResolvedShellSettings, type ResolvedShellTipSettings, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHELL_FLOW_SETTINGS_PREFIX, SHELL_FLOW_TIPS_KEY, SHELL_TIP_LABEL_MAX_LENGTH, SHELL_TIP_PERCENT_MAX, SHELL_TIP_PERCENT_MIN, 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, type ShellSettings, type ShellSettingsLevels, type ShellSettingsProblem, type ShellSettingsProblemCode, type ShellSettingsSource, type ShellSettingsSources, type ShellStationField, type ShellTipField, type ShellTipOption, type ShellTipSettings, type ShellTipsLevel, 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, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, flowSettingsFromShellSettings, 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, isShellTipPercent, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, readShellTipSettings, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShellSettings, resolveShellSettingsWithSources, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shellSettingsFromCompanyTips, shellSettingsFromFlowSettings, shellSettingsProblems, shellTipSettingsProblems, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -572,6 +572,11 @@ interface FeesTuple {
572
572
  refundedFees: number;
573
573
  netFees: number;
574
574
  }
575
+ interface ShippingTuple {
576
+ grossShipping: number;
577
+ refundedShipping: number;
578
+ netShipping: number;
579
+ }
575
580
  interface ModifiersTuple {
576
581
  grossModifiers: number;
577
582
  refundedModifiers: number;
@@ -602,6 +607,7 @@ interface SalesSummary {
602
607
  discounts: DiscountsTuple;
603
608
  refundsItems: number;
604
609
  fees: FeesTuple;
610
+ shipping?: ShippingTuple;
605
611
  modifiers?: ModifiersTuple;
606
612
  taxes?: TaxesTuple;
607
613
  totalSales: number;
@@ -1081,6 +1087,78 @@ interface LineStockMove {
1081
1087
  }
1082
1088
  declare function lineStockMoves(item: StockLine, quantity: number, reservations?: readonly StockReservationLink[]): LineStockMove[];
1083
1089
 
1090
+ interface ShellTipOption {
1091
+ label: string;
1092
+ value: number;
1093
+ }
1094
+ interface ShellTipSettings {
1095
+ enabled?: boolean;
1096
+ tip1?: ShellTipOption;
1097
+ tip2?: ShellTipOption;
1098
+ tip3?: ShellTipOption;
1099
+ customTipLabel?: string;
1100
+ noTipLabel?: string;
1101
+ }
1102
+ interface ShellSettings {
1103
+ pinSwitchUser?: boolean;
1104
+ pinSession?: boolean;
1105
+ stationLock?: number;
1106
+ buildTimeout?: number;
1107
+ lockedAccess?: boolean;
1108
+ cashManagement?: boolean;
1109
+ tips?: ShellTipSettings;
1110
+ }
1111
+ type ShellTipsLevel = Pick<ShellSettings, 'tips'>;
1112
+
1113
+ type ShellSettingsSource = 'station' | 'outlet' | 'flow' | 'company' | 'default';
1114
+ interface ShellSettingsLevels {
1115
+ station?: ShellSettings | null;
1116
+ outlet?: ShellTipsLevel | null;
1117
+ flow?: ShellTipsLevel | null;
1118
+ company?: ShellTipsLevel | null;
1119
+ }
1120
+ type ResolvedShellTipSettings = Required<ShellTipSettings>;
1121
+ interface ResolvedShellSettings {
1122
+ pinSwitchUser: boolean;
1123
+ pinSession: boolean;
1124
+ stationLock: number;
1125
+ buildTimeout: number;
1126
+ lockedAccess: boolean;
1127
+ cashManagement: boolean;
1128
+ tips: ResolvedShellTipSettings;
1129
+ }
1130
+ type TopField = Exclude<keyof ShellSettings, 'tips'>;
1131
+ type TipField = keyof ShellTipSettings;
1132
+ type ShellStationField = TopField;
1133
+ type ShellTipField = TipField;
1134
+ interface ShellSettingsSources {
1135
+ fields: Record<TopField, ShellSettingsSource>;
1136
+ tips: Record<TipField, ShellSettingsSource>;
1137
+ }
1138
+ declare const DEFAULT_SHELL_SETTINGS: ResolvedShellSettings;
1139
+ declare function resolveShellSettingsWithSources(levels: ShellSettingsLevels): {
1140
+ settings: ResolvedShellSettings;
1141
+ sources: ShellSettingsSources;
1142
+ };
1143
+ declare function resolveShellSettings(levels: ShellSettingsLevels): ResolvedShellSettings;
1144
+ declare const SHELL_TIP_PERCENT_MIN = 1;
1145
+ declare const SHELL_TIP_PERCENT_MAX = 100;
1146
+ declare const SHELL_TIP_LABEL_MAX_LENGTH = 20;
1147
+ type ShellSettingsProblemCode = 'boolean' | 'timeout' | 'percent' | 'label' | 'preset';
1148
+ interface ShellSettingsProblem {
1149
+ field: string;
1150
+ code: ShellSettingsProblemCode;
1151
+ }
1152
+ declare const isShellTipPercent: (raw: unknown) => boolean;
1153
+ declare function shellTipSettingsProblems(tips: ShellTipSettings | null | undefined): ShellSettingsProblem[];
1154
+ declare function shellSettingsProblems(settings: ShellSettings | null | undefined): ShellSettingsProblem[];
1155
+ declare const SHELL_FLOW_SETTINGS_PREFIX = "flowSettingsKey";
1156
+ declare const SHELL_FLOW_TIPS_KEY = "flowSettingsKey.tips";
1157
+ declare function readShellTipSettings(raw: unknown): ShellTipSettings | undefined;
1158
+ declare function shellSettingsFromFlowSettings(dict: Record<string, string> | null | undefined): ShellTipsLevel;
1159
+ declare function flowSettingsFromShellSettings(settings: ShellTipsLevel): Record<string, string>;
1160
+ declare function shellSettingsFromCompanyTips(enabled: unknown, options: unknown): ShellTipsLevel;
1161
+
1084
1162
  declare const SYSTEM_FAMILY_IDS: {
1085
1163
  readonly COUNT: "count";
1086
1164
  readonly WEIGHT: "weight-metric";
@@ -1960,4 +2038,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1960
2038
  }];
1961
2039
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1962
2040
 
1963
- 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 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, 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 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, 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, 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, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, 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, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
2041
+ 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 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, 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_SHELL_SETTINGS, 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 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, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResolvedShellSettings, type ResolvedShellTipSettings, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHELL_FLOW_SETTINGS_PREFIX, SHELL_FLOW_TIPS_KEY, SHELL_TIP_LABEL_MAX_LENGTH, SHELL_TIP_PERCENT_MAX, SHELL_TIP_PERCENT_MIN, 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, type ShellSettings, type ShellSettingsLevels, type ShellSettingsProblem, type ShellSettingsProblemCode, type ShellSettingsSource, type ShellSettingsSources, type ShellStationField, type ShellTipField, type ShellTipOption, type ShellTipSettings, type ShellTipsLevel, 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, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, flowSettingsFromShellSettings, 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, isShellTipPercent, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, readShellTipSettings, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShellSettings, resolveShellSettingsWithSources, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shellSettingsFromCompanyTips, shellSettingsFromFlowSettings, shellSettingsProblems, shellTipSettingsProblems, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  DEFAULT_DISPLAY_STATE_MAP: () => DEFAULT_DISPLAY_STATE_MAP,
50
50
  DEFAULT_HOLD_MINUTES: () => DEFAULT_HOLD_MINUTES,
51
51
  DEFAULT_RESOLVED_CONFIG: () => DEFAULT_RESOLVED_CONFIG,
52
+ DEFAULT_SHELL_SETTINGS: () => DEFAULT_SHELL_SETTINGS,
52
53
  DEFAULT_UNIT_ID: () => DEFAULT_UNIT_ID,
53
54
  DualWriteStrategy: () => DualWriteStrategy,
54
55
  EUFixedRates: () => EUFixedRates,
@@ -104,6 +105,11 @@ __export(index_exports, {
104
105
  ResidualPaymentMethod: () => ResidualPaymentMethod,
105
106
  ResidualStatus: () => ResidualStatus,
106
107
  ResourceAvailabilityState: () => ResourceAvailabilityState,
108
+ SHELL_FLOW_SETTINGS_PREFIX: () => SHELL_FLOW_SETTINGS_PREFIX,
109
+ SHELL_FLOW_TIPS_KEY: () => SHELL_FLOW_TIPS_KEY,
110
+ SHELL_TIP_LABEL_MAX_LENGTH: () => SHELL_TIP_LABEL_MAX_LENGTH,
111
+ SHELL_TIP_PERCENT_MAX: () => SHELL_TIP_PERCENT_MAX,
112
+ SHELL_TIP_PERCENT_MIN: () => SHELL_TIP_PERCENT_MIN,
107
113
  SHIPPING_COUNTRIES: () => SHIPPING_COUNTRIES,
108
114
  STATE_SCHEMA: () => STATE_SCHEMA,
109
115
  STRIPE_SUPPORTED_COUNTRIES: () => STRIPE_SUPPORTED_COUNTRIES,
@@ -170,6 +176,7 @@ __export(index_exports, {
170
176
  evaluateConditionSet: () => evaluateConditionSet,
171
177
  extendPrice: () => extendPrice,
172
178
  extendPriceFor: () => extendPriceFor,
179
+ flowSettingsFromShellSettings: () => flowSettingsFromShellSettings,
173
180
  formatCurrency: () => formatCurrency,
174
181
  formatInUnit: () => formatInUnit,
175
182
  formatMinorUnitsToString: () => formatMinorUnitsToString,
@@ -203,6 +210,7 @@ __export(index_exports, {
203
210
  isFulfillmentState: () => isFulfillmentState,
204
211
  isInCart: () => isInCart,
205
212
  isPaymentState: () => isPaymentState,
213
+ isShellTipPercent: () => isShellTipPercent,
206
214
  isSupportedCurrency: () => isSupportedCurrency,
207
215
  isSystemFamilyCode: () => isSystemFamilyCode,
208
216
  isValidQuantity: () => isValidQuantity,
@@ -237,15 +245,22 @@ __export(index_exports, {
237
245
  presentAt: () => presentAt,
238
246
  priceForTotal: () => priceForTotal,
239
247
  provincesForPostCode: () => provincesForPostCode,
248
+ readShellTipSettings: () => readShellTipSettings,
240
249
  removeFragment: () => removeFragment,
241
250
  resolveFamily: () => resolveFamily,
242
251
  resolveModifiersForProduct: () => resolveModifiersForProduct,
252
+ resolveShellSettings: () => resolveShellSettings,
253
+ resolveShellSettingsWithSources: () => resolveShellSettingsWithSources,
243
254
  resolveShipping: () => resolveShipping,
244
255
  resolveTemplate: () => resolveTemplate,
245
256
  resolveUnit: () => resolveUnit,
246
257
  roundToPrecision: () => roundToPrecision,
247
258
  sameFamily: () => sameFamily,
248
259
  setOrderState: () => setOrderState,
260
+ shellSettingsFromCompanyTips: () => shellSettingsFromCompanyTips,
261
+ shellSettingsFromFlowSettings: () => shellSettingsFromFlowSettings,
262
+ shellSettingsProblems: () => shellSettingsProblems,
263
+ shellTipSettingsProblems: () => shellTipSettingsProblems,
249
264
  shipsToCountry: () => shipsToCountry,
250
265
  shopDayKey: () => shopDayKey,
251
266
  shopDayRange: () => shopDayRange,
@@ -2048,6 +2063,157 @@ function lineStockMoves(item, quantity, reservations = []) {
2048
2063
  });
2049
2064
  }
2050
2065
 
2066
+ // utils/shell-settings.util.ts
2067
+ var DEFAULT_SHELL_SETTINGS = {
2068
+ pinSwitchUser: false,
2069
+ pinSession: false,
2070
+ stationLock: 0,
2071
+ buildTimeout: 0,
2072
+ lockedAccess: false,
2073
+ cashManagement: true,
2074
+ tips: {
2075
+ enabled: true,
2076
+ tip1: { label: "Good", value: 15 },
2077
+ tip2: { label: "Great", value: 18 },
2078
+ tip3: { label: "Amazing!", value: 25 },
2079
+ customTipLabel: "Custom",
2080
+ noTipLabel: "No tip"
2081
+ }
2082
+ };
2083
+ var FIELD_ORDER = ["station"];
2084
+ var TIP_ORDER = ["station", "outlet", "flow", "company"];
2085
+ var TOP_FIELDS = [
2086
+ "pinSwitchUser",
2087
+ "pinSession",
2088
+ "stationLock",
2089
+ "buildTimeout",
2090
+ "lockedAccess",
2091
+ "cashManagement"
2092
+ ];
2093
+ var TIP_FIELDS = ["enabled", "tip1", "tip2", "tip3", "customTipLabel", "noTipLabel"];
2094
+ function pick(levels, order, read, fallback) {
2095
+ for (const level of order) {
2096
+ const settings = levels[level];
2097
+ if (!settings) continue;
2098
+ const value = read(settings);
2099
+ if (value !== void 0 && value !== null) return { value, source: level };
2100
+ }
2101
+ return { value: fallback, source: "default" };
2102
+ }
2103
+ function resolveShellSettingsWithSources(levels) {
2104
+ const settings = { ...DEFAULT_SHELL_SETTINGS, tips: { ...DEFAULT_SHELL_SETTINGS.tips } };
2105
+ const sources = { fields: {}, tips: {} };
2106
+ for (const field of TOP_FIELDS) {
2107
+ const { value, source } = pick(levels, FIELD_ORDER, (s) => s[field], DEFAULT_SHELL_SETTINGS[field]);
2108
+ settings[field] = value;
2109
+ sources.fields[field] = source;
2110
+ }
2111
+ for (const field of TIP_FIELDS) {
2112
+ const { value, source } = pick(levels, TIP_ORDER, (s) => s.tips?.[field], DEFAULT_SHELL_SETTINGS.tips[field]);
2113
+ settings.tips[field] = value;
2114
+ sources.tips[field] = source;
2115
+ }
2116
+ return { settings, sources };
2117
+ }
2118
+ function resolveShellSettings(levels) {
2119
+ return resolveShellSettingsWithSources(levels).settings;
2120
+ }
2121
+ var SHELL_TIP_PERCENT_MIN = 1;
2122
+ var SHELL_TIP_PERCENT_MAX = 100;
2123
+ var SHELL_TIP_LABEL_MAX_LENGTH = 20;
2124
+ var isLabel = (raw) => typeof raw === "string" && raw.trim().length > 0 && raw.length <= SHELL_TIP_LABEL_MAX_LENGTH;
2125
+ var isShellTipPercent = (raw) => typeof raw === "number" && Number.isInteger(raw) && raw >= SHELL_TIP_PERCENT_MIN && raw <= SHELL_TIP_PERCENT_MAX;
2126
+ function shellTipSettingsProblems(tips) {
2127
+ if (!tips) return [];
2128
+ const problems = [];
2129
+ if (tips.enabled !== void 0 && typeof tips.enabled !== "boolean") {
2130
+ problems.push({ field: "tips.enabled", code: "boolean" });
2131
+ }
2132
+ for (const key of ["tip1", "tip2", "tip3"]) {
2133
+ const option = tips[key];
2134
+ if (option === void 0) continue;
2135
+ if (!option || typeof option !== "object") {
2136
+ problems.push({ field: `tips.${key}`, code: "preset" });
2137
+ continue;
2138
+ }
2139
+ if (!isShellTipPercent(option.value)) problems.push({ field: `tips.${key}`, code: "percent" });
2140
+ if (!isLabel(option.label)) problems.push({ field: `tips.${key}`, code: "label" });
2141
+ }
2142
+ for (const key of ["customTipLabel", "noTipLabel"]) {
2143
+ if (tips[key] !== void 0 && !isLabel(tips[key])) problems.push({ field: `tips.${key}`, code: "label" });
2144
+ }
2145
+ return problems;
2146
+ }
2147
+ function shellSettingsProblems(settings) {
2148
+ if (!settings) return [];
2149
+ const problems = [];
2150
+ for (const field of ["pinSwitchUser", "pinSession", "lockedAccess", "cashManagement"]) {
2151
+ if (settings[field] !== void 0 && typeof settings[field] !== "boolean")
2152
+ problems.push({ field, code: "boolean" });
2153
+ }
2154
+ for (const field of ["stationLock", "buildTimeout"]) {
2155
+ const value = settings[field];
2156
+ if (value !== void 0 && !(typeof value === "number" && Number.isInteger(value) && value >= 0)) {
2157
+ problems.push({ field, code: "timeout" });
2158
+ }
2159
+ }
2160
+ return [...problems, ...shellTipSettingsProblems(settings.tips)];
2161
+ }
2162
+ var SHELL_FLOW_SETTINGS_PREFIX = "flowSettingsKey";
2163
+ var SHELL_FLOW_TIPS_KEY = `${SHELL_FLOW_SETTINGS_PREFIX}.tips`;
2164
+ var readBoolean = (raw) => {
2165
+ if (raw === void 0 || raw === "") return void 0;
2166
+ const v = raw.trim().toLowerCase();
2167
+ if (v === "true") return true;
2168
+ if (v === "false") return false;
2169
+ return void 0;
2170
+ };
2171
+ function readTipOption(raw) {
2172
+ if (!raw || typeof raw !== "object") return void 0;
2173
+ const { label, value } = raw;
2174
+ const n = typeof value === "number" ? value : parseFloat(String(value ?? ""));
2175
+ if (typeof label !== "string" || !Number.isFinite(n) || n < 0) return void 0;
2176
+ return { label, value: n };
2177
+ }
2178
+ function readShellTipSettings(raw) {
2179
+ if (!raw || typeof raw !== "object") return void 0;
2180
+ const r = raw;
2181
+ const tips = {};
2182
+ if (typeof r.enabled === "boolean") tips.enabled = r.enabled;
2183
+ const tip1 = readTipOption(r.tip1);
2184
+ const tip2 = readTipOption(r.tip2);
2185
+ const tip3 = readTipOption(r.tip3);
2186
+ if (tip1) tips.tip1 = tip1;
2187
+ if (tip2) tips.tip2 = tip2;
2188
+ if (tip3) tips.tip3 = tip3;
2189
+ if (typeof r.customTipLabel === "string") tips.customTipLabel = r.customTipLabel;
2190
+ if (typeof r.noTipLabel === "string") tips.noTipLabel = r.noTipLabel;
2191
+ return Object.keys(tips).length > 0 ? tips : void 0;
2192
+ }
2193
+ var parseJson = (raw) => {
2194
+ if (!raw) return void 0;
2195
+ try {
2196
+ return JSON.parse(raw);
2197
+ } catch {
2198
+ return void 0;
2199
+ }
2200
+ };
2201
+ function shellSettingsFromFlowSettings(dict) {
2202
+ const tips = readShellTipSettings(parseJson(dict?.[SHELL_FLOW_TIPS_KEY]));
2203
+ return tips ? { tips } : {};
2204
+ }
2205
+ function flowSettingsFromShellSettings(settings) {
2206
+ return settings.tips && Object.keys(settings.tips).length > 0 ? { [SHELL_FLOW_TIPS_KEY]: JSON.stringify(settings.tips) } : {};
2207
+ }
2208
+ function shellSettingsFromCompanyTips(enabled, options) {
2209
+ const tips = {
2210
+ ...readShellTipSettings(typeof options === "string" ? parseJson(options) : options)
2211
+ };
2212
+ const on = typeof enabled === "boolean" ? enabled : readBoolean(typeof enabled === "string" ? enabled : void 0);
2213
+ if (on !== void 0) tips.enabled = on;
2214
+ return Object.keys(tips).length > 0 ? { tips } : {};
2215
+ }
2216
+
2051
2217
  // units/family-code.ts
2052
2218
  var MAX_SLUG_LENGTH = 32;
2053
2219
  var FALLBACK_SLUG = "family";
@@ -4437,6 +4603,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4437
4603
  DEFAULT_DISPLAY_STATE_MAP,
4438
4604
  DEFAULT_HOLD_MINUTES,
4439
4605
  DEFAULT_RESOLVED_CONFIG,
4606
+ DEFAULT_SHELL_SETTINGS,
4440
4607
  DEFAULT_UNIT_ID,
4441
4608
  DualWriteStrategy,
4442
4609
  EUFixedRates,
@@ -4492,6 +4659,11 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4492
4659
  ResidualPaymentMethod,
4493
4660
  ResidualStatus,
4494
4661
  ResourceAvailabilityState,
4662
+ SHELL_FLOW_SETTINGS_PREFIX,
4663
+ SHELL_FLOW_TIPS_KEY,
4664
+ SHELL_TIP_LABEL_MAX_LENGTH,
4665
+ SHELL_TIP_PERCENT_MAX,
4666
+ SHELL_TIP_PERCENT_MIN,
4495
4667
  SHIPPING_COUNTRIES,
4496
4668
  STATE_SCHEMA,
4497
4669
  STRIPE_SUPPORTED_COUNTRIES,
@@ -4558,6 +4730,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4558
4730
  evaluateConditionSet,
4559
4731
  extendPrice,
4560
4732
  extendPriceFor,
4733
+ flowSettingsFromShellSettings,
4561
4734
  formatCurrency,
4562
4735
  formatInUnit,
4563
4736
  formatMinorUnitsToString,
@@ -4591,6 +4764,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4591
4764
  isFulfillmentState,
4592
4765
  isInCart,
4593
4766
  isPaymentState,
4767
+ isShellTipPercent,
4594
4768
  isSupportedCurrency,
4595
4769
  isSystemFamilyCode,
4596
4770
  isValidQuantity,
@@ -4625,15 +4799,22 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4625
4799
  presentAt,
4626
4800
  priceForTotal,
4627
4801
  provincesForPostCode,
4802
+ readShellTipSettings,
4628
4803
  removeFragment,
4629
4804
  resolveFamily,
4630
4805
  resolveModifiersForProduct,
4806
+ resolveShellSettings,
4807
+ resolveShellSettingsWithSources,
4631
4808
  resolveShipping,
4632
4809
  resolveTemplate,
4633
4810
  resolveUnit,
4634
4811
  roundToPrecision,
4635
4812
  sameFamily,
4636
4813
  setOrderState,
4814
+ shellSettingsFromCompanyTips,
4815
+ shellSettingsFromFlowSettings,
4816
+ shellSettingsProblems,
4817
+ shellTipSettingsProblems,
4637
4818
  shipsToCountry,
4638
4819
  shopDayKey,
4639
4820
  shopDayRange,