@final-commerce/common 2.11.0 → 2.11.1-online.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/bin/gate-done.mjs CHANGED
@@ -2,14 +2,13 @@
2
2
  /**
3
3
  * gate-done — pre-push hook.
4
4
  *
5
- * Runs four sweeps inside a 90-second wall-clock budget:
5
+ * Runs three sweeps inside a 90-second wall-clock budget:
6
6
  *
7
- * 1. npm audit — known CVE check against the installed dependency tree (warn only)
8
- * 2. gitleaks — credential / secret scanning (git log + staged)
9
- * 3. vitest — full test suite with coverage threshold enforcement
10
- * 4. bundle — size-limit or custom bundle-size script (if configured)
7
+ * 1. gitleaks — credential / secret scanning (git log + staged)
8
+ * 2. vitest — full test suite with coverage threshold enforcement
9
+ * 3. bundle — size-limit or custom bundle-size script (if configured)
11
10
  *
12
- * Any sweep failure except npm audit exits 1, blocking the push.
11
+ * Any sweep failure exits 1, blocking the push.
13
12
  * Budget overrun also exits 1.
14
13
  *
15
14
  * Install as Husky pre-push hook:
@@ -74,21 +73,9 @@ function ok(msg) {
74
73
  process.stdout.write(`\x1b[32m✔ [${elapsed()}s] ${msg}\x1b[0m\n`);
75
74
  }
76
75
 
77
- // ── 1. npm audit ─────────────────────────────────────────────────────────────
76
+ // ── 1. gitleaks ───────────────────────────────────────────────────────────────
78
77
 
79
- info('Sweep 1/4 — npm audit (known CVEs)…');
80
- checkBudget('npm audit');
81
-
82
- const auditResult = run('npm audit --audit-level=high');
83
- if (auditResult.status !== 0) {
84
- warn('npm audit found high or critical vulnerabilities. Run `npm audit` for details.');
85
- } else {
86
- ok('npm audit: no high/critical vulnerabilities.');
87
- }
88
-
89
- // ── 2. gitleaks ───────────────────────────────────────────────────────────────
90
-
91
- info('Sweep 2/4 — gitleaks secrets scan…');
78
+ info('Sweep 1/3 — gitleaks secrets scan…');
92
79
  checkBudget('gitleaks');
93
80
 
94
81
  const hasGitleaks = capture('command -v gitleaks 2>/dev/null').status === 0;
@@ -108,9 +95,9 @@ if (!hasGitleaks) {
108
95
  ok('gitleaks: no secrets detected.');
109
96
  }
110
97
 
111
- // ── 3. vitest coverage ────────────────────────────────────────────────────────
98
+ // ── 2. vitest coverage ────────────────────────────────────────────────────────
112
99
 
113
- info('Sweep 3/4 — Vitest test suite + coverage thresholds…');
100
+ info('Sweep 2/3 — Vitest test suite + coverage thresholds…');
114
101
  checkBudget('vitest');
115
102
 
116
103
  const vitestResult = run('npx vitest run --coverage');
@@ -121,9 +108,9 @@ if (vitestResult.status !== 0) {
121
108
 
122
109
  ok('Vitest: all tests passed, coverage thresholds met.');
123
110
 
124
- // ── 4. bundle size ────────────────────────────────────────────────────────────
111
+ // ── 3. bundle size ────────────────────────────────────────────────────────────
125
112
 
126
- info('Sweep 4/4 — bundle size audit…');
113
+ info('Sweep 3/3 — bundle size audit…');
127
114
  checkBudget('bundle audit');
128
115
 
129
116
  const pkgPath = resolve(process.cwd(), 'package.json');
package/dist/index.d.mts CHANGED
@@ -490,6 +490,25 @@ declare enum ShippingZoneError {
490
490
  MISSING_NAME = "MISSING_NAME"
491
491
  }
492
492
 
493
+ declare enum TaxRegistrationKind {
494
+ GST_HST = "GST_HST",
495
+ PST = "PST",
496
+ QST = "QST"
497
+ }
498
+ declare enum TaxSource {
499
+ MERCHANT = "merchant",
500
+ AUTOMATIC = "automatic"
501
+ }
502
+ declare enum OutOfProvinceTaxes {
503
+ AUTOMATIC = "automatic",
504
+ HOME = "home"
505
+ }
506
+ declare enum TaxWarningCode {
507
+ NOT_REGISTERED = "NOT_REGISTERED",
508
+ NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE",
509
+ NO_TABLE = "NO_TABLE"
510
+ }
511
+
493
512
  declare enum SalesLineAction {
494
513
  SALE = "sale",
495
514
  REFUND = "refund"
@@ -1898,6 +1917,70 @@ interface ShippingZoneProblem {
1898
1917
  }
1899
1918
  declare function validateShippingZone(zone: ShippingZoneRule): ShippingZoneProblem[];
1900
1919
 
1920
+ interface TaxRegistration {
1921
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1922
+ place: string;
1923
+ number?: string | null;
1924
+ from?: string | null;
1925
+ }
1926
+
1927
+ declare const STANDARD_TAX_TYPE = "standard";
1928
+ type AutomaticTaxRowStatus = 'confirmed' | 'to_confirm';
1929
+ interface AutomaticTaxTypeRow {
1930
+ key: string;
1931
+ name: string;
1932
+ description?: string | null;
1933
+ sortOrder: number;
1934
+ active: boolean;
1935
+ }
1936
+ interface AutomaticTaxPart {
1937
+ code: string;
1938
+ name: string;
1939
+ rate: string;
1940
+ level: 'federal' | 'provincial';
1941
+ }
1942
+ interface AutomaticTaxRateRow {
1943
+ code: string;
1944
+ name: string;
1945
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1946
+ places: string[];
1947
+ rate: string;
1948
+ from?: string | null;
1949
+ to?: string | null;
1950
+ order: number;
1951
+ compound: boolean;
1952
+ registrationPlace: string;
1953
+ harmonized: boolean;
1954
+ parts?: AutomaticTaxPart[] | null;
1955
+ sourceUrl?: string | null;
1956
+ status: AutomaticTaxRowStatus;
1957
+ }
1958
+ interface AutomaticTaxRuleRow {
1959
+ taxType: string;
1960
+ codes: string[];
1961
+ rate: string;
1962
+ from?: string | null;
1963
+ to?: string | null;
1964
+ sourceUrl?: string | null;
1965
+ status: AutomaticTaxRowStatus;
1966
+ note?: string | null;
1967
+ }
1968
+ interface AutomaticTaxTable {
1969
+ version: string;
1970
+ types: AutomaticTaxTypeRow[];
1971
+ rates: AutomaticTaxRateRow[];
1972
+ rules: AutomaticTaxRuleRow[];
1973
+ }
1974
+ declare function automaticTaxTableVersion(table: Omit<AutomaticTaxTable, 'version'>): string;
1975
+ declare function buildAutomaticTaxTable(rows: {
1976
+ types: readonly AutomaticTaxTypeRow[];
1977
+ rates: readonly AutomaticTaxRateRow[];
1978
+ rules: readonly AutomaticTaxRuleRow[];
1979
+ }): AutomaticTaxTable;
1980
+ declare function registrationPlacesByKind(rates: readonly AutomaticTaxRateRow[]): ReadonlyMap<string, readonly string[]>;
1981
+
1982
+ declare function sha1Hex(text: string): string;
1983
+
1901
1984
  interface CurrencyRate {
1902
1985
  rate: number;
1903
1986
  country: string;
@@ -1966,4 +2049,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1966
2049
  }];
1967
2050
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1968
2051
 
1969
- 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, 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, 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 };
2052
+ 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 AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, 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, OutOfProvinceTaxes, 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, STANDARD_TAX_TYPE, 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, 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 TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, 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, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, 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, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -490,6 +490,25 @@ declare enum ShippingZoneError {
490
490
  MISSING_NAME = "MISSING_NAME"
491
491
  }
492
492
 
493
+ declare enum TaxRegistrationKind {
494
+ GST_HST = "GST_HST",
495
+ PST = "PST",
496
+ QST = "QST"
497
+ }
498
+ declare enum TaxSource {
499
+ MERCHANT = "merchant",
500
+ AUTOMATIC = "automatic"
501
+ }
502
+ declare enum OutOfProvinceTaxes {
503
+ AUTOMATIC = "automatic",
504
+ HOME = "home"
505
+ }
506
+ declare enum TaxWarningCode {
507
+ NOT_REGISTERED = "NOT_REGISTERED",
508
+ NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE",
509
+ NO_TABLE = "NO_TABLE"
510
+ }
511
+
493
512
  declare enum SalesLineAction {
494
513
  SALE = "sale",
495
514
  REFUND = "refund"
@@ -1898,6 +1917,70 @@ interface ShippingZoneProblem {
1898
1917
  }
1899
1918
  declare function validateShippingZone(zone: ShippingZoneRule): ShippingZoneProblem[];
1900
1919
 
1920
+ interface TaxRegistration {
1921
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1922
+ place: string;
1923
+ number?: string | null;
1924
+ from?: string | null;
1925
+ }
1926
+
1927
+ declare const STANDARD_TAX_TYPE = "standard";
1928
+ type AutomaticTaxRowStatus = 'confirmed' | 'to_confirm';
1929
+ interface AutomaticTaxTypeRow {
1930
+ key: string;
1931
+ name: string;
1932
+ description?: string | null;
1933
+ sortOrder: number;
1934
+ active: boolean;
1935
+ }
1936
+ interface AutomaticTaxPart {
1937
+ code: string;
1938
+ name: string;
1939
+ rate: string;
1940
+ level: 'federal' | 'provincial';
1941
+ }
1942
+ interface AutomaticTaxRateRow {
1943
+ code: string;
1944
+ name: string;
1945
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1946
+ places: string[];
1947
+ rate: string;
1948
+ from?: string | null;
1949
+ to?: string | null;
1950
+ order: number;
1951
+ compound: boolean;
1952
+ registrationPlace: string;
1953
+ harmonized: boolean;
1954
+ parts?: AutomaticTaxPart[] | null;
1955
+ sourceUrl?: string | null;
1956
+ status: AutomaticTaxRowStatus;
1957
+ }
1958
+ interface AutomaticTaxRuleRow {
1959
+ taxType: string;
1960
+ codes: string[];
1961
+ rate: string;
1962
+ from?: string | null;
1963
+ to?: string | null;
1964
+ sourceUrl?: string | null;
1965
+ status: AutomaticTaxRowStatus;
1966
+ note?: string | null;
1967
+ }
1968
+ interface AutomaticTaxTable {
1969
+ version: string;
1970
+ types: AutomaticTaxTypeRow[];
1971
+ rates: AutomaticTaxRateRow[];
1972
+ rules: AutomaticTaxRuleRow[];
1973
+ }
1974
+ declare function automaticTaxTableVersion(table: Omit<AutomaticTaxTable, 'version'>): string;
1975
+ declare function buildAutomaticTaxTable(rows: {
1976
+ types: readonly AutomaticTaxTypeRow[];
1977
+ rates: readonly AutomaticTaxRateRow[];
1978
+ rules: readonly AutomaticTaxRuleRow[];
1979
+ }): AutomaticTaxTable;
1980
+ declare function registrationPlacesByKind(rates: readonly AutomaticTaxRateRow[]): ReadonlyMap<string, readonly string[]>;
1981
+
1982
+ declare function sha1Hex(text: string): string;
1983
+
1901
1984
  interface CurrencyRate {
1902
1985
  rate: number;
1903
1986
  country: string;
@@ -1966,4 +2049,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1966
2049
  }];
1967
2050
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1968
2051
 
1969
- 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, 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, 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 };
2052
+ 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 AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, 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, OutOfProvinceTaxes, 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, STANDARD_TAX_TYPE, 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, 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 TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, 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, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, 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, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.js CHANGED
@@ -77,6 +77,7 @@ __export(index_exports, {
77
77
  ORDER_STATE_TOPIC: () => ORDER_STATE_TOPIC,
78
78
  OrderPlatform: () => OrderPlatform,
79
79
  OtherFixedRates: () => OtherFixedRates,
80
+ OutOfProvinceTaxes: () => OutOfProvinceTaxes,
80
81
  OwnerType: () => OwnerType,
81
82
  PATH_MODES: () => PATH_MODES,
82
83
  PAYMENT_CHANNELS: () => PAYMENT_CHANNELS,
@@ -105,6 +106,7 @@ __export(index_exports, {
105
106
  ResidualStatus: () => ResidualStatus,
106
107
  ResourceAvailabilityState: () => ResourceAvailabilityState,
107
108
  SHIPPING_COUNTRIES: () => SHIPPING_COUNTRIES,
109
+ STANDARD_TAX_TYPE: () => STANDARD_TAX_TYPE,
108
110
  STATE_SCHEMA: () => STATE_SCHEMA,
109
111
  STRIPE_SUPPORTED_COUNTRIES: () => STRIPE_SUPPORTED_COUNTRIES,
110
112
  SYSTEM_FAMILIES: () => SYSTEM_FAMILIES,
@@ -122,6 +124,9 @@ __export(index_exports, {
122
124
  StationStatus: () => StationStatus,
123
125
  StripeCurrencyCode: () => StripeCurrencyCode,
124
126
  StripeStatus: () => StripeStatus,
127
+ TaxRegistrationKind: () => TaxRegistrationKind,
128
+ TaxSource: () => TaxSource,
129
+ TaxWarningCode: () => TaxWarningCode,
125
130
  TimePeriod: () => TimePeriod,
126
131
  TopMetericsSort: () => TopMetericsSort,
127
132
  UserTypes: () => UserTypes,
@@ -136,11 +141,13 @@ __export(index_exports, {
136
141
  ancestorChain: () => ancestorChain,
137
142
  applyAssignment: () => applyAssignment,
138
143
  assertUnitSane: () => assertUnitSane,
144
+ automaticTaxTableVersion: () => automaticTaxTableVersion,
139
145
  availableIn: () => availableIn,
140
146
  baseFor: () => baseFor,
141
147
  baseFulfillmentDefinitions: () => baseFulfillmentDefinitions,
142
148
  baseOf: () => baseOf,
143
149
  basePaymentDefinitions: () => basePaymentDefinitions,
150
+ buildAutomaticTaxTable: () => buildAutomaticTaxTable,
144
151
  buildAvailability: () => buildAvailability,
145
152
  buildGrid: () => buildGrid,
146
153
  buildOrderContext: () => buildOrderContext,
@@ -237,6 +244,7 @@ __export(index_exports, {
237
244
  presentAt: () => presentAt,
238
245
  priceForTotal: () => priceForTotal,
239
246
  provincesForPostCode: () => provincesForPostCode,
247
+ registrationPlacesByKind: () => registrationPlacesByKind,
240
248
  removeFragment: () => removeFragment,
241
249
  resolveFamily: () => resolveFamily,
242
250
  resolveModifiersForProduct: () => resolveModifiersForProduct,
@@ -246,6 +254,7 @@ __export(index_exports, {
246
254
  roundToPrecision: () => roundToPrecision,
247
255
  sameFamily: () => sameFamily,
248
256
  setOrderState: () => setOrderState,
257
+ sha1Hex: () => sha1Hex,
249
258
  shipsToCountry: () => shipsToCountry,
250
259
  shopDayKey: () => shopDayKey,
251
260
  shopDayRange: () => shopDayRange,
@@ -808,6 +817,30 @@ var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
808
817
  return ShippingZoneError2;
809
818
  })(ShippingZoneError || {});
810
819
 
820
+ // enums/tax.enum.ts
821
+ var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
822
+ TaxRegistrationKind2["GST_HST"] = "GST_HST";
823
+ TaxRegistrationKind2["PST"] = "PST";
824
+ TaxRegistrationKind2["QST"] = "QST";
825
+ return TaxRegistrationKind2;
826
+ })(TaxRegistrationKind || {});
827
+ var TaxSource = /* @__PURE__ */ ((TaxSource2) => {
828
+ TaxSource2["MERCHANT"] = "merchant";
829
+ TaxSource2["AUTOMATIC"] = "automatic";
830
+ return TaxSource2;
831
+ })(TaxSource || {});
832
+ var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
833
+ OutOfProvinceTaxes2["AUTOMATIC"] = "automatic";
834
+ OutOfProvinceTaxes2["HOME"] = "home";
835
+ return OutOfProvinceTaxes2;
836
+ })(OutOfProvinceTaxes || {});
837
+ var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
838
+ TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
839
+ TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
840
+ TaxWarningCode2["NO_TABLE"] = "NO_TABLE";
841
+ return TaxWarningCode2;
842
+ })(TaxWarningCode || {});
843
+
811
844
  // enums/sales-line.enum.ts
812
845
  var SalesLineAction = /* @__PURE__ */ ((SalesLineAction2) => {
813
846
  SalesLineAction2["SALE"] = "sale";
@@ -4312,6 +4345,147 @@ function tiersAreValid(option) {
4312
4345
  return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
4313
4346
  }
4314
4347
 
4348
+ // tax/sha1.ts
4349
+ function utf8Bytes(text) {
4350
+ const bytes = [];
4351
+ for (const char of text) {
4352
+ const cp = char.codePointAt(0);
4353
+ if (cp < 128) bytes.push(cp);
4354
+ else if (cp < 2048) bytes.push(192 | cp >> 6, 128 | cp & 63);
4355
+ else if (cp < 65536) bytes.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
4356
+ else bytes.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
4357
+ }
4358
+ return bytes;
4359
+ }
4360
+ var rotl = (x, n) => x << n | x >>> 32 - n;
4361
+ function sha1Hex(text) {
4362
+ const bytes = utf8Bytes(text);
4363
+ const bitLength = bytes.length * 8;
4364
+ bytes.push(128);
4365
+ while (bytes.length % 64 !== 56) bytes.push(0);
4366
+ const high = Math.floor(bitLength / 4294967296);
4367
+ for (const word of [high, bitLength >>> 0])
4368
+ bytes.push(word >>> 24 & 255, word >>> 16 & 255, word >>> 8 & 255, word & 255);
4369
+ const h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
4370
+ const w = new Array(80);
4371
+ for (let offset = 0; offset < bytes.length; offset += 64) {
4372
+ for (let i = 0; i < 16; i++) {
4373
+ const j = offset + i * 4;
4374
+ w[i] = bytes[j] << 24 | bytes[j + 1] << 16 | bytes[j + 2] << 8 | bytes[j + 3];
4375
+ }
4376
+ for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
4377
+ let [a, b, c, d, e] = h;
4378
+ for (let i = 0; i < 80; i++) {
4379
+ const [f, k] = i < 20 ? [b & c | ~b & d, 1518500249] : i < 40 ? [b ^ c ^ d, 1859775393] : i < 60 ? [b & c | b & d | c & d, 2400959708] : [b ^ c ^ d, 3395469782];
4380
+ const t = rotl(a, 5) + f + e + k + w[i] | 0;
4381
+ e = d;
4382
+ d = c;
4383
+ c = rotl(b, 30);
4384
+ b = a;
4385
+ a = t;
4386
+ }
4387
+ h[0] = h[0] + a | 0;
4388
+ h[1] = h[1] + b | 0;
4389
+ h[2] = h[2] + c | 0;
4390
+ h[3] = h[3] + d | 0;
4391
+ h[4] = h[4] + e | 0;
4392
+ }
4393
+ return h.map((x) => (x >>> 0).toString(16).padStart(8, "0")).join("");
4394
+ }
4395
+
4396
+ // tax/table.ts
4397
+ var STANDARD_TAX_TYPE = "standard";
4398
+ var TYPE_FIELDS = ["key", "name", "description", "sortOrder", "active"];
4399
+ var RATE_FIELDS = [
4400
+ "code",
4401
+ "name",
4402
+ "kind",
4403
+ "places",
4404
+ "rate",
4405
+ "from",
4406
+ "to",
4407
+ "order",
4408
+ "compound",
4409
+ "registrationPlace",
4410
+ "harmonized",
4411
+ "parts",
4412
+ "sourceUrl",
4413
+ "status"
4414
+ ];
4415
+ var RULE_FIELDS = ["taxType", "codes", "rate", "from", "to", "sourceUrl", "status", "note"];
4416
+ function canonical(row, fields) {
4417
+ return JSON.stringify(fields.map((field) => row[field] ?? null));
4418
+ }
4419
+ var sortedCanonical = (rows, fields) => rows.map((row) => canonical(row, fields)).sort();
4420
+ function automaticTaxTableVersion(table) {
4421
+ return sha1Hex(
4422
+ JSON.stringify([
4423
+ sortedCanonical(table.types, TYPE_FIELDS),
4424
+ sortedCanonical(table.rates, RATE_FIELDS),
4425
+ sortedCanonical(table.rules, RULE_FIELDS)
4426
+ ])
4427
+ );
4428
+ }
4429
+ var toTypeRow = ({ key, name, description, sortOrder, active }) => ({
4430
+ key,
4431
+ name,
4432
+ description,
4433
+ sortOrder,
4434
+ active
4435
+ });
4436
+ var toRateRow = (rate) => ({
4437
+ code: rate.code,
4438
+ name: rate.name,
4439
+ kind: rate.kind,
4440
+ places: rate.places,
4441
+ rate: rate.rate,
4442
+ from: rate.from,
4443
+ to: rate.to,
4444
+ order: rate.order,
4445
+ compound: rate.compound,
4446
+ registrationPlace: rate.registrationPlace,
4447
+ harmonized: rate.harmonized,
4448
+ parts: rate.parts?.map(({ code, name, rate: partRate, level }) => ({ code, name, rate: partRate, level })),
4449
+ sourceUrl: rate.sourceUrl,
4450
+ status: rate.status
4451
+ });
4452
+ var toRuleRow = ({
4453
+ taxType,
4454
+ codes: codes2,
4455
+ rate,
4456
+ from,
4457
+ to,
4458
+ sourceUrl,
4459
+ status,
4460
+ note
4461
+ }) => ({
4462
+ taxType,
4463
+ codes: codes2,
4464
+ rate,
4465
+ from,
4466
+ to,
4467
+ sourceUrl,
4468
+ status,
4469
+ note
4470
+ });
4471
+ function buildAutomaticTaxTable(rows) {
4472
+ const table = {
4473
+ types: [...rows.types].sort((a, b) => a.sortOrder - b.sortOrder).map(toTypeRow),
4474
+ rates: rows.rates.map(toRateRow),
4475
+ rules: rows.rules.map(toRuleRow)
4476
+ };
4477
+ return { version: automaticTaxTableVersion(table), ...table };
4478
+ }
4479
+ function registrationPlacesByKind(rates) {
4480
+ const places = /* @__PURE__ */ new Map();
4481
+ for (const rate of rates) {
4482
+ const list = places.get(rate.kind) ?? [];
4483
+ if (!list.includes(rate.registrationPlace)) list.push(rate.registrationPlace);
4484
+ places.set(rate.kind, list);
4485
+ }
4486
+ return places;
4487
+ }
4488
+
4315
4489
  // constants/adyen.constants.ts
4316
4490
  var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
4317
4491
  function isAdyenRolloutCountry(alpha2) {
@@ -4465,6 +4639,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4465
4639
  ORDER_STATE_TOPIC,
4466
4640
  OrderPlatform,
4467
4641
  OtherFixedRates,
4642
+ OutOfProvinceTaxes,
4468
4643
  OwnerType,
4469
4644
  PATH_MODES,
4470
4645
  PAYMENT_CHANNELS,
@@ -4493,6 +4668,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4493
4668
  ResidualStatus,
4494
4669
  ResourceAvailabilityState,
4495
4670
  SHIPPING_COUNTRIES,
4671
+ STANDARD_TAX_TYPE,
4496
4672
  STATE_SCHEMA,
4497
4673
  STRIPE_SUPPORTED_COUNTRIES,
4498
4674
  SYSTEM_FAMILIES,
@@ -4510,6 +4686,9 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4510
4686
  StationStatus,
4511
4687
  StripeCurrencyCode,
4512
4688
  StripeStatus,
4689
+ TaxRegistrationKind,
4690
+ TaxSource,
4691
+ TaxWarningCode,
4513
4692
  TimePeriod,
4514
4693
  TopMetericsSort,
4515
4694
  UserTypes,
@@ -4524,11 +4703,13 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4524
4703
  ancestorChain,
4525
4704
  applyAssignment,
4526
4705
  assertUnitSane,
4706
+ automaticTaxTableVersion,
4527
4707
  availableIn,
4528
4708
  baseFor,
4529
4709
  baseFulfillmentDefinitions,
4530
4710
  baseOf,
4531
4711
  basePaymentDefinitions,
4712
+ buildAutomaticTaxTable,
4532
4713
  buildAvailability,
4533
4714
  buildGrid,
4534
4715
  buildOrderContext,
@@ -4625,6 +4806,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4625
4806
  presentAt,
4626
4807
  priceForTotal,
4627
4808
  provincesForPostCode,
4809
+ registrationPlacesByKind,
4628
4810
  removeFragment,
4629
4811
  resolveFamily,
4630
4812
  resolveModifiersForProduct,
@@ -4634,6 +4816,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4634
4816
  roundToPrecision,
4635
4817
  sameFamily,
4636
4818
  setOrderState,
4819
+ sha1Hex,
4637
4820
  shipsToCountry,
4638
4821
  shopDayKey,
4639
4822
  shopDayRange,