@classytic/cart 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/{cart-event-catalog-BIbi2Q_n.d.mts → cart-event-catalog-BxDJhtTM.d.mts} +1 -1
  2. package/dist/cart.error-BwWy4RlY.mjs +27 -0
  3. package/dist/{create-cart-DRYSw5Bj.mjs → create-cart-B4l61iKT.mjs} +8 -8
  4. package/dist/domain/errors/index.d.mts +1 -1
  5. package/dist/domain/errors/index.mjs +5 -3
  6. package/dist/domain/events/index.d.mts +2 -2
  7. package/dist/domain/events/index.mjs +2 -2
  8. package/dist/domain/index.d.mts +11 -11
  9. package/dist/domain/index.mjs +11 -10
  10. package/dist/domain/ports/index.d.mts +2 -2
  11. package/dist/domain/ports/index.mjs +1 -1
  12. package/dist/domain/saga/index.d.mts +2 -2
  13. package/dist/domain/saga/index.mjs +2 -3
  14. package/dist/engine/index.d.mts +1 -1
  15. package/dist/engine/index.mjs +1 -1
  16. package/dist/{errors-iFWUnl8m.mjs → errors-DzR7Pipp.mjs} +1 -1
  17. package/dist/{index-PD-kf5pR.d.mts → index-BFBUk6qT.d.mts} +1 -1
  18. package/dist/index.d.mts +12 -12
  19. package/dist/index.mjs +12 -11
  20. package/dist/{internal-event-bus-BGcwAeqK.d.mts → internal-event-bus-DKcDteh-.d.mts} +5 -5
  21. package/dist/{kind-registry-CqOJHV-2.d.mts → kind-registry-C1n47C7h.d.mts} +1 -1
  22. package/dist/{kind-registry-Ba4PO4WC.mjs → kind-registry-C99h_-8t.mjs} +1 -1
  23. package/dist/{kind.error-CCjTB6kW.mjs → kind.error-DIaJpdUb.mjs} +2 -27
  24. package/dist/kinds/index.d.mts +1 -1
  25. package/dist/kinds/index.mjs +1 -1
  26. package/dist/{line-kind-DOYygKG4.d.mts → line-kind-Ck3fVXzG.d.mts} +1 -1
  27. package/dist/{outbox-store-bP30uBXd.mjs → outbox-store-CWW8ppxS.mjs} +1 -1
  28. package/dist/{state-transition.error-CML7cQSd.mjs → price-changed.error-C-wGVcfc.mjs} +2 -26
  29. package/dist/{reservation.entity-gmeCFe8a.d.mts → reservation.entity-b5cZ1ojx.d.mts} +4 -4
  30. package/dist/state-transition.error-2fRLh3p0.mjs +26 -0
  31. package/dist/{state-transitions-CbPYzeca.d.mts → state-transitions-X_Eix5Iw.d.mts} +15 -5
  32. package/dist/state-transitions-e4z3Yhxb.mjs +61 -0
  33. package/dist/{variant.kind-CCwwWAB6.d.mts → variant.kind-9P1DXdXu.d.mts} +1 -1
  34. package/dist/{variant.kind-BpEzENX-.mjs → variant.kind-DfEh2oku.mjs} +1 -1
  35. package/package.json +3 -3
  36. package/dist/saga-steps-aP8iTHT3.mjs +0 -26
  37. package/dist/state-transitions-CpJpZZTK.mjs +0 -21
  38. /package/dist/{cart-status.vo-2iisZGhb.d.mts → cart-status.vo-CNJw4aaB.d.mts} +0 -0
  39. /package/dist/{domain-event-DHNkz15G.mjs → domain-event-CIEORKF6.mjs} +0 -0
  40. /package/dist/{id.port-C3rlDAKP.mjs → id.port-BhbFZJPm.mjs} +0 -0
  41. /package/dist/{id.port-CpYO7sc1.d.mts → id.port-C7ygWLRU.d.mts} +0 -0
  42. /package/dist/{index-DNLi60D-.d.mts → index-2Ag-54t8.d.mts} +0 -0
  43. /package/dist/{outbox-store-CTWz9pvG.d.mts → outbox-store-CBt9fSYh.d.mts} +0 -0
  44. /package/dist/{shipping.bridge-_VwuKCSE.d.mts → shipping.bridge-CmQFTgSE.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { _ as CartEventMeta, b as CartEventName, h as CartDomainEvent } from "./outbox-store-CTWz9pvG.mjs";
1
+ import { _ as CartEventMeta, b as CartEventName, h as CartDomainEvent } from "./outbox-store-CBt9fSYh.mjs";
2
2
 
3
3
  //#region src/domain/events/event-schema.d.ts
4
4
  /**
@@ -0,0 +1,27 @@
1
+ //#region src/domain/errors/cart.error.ts
2
+ var CartError = class extends Error {
3
+ /** Optional structured context for logging / debugging. */
4
+ context;
5
+ constructor(message, context) {
6
+ super(message);
7
+ this.name = new.target.name;
8
+ this.context = context;
9
+ Object.setPrototypeOf(this, new.target.prototype);
10
+ }
11
+ /**
12
+ * Serialize to a wire-safe shape. Suitable for HTTP error bodies and
13
+ * structured logging. Never includes stack frames.
14
+ */
15
+ toJSON() {
16
+ return {
17
+ name: this.name,
18
+ code: this.code,
19
+ category: this.category,
20
+ message: this.message,
21
+ retryable: this.retryable,
22
+ context: this.context
23
+ };
24
+ }
25
+ };
26
+ //#endregion
27
+ export { CartError as t };
@@ -1,9 +1,9 @@
1
- import { t as KindError } from "./kind.error-CCjTB6kW.mjs";
2
- import { i as ConcurrencyError, n as PriceChangedError, r as NotFoundError, t as StateTransitionError } from "./state-transition.error-CML7cQSd.mjs";
3
- import { n as CartEvents, t as createCartEvent } from "./domain-event-DHNkz15G.mjs";
4
- import { n as cryptoIdPort, r as systemClock } from "./id.port-C3rlDAKP.mjs";
5
- import { t as createKindRegistry } from "./kind-registry-Ba4PO4WC.mjs";
6
- import { t as CheckoutStep } from "./saga-steps-aP8iTHT3.mjs";
1
+ import { n as NotFoundError, r as ConcurrencyError, t as PriceChangedError } from "./price-changed.error-C-wGVcfc.mjs";
2
+ import { t as KindError } from "./kind.error-DIaJpdUb.mjs";
3
+ import { n as CartEvents, t as createCartEvent } from "./domain-event-CIEORKF6.mjs";
4
+ import { n as cryptoIdPort, r as systemClock } from "./id.port-BhbFZJPm.mjs";
5
+ import { t as createKindRegistry } from "./kind-registry-C99h_-8t.mjs";
6
+ import { i as CheckoutStep, t as CHECKOUT_MACHINE } from "./state-transitions-e4z3Yhxb.mjs";
7
7
  import { money } from "@classytic/primitives/money";
8
8
  import { matchEventPattern } from "@classytic/primitives/events";
9
9
  import mongoose, { Schema } from "mongoose";
@@ -672,7 +672,7 @@ var CheckoutRepository = class extends Repository {
672
672
  lean: true,
673
673
  throwOnNotFound: false
674
674
  });
675
- if (checkout.state !== "open") throw new StateTransitionError(checkout.publicId, checkout.state, "finalized");
675
+ CHECKOUT_MACHINE.assertTransition(checkout.publicId, checkout.state, "finalized");
676
676
  const nowIso = this.clock.now().toISOString();
677
677
  const updated = await this.updateWithVersion(checkout._id, checkout.version, {
678
678
  state: "finalized",
@@ -705,7 +705,7 @@ var CheckoutRepository = class extends Repository {
705
705
  }
706
706
  async cancel(input, ctx) {
707
707
  const checkout = await this.requireCheckout(input.checkoutPublicId, ctx);
708
- if (checkout.state !== "open") throw new StateTransitionError(checkout.publicId, checkout.state, "canceled");
708
+ CHECKOUT_MACHINE.assertTransition(checkout.publicId, checkout.state, "canceled");
709
709
  const nowIso = this.clock.now().toISOString();
710
710
  const updated = await this.updateWithVersion(checkout._id, checkout.version, {
711
711
  state: "canceled",
@@ -1,2 +1,2 @@
1
- import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "../../index-PD-kf5pR.mjs";
1
+ import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "../../index-BFBUk6qT.mjs";
2
2
  export { CartError, CartErrorCategory, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, SagaFailurePhase, StaleQuoteError, StateTransitionError, UnknownKindError };
@@ -1,4 +1,6 @@
1
- import { n as UnknownKindError, r as CartError, t as KindError } from "../../kind.error-CCjTB6kW.mjs";
2
- import { i as ConcurrencyError, n as PriceChangedError, r as NotFoundError, t as StateTransitionError } from "../../state-transition.error-CML7cQSd.mjs";
3
- import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "../../errors-iFWUnl8m.mjs";
1
+ import { t as CartError } from "../../cart.error-BwWy4RlY.mjs";
2
+ import { n as NotFoundError, r as ConcurrencyError, t as PriceChangedError } from "../../price-changed.error-C-wGVcfc.mjs";
3
+ import { n as UnknownKindError, t as KindError } from "../../kind.error-DIaJpdUb.mjs";
4
+ import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "../../errors-DzR7Pipp.mjs";
5
+ import { t as StateTransitionError } from "../../state-transition.error-2fRLh3p0.mjs";
4
6
  export { CartError, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, KindError, NotFoundError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError };
@@ -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-CTWz9pvG.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-BIbi2Q_n.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-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";
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-DHNkz15G.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-bP30uBXd.mjs";
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";
3
3
  export { CartEvents, InvalidOutboxEventError, MemoryOutboxStore, OutboxOwnershipError, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, defineCartEvent };
@@ -1,12 +1,12 @@
1
- import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "../index-PD-kf5pR.mjs";
2
- import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "../cart-status.vo-2iisZGhb.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-CTWz9pvG.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-BIbi2Q_n.mjs";
5
- import { C as PricingSnapshot, S as PricedLine, _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, x as OperationContext, y as BridgeRef } from "../shipping.bridge-_VwuKCSE.mjs";
6
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-gmeCFe8a.mjs";
7
- import { a as CheckoutFlowState, i as SagaStepFn, n as isLegalCheckoutTransition, o as CheckoutStep, r as SagaDependencies, s as CheckoutStepNumber, t as CHECKOUT_STATE_TRANSITIONS } from "../state-transitions-CbPYzeca.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-DOYygKG4.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-CqOJHV-2.mjs";
10
- import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-CpYO7sc1.mjs";
1
+ import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "../index-BFBUk6qT.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 PricingSnapshot, S as PricedLine, _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, x as OperationContext, y as BridgeRef } from "../shipping.bridge-CmQFTgSE.mjs";
6
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-b5cZ1ojx.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-X_Eix5Iw.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-Ck3fVXzG.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-C1n47C7h.mjs";
10
+ import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-C7ygWLRU.mjs";
11
11
  import { Money, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
12
- export { type Adjustment, AdjustmentSpec, BridgeRef, BridgeStatus, CART_REF_NEW, 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, type ValidityPolicy, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
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, type ValidityPolicy, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
@@ -1,15 +1,16 @@
1
1
  import { t as CART_REF_NEW } from "../idempotency-key.vo-D0lJsvGn.mjs";
2
- import { n as UnknownKindError, r as CartError, t as KindError } from "../kind.error-CCjTB6kW.mjs";
3
- import { i as ConcurrencyError, n as PriceChangedError, r as NotFoundError, t as StateTransitionError } from "../state-transition.error-CML7cQSd.mjs";
4
- import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "../errors-iFWUnl8m.mjs";
5
- import { n as CartEvents, t as createCartEvent } from "../domain-event-DHNkz15G.mjs";
6
- 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-bP30uBXd.mjs";
7
- import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../id.port-C3rlDAKP.mjs";
8
- import { t as createKindRegistry } from "../kind-registry-Ba4PO4WC.mjs";
9
- import { t as CheckoutStep } from "../saga-steps-aP8iTHT3.mjs";
10
- import { n as isLegalCheckoutTransition, t as CHECKOUT_STATE_TRANSITIONS } from "../state-transitions-CpJpZZTK.mjs";
2
+ import { t as CartError } from "../cart.error-BwWy4RlY.mjs";
3
+ import { n as NotFoundError, r as ConcurrencyError, t as PriceChangedError } from "../price-changed.error-C-wGVcfc.mjs";
4
+ import { n as UnknownKindError, t as KindError } from "../kind.error-DIaJpdUb.mjs";
5
+ import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "../errors-DzR7Pipp.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-C99h_-8t.mjs";
11
+ import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../state-transitions-e4z3Yhxb.mjs";
11
12
  import "./events/index.mjs";
12
13
  import "./ports/index.mjs";
13
14
  import "./saga/index.mjs";
14
15
  import { addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
15
- export { CART_REF_NEW, CHECKOUT_STATE_TRANSITIONS, CartError, CartEvents, CheckoutStep, ConcurrencyError, IdempotencyBusyError, IdempotencyStorageError, InvalidOutboxEventError, KindError, MemoryOutboxStore, NotFoundError, OutboxOwnershipError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, 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, IdempotencyBusyError, IdempotencyStorageError, InvalidOutboxEventError, KindError, MemoryOutboxStore, NotFoundError, OutboxOwnershipError, PriceChangedError, ReservationError, SagaError, StaleQuoteError, StateTransitionError, UnknownKindError, addMoney, cartEventDefinitions, cartEventsByName, createCartEvent, createCartEventRegistry, createCounterIdPort, createKindRegistry, cryptoIdPort, defineCartEvent, fromMajor, isLegalCheckoutTransition, money, multiplyMoney, subtractMoney, sumMoney, systemClock, toMajor };
@@ -1,3 +1,3 @@
1
- import { _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, x as OperationContext, y as BridgeRef } from "../../shipping.bridge-_VwuKCSE.mjs";
2
- import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../../id.port-CpYO7sc1.mjs";
1
+ import { _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, x as OperationContext, y as BridgeRef } from "../../shipping.bridge-CmQFTgSE.mjs";
2
+ import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../../id.port-C7ygWLRU.mjs";
3
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,2 +1,2 @@
1
- import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../../id.port-C3rlDAKP.mjs";
1
+ import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "../../id.port-BhbFZJPm.mjs";
2
2
  export { createCounterIdPort, cryptoIdPort, systemClock };
@@ -1,2 +1,2 @@
1
- import { a as CheckoutFlowState, i as SagaStepFn, n as isLegalCheckoutTransition, o as CheckoutStep, r as SagaDependencies, s as CheckoutStepNumber, t as CHECKOUT_STATE_TRANSITIONS } from "../../state-transitions-CbPYzeca.mjs";
2
- export { CHECKOUT_STATE_TRANSITIONS, type CheckoutFlowState, CheckoutStep, type CheckoutStepNumber, type SagaDependencies, type SagaStepFn, isLegalCheckoutTransition };
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-X_Eix5Iw.mjs";
2
+ export { CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, type CheckoutFlowState, CheckoutStep, type CheckoutStepNumber, type SagaDependencies, type SagaStepFn, isLegalCheckoutTransition };
@@ -1,3 +1,2 @@
1
- import { t as CheckoutStep } from "../../saga-steps-aP8iTHT3.mjs";
2
- import { n as isLegalCheckoutTransition, t as CHECKOUT_STATE_TRANSITIONS } from "../../state-transitions-CpJpZZTK.mjs";
3
- export { CHECKOUT_STATE_TRANSITIONS, CheckoutStep, isLegalCheckoutTransition };
1
+ import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition, t as CHECKOUT_MACHINE } from "../../state-transitions-e4z3Yhxb.mjs";
2
+ export { CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, CheckoutStep, isLegalCheckoutTransition };
@@ -1,3 +1,3 @@
1
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-BGcwAeqK.mjs";
2
+ import { a as CartEngine, i as CartConfig, n as createCart, r as CartBridges, t as InProcessCartEventBus } from "../internal-event-bus-DKcDteh-.mjs";
3
3
  export { type CartBridges, type CartConfig, type CartConfigShape, type CartEngine, InProcessCartEventBus, cartConfigSchema, createCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
@@ -1,3 +1,3 @@
1
- import { n as InProcessCartEventBus, t as createCart } from "../create-cart-DRYSw5Bj.mjs";
1
+ import { n as InProcessCartEventBus, t as createCart } from "../create-cart-B4l61iKT.mjs";
2
2
  import { cartConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
3
3
  export { InProcessCartEventBus, cartConfigSchema, createCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
@@ -1,4 +1,4 @@
1
- import { r as CartError } from "./kind.error-CCjTB6kW.mjs";
1
+ import { t as CartError } from "./cart.error-BwWy4RlY.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
@@ -1,4 +1,4 @@
1
- import { t as CheckoutState } from "./cart-status.vo-2iisZGhb.mjs";
1
+ import { t as CheckoutState } from "./cart-status.vo-CNJw4aaB.mjs";
2
2
 
3
3
  //#region src/domain/errors/cart.error.d.ts
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,16 +1,16 @@
1
- import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "./index-PD-kf5pR.mjs";
2
- import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-2iisZGhb.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-CTWz9pvG.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-BIbi2Q_n.mjs";
5
- import { C as PricingSnapshot, S as PricedLine, _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, v as Address, x as OperationContext, y as BridgeRef } from "./shipping.bridge-_VwuKCSE.mjs";
6
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-gmeCFe8a.mjs";
7
- import { a as CheckoutFlowState, i as SagaStepFn, n as isLegalCheckoutTransition, o as CheckoutStep, r as SagaDependencies, s as CheckoutStepNumber, t as CHECKOUT_STATE_TRANSITIONS } from "./state-transitions-CbPYzeca.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-DOYygKG4.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-CqOJHV-2.mjs";
10
- import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-CpYO7sc1.mjs";
1
+ import { a as SagaError, c as PriceChangedError, d as UnknownKindError, f as ConcurrencyError, i as IdempotencyStorageError, l as NotFoundError, m as CartErrorCategory, n as StaleQuoteError, o as SagaFailurePhase, p as CartError, r as IdempotencyBusyError, s as ReservationError, t as StateTransitionError, u as KindError } from "./index-BFBUk6qT.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 PricingSnapshot, S as PricedLine, _ as PromotionsBridge, a as TaxBreakdown, b as BridgeStatus, c as TaxCalculationResult, d as ReservationRequest, f as CatalogBridge, g as PromotionResult, h as CartSnapshot, i as ShippingQuoteRequest, l as InventoryBridge, m as AdjustmentSpec, n as ShippingMethod, o as TaxBridge, p as ProductSummary, r as ShippingQuote, s as TaxCalculationRequest, t as ShippingBridge, u as ReservationRef, v as Address, x as OperationContext, y as BridgeRef } from "./shipping.bridge-CmQFTgSE.mjs";
6
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-b5cZ1ojx.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-X_Eix5Iw.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-Ck3fVXzG.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-C1n47C7h.mjs";
10
+ import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-C7ygWLRU.mjs";
11
11
  import { CartConfigShape, cartConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
12
- import { C as IdempotencyDocument, D as CheckoutDocument, E as createDraftModel, O as createCheckoutModel, S as createReservationModel, T as DraftDocument, _ as CartModelName, a as CartEngine, b as createCartModels, c as CreateCartRepositoriesConfig, d as IdempotencyRepository, f as CheckoutRepository, g as CartEventPublisherDeps, h as DraftRepositoryDeps, i as CartConfig, l as createCartRepositories, m as DraftRepository, n as createCart, o as CartRepositories, p as CheckoutRepositoryDeps, r as CartBridges, s as CartRepositoryPluginBundle, t as InProcessCartEventBus, u as ReservationRepository, v as CartModels, w as createIdempotencyModel, x as ReservationDocument, y as CreateCartModelsOptions } from "./internal-event-bus-BGcwAeqK.mjs";
13
- import { a as timeslotKind, c as skuKind, d as BundlePayload, f as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, n as variantKind, o as timeslotPayloadSchema, p as bundlePayloadSchema, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as BundleComponent } from "./variant.kind-CCwwWAB6.mjs";
12
+ import { C as IdempotencyDocument, D as CheckoutDocument, E as createDraftModel, O as createCheckoutModel, S as createReservationModel, T as DraftDocument, _ as CartModelName, a as CartEngine, b as createCartModels, c as CreateCartRepositoriesConfig, d as IdempotencyRepository, f as CheckoutRepository, g as CartEventPublisherDeps, h as DraftRepositoryDeps, i as CartConfig, l as createCartRepositories, m as DraftRepository, n as createCart, o as CartRepositories, p as CheckoutRepositoryDeps, r as CartBridges, s as CartRepositoryPluginBundle, t as InProcessCartEventBus, u as ReservationRepository, v as CartModels, w as createIdempotencyModel, x as ReservationDocument, y as CreateCartModelsOptions } from "./internal-event-bus-DKcDteh-.mjs";
13
+ import { a as timeslotKind, c as skuKind, d as BundlePayload, f as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, n as variantKind, o as timeslotPayloadSchema, p as bundlePayloadSchema, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as BundleComponent } from "./variant.kind-9P1DXdXu.mjs";
14
14
  import { Money, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
15
15
  import { EventHandler, EventTransport, PublishManyResult } from "@classytic/primitives/events";
16
16
  import { Schema } from "mongoose";
package/dist/index.mjs CHANGED
@@ -1,15 +1,16 @@
1
1
  import { t as CART_REF_NEW } from "./idempotency-key.vo-D0lJsvGn.mjs";
2
- import { n as UnknownKindError, r as CartError, t as KindError } from "./kind.error-CCjTB6kW.mjs";
3
- import { i as ConcurrencyError, n as PriceChangedError, r as NotFoundError, t as StateTransitionError } from "./state-transition.error-CML7cQSd.mjs";
4
- import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "./errors-iFWUnl8m.mjs";
5
- import { n as CartEvents, t as createCartEvent } from "./domain-event-DHNkz15G.mjs";
6
- 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-bP30uBXd.mjs";
7
- import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "./id.port-C3rlDAKP.mjs";
8
- import { t as createKindRegistry } from "./kind-registry-Ba4PO4WC.mjs";
9
- import { t as CheckoutStep } from "./saga-steps-aP8iTHT3.mjs";
10
- import { n as isLegalCheckoutTransition, t as CHECKOUT_STATE_TRANSITIONS } from "./state-transitions-CpJpZZTK.mjs";
11
- import { a as IdempotencyRepository, c as CheckoutRepository, d as createIdempotencyModel, f as createDraftModel, i as ReservationRepository, l as createCartModels, n as InProcessCartEventBus, o as DraftRepository, p as createCheckoutModel, r as createCartRepositories, s as runPricing, t as createCart, u as createReservationModel } from "./create-cart-DRYSw5Bj.mjs";
12
- import { a as skuKind, c as bundlePayloadSchema, i as timeslotPayloadSchema, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as bundleKind, t as variantKind } from "./variant.kind-BpEzENX-.mjs";
2
+ import { t as CartError } from "./cart.error-BwWy4RlY.mjs";
3
+ import { n as NotFoundError, r as ConcurrencyError, t as PriceChangedError } from "./price-changed.error-C-wGVcfc.mjs";
4
+ import { n as UnknownKindError, t as KindError } from "./kind.error-DIaJpdUb.mjs";
5
+ import { a as ReservationError, i as SagaError, n as IdempotencyBusyError, r as IdempotencyStorageError, t as StaleQuoteError } from "./errors-DzR7Pipp.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-C99h_-8t.mjs";
11
+ import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition } from "./state-transitions-e4z3Yhxb.mjs";
12
+ import { a as IdempotencyRepository, c as CheckoutRepository, d as createIdempotencyModel, f as createDraftModel, i as ReservationRepository, l as createCartModels, n as InProcessCartEventBus, o as DraftRepository, p as createCheckoutModel, r as createCartRepositories, s as runPricing, t as createCart, u as createReservationModel } from "./create-cart-B4l61iKT.mjs";
13
+ import { a as skuKind, c as bundlePayloadSchema, i as timeslotPayloadSchema, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as bundleKind, t as variantKind } from "./variant.kind-DfEh2oku.mjs";
13
14
  import { cartConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
14
15
  import { addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
15
16
  //#region src/services/abandonment.service.ts
@@ -1,8 +1,8 @@
1
- import { b as CartEventName, d as OutboxStore, h as CartDomainEvent, x as CartEventPayload } from "./outbox-store-CTWz9pvG.mjs";
2
- import { _ as PromotionsBridge, f as CatalogBridge, l as InventoryBridge, o as TaxBridge, t as ShippingBridge, x as OperationContext } from "./shipping.bridge-_VwuKCSE.mjs";
3
- import { l as LineDisplay, r as LineKind } from "./line-kind-DOYygKG4.mjs";
4
- import { c as LineItem, i as IdempotencyIdentity, t as KindRegistry } from "./kind-registry-CqOJHV-2.mjs";
5
- import { i as ClockPort, t as IdPort } from "./id.port-CpYO7sc1.mjs";
1
+ import { b as CartEventName, d as OutboxStore, h as CartDomainEvent, x as CartEventPayload } from "./outbox-store-CBt9fSYh.mjs";
2
+ import { _ as PromotionsBridge, f as CatalogBridge, l as InventoryBridge, o as TaxBridge, t as ShippingBridge, x as OperationContext } from "./shipping.bridge-CmQFTgSE.mjs";
3
+ import { l as LineDisplay, r as LineKind } from "./line-kind-Ck3fVXzG.mjs";
4
+ import { c as LineItem, i as IdempotencyIdentity, t as KindRegistry } from "./kind-registry-C1n47C7h.mjs";
5
+ import { i as ClockPort, t as IdPort } from "./id.port-C7ygWLRU.mjs";
6
6
  import { CartConfigShape } from "./engine/cart-config.schema.mjs";
7
7
  import { Money } from "@classytic/primitives/money";
8
8
  import { DomainEvent, EventHandler, EventTransport, PublishManyResult } from "@classytic/primitives/events";
@@ -1,4 +1,4 @@
1
- import { l as LineDisplay, r as LineKind } from "./line-kind-DOYygKG4.mjs";
1
+ import { l as LineDisplay, r as LineKind } from "./line-kind-Ck3fVXzG.mjs";
2
2
  import * as _$_classytic_primitives_money0 from "@classytic/primitives/money";
3
3
  import { Money } from "@classytic/primitives/money";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as UnknownKindError } from "./kind.error-CCjTB6kW.mjs";
1
+ import { n as UnknownKindError } from "./kind.error-DIaJpdUb.mjs";
2
2
  //#region src/domain/kinds/kind-registry.ts
3
3
  /**
4
4
  * Build a KindRegistry from a list of LineKind implementations.
@@ -1,29 +1,4 @@
1
- //#region src/domain/errors/cart.error.ts
2
- var CartError = class extends Error {
3
- /** Optional structured context for logging / debugging. */
4
- context;
5
- constructor(message, context) {
6
- super(message);
7
- this.name = new.target.name;
8
- this.context = context;
9
- Object.setPrototypeOf(this, new.target.prototype);
10
- }
11
- /**
12
- * Serialize to a wire-safe shape. Suitable for HTTP error bodies and
13
- * structured logging. Never includes stack frames.
14
- */
15
- toJSON() {
16
- return {
17
- name: this.name,
18
- code: this.code,
19
- category: this.category,
20
- message: this.message,
21
- retryable: this.retryable,
22
- context: this.context
23
- };
24
- }
25
- };
26
- //#endregion
1
+ import { t as CartError } from "./cart.error-BwWy4RlY.mjs";
27
2
  //#region src/domain/errors/kind.error.ts
28
3
  /**
29
4
  * A LineKind rejected a line during validate() or price().
@@ -66,4 +41,4 @@ var UnknownKindError = class extends CartError {
66
41
  }
67
42
  };
68
43
  //#endregion
69
- export { UnknownKindError as n, CartError as r, KindError as t };
44
+ export { UnknownKindError as n, KindError as t };
@@ -1,2 +1,2 @@
1
- import { a as timeslotKind, c as skuKind, d as BundlePayload, f as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, n as variantKind, o as timeslotPayloadSchema, p as bundlePayloadSchema, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as BundleComponent } from "../variant.kind-CCwwWAB6.mjs";
1
+ import { a as timeslotKind, c as skuKind, d as BundlePayload, f as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, n as variantKind, o as timeslotPayloadSchema, p as bundlePayloadSchema, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as BundleComponent } from "../variant.kind-9P1DXdXu.mjs";
2
2
  export { type BundleComponent, type BundlePayload, type SkuPayload, type TimeslotPayload, type VariantPayload, bundleKind, bundlePayloadSchema, skuKind, skuPayloadSchema, timeslotKind, timeslotPayloadSchema, variantKind, variantPayloadSchema };
@@ -1,2 +1,2 @@
1
- import { a as skuKind, c as bundlePayloadSchema, i as timeslotPayloadSchema, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as bundleKind, t as variantKind } from "../variant.kind-BpEzENX-.mjs";
1
+ import { a as skuKind, c as bundlePayloadSchema, i as timeslotPayloadSchema, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as bundleKind, t as variantKind } from "../variant.kind-DfEh2oku.mjs";
2
2
  export { bundleKind, bundlePayloadSchema, skuKind, skuPayloadSchema, timeslotKind, timeslotPayloadSchema, variantKind, variantPayloadSchema };
@@ -1,4 +1,4 @@
1
- import { S as PricedLine, _ as PromotionsBridge, f as CatalogBridge, l as InventoryBridge, o as TaxBridge, t as ShippingBridge, u as ReservationRef, x as OperationContext } from "./shipping.bridge-_VwuKCSE.mjs";
1
+ import { S as PricedLine, _ as PromotionsBridge, f as CatalogBridge, l as InventoryBridge, o as TaxBridge, t as ShippingBridge, u as ReservationRef, x as OperationContext } from "./shipping.bridge-CmQFTgSE.mjs";
2
2
  import { Money } from "@classytic/primitives/money";
3
3
  import { z } from "zod";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as CartEvents, t as createCartEvent } from "./domain-event-DHNkz15G.mjs";
1
+ import { n as CartEvents, t as createCartEvent } from "./domain-event-CIEORKF6.mjs";
2
2
  import { InvalidOutboxEventError, OutboxOwnershipError } from "@classytic/primitives/outbox";
3
3
  //#region src/domain/events/event-definition.ts
4
4
  function defineCartEvent(input) {
@@ -1,4 +1,4 @@
1
- import { r as CartError } from "./kind.error-CCjTB6kW.mjs";
1
+ import { t as CartError } from "./cart.error-BwWy4RlY.mjs";
2
2
  //#region src/domain/errors/concurrency.error.ts
3
3
  /**
4
4
  * Optimistic-lock mismatch. Thrown when a mutation attempts to update a
@@ -68,28 +68,4 @@ var PriceChangedError = class extends CartError {
68
68
  }
69
69
  };
70
70
  //#endregion
71
- //#region src/domain/errors/state-transition.error.ts
72
- /**
73
- * A write attempted to transition `checkout.state` along an edge that
74
- * does not exist in the frozen state machine (see plan simplification —
75
- * `open → finalized | canceled`).
76
- *
77
- * Thrown by service methods before the mutation reaches the database.
78
- * Never retryable — the caller either has a bug or is racing another
79
- * writer. A concurrency race manifests as `ConcurrencyError` first via
80
- * the version check; if it reaches here, it is a logic bug.
81
- */
82
- var StateTransitionError = class extends CartError {
83
- code = "cart/illegal_state_transition";
84
- category = "state";
85
- retryable = false;
86
- constructor(checkoutId, from, to) {
87
- super(`Illegal checkout state transition on ${checkoutId}: ${from} -> ${to}`, {
88
- checkoutId,
89
- from,
90
- to
91
- });
92
- }
93
- };
94
- //#endregion
95
- export { ConcurrencyError as i, PriceChangedError as n, NotFoundError as r, StateTransitionError as t };
71
+ export { NotFoundError as n, ConcurrencyError as r, PriceChangedError as t };
@@ -1,7 +1,7 @@
1
- import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-2iisZGhb.mjs";
2
- import { C as PricingSnapshot, m as AdjustmentSpec } from "./shipping.bridge-_VwuKCSE.mjs";
3
- import { a as CheckoutFlowState } from "./state-transitions-CbPYzeca.mjs";
4
- import { a as IdempotencyReplay, c as LineItem, o as OperationName } from "./kind-registry-CqOJHV-2.mjs";
1
+ import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-CNJw4aaB.mjs";
2
+ import { C as PricingSnapshot, m as AdjustmentSpec } from "./shipping.bridge-CmQFTgSE.mjs";
3
+ import { o as CheckoutFlowState } from "./state-transitions-X_Eix5Iw.mjs";
4
+ import { a as IdempotencyReplay, c as LineItem, o as OperationName } from "./kind-registry-C1n47C7h.mjs";
5
5
  import { Money } from "@classytic/primitives/money";
6
6
 
7
7
  //#region src/domain/entities/adjustment.entity.d.ts
@@ -0,0 +1,26 @@
1
+ import { t as CartError } from "./cart.error-BwWy4RlY.mjs";
2
+ //#region src/domain/errors/state-transition.error.ts
3
+ /**
4
+ * A write attempted to transition `checkout.state` along an edge that
5
+ * does not exist in the frozen state machine (see plan simplification —
6
+ * `open → finalized | canceled`).
7
+ *
8
+ * Thrown by service methods before the mutation reaches the database.
9
+ * Never retryable — the caller either has a bug or is racing another
10
+ * writer. A concurrency race manifests as `ConcurrencyError` first via
11
+ * the version check; if it reaches here, it is a logic bug.
12
+ */
13
+ var StateTransitionError = class extends CartError {
14
+ code = "cart/illegal_state_transition";
15
+ category = "state";
16
+ retryable = false;
17
+ constructor(checkoutId, from, to) {
18
+ super(`Illegal checkout state transition on ${checkoutId}: ${from} -> ${to}`, {
19
+ checkoutId,
20
+ from,
21
+ to
22
+ });
23
+ }
24
+ };
25
+ //#endregion
26
+ export { StateTransitionError as t };
@@ -1,7 +1,8 @@
1
- import { t as CheckoutState } from "./cart-status.vo-2iisZGhb.mjs";
2
- import { x as OperationContext } from "./shipping.bridge-_VwuKCSE.mjs";
3
- import { t as KindBridges } from "./line-kind-DOYygKG4.mjs";
4
- import { i as ClockPort, t as IdPort } from "./id.port-CpYO7sc1.mjs";
1
+ import { t as CheckoutState } from "./cart-status.vo-CNJw4aaB.mjs";
2
+ import { x as OperationContext } from "./shipping.bridge-CmQFTgSE.mjs";
3
+ import { t as KindBridges } from "./line-kind-Ck3fVXzG.mjs";
4
+ import { i as ClockPort, t as IdPort } from "./id.port-C7ygWLRU.mjs";
5
+ import * as _$_classytic_primitives_state_machine0 from "@classytic/primitives/state-machine";
5
6
 
6
7
  //#region src/domain/saga/saga-steps.d.ts
7
8
  /**
@@ -120,7 +121,16 @@ interface SagaDependencies {
120
121
  * racing writers see exactly one winner.
121
122
  */
122
123
  declare const CHECKOUT_STATE_TRANSITIONS: Record<CheckoutState, readonly CheckoutState[]>;
124
+ /**
125
+ * Checkout state machine — single throw site, declarative table.
126
+ *
127
+ * Wires cart's domain `StateTransitionError` (with code
128
+ * `cart/illegal_state_transition` and structured `{ checkoutId, from, to }`
129
+ * meta) via `errorFactory`, so existing catch sites that match on
130
+ * `error.code` or `instanceof StateTransitionError` keep working.
131
+ */
132
+ declare const CHECKOUT_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<CheckoutState>;
123
133
  /** Predicate — is `to` a legal transition from `from`? */
124
134
  declare function isLegalCheckoutTransition(from: CheckoutState, to: CheckoutState): boolean;
125
135
  //#endregion
126
- export { CheckoutFlowState as a, SagaStepFn as i, isLegalCheckoutTransition as n, CheckoutStep as o, SagaDependencies as r, CheckoutStepNumber as s, CHECKOUT_STATE_TRANSITIONS as t };
136
+ export { SagaStepFn as a, CheckoutStepNumber as c, SagaDependencies as i, CHECKOUT_STATE_TRANSITIONS as n, CheckoutFlowState as o, isLegalCheckoutTransition as r, CheckoutStep as s, CHECKOUT_MACHINE as t };
@@ -0,0 +1,61 @@
1
+ import { t as StateTransitionError } from "./state-transition.error-2fRLh3p0.mjs";
2
+ import { defineStateMachine } from "@classytic/primitives/state-machine";
3
+ //#region src/domain/saga/saga-steps.ts
4
+ /**
5
+ * Checkout flow steps. Deliberately minimal — cart's job is to freeze a
6
+ * snapshot and transition its state. Everything external (payment, order
7
+ * creation, fulfillment) is the host's problem.
8
+ *
9
+ * This enum exists purely for logging / metrics / ordered state-transition
10
+ * dispatch. Cart does not run a "saga engine" — the `CheckoutRepository`
11
+ * domain methods run these steps in plain sequential code and let
12
+ * exceptions propagate. Compensation is one operation (`cancel`) rather
13
+ * than a reverse walk of a multi-step chain.
14
+ */
15
+ const CheckoutStep = {
16
+ /** Step 1 — load draft + validate status + version. */
17
+ LoadDraft: 1,
18
+ /** Step 2 — re-run kind.revalidate() on stale lines. */
19
+ Revalidate: 2,
20
+ /** Step 3 — re-run pricing pipeline, compare expectedPricingHash. */
21
+ Reprice: 3,
22
+ /** Step 4 — create the checkout document with the frozen snapshot. */
23
+ CreateCheckout: 4,
24
+ /** Step 5 — commit (host-called after its own external work succeeds). */
25
+ Commit: 5
26
+ };
27
+ //#endregion
28
+ //#region src/domain/saga/state-transitions.ts
29
+ /**
30
+ * Frozen state transitions for Checkout.state. Three states, two
31
+ * terminal outcomes — finalized (success) or canceled (failure / manual
32
+ * cancel / abandonment).
33
+ *
34
+ * Enforced by `CheckoutRepository.updateWithVersion` callers: the
35
+ * service methods pass the expected current state in the filter so
36
+ * racing writers see exactly one winner.
37
+ */
38
+ const CHECKOUT_STATE_TRANSITIONS = {
39
+ open: ["finalized", "canceled"],
40
+ finalized: [],
41
+ canceled: []
42
+ };
43
+ /**
44
+ * Checkout state machine — single throw site, declarative table.
45
+ *
46
+ * Wires cart's domain `StateTransitionError` (with code
47
+ * `cart/illegal_state_transition` and structured `{ checkoutId, from, to }`
48
+ * meta) via `errorFactory`, so existing catch sites that match on
49
+ * `error.code` or `instanceof StateTransitionError` keep working.
50
+ */
51
+ const CHECKOUT_MACHINE = defineStateMachine({
52
+ name: "Checkout",
53
+ transitions: CHECKOUT_STATE_TRANSITIONS,
54
+ errorFactory: ({ entityId, from, to }) => new StateTransitionError(entityId, from, to)
55
+ });
56
+ /** Predicate — is `to` a legal transition from `from`? */
57
+ function isLegalCheckoutTransition(from, to) {
58
+ return CHECKOUT_MACHINE.canTransition(from, to);
59
+ }
60
+ //#endregion
61
+ export { CheckoutStep as i, CHECKOUT_STATE_TRANSITIONS as n, isLegalCheckoutTransition as r, CHECKOUT_MACHINE as t };
@@ -1,4 +1,4 @@
1
- import { r as LineKind } from "./line-kind-DOYygKG4.mjs";
1
+ import { r as LineKind } from "./line-kind-Ck3fVXzG.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/kinds/bundle.kind.d.ts
@@ -1,4 +1,4 @@
1
- import { t as KindError } from "./kind.error-CCjTB6kW.mjs";
1
+ import { t as KindError } from "./kind.error-DIaJpdUb.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/kinds/bundle.kind.ts
4
4
  const bundlePayloadSchema = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/cart",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Framework-agnostic universal cart engine for commerce — drafts, checkouts, reservations, the LineKind strategy, and a disciplined finalization saga. Powered by MongoDB via @classytic/mongokit. Zero framework deps — usable from Arc, Express, Nest, Next.js, or raw Node.",
5
5
  "author": "Classytic",
6
6
  "type": "module",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@classytic/mongokit": ">=3.11.0",
87
- "@classytic/primitives": ">=0.1.0",
87
+ "@classytic/primitives": ">=0.2.0",
88
88
  "mongoose": ">=9.4.1",
89
89
  "zod": ">=4.0.0"
90
90
  },
@@ -92,7 +92,7 @@
92
92
  "@biomejs/biome": "^2.4.13",
93
93
  "@classytic/dev-tools": "^0.2.0",
94
94
  "@classytic/mongokit": "^3.11.0",
95
- "@classytic/primitives": "^0.1.0",
95
+ "@classytic/primitives": ">=0.2.0",
96
96
  "@types/node": "^25.5.0",
97
97
  "knip": "^6.7.0",
98
98
  "mongodb-memory-server": "^10.2.3",
@@ -1,26 +0,0 @@
1
- //#region src/domain/saga/saga-steps.ts
2
- /**
3
- * Checkout flow steps. Deliberately minimal — cart's job is to freeze a
4
- * snapshot and transition its state. Everything external (payment, order
5
- * creation, fulfillment) is the host's problem.
6
- *
7
- * This enum exists purely for logging / metrics / ordered state-transition
8
- * dispatch. Cart does not run a "saga engine" — the `CheckoutRepository`
9
- * domain methods run these steps in plain sequential code and let
10
- * exceptions propagate. Compensation is one operation (`cancel`) rather
11
- * than a reverse walk of a multi-step chain.
12
- */
13
- const CheckoutStep = {
14
- /** Step 1 — load draft + validate status + version. */
15
- LoadDraft: 1,
16
- /** Step 2 — re-run kind.revalidate() on stale lines. */
17
- Revalidate: 2,
18
- /** Step 3 — re-run pricing pipeline, compare expectedPricingHash. */
19
- Reprice: 3,
20
- /** Step 4 — create the checkout document with the frozen snapshot. */
21
- CreateCheckout: 4,
22
- /** Step 5 — commit (host-called after its own external work succeeds). */
23
- Commit: 5
24
- };
25
- //#endregion
26
- export { CheckoutStep as t };
@@ -1,21 +0,0 @@
1
- //#region src/domain/saga/state-transitions.ts
2
- /**
3
- * Frozen state transitions for Checkout.state. Three states, two
4
- * terminal outcomes — finalized (success) or canceled (failure / manual
5
- * cancel / abandonment).
6
- *
7
- * Enforced by `CheckoutRepository.updateWithVersion` callers: the
8
- * service methods pass the expected current state in the filter so
9
- * racing writers see exactly one winner.
10
- */
11
- const CHECKOUT_STATE_TRANSITIONS = {
12
- open: ["finalized", "canceled"],
13
- finalized: [],
14
- canceled: []
15
- };
16
- /** Predicate — is `to` a legal transition from `from`? */
17
- function isLegalCheckoutTransition(from, to) {
18
- return CHECKOUT_STATE_TRANSITIONS[from]?.includes(to) ?? false;
19
- }
20
- //#endregion
21
- export { isLegalCheckoutTransition as n, CHECKOUT_STATE_TRANSITIONS as t };