@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.
- package/dist/{cart-event-catalog-BIbi2Q_n.d.mts → cart-event-catalog-BxDJhtTM.d.mts} +1 -1
- package/dist/cart.error-BwWy4RlY.mjs +27 -0
- package/dist/{create-cart-DRYSw5Bj.mjs → create-cart-B4l61iKT.mjs} +8 -8
- package/dist/domain/errors/index.d.mts +1 -1
- package/dist/domain/errors/index.mjs +5 -3
- package/dist/domain/events/index.d.mts +2 -2
- package/dist/domain/events/index.mjs +2 -2
- package/dist/domain/index.d.mts +11 -11
- package/dist/domain/index.mjs +11 -10
- package/dist/domain/ports/index.d.mts +2 -2
- package/dist/domain/ports/index.mjs +1 -1
- package/dist/domain/saga/index.d.mts +2 -2
- package/dist/domain/saga/index.mjs +2 -3
- package/dist/engine/index.d.mts +1 -1
- package/dist/engine/index.mjs +1 -1
- package/dist/{errors-iFWUnl8m.mjs → errors-DzR7Pipp.mjs} +1 -1
- package/dist/{index-PD-kf5pR.d.mts → index-BFBUk6qT.d.mts} +1 -1
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +12 -11
- package/dist/{internal-event-bus-BGcwAeqK.d.mts → internal-event-bus-DKcDteh-.d.mts} +5 -5
- package/dist/{kind-registry-CqOJHV-2.d.mts → kind-registry-C1n47C7h.d.mts} +1 -1
- package/dist/{kind-registry-Ba4PO4WC.mjs → kind-registry-C99h_-8t.mjs} +1 -1
- package/dist/{kind.error-CCjTB6kW.mjs → kind.error-DIaJpdUb.mjs} +2 -27
- package/dist/kinds/index.d.mts +1 -1
- package/dist/kinds/index.mjs +1 -1
- package/dist/{line-kind-DOYygKG4.d.mts → line-kind-Ck3fVXzG.d.mts} +1 -1
- package/dist/{outbox-store-bP30uBXd.mjs → outbox-store-CWW8ppxS.mjs} +1 -1
- package/dist/{state-transition.error-CML7cQSd.mjs → price-changed.error-C-wGVcfc.mjs} +2 -26
- package/dist/{reservation.entity-gmeCFe8a.d.mts → reservation.entity-b5cZ1ojx.d.mts} +4 -4
- package/dist/state-transition.error-2fRLh3p0.mjs +26 -0
- package/dist/{state-transitions-CbPYzeca.d.mts → state-transitions-X_Eix5Iw.d.mts} +15 -5
- package/dist/state-transitions-e4z3Yhxb.mjs +61 -0
- package/dist/{variant.kind-CCwwWAB6.d.mts → variant.kind-9P1DXdXu.d.mts} +1 -1
- package/dist/{variant.kind-BpEzENX-.mjs → variant.kind-DfEh2oku.mjs} +1 -1
- package/package.json +3 -3
- package/dist/saga-steps-aP8iTHT3.mjs +0 -26
- package/dist/state-transitions-CpJpZZTK.mjs +0 -21
- /package/dist/{cart-status.vo-2iisZGhb.d.mts → cart-status.vo-CNJw4aaB.d.mts} +0 -0
- /package/dist/{domain-event-DHNkz15G.mjs → domain-event-CIEORKF6.mjs} +0 -0
- /package/dist/{id.port-C3rlDAKP.mjs → id.port-BhbFZJPm.mjs} +0 -0
- /package/dist/{id.port-CpYO7sc1.d.mts → id.port-C7ygWLRU.d.mts} +0 -0
- /package/dist/{index-DNLi60D-.d.mts → index-2Ag-54t8.d.mts} +0 -0
- /package/dist/{outbox-store-CTWz9pvG.d.mts → outbox-store-CBt9fSYh.d.mts} +0 -0
- /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-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import { n as CartEvents, t as createCartEvent } from "./domain-event-
|
|
4
|
-
import { n as cryptoIdPort, r as systemClock } from "./id.port-
|
|
5
|
-
import { t as createKindRegistry } from "./kind-registry-
|
|
6
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 };
|
package/dist/domain/index.d.mts
CHANGED
|
@@ -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-
|
|
2
|
-
import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "../cart-status.vo-
|
|
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-
|
|
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-
|
|
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-
|
|
6
|
-
import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-
|
|
7
|
-
import { a as
|
|
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-
|
|
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-
|
|
10
|
-
import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-
|
|
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 };
|
package/dist/domain/index.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { t as CART_REF_NEW } from "../idempotency-key.vo-D0lJsvGn.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
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-
|
|
2
|
-
import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../../id.port-
|
|
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-
|
|
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
|
|
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 {
|
|
2
|
-
|
|
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 };
|
package/dist/engine/index.d.mts
CHANGED
|
@@ -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-
|
|
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 };
|
package/dist/engine/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as InProcessCartEventBus, t as createCart } from "../create-cart-
|
|
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 };
|
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-
|
|
2
|
-
import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-
|
|
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-
|
|
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-
|
|
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-
|
|
6
|
-
import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-
|
|
7
|
-
import { a as
|
|
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-
|
|
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-
|
|
10
|
-
import { a as systemClock, i as ClockPort, n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-
|
|
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-
|
|
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-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { a as
|
|
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-
|
|
2
|
-
import { _ as PromotionsBridge, f as CatalogBridge, l as InventoryBridge, o as TaxBridge, t as ShippingBridge, x as OperationContext } from "./shipping.bridge-
|
|
3
|
-
import { l as LineDisplay, r as LineKind } from "./line-kind-
|
|
4
|
-
import { c as LineItem, i as IdempotencyIdentity, t as KindRegistry } from "./kind-registry-
|
|
5
|
-
import { i as ClockPort, t as IdPort } from "./id.port-
|
|
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-
|
|
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,29 +1,4 @@
|
|
|
1
|
-
|
|
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,
|
|
44
|
+
export { UnknownKindError as n, KindError as t };
|
package/dist/kinds/index.d.mts
CHANGED
|
@@ -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-
|
|
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 };
|
package/dist/kinds/index.mjs
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
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 {
|
|
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
|
-
|
|
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-
|
|
2
|
-
import { C as PricingSnapshot, m as AdjustmentSpec } from "./shipping.bridge-
|
|
3
|
-
import {
|
|
4
|
-
import { a as IdempotencyReplay, c as LineItem, o as OperationName } from "./kind-registry-
|
|
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-
|
|
2
|
-
import { x as OperationContext } from "./shipping.bridge-
|
|
3
|
-
import { t as KindBridges } from "./line-kind-
|
|
4
|
-
import { i as ClockPort, t as IdPort } from "./id.port-
|
|
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 {
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/cart",
|
|
3
|
-
"version": "0.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.
|
|
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": "
|
|
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 };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|