@final-commerce/common 2.0.4 → 2.0.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +29 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -10
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +1 -0
- package/dist/pos-types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -189,7 +189,8 @@ declare enum Platform {
|
|
|
189
189
|
}
|
|
190
190
|
declare enum OrderPlatform {
|
|
191
191
|
POS = "in-store",
|
|
192
|
-
WOO_COMMERCE = "woo-commerce"
|
|
192
|
+
WOO_COMMERCE = "woo-commerce",
|
|
193
|
+
PUBLIC_API = "public-api"
|
|
193
194
|
}
|
|
194
195
|
declare enum CustomerPlatform {
|
|
195
196
|
POS = "in-store",
|
|
@@ -932,6 +933,40 @@ declare function setOrderState(order: OrderStateWritable, paymentState: PaymentS
|
|
|
932
933
|
|
|
933
934
|
declare function inferStatesFromLegacyStatus(order: OrderLikeForLegacyInference): StatePair;
|
|
934
935
|
|
|
936
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
937
|
+
total?: number;
|
|
938
|
+
balance?: number;
|
|
939
|
+
paymentMethods?: {
|
|
940
|
+
amount?: number;
|
|
941
|
+
[key: string]: unknown;
|
|
942
|
+
}[];
|
|
943
|
+
refunds?: {
|
|
944
|
+
quantity?: number;
|
|
945
|
+
[key: string]: unknown;
|
|
946
|
+
}[];
|
|
947
|
+
refund?: {
|
|
948
|
+
quantity?: number;
|
|
949
|
+
[key: string]: unknown;
|
|
950
|
+
}[];
|
|
951
|
+
lineItems?: {
|
|
952
|
+
quantity?: number;
|
|
953
|
+
fulfilledQuantity?: number;
|
|
954
|
+
returnedQuantity?: number;
|
|
955
|
+
[key: string]: unknown;
|
|
956
|
+
}[];
|
|
957
|
+
}
|
|
958
|
+
interface OrderWriteStrategy {
|
|
959
|
+
applyState(order: OrderMutationData): void;
|
|
960
|
+
}
|
|
961
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
962
|
+
applyState(_order: OrderMutationData): void;
|
|
963
|
+
}
|
|
964
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
965
|
+
private readonly config;
|
|
966
|
+
constructor(config: StoredStateConfig);
|
|
967
|
+
applyState(order: OrderMutationData): void;
|
|
968
|
+
}
|
|
969
|
+
|
|
935
970
|
interface ResolveTemplateResult {
|
|
936
971
|
fragment: StateConfigFragment;
|
|
937
972
|
resolvedValues: Record<string, unknown>;
|
|
@@ -1058,4 +1093,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1058
1093
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1059
1094
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1060
1095
|
|
|
1061
|
-
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, 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 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, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
|
1096
|
+
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, 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 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, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, 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
|
@@ -189,7 +189,8 @@ declare enum Platform {
|
|
|
189
189
|
}
|
|
190
190
|
declare enum OrderPlatform {
|
|
191
191
|
POS = "in-store",
|
|
192
|
-
WOO_COMMERCE = "woo-commerce"
|
|
192
|
+
WOO_COMMERCE = "woo-commerce",
|
|
193
|
+
PUBLIC_API = "public-api"
|
|
193
194
|
}
|
|
194
195
|
declare enum CustomerPlatform {
|
|
195
196
|
POS = "in-store",
|
|
@@ -932,6 +933,40 @@ declare function setOrderState(order: OrderStateWritable, paymentState: PaymentS
|
|
|
932
933
|
|
|
933
934
|
declare function inferStatesFromLegacyStatus(order: OrderLikeForLegacyInference): StatePair;
|
|
934
935
|
|
|
936
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
937
|
+
total?: number;
|
|
938
|
+
balance?: number;
|
|
939
|
+
paymentMethods?: {
|
|
940
|
+
amount?: number;
|
|
941
|
+
[key: string]: unknown;
|
|
942
|
+
}[];
|
|
943
|
+
refunds?: {
|
|
944
|
+
quantity?: number;
|
|
945
|
+
[key: string]: unknown;
|
|
946
|
+
}[];
|
|
947
|
+
refund?: {
|
|
948
|
+
quantity?: number;
|
|
949
|
+
[key: string]: unknown;
|
|
950
|
+
}[];
|
|
951
|
+
lineItems?: {
|
|
952
|
+
quantity?: number;
|
|
953
|
+
fulfilledQuantity?: number;
|
|
954
|
+
returnedQuantity?: number;
|
|
955
|
+
[key: string]: unknown;
|
|
956
|
+
}[];
|
|
957
|
+
}
|
|
958
|
+
interface OrderWriteStrategy {
|
|
959
|
+
applyState(order: OrderMutationData): void;
|
|
960
|
+
}
|
|
961
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
962
|
+
applyState(_order: OrderMutationData): void;
|
|
963
|
+
}
|
|
964
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
965
|
+
private readonly config;
|
|
966
|
+
constructor(config: StoredStateConfig);
|
|
967
|
+
applyState(order: OrderMutationData): void;
|
|
968
|
+
}
|
|
969
|
+
|
|
935
970
|
interface ResolveTemplateResult {
|
|
936
971
|
fragment: StateConfigFragment;
|
|
937
972
|
resolvedValues: Record<string, unknown>;
|
|
@@ -1058,4 +1093,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1058
1093
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1059
1094
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1060
1095
|
|
|
1061
|
-
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, 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 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, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
|
|
1096
|
+
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, 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 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, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, 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,
|
|
@@ -334,6 +336,7 @@ var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
|
334
336
|
var OrderPlatform = /* @__PURE__ */ ((OrderPlatform2) => {
|
|
335
337
|
OrderPlatform2["POS"] = "in-store";
|
|
336
338
|
OrderPlatform2["WOO_COMMERCE"] = "woo-commerce";
|
|
339
|
+
OrderPlatform2["PUBLIC_API"] = "public-api";
|
|
337
340
|
return OrderPlatform2;
|
|
338
341
|
})(OrderPlatform || {});
|
|
339
342
|
var CustomerPlatform = /* @__PURE__ */ ((CustomerPlatform2) => {
|
|
@@ -1131,10 +1134,7 @@ function negateAtPaths(value, path, paths) {
|
|
|
1131
1134
|
function padHex(value, length) {
|
|
1132
1135
|
return value.toString(16).padStart(length, "0");
|
|
1133
1136
|
}
|
|
1134
|
-
var PROCESS_RANDOM = Array.from(
|
|
1135
|
-
{ length: 5 },
|
|
1136
|
-
() => padHex(Math.floor(Math.random() * 256), 2)
|
|
1137
|
-
).join("");
|
|
1137
|
+
var PROCESS_RANDOM = Array.from({ length: 5 }, () => padHex(Math.floor(Math.random() * 256), 2)).join("");
|
|
1138
1138
|
var objectIdCounter = Math.floor(Math.random() * 16777215);
|
|
1139
1139
|
function generateMongoID() {
|
|
1140
1140
|
const timestamp = padHex(Math.floor(Date.now() / 1e3), 8);
|
|
@@ -1352,12 +1352,8 @@ var DEFAULT_CROSS_AXIS_RULES = [
|
|
|
1352
1352
|
|
|
1353
1353
|
// order-state-machine/default-config.ts
|
|
1354
1354
|
var DEFAULT_EPOCH = /* @__PURE__ */ new Date(0);
|
|
1355
|
-
var PAYMENT_LABELS = new Map(
|
|
1356
|
-
|
|
1357
|
-
);
|
|
1358
|
-
var FULFILLMENT_LABELS = new Map(
|
|
1359
|
-
baseFulfillmentDefinitions().map((d) => [d.id, d.label])
|
|
1360
|
-
);
|
|
1355
|
+
var PAYMENT_LABELS = new Map(basePaymentDefinitions().map((d) => [d.id, d.label]));
|
|
1356
|
+
var FULFILLMENT_LABELS = new Map(baseFulfillmentDefinitions().map((d) => [d.id, d.label]));
|
|
1361
1357
|
var TERMINAL_PAYMENT_STATES = new Set(
|
|
1362
1358
|
basePaymentDefinitions().filter((d) => d.isTerminal).map((d) => d.id)
|
|
1363
1359
|
);
|
|
@@ -2269,6 +2265,27 @@ function inferStatesFromLegacyStatus(order) {
|
|
|
2269
2265
|
return { payment: "unpaid", fulfillment: "pending" };
|
|
2270
2266
|
}
|
|
2271
2267
|
|
|
2268
|
+
// order-state-machine/write-strategy.ts
|
|
2269
|
+
var LegacyWriteStrategy = class {
|
|
2270
|
+
applyState(_order) {
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
var DualWriteStrategy = class {
|
|
2274
|
+
constructor(config) {
|
|
2275
|
+
this.config = config;
|
|
2276
|
+
}
|
|
2277
|
+
applyState(order) {
|
|
2278
|
+
if (order.paymentState && order.fulfillmentState) {
|
|
2279
|
+
setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
|
|
2280
|
+
return;
|
|
2281
|
+
}
|
|
2282
|
+
if (order.status) {
|
|
2283
|
+
const inferred = inferStatesFromLegacyStatus(order);
|
|
2284
|
+
setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2272
2289
|
// order-state-machine/resolve-template.ts
|
|
2273
2290
|
function resolveTemplate(templateJson, params, values = {}) {
|
|
2274
2291
|
const resolvedValues = {};
|
|
@@ -2584,6 +2601,7 @@ var ORDER_STATE_EVENTS = {
|
|
|
2584
2601
|
DEFAULT_CROSS_AXIS_RULES,
|
|
2585
2602
|
DEFAULT_DISPLAY_STATE_MAP,
|
|
2586
2603
|
DEFAULT_RESOLVED_CONFIG,
|
|
2604
|
+
DualWriteStrategy,
|
|
2587
2605
|
EUFixedRates,
|
|
2588
2606
|
EUROPE,
|
|
2589
2607
|
ExtensionCategory,
|
|
@@ -2593,6 +2611,7 @@ var ORDER_STATE_EVENTS = {
|
|
|
2593
2611
|
InventoryBaseActionEnum,
|
|
2594
2612
|
InventorySpecificActionType,
|
|
2595
2613
|
InvoiceStatus,
|
|
2614
|
+
LegacyWriteStrategy,
|
|
2596
2615
|
LibraryItemType,
|
|
2597
2616
|
MenuProject,
|
|
2598
2617
|
NAFixedRates,
|