@classytic/cart 0.2.1 → 1.0.0

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +75 -21
  3. package/dist/{cart-event-catalog-BxDJhtTM.d.mts → cart-event-catalog-Cokx0iOw.d.mts} +1 -2
  4. package/dist/cart.error-xi5OT4Sz.mjs +52 -0
  5. package/dist/{clock.port-CNu2wgdA.d.mts → clock.port-DrSBrsit.d.mts} +9 -5
  6. package/dist/{create-cart-BeW0xAqD.mjs → define-cart-BPq2kb_V.mjs} +344 -224
  7. package/dist/domain/errors/index.d.mts +2 -2
  8. package/dist/domain/errors/index.mjs +6 -6
  9. package/dist/domain/events/index.d.mts +2 -2
  10. package/dist/domain/events/index.mjs +2 -2
  11. package/dist/domain/index.d.mts +14 -11
  12. package/dist/domain/index.mjs +12 -12
  13. package/dist/domain/ports/index.d.mts +3 -3
  14. package/dist/domain/ports/index.mjs +1 -1
  15. package/dist/domain/saga/index.d.mts +1 -1
  16. package/dist/domain/saga/index.mjs +1 -1
  17. package/dist/engine/cart-config.schema.d.mts +3 -4
  18. package/dist/engine/cart-config.schema.mjs +7 -7
  19. package/dist/engine/index.d.mts +3 -3
  20. package/dist/engine/index.mjs +3 -3
  21. package/dist/{errors-7Pd0yATM.mjs → errors-Dj8itvAh.mjs} +1 -4
  22. package/dist/{id.port-BhbFZJPm.mjs → id.port-DYAnXbfV.mjs} +1 -1
  23. package/dist/{index-BB0XzkXF.d.mts → index-BTSo-RLv.d.mts} +41 -4
  24. package/dist/index.d.mts +75 -17
  25. package/dist/index.mjs +180 -15
  26. package/dist/{internal-event-bus-DhQKi9KS.d.mts → internal-event-bus-Bu7Xj7j6.d.mts} +203 -170
  27. package/dist/{kind-registry-DG2iCCH1.d.mts → kind-registry-DFvNDb81.d.mts} +3 -5
  28. package/dist/{kind-registry-Bvrj3P1Q.mjs → kind-registry-DQYqRQZU.mjs} +1 -1
  29. package/dist/{kind.error-DIaJpdUb.mjs → kind.error-BoyoVjKx.mjs} +1 -1
  30. package/dist/kinds/index.d.mts +1 -1
  31. package/dist/kinds/index.mjs +1 -1
  32. package/dist/{line-kind-B1mU1iJp.d.mts → line-kind-BW2zLNSr.d.mts} +3 -4
  33. package/dist/line-total-6VJQMjGV.mjs +24 -0
  34. package/dist/{outbox-store-CBt9fSYh.d.mts → outbox-store-Br7MHuOz.d.mts} +3 -18
  35. package/dist/{outbox-store-CWW8ppxS.mjs → outbox-store-DLxCPOUN.mjs} +2 -30
  36. package/dist/{reservation.entity-DLMxgpLE.d.mts → reservation.entity-BEeYbRUY.d.mts} +4 -5
  37. package/dist/{state-transition.error-2fRLh3p0.mjs → state-transition.error-BssJiRoW.mjs} +1 -1
  38. package/dist/{state-transitions-D19wZe-w.d.mts → state-transitions-BQ2Nhxnb.d.mts} +14 -11
  39. package/dist/{state-transitions-Defw8gAt.mjs → state-transitions-wunwhjap.mjs} +1 -1
  40. package/dist/{unmanaged-session.error-C9Z1Yh9j.mjs → unmanaged-session.error-DIRT2PR3.mjs} +31 -2
  41. package/dist/{variant.kind-q-yv-vnQ.d.mts → variant.kind-CClf8MTF.d.mts} +3 -3
  42. package/dist/{variant.kind-BHiivO9B.mjs → variant.kind-NmWSslu-.mjs} +23 -32
  43. package/package.json +10 -9
  44. package/dist/cart.error-BwWy4RlY.mjs +0 -27
  45. package/dist/index-2Ag-54t8.d.mts +0 -1
  46. /package/dist/{cart-status.vo-CNJw4aaB.d.mts → cart-status.vo-BoVPaSXX.d.mts} +0 -0
  47. /package/dist/{domain-event-CIEORKF6.mjs → domain-event-DBFsiHNJ.mjs} +0 -0
  48. /package/dist/{id.port-DitjeoHg.d.mts → id.port-DzgWy8sy.d.mts} +0 -0
  49. /package/dist/{idempotency-key.vo-D0lJsvGn.mjs → idempotency-key.vo-BoRvSIxx.mjs} +0 -0
@@ -1,2 +1,2 @@
1
- import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, h as CartErrorCategory, i as IdempotencyBusyError, l as PriceChangedError, m as CartError, n as StateTransitionError, o as SagaError, p as ConcurrencyError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "../../index-BB0XzkXF.mjs";
2
- export { CartError, CartErrorCategory, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, SagaFailurePhase, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError };
1
+ import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, g as CartErrorCategory, h as CartError, i as IdempotencyBusyError, l as PriceChangedError, m as ConcurrencyError, n as StateTransitionError, o as SagaError, p as CurrencyMismatchError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "../../index-BTSo-RLv.mjs";
2
+ export { CartError, type CartErrorCategory, ConcurrencyError, CurrencyMismatchError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, type SagaFailurePhase, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError };
@@ -1,6 +1,6 @@
1
- import { t as CartError } from "../../cart.error-BwWy4RlY.mjs";
2
- import { a as ConcurrencyError, i as NotFoundError, n as StaleQuoteError, r as PriceChangedError, t as UnmanagedSessionError } from "../../unmanaged-session.error-C9Z1Yh9j.mjs";
3
- import { n as UnknownKindError, t as KindError } from "../../kind.error-DIaJpdUb.mjs";
4
- import { i as ReservationError, n as IdempotencyStorageError, r as SagaError, t as IdempotencyBusyError } from "../../errors-7Pd0yATM.mjs";
5
- import { t as StateTransitionError } from "../../state-transition.error-2fRLh3p0.mjs";
6
- export { CartError, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError };
1
+ import { t as CartError } from "../../cart.error-xi5OT4Sz.mjs";
2
+ import { a as CurrencyMismatchError, i as NotFoundError, n as StaleQuoteError, o as ConcurrencyError, r as PriceChangedError, t as UnmanagedSessionError } from "../../unmanaged-session.error-DIRT2PR3.mjs";
3
+ import { n as UnknownKindError, t as KindError } from "../../kind.error-BoyoVjKx.mjs";
4
+ import { i as ReservationError, n as IdempotencyStorageError, r as SagaError, t as IdempotencyBusyError } from "../../errors-Dj8itvAh.mjs";
5
+ import { t as StateTransitionError } from "../../state-transition.error-BssJiRoW.mjs";
6
+ export { CartError, ConcurrencyError, CurrencyMismatchError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError };
@@ -1,3 +1,3 @@
1
- import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "../../outbox-store-CBt9fSYh.mjs";
2
- import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "../../cart-event-catalog-BxDJhtTM.mjs";
1
+ import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "../../outbox-store-Br7MHuOz.mjs";
2
+ import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "../../cart-event-catalog-Cokx0iOw.mjs";
3
3
  export { type CartAggregateType, type CartDomainEvent, type CartEventAggregate, type CartEventDefinition, type CartEventDefinitionInput, type CartEventMap, type CartEventMeta, type CartEventName, type CartEventPayload, type CartEventRegistry, CartEvents, type EventSchema, type EventSchemaProperty, type EventValidationResult, type EventValidator, InvalidOutboxEventError, MemoryOutboxStore, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxStoreWriteOptions, type OutboxWriteOptions, type PayloadOf, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, defineCartEvent };
@@ -1,3 +1,3 @@
1
- import { n as CartEvents, t as createCartEvent } from "../../domain-event-CIEORKF6.mjs";
2
- import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "../../outbox-store-CWW8ppxS.mjs";
1
+ import { n as CartEvents, t as createCartEvent } from "../../domain-event-DBFsiHNJ.mjs";
2
+ import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "../../outbox-store-DLxCPOUN.mjs";
3
3
  export { CartEvents, InvalidOutboxEventError, MemoryOutboxStore, OutboxOwnershipError, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, defineCartEvent };
@@ -1,12 +1,15 @@
1
- import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, h as CartErrorCategory, i as IdempotencyBusyError, l as PriceChangedError, m as CartError, n as StateTransitionError, o as SagaError, p as ConcurrencyError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "../index-BB0XzkXF.mjs";
2
- import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "../cart-status.vo-CNJw4aaB.mjs";
3
- import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "../outbox-store-CBt9fSYh.mjs";
4
- import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "../cart-event-catalog-BxDJhtTM.mjs";
5
- import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, x as BridgeRef, y as PromotionsBridge } from "../clock.port-CNu2wgdA.mjs";
6
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-DLMxgpLE.mjs";
7
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../state-transitions-D19wZe-w.mjs";
8
- import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "../line-kind-B1mU1iJp.mjs";
9
- import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "../kind-registry-DG2iCCH1.mjs";
10
- import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-DitjeoHg.mjs";
1
+ import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, g as CartErrorCategory, h as CartError, i as IdempotencyBusyError, l as PriceChangedError, m as ConcurrencyError, n as StateTransitionError, o as SagaError, p as CurrencyMismatchError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "../index-BTSo-RLv.mjs";
2
+ import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "../cart-status.vo-BoVPaSXX.mjs";
3
+ import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "../outbox-store-Br7MHuOz.mjs";
4
+ import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "../cart-event-catalog-Cokx0iOw.mjs";
5
+ import "./events/index.mjs";
6
+ import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, x as BridgeRef, y as PromotionsBridge } from "../clock.port-DrSBrsit.mjs";
7
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-BEeYbRUY.mjs";
8
+ import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../state-transitions-BQ2Nhxnb.mjs";
9
+ import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "../line-kind-BW2zLNSr.mjs";
10
+ import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "../kind-registry-DFvNDb81.mjs";
11
+ import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-DzgWy8sy.mjs";
12
+ import "./ports/index.mjs";
13
+ import "./saga/index.mjs";
11
14
  import { Money, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
12
- export { type Adjustment, AdjustmentSpec, BridgeRef, BridgeStatus, CART_REF_NEW, CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, CartAggregateType, CartDomainEvent, CartError, CartErrorCategory, CartEventAggregate, CartEventDefinition, CartEventDefinitionInput, CartEventMap, CartEventMeta, CartEventName, CartEventPayload, CartEventRegistry, CartEvents, CartSnapshot, CatalogBridge, type Checkout, CheckoutFlowState, type CheckoutState, CheckoutStep, CheckoutStepNumber, ClockPort, ConcurrencyError, type Draft, type DraftStatus, EventSchema, EventSchemaProperty, EventValidationResult, EventValidator, IdPort, IdempotencyBusyError, type IdempotencyIdentity, type IdempotencyRecord, type IdempotencyReplay, IdempotencyStorageError, InvalidOutboxEventError, InventoryBridge, type KindBridges, type KindContext, KindError, type KindRegistry, type LineDisplay, type LineItem, type LineKind, type LineLike, MemoryOutboxStore, type Money, NotFoundError, OperationContext, type OperationName, OutboxAcknowledgeOptions, OutboxClaimOptions, OutboxErrorInfo, OutboxFailOptions, OutboxFailureContext, OutboxFailureDecision, OutboxFailurePolicy, OutboxOwnershipError, OutboxStore, OutboxStoreWriteOptions, OutboxWriteOptions, PayloadOf, PriceChangedError, type PricedLine, type PricingSnapshot, ProductSummary, PromotionResult, PromotionsBridge, type Reservation, ReservationError, ReservationRef, ReservationRequest, type ReservationStatus, type RevalidationResult, SagaDependencies, SagaError, SagaFailurePhase, SagaStepFn, ShippingBridge, ShippingMethod, ShippingQuote, ShippingQuoteRequest, type StaleBehavior, StaleQuoteError, type StaleTrigger, StateTransitionError, TaxBreakdown, TaxBridge, TaxCalculationRequest, TaxCalculationResult, type TotalsSnapshot, UnknownKindError, UnmanagedSessionError, type ValidityPolicy, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
15
+ export { type Adjustment, type AdjustmentSpec, type BridgeRef, type BridgeStatus, CART_REF_NEW, CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, type CartAggregateType, type CartDomainEvent, CartError, type CartErrorCategory, type CartEventAggregate, type CartEventDefinition, type CartEventDefinitionInput, type CartEventMap, type CartEventMeta, type CartEventName, type CartEventPayload, type CartEventRegistry, CartEvents, type CartSnapshot, type CatalogBridge, type Checkout, type CheckoutFlowState, type CheckoutState, CheckoutStep, type CheckoutStepNumber, type ClockPort, ConcurrencyError, CurrencyMismatchError, type Draft, type DraftStatus, type EventSchema, type EventSchemaProperty, type EventValidationResult, type EventValidator, type IdPort, IdempotencyBusyError, type IdempotencyIdentity, type IdempotencyRecord, type IdempotencyReplay, IdempotencyStorageError, InvalidOutboxEventError, type InventoryBridge, type KindBridges, type KindContext, KindError, type KindRegistry, type LineDisplay, type LineItem, type LineKind, type LineLike, MemoryOutboxStore, type Money, NotFoundError, type OperationContext, type OperationName, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxStoreWriteOptions, type OutboxWriteOptions, type PayloadOf, PriceChangedError, type PricedLine, type PricingSnapshot, type ProductSummary, type PromotionResult, type PromotionsBridge, type Reservation, ReservationError, type ReservationRef, type ReservationRequest, type ReservationStatus, type RevalidationResult, type SagaDependencies, SagaError, type SagaFailurePhase, type SagaStepFn, type ShippingBridge, type ShippingMethod, type ShippingQuote, type ShippingQuoteRequest, type StaleBehavior, StaleQuoteError, type StaleTrigger, StateTransitionError, type TaxBreakdown, type TaxBridge, type TaxCalculationRequest, type TaxCalculationResult, type TotalsSnapshot, UnknownKindError, UnmanagedSessionError, type ValidityPolicy, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
@@ -1,16 +1,16 @@
1
- import { t as CART_REF_NEW } from "../idempotency-key.vo-D0lJsvGn.mjs";
2
- import { t as CartError } from "../cart.error-BwWy4RlY.mjs";
3
- import { a as ConcurrencyError, i as NotFoundError, n as StaleQuoteError, r as PriceChangedError, t as UnmanagedSessionError } from "../unmanaged-session.error-C9Z1Yh9j.mjs";
4
- import { n as UnknownKindError, t as KindError } from "../kind.error-DIaJpdUb.mjs";
5
- import { i as ReservationError, n as IdempotencyStorageError, r as SagaError, t as IdempotencyBusyError } from "../errors-7Pd0yATM.mjs";
6
- import { t as StateTransitionError } from "../state-transition.error-2fRLh3p0.mjs";
7
- import { n as CartEvents, t as createCartEvent } from "../domain-event-CIEORKF6.mjs";
8
- import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "../outbox-store-CWW8ppxS.mjs";
9
- import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../id.port-BhbFZJPm.mjs";
10
- import { t as createKindRegistry } from "../kind-registry-Bvrj3P1Q.mjs";
11
- import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../state-transitions-Defw8gAt.mjs";
1
+ import { t as CART_REF_NEW } from "../idempotency-key.vo-BoRvSIxx.mjs";
2
+ import { t as CartError } from "../cart.error-xi5OT4Sz.mjs";
3
+ import { a as CurrencyMismatchError, i as NotFoundError, n as StaleQuoteError, o as ConcurrencyError, r as PriceChangedError, t as UnmanagedSessionError } from "../unmanaged-session.error-DIRT2PR3.mjs";
4
+ import { n as UnknownKindError, t as KindError } from "../kind.error-BoyoVjKx.mjs";
5
+ import { i as ReservationError, n as IdempotencyStorageError, r as SagaError, t as IdempotencyBusyError } from "../errors-Dj8itvAh.mjs";
6
+ import { t as StateTransitionError } from "../state-transition.error-BssJiRoW.mjs";
7
+ import { n as CartEvents, t as createCartEvent } from "../domain-event-DBFsiHNJ.mjs";
8
+ import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "../outbox-store-DLxCPOUN.mjs";
9
+ import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../id.port-DYAnXbfV.mjs";
10
+ import { t as createKindRegistry } from "../kind-registry-DQYqRQZU.mjs";
11
+ import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../state-transitions-wunwhjap.mjs";
12
12
  import "./events/index.mjs";
13
13
  import "./ports/index.mjs";
14
14
  import "./saga/index.mjs";
15
15
  import { addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
16
- export { CART_REF_NEW, CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, CartError, CartEvents, CheckoutStep, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, InvalidOutboxEventError, KindError, MemoryOutboxStore, NotFoundError, OutboxOwnershipError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
16
+ export { CART_REF_NEW, CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, CartError, CartEvents, CheckoutStep, ConcurrencyError, CurrencyMismatchError, IdempotencyBusyError, IdempotencyStorageError, InvalidOutboxEventError, KindError, MemoryOutboxStore, NotFoundError, OutboxOwnershipError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, UnmanagedSessionError, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
@@ -1,3 +1,3 @@
1
- import { C as OperationContext, S as BridgeStatus, _ as CartSnapshot, a as ShippingQuote, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, x as BridgeRef, y as PromotionsBridge } from "../../clock.port-CNu2wgdA.mjs";
2
- import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../../id.port-DitjeoHg.mjs";
3
- export { AdjustmentSpec, BridgeRef, BridgeStatus, CartSnapshot, CatalogBridge, ClockPort, IdPort, InventoryBridge, OperationContext, ProductSummary, PromotionResult, PromotionsBridge, ReservationRef, ReservationRequest, ShippingBridge, ShippingMethod, ShippingQuote, ShippingQuoteRequest, TaxBreakdown, TaxBridge, TaxCalculationRequest, TaxCalculationResult, createCounterIdPort, cryptoIdPort, systemClock };
1
+ import { C as OperationContext, S as BridgeStatus, _ as CartSnapshot, a as ShippingQuote, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, x as BridgeRef, y as PromotionsBridge } from "../../clock.port-DrSBrsit.mjs";
2
+ import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../../id.port-DzgWy8sy.mjs";
3
+ export { type AdjustmentSpec, type BridgeRef, type BridgeStatus, type CartSnapshot, type CatalogBridge, type ClockPort, type IdPort, type InventoryBridge, type OperationContext, type ProductSummary, type PromotionResult, type PromotionsBridge, type ReservationRef, type ReservationRequest, type ShippingBridge, type ShippingMethod, type ShippingQuote, type ShippingQuoteRequest, type TaxBreakdown, type TaxBridge, type TaxCalculationRequest, type TaxCalculationResult, createCounterIdPort, cryptoIdPort, systemClock };
@@ -1,2 +1,2 @@
1
- import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../../id.port-BhbFZJPm.mjs";
1
+ import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../../id.port-DYAnXbfV.mjs";
2
2
  export { createCounterIdPort, cryptoIdPort, systemClock };
@@ -1,2 +1,2 @@
1
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../../state-transitions-D19wZe-w.mjs";
1
+ import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../../state-transitions-BQ2Nhxnb.mjs";
2
2
  export { CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, type CheckoutFlowState, CheckoutStep, type CheckoutStepNumber, type SagaDependencies, type SagaStepFn, isLegalCheckoutTransition };
@@ -1,2 +1,2 @@
1
- import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../../state-transitions-Defw8gAt.mjs";
1
+ import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../../state-transitions-wunwhjap.mjs";
2
2
  export { CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, CheckoutStep, isLegalCheckoutTransition };
@@ -1,10 +1,9 @@
1
1
  import { z } from "zod";
2
-
3
2
  //#region src/engine/cart-config.schema.d.ts
4
3
  /**
5
- * Zod v4 schema for `CartConfig`. Non-shape fields (connection, kinds,
6
- * bridges) carry functions and class instances and are validated
7
- * structurally by the engine factory.
4
+ * Zod v4 schema for the cart config surface embedded in `CartShape`. Non-shape
5
+ * fields (kinds, bridges) carry functions and class instances and are validated
6
+ * structurally by `defineCart` / its bind runtime.
8
7
  */
9
8
  declare const idempotencyConfigSchema: z.ZodObject<{
10
9
  inlineThresholdBytes: z.ZodDefault<z.ZodNumber>;
@@ -2,17 +2,17 @@ import { CURRENCY_PATTERN } from "@classytic/primitives/currency";
2
2
  import { z } from "zod";
3
3
  //#region src/engine/cart-config.schema.ts
4
4
  /**
5
- * Zod v4 schema for `CartConfig`. Non-shape fields (connection, kinds,
6
- * bridges) carry functions and class instances and are validated
7
- * structurally by the engine factory.
5
+ * Zod v4 schema for the cart config surface embedded in `CartShape`. Non-shape
6
+ * fields (kinds, bridges) carry functions and class instances and are validated
7
+ * structurally by `defineCart` / its bind runtime.
8
8
  */
9
9
  const idempotencyConfigSchema = z.object({
10
10
  /** Inline replay payload byte threshold. Default 12KB. */
11
- inlineThresholdBytes: z.number().int().positive().default(12 * 1024),
11
+ inlineThresholdBytes: z.number().int().positive().default(12288),
12
12
  /** Lease duration for in_flight records. Default 30s. */
13
13
  leaseMs: z.number().int().positive().default(3e4),
14
14
  /** Retention of resolved records. Default 24h. */
15
- retentionSeconds: z.number().int().positive().default(1440 * 60)
15
+ retentionSeconds: z.number().int().positive().default(86400)
16
16
  });
17
17
  const reservationConfigSchema = z.object({
18
18
  /** Default TTL for reservations in seconds. Default 10 minutes. */
@@ -37,9 +37,9 @@ const cartConfigSchema = z.object({
37
37
  /** Default currency if a draft is created with no currency set. */
38
38
  defaultCurrency: z.string().regex(CURRENCY_PATTERN, "ISO 4217 (3 uppercase letters)").default("USD"),
39
39
  idempotency: idempotencyConfigSchema.default({
40
- inlineThresholdBytes: 12 * 1024,
40
+ inlineThresholdBytes: 12288,
41
41
  leaseMs: 3e4,
42
- retentionSeconds: 1440 * 60
42
+ retentionSeconds: 86400
43
43
  }),
44
44
  reservation: reservationConfigSchema.default({ defaultTtlSeconds: 600 }),
45
45
  checkout: checkoutConfigSchema.default({ staleOpenCheckoutMs: 6e5 }),
@@ -1,3 +1,3 @@
1
- import { CartConfigShape, cartConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
2
- import { a as CartEngine, i as CartConfig, n as createCart, r as CartBridges, t as InProcessCartEventBus } from "../internal-event-bus-DhQKi9KS.mjs";
3
- export { type CartBridges, type CartConfig, type CartConfigShape, type CartEngine, InProcessCartEventBus, cartConfigSchema, createCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
1
+ import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
2
+ import { a as defineCart, c as CartEngine, d as CartShape, f as ResolvedCartConfig, i as createCartDomain, l as CartLogger, n as CartBlueprint, o as CartBridges, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime } from "../internal-event-bus-Bu7Xj7j6.mjs";
3
+ export { type CartBlueprint, type CartBridges, type CartConfigShape, type CartDomain, type CartDomainRuntime, type CartEngine, type CartLogger, type CartRuntime, type CartShape, InProcessCartEventBus, type ResolvedCartConfig, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
@@ -1,3 +1,3 @@
1
- import { n as InProcessCartEventBus, t as createCart } from "../create-cart-BeW0xAqD.mjs";
2
- import { cartConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
3
- export { InProcessCartEventBus, cartConfigSchema, createCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
1
+ import { n as defineCart, r as InProcessCartEventBus, t as createCartDomain } from "../define-cart-BPq2kb_V.mjs";
2
+ import { cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
3
+ export { InProcessCartEventBus, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
@@ -1,4 +1,4 @@
1
- import { t as CartError } from "./cart.error-BwWy4RlY.mjs";
1
+ import { t as CartError } from "./cart.error-xi5OT4Sz.mjs";
2
2
  //#region src/domain/errors/reservation.error.ts
3
3
  /**
4
4
  * Inventory / slot reservation could not be secured. Thrown from the saga's
@@ -64,9 +64,6 @@ var IdempotencyStorageError = class extends CartError {
64
64
  code = "cart/idempotency_storage_corruption";
65
65
  category = "system";
66
66
  retryable = false;
67
- constructor(message, context) {
68
- super(message, context);
69
- }
70
67
  };
71
68
  //#endregion
72
69
  export { ReservationError as i, IdempotencyStorageError as n, SagaError as r, IdempotencyBusyError as t };
@@ -11,7 +11,7 @@ const systemClock = { now: () => /* @__PURE__ */ new Date() };
11
11
  const cryptoIdPort = { newId() {
12
12
  const g = globalThis;
13
13
  if (typeof g.crypto?.randomUUID === "function") return g.crypto.randomUUID();
14
- throw new Error("cryptoIdPort: globalThis.crypto.randomUUID is not available in this runtime. Node 19+, Deno, Bun, and modern browsers expose it natively. Older runtimes should supply a custom `id` port to createCart(), e.g. uuid v4 from the `uuid` package or Temporal's `workflow.uuid4()`.");
14
+ throw new Error("cryptoIdPort: globalThis.crypto.randomUUID is not available in this runtime. Node 19+, Deno, Bun, and modern browsers expose it natively. Older runtimes should supply a custom `id` port in the bind runtime, e.g. uuid v4 from the `uuid` package or Temporal's `workflow.uuid4()`.");
15
15
  } };
16
16
  /**
17
17
  * Deterministic counter-based id port for tests. Not exported from the
@@ -1,5 +1,4 @@
1
- import { t as CheckoutState } from "./cart-status.vo-CNJw4aaB.mjs";
2
-
1
+ import { t as CheckoutState } from "./cart-status.vo-BoVPaSXX.mjs";
3
2
  //#region src/domain/errors/cart.error.d.ts
4
3
  /**
5
4
  * Base class for every error the cart engine emits.
@@ -22,6 +21,22 @@ declare abstract class CartError extends Error {
22
21
  abstract readonly retryable: boolean;
23
22
  /** Optional structured context for logging / debugging. */
24
23
  readonly context?: Record<string, unknown>;
24
+ /**
25
+ * Canonical `HttpError.status` (`@classytic/repo-core/errors`), DERIVED from
26
+ * {@link category} — the category already encodes exactly the distinction a
27
+ * status code makes, so deriving it keeps the two from ever disagreeing.
28
+ *
29
+ * Without a numeric `status`, arc's global handler has nothing to key on and
30
+ * serializes every cart error as `arc.internal_error` / 500 — `NotFoundError`
31
+ * answered 500 instead of 404, `ConcurrencyError` 500 instead of 409. That
32
+ * tells a client "the server broke, retrying is pointless" about outcomes
33
+ * that are neither broken nor unretryable, and it defeats `retryable` above:
34
+ * the field says "retry is reasonable" while the status says "don't bother".
35
+ *
36
+ * A subclass may still override with `readonly status = N` for a genuinely
37
+ * special case; nothing here depends on the mapping being total.
38
+ */
39
+ get status(): number;
25
40
  constructor(message: string, context?: Record<string, unknown>);
26
41
  /**
27
42
  * Serialize to a wire-safe shape. Suitable for HTTP error bodies and
@@ -53,6 +68,29 @@ declare class ConcurrencyError extends CartError {
53
68
  constructor(resource: 'draft' | 'checkout' | 'reservation', expectedVersion: number, resourceId: string);
54
69
  }
55
70
  //#endregion
71
+ //#region src/domain/errors/currency-mismatch.error.d.ts
72
+ /**
73
+ * Two currencies were mixed inside a single money computation.
74
+ *
75
+ * The pricing pipeline assumes every line shares the draft's ONE currency —
76
+ * grand totals are summed as raw minor-unit integers and stamped with a single
77
+ * currency code. If a line's currency diverges (e.g. an `overrideUnitPrice` in
78
+ * EUR added to a USD draft), a blind sum would silently produce a wrong total
79
+ * and freeze it into the checkout snapshot. `sumMoney` asserts single-currency
80
+ * and throws this instead of returning a mislabeled amount.
81
+ *
82
+ * Kinds guard currency at add-time (`validate`), so in practice this is a
83
+ * defense-in-depth invariant — reaching it means a kind returned a
84
+ * mismatched-currency `PricedLine` or an override slipped past validation.
85
+ * Not retryable: the caller must supply same-currency inputs.
86
+ */
87
+ declare class CurrencyMismatchError extends CartError {
88
+ readonly code = "cart/currency_mismatch";
89
+ readonly category: CartErrorCategory;
90
+ readonly retryable = false;
91
+ constructor(expected: string, found: string, details?: Record<string, unknown>);
92
+ }
93
+ //#endregion
56
94
  //#region src/domain/errors/kind.error.d.ts
57
95
  /**
58
96
  * A LineKind rejected a line during validate() or price().
@@ -205,7 +243,6 @@ declare class IdempotencyStorageError extends CartError {
205
243
  readonly code = "cart/idempotency_storage_corruption";
206
244
  readonly category: CartErrorCategory;
207
245
  readonly retryable = false;
208
- constructor(message: string, context: Record<string, unknown>);
209
246
  }
210
247
  //#endregion
211
248
  //#region src/domain/errors/stale-quote.error.d.ts
@@ -272,4 +309,4 @@ declare class UnmanagedSessionError extends CartError {
272
309
  constructor();
273
310
  }
274
311
  //#endregion
275
- export { IdempotencyStorageError as a, ReservationError as c, KindError as d, UnknownKindError as f, CartErrorCategory as h, IdempotencyBusyError as i, PriceChangedError as l, CartError as m, StateTransitionError as n, SagaError as o, ConcurrencyError as p, StaleQuoteError as r, SagaFailurePhase as s, UnmanagedSessionError as t, NotFoundError as u };
312
+ export { IdempotencyStorageError as a, ReservationError as c, KindError as d, UnknownKindError as f, CartErrorCategory as g, CartError as h, IdempotencyBusyError as i, PriceChangedError as l, ConcurrencyError as m, StateTransitionError as n, SagaError as o, CurrencyMismatchError as p, StaleQuoteError as r, SagaFailurePhase as s, UnmanagedSessionError as t, NotFoundError as u };
package/dist/index.d.mts CHANGED
@@ -1,21 +1,22 @@
1
- import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, h as CartErrorCategory, i as IdempotencyBusyError, l as PriceChangedError, m as CartError, n as StateTransitionError, o as SagaError, p as ConcurrencyError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "./index-BB0XzkXF.mjs";
2
- import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-CNJw4aaB.mjs";
3
- import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "./outbox-store-CBt9fSYh.mjs";
4
- import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "./cart-event-catalog-BxDJhtTM.mjs";
5
- import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, b as Address, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, w as PENDING_EVENTS, x as BridgeRef, y as PromotionsBridge } from "./clock.port-CNu2wgdA.mjs";
6
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-DLMxgpLE.mjs";
7
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep } from "./state-transitions-D19wZe-w.mjs";
8
- import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "./line-kind-B1mU1iJp.mjs";
9
- import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "./kind-registry-DG2iCCH1.mjs";
10
- import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-DitjeoHg.mjs";
1
+ import { a as IdempotencyStorageError, c as ReservationError, d as KindError, f as UnknownKindError, g as CartErrorCategory, h as CartError, i as IdempotencyBusyError, l as PriceChangedError, m as ConcurrencyError, n as StateTransitionError, o as SagaError, p as CurrencyMismatchError, r as StaleQuoteError, s as SagaFailurePhase, t as UnmanagedSessionError, u as NotFoundError } from "./index-BTSo-RLv.mjs";
2
+ import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-BoVPaSXX.mjs";
3
+ import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "./outbox-store-Br7MHuOz.mjs";
4
+ import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "./cart-event-catalog-Cokx0iOw.mjs";
5
+ import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, b as Address, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, w as PENDING_EVENTS, x as BridgeRef, y as PromotionsBridge } from "./clock.port-DrSBrsit.mjs";
6
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-BEeYbRUY.mjs";
7
+ import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep } from "./state-transitions-BQ2Nhxnb.mjs";
8
+ import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "./line-kind-BW2zLNSr.mjs";
9
+ import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "./kind-registry-DFvNDb81.mjs";
10
+ import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-DzgWy8sy.mjs";
11
11
  import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
12
- import { C as createReservationModel, D as createDraftModel, E as DraftDocument, O as CheckoutDocument, S as ReservationDocument, T as createIdempotencyModel, _ as CartEventPublisherDeps, a as CartEngine, b as CreateCartModelsOptions, c as CreateCartRepositoriesConfig, d as IdempotencyRepository, f as CheckoutRepository, g as DraftRepositoryDeps, h as DraftRepository, i as CartConfig, k as createCheckoutModel, l as createCartRepositories, m as DEFAULT_STALE_OPEN_CHECKOUT_MS, n as createCart, o as CartRepositories, p as CheckoutRepositoryDeps, r as CartBridges, s as CartRepositoryPluginBundle, t as InProcessCartEventBus, u as ReservationRepository, v as CartModelName, w as IdempotencyDocument, x as createCartModels, y as CartModels } from "./internal-event-bus-DhQKi9KS.mjs";
13
- import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "./variant.kind-q-yv-vnQ.mjs";
14
- import { Money, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
12
+ import { A as buildReservationSchema, C as DraftRepositoryDeps, D as DefineCartModelsConfig, E as CartModels, F as CheckoutDocument, I as buildCheckoutSchema, M as buildIdempotencySchema, N as DraftDocument, O as defineCartModels, P as buildDraftSchema, S as DraftRepository, T as CartModelName, _ as ReservationRepository, a as defineCart, b as CheckoutRepositoryDeps, c as CartEngine, d as CartShape, f as ResolvedCartConfig, g as createCartRepositories, h as CreateCartRepositoriesConfig, i as createCartDomain, j as IdempotencyDocument, k as ReservationDocument, l as CartLogger, m as CartRepositoryPluginBundle, n as CartBlueprint, o as CartBridges, p as CartRepositories, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime, v as IdempotencyRepository, w as CartEventPublisherDeps, x as DEFAULT_STALE_OPEN_CHECKOUT_MS, y as CheckoutRepository } from "./internal-event-bus-Bu7Xj7j6.mjs";
13
+ import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "./variant.kind-CClf8MTF.mjs";
14
+ import { Money, Money as Money$1, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
15
15
  import { DomainEvent, EventHandler, EventTransport, EventTransport as EventTransport$1, PublishManyResult } from "@classytic/primitives/events";
16
+ import { CurrencyCode } from "@classytic/primitives/currency";
16
17
  import { Connection, Schema } from "mongoose";
17
18
  import { ResolvedTenantConfig, TenantConfig } from "@classytic/repo-core/tenant";
18
-
19
+ import { CleanupStep } from "@classytic/repo-core/cleanup";
19
20
  //#region src/engine/run-unit.d.ts
20
21
  /**
21
22
  * Drain a `[PENDING_EVENTS]` queue through a transport after commit,
@@ -128,11 +129,12 @@ declare function mergeDrafts(opts: {
128
129
  */
129
130
  declare function runPricing(opts: {
130
131
  lines: readonly LineItem[];
131
- currency: string;
132
+ currency: CurrencyCode;
132
133
  kinds: KindRegistry;
133
134
  bridges: CartBridges;
134
135
  clock: ClockPort;
135
- ctx: OperationContext; /** Prior snapshot to reuse unchanged per-line prices from. */
136
+ ctx: OperationContext;
137
+ /** Prior snapshot to reuse unchanged per-line prices from. */
136
138
  previous?: PricingSnapshot | null;
137
139
  }): Promise<{
138
140
  snapshot: PricingSnapshot;
@@ -152,4 +154,60 @@ type CartTenantInput = TenantConfig | boolean | {
152
154
  /** Re-export of primitives' resolved shape under the legacy name. */
153
155
  type ResolvedTenant = ResolvedTenantConfig;
154
156
  //#endregion
155
- export { type Address, type Adjustment, type AdjustmentSpec, type BridgeRef, type BridgeStatus, type BundleComponent, type BundlePayload, CART_REF_NEW, CHECKOUT_STATE_TRANSITIONS, type CartAggregateType, type CartBridges, type CartConfig, type CartConfigShape, type CartDomainEvent, type CartEngine, CartError, type CartErrorCategory, type CartEventAggregate, type CartEventDefinition, type CartEventDefinitionInput, type CartEventMap, type CartEventMeta, type CartEventName, type CartEventPayload, type CartEventPublisherDeps, type CartEventRegistry, CartEvents, type CartModelName, type CartModels, type CartRepositories, type CartRepositoryPluginBundle, type CartSnapshot, type CartTenantInput, type CatalogBridge, type Checkout, type CheckoutDocument, type CheckoutFlowState, CheckoutRepository, type CheckoutRepositoryDeps, type CheckoutState, CheckoutStep, type CheckoutStepNumber, type ClockPort, ConcurrencyError, type CreateCartModelsOptions, type CreateCartRepositoriesConfig, DEFAULT_STALE_OPEN_CHECKOUT_MS, type Draft, type DraftDocument, DraftRepository, type DraftRepositoryDeps, type DraftStatus, type EventHandler, type EventSchema, type EventSchemaProperty, type EventTransport, type EventValidationResult, type EventValidator, type IdPort, IdempotencyBusyError, type IdempotencyDocument, type IdempotencyIdentity, type IdempotencyRecord, type IdempotencyReplay, IdempotencyRepository, IdempotencyStorageError, InProcessCartEventBus, InvalidOutboxEventError, type InventoryBridge, type KindBridges, type KindContext, KindError, type KindRegistry, type LineDisplay, type LineItem, type LineKind, type LineLike, MemoryOutboxStore, type Money, NotFoundError, type OperationContext, type OperationName, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxStoreWriteOptions, type OutboxWriteOptions, PENDING_EVENTS, type PayloadOf, PriceChangedError, type PricedLine, type PricingSnapshot, type ProductSummary, type PromotionResult, type PromotionsBridge, type PublishManyResult, type Reservation, type ReservationDocument, ReservationError, type ReservationRef, ReservationRepository, type ReservationRequest, type ReservationStatus, type ResolvedTenant, type RevalidationResult, type SagaDependencies, SagaError, type SagaFailurePhase, type SagaStepFn, type ServiceFeePayload, type ShippingBridge, type ShippingMethod, type ShippingQuote, type ShippingQuoteRequest, type SkuPayload, type StaleBehavior, StaleQuoteError, type StaleTrigger, StateTransitionError, type TaxBreakdown, type TaxBridge, type TaxCalculationRequest, type TaxCalculationResult, type TimeslotPayload, type TotalsSnapshot, UnknownKindError, UnmanagedSessionError, type ValidityPolicy, type VariantPayload, addMoney, bundleKind, bundlePayloadSchema, cartConfigSchema, cartEventDefinitions, cartEventsByName, checkoutConfigSchema, createCart, createCartEvent, createCartEventRegistry, createCartModels, createCartRepositories, createCheckoutModel, createCounterIdPort, createDraftModel, createIdempotencyModel, createKindRegistry, createReservationModel, cryptoIdPort, defineCartEvent, findAbandonedDrafts, flushPending, fromMajor, idempotencyConfigSchema, isLegalCheckoutTransition, markAbandoned, mergeDrafts, money, multiplyMoney, reservationConfigSchema, runPricing, scopeConfigSchema, serviceFeeKind, serviceFeePayloadSchema, skuKind, skuPayloadSchema, subtractMoney, sumMoney, systemClock, timeslotKind, timeslotPayloadSchema, toMajor, variantKind, variantPayloadSchema };
157
+ //#region src/cleanup/cleanup.error.d.ts
158
+ /**
159
+ * Error raised by the cart data-cleanup provider steps
160
+ * (`src/cleanup/steps.ts`).
161
+ *
162
+ * Two failure classes flow through this one type — the concrete `code` +
163
+ * `category` tell them apart:
164
+ *
165
+ * - `cart/cleanup_invalid_param` (category `validation`) — an operator
166
+ * parameter (`before`, `organizationId`, `batchSize`) is malformed.
167
+ * Thrown at the edge, before any read or write. Never retryable — the
168
+ * caller must fix the parameter.
169
+ * - `cart/cleanup_purge_failed` (category `system`) — the underlying
170
+ * chunked purge reported `ok: false` (a chunk aborted). Surfaced LOUD
171
+ * instead of silently reporting a partial delete as success (retention
172
+ * design §8). Retryable: re-running the step resumes from the surviving
173
+ * rows.
174
+ *
175
+ * A `CartError` subclass so hosts catch cleanup failures with the same
176
+ * `instanceof CartError` net as every other cart error.
177
+ */
178
+ declare class CleanupError extends CartError {
179
+ readonly code: string;
180
+ readonly category: CartErrorCategory;
181
+ readonly retryable: boolean;
182
+ constructor(code: string, message: string, opts?: {
183
+ category?: CartErrorCategory;
184
+ retryable?: boolean;
185
+ context?: Record<string, unknown>;
186
+ });
187
+ }
188
+ //#endregion
189
+ //#region src/cleanup/steps.d.ts
190
+ /**
191
+ * The ONLY draft statuses this domain declares disposable — terminal,
192
+ * never-converted baskets. See the disposable-state decision in this
193
+ * module's docblock. `active` (live) and `converted` (became an order —
194
+ * business history) are never included.
195
+ */
196
+ declare const DISPOSABLE_DRAFT_STATUSES: readonly DraftStatus[];
197
+ /**
198
+ * The repository surface the step drives — a structural subset of a
199
+ * `CartEngine` (`engine.repositories`), so a host can pass the engine's
200
+ * repositories bundle straight through
201
+ * (`createCartCleanupSteps({ repositories: engine.repositories })`).
202
+ * Mirrors invoice's `InvoiceCleanupSource = { repositories: Pick<...> }`.
203
+ */
204
+ interface CartCleanupSource {
205
+ repositories: Pick<CartRepositories, 'draft'>;
206
+ }
207
+ interface CartCleanupSteps {
208
+ /** §4.1 remove-abandoned-carts provider — destructive (hard-delete). */
209
+ removeAbandonedCarts: CleanupStep;
210
+ }
211
+ declare function createCartCleanupSteps(source: CartCleanupSource): CartCleanupSteps;
212
+ //#endregion
213
+ export { type Address, type Adjustment, type AdjustmentSpec, type BridgeRef, type BridgeStatus, type BundleComponent, type BundlePayload, CART_REF_NEW, CHECKOUT_STATE_TRANSITIONS, type CartAggregateType, type CartBlueprint, type CartBridges, type CartCleanupSource, type CartCleanupSteps, type CartConfigShape, type CartDomain, type CartDomainEvent, type CartDomainRuntime, type CartEngine, CartError, type CartErrorCategory, type CartEventAggregate, type CartEventDefinition, type CartEventDefinitionInput, type CartEventMap, type CartEventMeta, type CartEventName, type CartEventPayload, type CartEventPublisherDeps, type CartEventRegistry, CartEvents, type CartLogger, type CartModelName, type CartModels, type CartRepositories, type CartRepositoryPluginBundle, type CartRuntime, type CartShape, type CartSnapshot, type CartTenantInput, type CatalogBridge, type Checkout, type CheckoutDocument, type CheckoutFlowState, CheckoutRepository, type CheckoutRepositoryDeps, type CheckoutState, CheckoutStep, type CheckoutStepNumber, CleanupError, type ClockPort, ConcurrencyError, type CreateCartRepositoriesConfig, CurrencyMismatchError, DEFAULT_STALE_OPEN_CHECKOUT_MS, DISPOSABLE_DRAFT_STATUSES, type DefineCartModelsConfig, type Draft, type DraftDocument, DraftRepository, type DraftRepositoryDeps, type DraftStatus, type EventHandler, type EventSchema, type EventSchemaProperty, type EventTransport, type EventValidationResult, type EventValidator, type IdPort, IdempotencyBusyError, type IdempotencyDocument, type IdempotencyIdentity, type IdempotencyRecord, type IdempotencyReplay, IdempotencyRepository, IdempotencyStorageError, InProcessCartEventBus, InvalidOutboxEventError, type InventoryBridge, type KindBridges, type KindContext, KindError, type KindRegistry, type LineDisplay, type LineItem, type LineKind, type LineLike, MemoryOutboxStore, type Money, NotFoundError, type OperationContext, type OperationName, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxStoreWriteOptions, type OutboxWriteOptions, PENDING_EVENTS, type PayloadOf, PriceChangedError, type PricedLine, type PricingSnapshot, type ProductSummary, type PromotionResult, type PromotionsBridge, type PublishManyResult, type Reservation, type ReservationDocument, ReservationError, type ReservationRef, ReservationRepository, type ReservationRequest, type ReservationStatus, type ResolvedCartConfig, type ResolvedTenant, type RevalidationResult, type SagaDependencies, SagaError, type SagaFailurePhase, type SagaStepFn, type ServiceFeePayload, type ShippingBridge, type ShippingMethod, type ShippingQuote, type ShippingQuoteRequest, type SkuPayload, type StaleBehavior, StaleQuoteError, type StaleTrigger, StateTransitionError, type TaxBreakdown, type TaxBridge, type TaxCalculationRequest, type TaxCalculationResult, type TimeslotPayload, type TotalsSnapshot, UnknownKindError, UnmanagedSessionError, type ValidityPolicy, type VariantPayload, addMoney, buildCheckoutSchema, buildDraftSchema, buildIdempotencySchema, buildReservationSchema, bundleKind, bundlePayloadSchema, cartConfigSchema, cartEventDefinitions, cartEventsByName, checkoutConfigSchema, createCartCleanupSteps, createCartDomain, createCartEvent, createCartEventRegistry, createCartRepositories, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCart, defineCartEvent, defineCartModels, findAbandonedDrafts, flushPending, fromMajor, idempotencyConfigSchema, isLegalCheckoutTransition, markAbandoned, mergeDrafts, money, multiplyMoney, reservationConfigSchema, runPricing, scopeConfigSchema, serviceFeeKind, serviceFeePayloadSchema, skuKind, skuPayloadSchema, subtractMoney, sumMoney, systemClock, timeslotKind, timeslotPayloadSchema, toMajor, variantKind, variantPayloadSchema };