@final-commerce/common 2.0.17 → 2.0.18-beta.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 +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +51 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -830,6 +830,7 @@ interface StoredStateConfig {
|
|
|
830
830
|
crossAxisRules: CrossAxisRule[];
|
|
831
831
|
transitionConditions: TransitionConditionSet[];
|
|
832
832
|
validInitialStates: StatePair[];
|
|
833
|
+
enforceValidInitialStates?: boolean;
|
|
833
834
|
displayStateMap: DisplayStateRule[];
|
|
834
835
|
createdAt: Date;
|
|
835
836
|
updatedAt: Date;
|
|
@@ -1067,6 +1068,40 @@ interface ConfigUpdatedPayload {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1069
1070
|
|
|
1071
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
1072
|
+
total?: number;
|
|
1073
|
+
balance?: number;
|
|
1074
|
+
paymentMethods?: {
|
|
1075
|
+
amount?: number;
|
|
1076
|
+
[key: string]: unknown;
|
|
1077
|
+
}[];
|
|
1078
|
+
refunds?: {
|
|
1079
|
+
quantity?: number;
|
|
1080
|
+
[key: string]: unknown;
|
|
1081
|
+
}[];
|
|
1082
|
+
refund?: {
|
|
1083
|
+
quantity?: number;
|
|
1084
|
+
[key: string]: unknown;
|
|
1085
|
+
}[];
|
|
1086
|
+
lineItems?: {
|
|
1087
|
+
quantity?: number;
|
|
1088
|
+
fulfilledQuantity?: number;
|
|
1089
|
+
returnedQuantity?: number;
|
|
1090
|
+
[key: string]: unknown;
|
|
1091
|
+
}[];
|
|
1092
|
+
}
|
|
1093
|
+
interface OrderWriteStrategy {
|
|
1094
|
+
applyState(order: OrderMutationData): void;
|
|
1095
|
+
}
|
|
1096
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1097
|
+
applyState(_order: OrderMutationData): void;
|
|
1098
|
+
}
|
|
1099
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1100
|
+
private readonly config;
|
|
1101
|
+
constructor(config: StoredStateConfig);
|
|
1102
|
+
applyState(order: OrderMutationData): void;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1070
1105
|
interface CurrencyRate {
|
|
1071
1106
|
rate: number;
|
|
1072
1107
|
country: string;
|
|
@@ -1078,4 +1113,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1078
1113
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1079
1114
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1080
1115
|
|
|
1081
|
-
export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
|
1116
|
+
export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
package/dist/index.d.ts
CHANGED
|
@@ -830,6 +830,7 @@ interface StoredStateConfig {
|
|
|
830
830
|
crossAxisRules: CrossAxisRule[];
|
|
831
831
|
transitionConditions: TransitionConditionSet[];
|
|
832
832
|
validInitialStates: StatePair[];
|
|
833
|
+
enforceValidInitialStates?: boolean;
|
|
833
834
|
displayStateMap: DisplayStateRule[];
|
|
834
835
|
createdAt: Date;
|
|
835
836
|
updatedAt: Date;
|
|
@@ -1067,6 +1068,40 @@ interface ConfigUpdatedPayload {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1069
1070
|
|
|
1071
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
1072
|
+
total?: number;
|
|
1073
|
+
balance?: number;
|
|
1074
|
+
paymentMethods?: {
|
|
1075
|
+
amount?: number;
|
|
1076
|
+
[key: string]: unknown;
|
|
1077
|
+
}[];
|
|
1078
|
+
refunds?: {
|
|
1079
|
+
quantity?: number;
|
|
1080
|
+
[key: string]: unknown;
|
|
1081
|
+
}[];
|
|
1082
|
+
refund?: {
|
|
1083
|
+
quantity?: number;
|
|
1084
|
+
[key: string]: unknown;
|
|
1085
|
+
}[];
|
|
1086
|
+
lineItems?: {
|
|
1087
|
+
quantity?: number;
|
|
1088
|
+
fulfilledQuantity?: number;
|
|
1089
|
+
returnedQuantity?: number;
|
|
1090
|
+
[key: string]: unknown;
|
|
1091
|
+
}[];
|
|
1092
|
+
}
|
|
1093
|
+
interface OrderWriteStrategy {
|
|
1094
|
+
applyState(order: OrderMutationData): void;
|
|
1095
|
+
}
|
|
1096
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1097
|
+
applyState(_order: OrderMutationData): void;
|
|
1098
|
+
}
|
|
1099
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1100
|
+
private readonly config;
|
|
1101
|
+
constructor(config: StoredStateConfig);
|
|
1102
|
+
applyState(order: OrderMutationData): void;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1070
1105
|
interface CurrencyRate {
|
|
1071
1106
|
rate: number;
|
|
1072
1107
|
country: string;
|
|
@@ -1078,4 +1113,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1078
1113
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1079
1114
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1080
1115
|
|
|
1081
|
-
export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
|
1116
|
+
export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
DEFAULT_CROSS_AXIS_RULES: () => DEFAULT_CROSS_AXIS_RULES,
|
|
32
32
|
DEFAULT_DISPLAY_STATE_MAP: () => DEFAULT_DISPLAY_STATE_MAP,
|
|
33
33
|
DEFAULT_RESOLVED_CONFIG: () => DEFAULT_RESOLVED_CONFIG,
|
|
34
|
+
DualWriteStrategy: () => DualWriteStrategy,
|
|
34
35
|
EUFixedRates: () => EUFixedRates,
|
|
35
36
|
EUROPE: () => EUROPE,
|
|
36
37
|
ExtensionCategory: () => ExtensionCategory,
|
|
@@ -40,6 +41,7 @@ __export(index_exports, {
|
|
|
40
41
|
InventoryBaseActionEnum: () => InventoryBaseActionEnum,
|
|
41
42
|
InventorySpecificActionType: () => InventorySpecificActionType,
|
|
42
43
|
InvoiceStatus: () => InvoiceStatus,
|
|
44
|
+
LegacyWriteStrategy: () => LegacyWriteStrategy,
|
|
43
45
|
LibraryItemType: () => LibraryItemType,
|
|
44
46
|
MenuProject: () => MenuProject,
|
|
45
47
|
NAFixedRates: () => NAFixedRates,
|
|
@@ -1260,7 +1262,9 @@ var PAYMENT_DEFS = [
|
|
|
1260
1262
|
var FULFILLMENT_DEFS = [
|
|
1261
1263
|
{ id: "draft", label: "Draft", terminal: false },
|
|
1262
1264
|
{ id: "pending", label: "Pending", terminal: false },
|
|
1263
|
-
|
|
1265
|
+
// 'Parked' is the product term for a held order (OS bug #30) — the atom id
|
|
1266
|
+
// stays `on_hold`; only the human label realigns.
|
|
1267
|
+
{ id: "on_hold", label: "Parked", terminal: false },
|
|
1264
1268
|
{ id: "in_progress", label: "In Progress", terminal: false },
|
|
1265
1269
|
{ id: "fulfilled", label: "Fulfilled", terminal: true },
|
|
1266
1270
|
{ id: "partially_fulfilled", label: "Partially Fulfilled", terminal: false },
|
|
@@ -1392,29 +1396,31 @@ var DEFAULT_CROSS_AXIS_RULES = [
|
|
|
1392
1396
|
|
|
1393
1397
|
// order-state-machine/default-config.ts
|
|
1394
1398
|
var DEFAULT_EPOCH = /* @__PURE__ */ new Date(0);
|
|
1395
|
-
var PAYMENT_LABELS = new Map(
|
|
1396
|
-
|
|
1397
|
-
);
|
|
1398
|
-
var FULFILLMENT_LABELS = new Map(
|
|
1399
|
-
baseFulfillmentDefinitions().map((d) => [d.id, d.label])
|
|
1400
|
-
);
|
|
1399
|
+
var PAYMENT_LABELS = new Map(basePaymentDefinitions().map((d) => [d.id, d.label]));
|
|
1400
|
+
var FULFILLMENT_LABELS = new Map(baseFulfillmentDefinitions().map((d) => [d.id, d.label]));
|
|
1401
1401
|
var TERMINAL_PAYMENT_STATES = new Set(
|
|
1402
1402
|
basePaymentDefinitions().filter((d) => d.isTerminal).map((d) => d.id)
|
|
1403
1403
|
);
|
|
1404
1404
|
var DISPLAY_LABEL_OVERRIDES = {
|
|
1405
1405
|
"unpaid|draft": "In Cart",
|
|
1406
1406
|
"unpaid|pending": "Pending Payment",
|
|
1407
|
-
"unpaid|on_hold": "
|
|
1407
|
+
"unpaid|on_hold": "Parked",
|
|
1408
1408
|
"unpaid|cancelled": "Cancelled",
|
|
1409
1409
|
"partially_paid|pending": "Deposit Received",
|
|
1410
|
-
"partially_paid|on_hold": "
|
|
1410
|
+
"partially_paid|on_hold": "Parked - Deposit Received",
|
|
1411
|
+
"partially_paid|in_progress": "Partially Paid",
|
|
1411
1412
|
"paid|pending": "Paid - Awaiting Fulfillment",
|
|
1412
|
-
"paid|on_hold": "
|
|
1413
|
+
"paid|on_hold": "Parked - Paid",
|
|
1413
1414
|
"paid|fulfilled": "Completed",
|
|
1414
1415
|
"partially_refunded|fulfilled": "Partially Refunded",
|
|
1415
|
-
"partially_refunded|partially_returned": "Partially
|
|
1416
|
+
"partially_refunded|partially_returned": "Partially Refunded",
|
|
1416
1417
|
"refunded|fulfilled": "Refunded",
|
|
1417
|
-
"refunded|returned": "
|
|
1418
|
+
"refunded|returned": "Refunded",
|
|
1419
|
+
// Full refund of a never-fulfilled order (kaching refund op lands on
|
|
1420
|
+
// cancelled when nothing was delivered). Terminal payment states emit no
|
|
1421
|
+
// generic rows, so without this the pair fell through to the raw
|
|
1422
|
+
// "refunded / cancelled" engine fallback.
|
|
1423
|
+
"refunded|cancelled": "Refunded",
|
|
1418
1424
|
"voided|cancelled": "Cancelled"
|
|
1419
1425
|
};
|
|
1420
1426
|
function buildDefaultDisplayStateMap() {
|
|
@@ -1464,7 +1470,8 @@ var POS_VALID_INITIAL_STATES = [
|
|
|
1464
1470
|
{ payment: "unpaid", fulfillment: "pending" },
|
|
1465
1471
|
{ payment: "paid", fulfillment: "fulfilled" },
|
|
1466
1472
|
{ payment: "partially_paid", fulfillment: "draft" },
|
|
1467
|
-
{ payment: "partially_paid", fulfillment: "pending" }
|
|
1473
|
+
{ payment: "partially_paid", fulfillment: "pending" },
|
|
1474
|
+
{ payment: "partially_paid", fulfillment: "in_progress" }
|
|
1468
1475
|
];
|
|
1469
1476
|
function buildPosPresetConfig(companyId) {
|
|
1470
1477
|
return {
|
|
@@ -1666,9 +1673,7 @@ function conditionSummary(c) {
|
|
|
1666
1673
|
|
|
1667
1674
|
// order-state-machine/engine.ts
|
|
1668
1675
|
function pairInInitialList(to, config) {
|
|
1669
|
-
return config.validInitialStates.some(
|
|
1670
|
-
(p) => p.payment === to.payment && p.fulfillment === to.fulfillment
|
|
1671
|
-
);
|
|
1676
|
+
return config.validInitialStates.some((p) => p.payment === to.payment && p.fulfillment === to.fulfillment);
|
|
1672
1677
|
}
|
|
1673
1678
|
function triggerTargets(rule) {
|
|
1674
1679
|
const t = rule.trigger.to;
|
|
@@ -1716,17 +1721,13 @@ function collectPathConditionFailures(config, from, to, context) {
|
|
|
1716
1721
|
const failed = [];
|
|
1717
1722
|
if (from === null) return { failed };
|
|
1718
1723
|
if (from.payment !== to.payment) {
|
|
1719
|
-
const p = config.paymentPaths.find(
|
|
1720
|
-
(x) => x.from === from.payment && x.to === to.payment
|
|
1721
|
-
);
|
|
1724
|
+
const p = config.paymentPaths.find((x) => x.from === from.payment && x.to === to.payment);
|
|
1722
1725
|
const set = findConditionSet(config, p?.conditionSetId);
|
|
1723
1726
|
const ev = evaluateConditionSet(set, context);
|
|
1724
1727
|
if (!ev.ok) failed.push(...ev.failedConditions);
|
|
1725
1728
|
}
|
|
1726
1729
|
if (from.fulfillment !== to.fulfillment) {
|
|
1727
|
-
const p = config.fulfillmentPaths.find(
|
|
1728
|
-
(x) => x.from === from.fulfillment && x.to === to.fulfillment
|
|
1729
|
-
);
|
|
1730
|
+
const p = config.fulfillmentPaths.find((x) => x.from === from.fulfillment && x.to === to.fulfillment);
|
|
1730
1731
|
const set = findConditionSet(config, p?.conditionSetId);
|
|
1731
1732
|
const ev = evaluateConditionSet(set, context);
|
|
1732
1733
|
if (!ev.ok) failed.push(...ev.failedConditions);
|
|
@@ -1735,20 +1736,10 @@ function collectPathConditionFailures(config, from, to, context) {
|
|
|
1735
1736
|
}
|
|
1736
1737
|
function pathBlocked(config, from, to) {
|
|
1737
1738
|
if (from === null) return false;
|
|
1738
|
-
if (from.payment !== to.payment && !axisTransitionAllowed(
|
|
1739
|
-
config.paymentPathMode,
|
|
1740
|
-
config.paymentPaths,
|
|
1741
|
-
from.payment,
|
|
1742
|
-
to.payment
|
|
1743
|
-
)) {
|
|
1739
|
+
if (from.payment !== to.payment && !axisTransitionAllowed(config.paymentPathMode, config.paymentPaths, from.payment, to.payment)) {
|
|
1744
1740
|
return true;
|
|
1745
1741
|
}
|
|
1746
|
-
if (from.fulfillment !== to.fulfillment && !axisTransitionAllowed(
|
|
1747
|
-
config.fulfillmentPathMode,
|
|
1748
|
-
config.fulfillmentPaths,
|
|
1749
|
-
from.fulfillment,
|
|
1750
|
-
to.fulfillment
|
|
1751
|
-
)) {
|
|
1742
|
+
if (from.fulfillment !== to.fulfillment && !axisTransitionAllowed(config.fulfillmentPathMode, config.fulfillmentPaths, from.fulfillment, to.fulfillment)) {
|
|
1752
1743
|
return true;
|
|
1753
1744
|
}
|
|
1754
1745
|
return false;
|
|
@@ -1774,7 +1765,7 @@ function canTransition(request) {
|
|
|
1774
1765
|
};
|
|
1775
1766
|
}
|
|
1776
1767
|
if (from === null) {
|
|
1777
|
-
if (!pairInInitialList(to, config)) {
|
|
1768
|
+
if (config.enforceValidInitialStates === true && !pairInInitialList(to, config)) {
|
|
1778
1769
|
return {
|
|
1779
1770
|
allowed: false,
|
|
1780
1771
|
blockedBy: "path",
|
|
@@ -1832,15 +1823,11 @@ function conditionMetLines(config, from, to, context) {
|
|
|
1832
1823
|
}
|
|
1833
1824
|
};
|
|
1834
1825
|
if (from.payment !== to.payment) {
|
|
1835
|
-
const p = config.paymentPaths.find(
|
|
1836
|
-
(x) => x.from === from.payment && x.to === to.payment
|
|
1837
|
-
);
|
|
1826
|
+
const p = config.paymentPaths.find((x) => x.from === from.payment && x.to === to.payment);
|
|
1838
1827
|
appendForPath(p);
|
|
1839
1828
|
}
|
|
1840
1829
|
if (from.fulfillment !== to.fulfillment) {
|
|
1841
|
-
const p = config.fulfillmentPaths.find(
|
|
1842
|
-
(x) => x.from === from.fulfillment && x.to === to.fulfillment
|
|
1843
|
-
);
|
|
1830
|
+
const p = config.fulfillmentPaths.find((x) => x.from === from.fulfillment && x.to === to.fulfillment);
|
|
1844
1831
|
appendForPath(p);
|
|
1845
1832
|
}
|
|
1846
1833
|
return lines;
|
|
@@ -2610,6 +2597,27 @@ var ORDER_STATE_EVENTS = {
|
|
|
2610
2597
|
stateTransitionBlocked: "state-transition-blocked",
|
|
2611
2598
|
configUpdated: "config-updated"
|
|
2612
2599
|
};
|
|
2600
|
+
|
|
2601
|
+
// order-state-machine/write-strategy.ts
|
|
2602
|
+
var LegacyWriteStrategy = class {
|
|
2603
|
+
applyState(_order) {
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
var DualWriteStrategy = class {
|
|
2607
|
+
constructor(config) {
|
|
2608
|
+
this.config = config;
|
|
2609
|
+
}
|
|
2610
|
+
applyState(order) {
|
|
2611
|
+
if (order.paymentState && order.fulfillmentState) {
|
|
2612
|
+
setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
|
|
2613
|
+
return;
|
|
2614
|
+
}
|
|
2615
|
+
if (order.status) {
|
|
2616
|
+
const inferred = inferStatesFromLegacyStatus(order);
|
|
2617
|
+
setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2613
2621
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2614
2622
|
0 && (module.exports = {
|
|
2615
2623
|
AttributeType,
|
|
@@ -2624,6 +2632,7 @@ var ORDER_STATE_EVENTS = {
|
|
|
2624
2632
|
DEFAULT_CROSS_AXIS_RULES,
|
|
2625
2633
|
DEFAULT_DISPLAY_STATE_MAP,
|
|
2626
2634
|
DEFAULT_RESOLVED_CONFIG,
|
|
2635
|
+
DualWriteStrategy,
|
|
2627
2636
|
EUFixedRates,
|
|
2628
2637
|
EUROPE,
|
|
2629
2638
|
ExtensionCategory,
|
|
@@ -2633,6 +2642,7 @@ var ORDER_STATE_EVENTS = {
|
|
|
2633
2642
|
InventoryBaseActionEnum,
|
|
2634
2643
|
InventorySpecificActionType,
|
|
2635
2644
|
InvoiceStatus,
|
|
2645
|
+
LegacyWriteStrategy,
|
|
2636
2646
|
LibraryItemType,
|
|
2637
2647
|
MenuProject,
|
|
2638
2648
|
NAFixedRates,
|