@classytic/cart 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
  adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## 1.2.0 — 2026-09-04
7
+
8
+ ### Added — `DraftRepository.markActiveConvertedForActor`
9
+
10
+ Hosts that place an order without freezing a checkout first have no `checkout.draftId` for `markConverted` to key on, leaving the draft `active` with lines intact — exactly the shape the abandonment sweep selects. `markActiveConvertedForActor(actorRef, ctx)` looks up the actor's active draft and converts it in one call. Returns `false` if no active draft exists or `actorRef` is empty (guard against broad-match on empty string). Best-effort like `markConverted`: a miss does not fail the order.
11
+
12
+ ## 1.1.1 — 2026-08-26
13
+
14
+ ### Fixed
15
+
16
+ - **`LineDisplay.weightGrams` captured from catalog bridge snapshot** — both
17
+ `skuKind` and `variantKind` now emit `weightGrams` when the bridge supplies it
18
+ (real and positive only; absent stays absent so weight-tiered delivery zones
19
+ fall back to the flat charge rather than pricing the cheapest step). The field
20
+ was already in the bridge's product shape; the snapshot simply never forwarded
21
+ it, so every weight-tiered checkout fell back to flat.
22
+ - **`draft.model.ts` declares `weightGrams`** — Mongoose strips unknown paths
23
+ silently; without the schema declaration the field would be dropped on every
24
+ write. `default: null` preserves the absent/unweighed distinction (no `0`
25
+ default).
26
+
27
+ ### Changed
28
+
29
+ - **Peer floors raised** — mongokit `>=3.35.0`, primitives `>=0.25.0`,
30
+ repo-core `>=0.25.0`.
31
+
6
32
  ## 1.1.0 - 2026-08-17
7
33
 
8
34
  ### Changed
@@ -190,6 +190,17 @@ const lineDisplaySubSchema = new Schema({
190
190
  type: Schema.Types.Mixed,
191
191
  default: null
192
192
  },
193
+ /**
194
+ * Per-unit shipping weight. Declared here or mongoose strips it — the failure
195
+ * this repo has paid for with `stockTracked`, `monetizationKind` and the order
196
+ * `payment` block. NO `default: 0`: absent must stay distinguishable from
197
+ * weightless, because a weight-tiered delivery zone prices the cheapest step
198
+ * for a zero and under-charges every unweighed cart.
199
+ */
200
+ weightGrams: {
201
+ type: Number,
202
+ default: null
203
+ },
193
204
  capturedAt: {
194
205
  type: Date,
195
206
  default: () => /* @__PURE__ */ new Date()
@@ -1553,6 +1564,26 @@ var DraftRepository = class extends Repository {
1553
1564
  }
1554
1565
  }
1555
1566
  /**
1567
+ * Mark this ACTOR's active draft converted, if they have one.
1568
+ *
1569
+ * For hosts that place an order without freezing a checkout first — there is
1570
+ * then no `checkout.draftId` for `markConverted` to key on, and the draft
1571
+ * stays `active` with its lines intact. The abandonment sweep selects exactly
1572
+ * that shape (`status: 'active'` + `lines.0` exists), so a purchased cart
1573
+ * becomes an abandoned-cart email.
1574
+ *
1575
+ * Returns whether anything was converted, so a caller can log the miss rather
1576
+ * than assume. Best-effort like `markConverted`: the order is already placed
1577
+ * and nothing here may fail it.
1578
+ */
1579
+ async markActiveConvertedForActor(actorRef, ctx) {
1580
+ if (!actorRef) return false;
1581
+ const draft = await this.findActiveByActor(actorRef, ctx);
1582
+ if (!draft) return false;
1583
+ await this.markConverted(draft._id, ctx);
1584
+ return true;
1585
+ }
1586
+ /**
1556
1587
  * Mark a draft as converted (called from CheckoutRepository.commit).
1557
1588
  * Best-effort: a missed update is reconciled by the next getOrCreate.
1558
1589
  */
@@ -4,10 +4,10 @@ import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEve
4
4
  import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "../cart-event-catalog-Cokx0iOw.mjs";
5
5
  import "./events/index.mjs";
6
6
  import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, x as BridgeRef, y as PromotionsBridge } from "../clock.port-DrSBrsit.mjs";
7
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-BEeYbRUY.mjs";
8
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../state-transitions-BQ2Nhxnb.mjs";
9
- import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "../line-kind-BW2zLNSr.mjs";
10
- import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "../kind-registry-DFvNDb81.mjs";
7
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "../reservation.entity-CLRqLD6X.mjs";
8
+ import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../state-transitions-B_ozUaqV.mjs";
9
+ import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "../line-kind-kYeQzpCy.mjs";
10
+ import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "../kind-registry-BkYl0cjc.mjs";
11
11
  import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "../id.port-DzgWy8sy.mjs";
12
12
  import "./ports/index.mjs";
13
13
  import "./saga/index.mjs";
@@ -1,2 +1,2 @@
1
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../../state-transitions-BQ2Nhxnb.mjs";
1
+ import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep, t as CHECKOUT_MACHINE } from "../../state-transitions-B_ozUaqV.mjs";
2
2
  export { CHECKOUT_MACHINE, CHECKOUT_STATE_TRANSITIONS, type CheckoutFlowState, CheckoutStep, type CheckoutStepNumber, type SagaDependencies, type SagaStepFn, isLegalCheckoutTransition };
@@ -1,3 +1,3 @@
1
1
  import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
2
- import { a as defineCart, c as CartEngine, d as CartShape, f as ResolvedCartConfig, i as createCartDomain, l as CartLogger, n as CartBlueprint, o as CartBridges, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime } from "../internal-event-bus-BA-WrtE0.mjs";
2
+ import { a as defineCart, c as CartEngine, d as CartShape, f as ResolvedCartConfig, i as createCartDomain, l as CartLogger, n as CartBlueprint, o as CartBridges, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime } from "../internal-event-bus-CC0PxRhB.mjs";
3
3
  export { type CartBlueprint, type CartBridges, type CartConfigShape, type CartDomain, type CartDomainRuntime, type CartEngine, type CartLogger, type CartRuntime, type CartShape, InProcessCartEventBus, type ResolvedCartConfig, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
@@ -1,3 +1,3 @@
1
- import { n as defineCart, r as InProcessCartEventBus, t as createCartDomain } from "../define-cart-Cr9VMeVc.mjs";
1
+ import { n as defineCart, r as InProcessCartEventBus, t as createCartDomain } from "../define-cart-DESSv8Rt.mjs";
2
2
  import { cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
3
3
  export { InProcessCartEventBus, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
package/dist/index.d.mts CHANGED
@@ -3,14 +3,14 @@ import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./
3
3
  import { S as CartEvents, _ as CartEventMeta, a as OutboxErrorInfo, b as CartEventName, c as OutboxFailureDecision, d as OutboxStore, f as OutboxStoreWriteOptions, g as CartEventAggregate, h as CartDomainEvent, i as OutboxClaimOptions, l as OutboxFailurePolicy, m as CartAggregateType, n as MemoryOutboxStore, o as OutboxFailOptions, p as OutboxWriteOptions, r as OutboxAcknowledgeOptions, s as OutboxFailureContext, t as InvalidOutboxEventError, u as OutboxOwnershipError, v as createCartEvent, x as CartEventPayload, y as CartEventMap } from "./outbox-store-Br7MHuOz.mjs";
4
4
  import { a as CartEventRegistry, c as defineCartEvent, d as EventValidationResult, f as EventValidator, i as CartEventDefinitionInput, l as EventSchema, n as cartEventsByName, o as PayloadOf, r as CartEventDefinition, s as createCartEventRegistry, t as cartEventDefinitions, u as EventSchemaProperty } from "./cart-event-catalog-Cokx0iOw.mjs";
5
5
  import { C as OperationContext, E as PricingSnapshot, S as BridgeStatus, T as PricedLine, _ as CartSnapshot, a as ShippingQuote, b as Address, c as TaxBridge, d as InventoryBridge, f as ReservationRef, g as AdjustmentSpec, h as ProductSummary, i as ShippingMethod, l as TaxCalculationRequest, m as CatalogBridge, n as systemClock, o as ShippingQuoteRequest, p as ReservationRequest, r as ShippingBridge, s as TaxBreakdown, t as ClockPort, u as TaxCalculationResult, v as PromotionResult, w as PENDING_EVENTS, x as BridgeRef, y as PromotionsBridge } from "./clock.port-DrSBrsit.mjs";
6
- import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-BEeYbRUY.mjs";
7
- import { a as SagaStepFn, c as CheckoutStepNumber, i as SagaDependencies, n as CHECKOUT_STATE_TRANSITIONS, o as CheckoutFlowState, r as isLegalCheckoutTransition, s as CheckoutStep } from "./state-transitions-BQ2Nhxnb.mjs";
8
- import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineDisplay, n as KindContext, o as StaleBehavior, r as LineKind, s as StaleTrigger, t as KindBridges } from "./line-kind-BW2zLNSr.mjs";
9
- import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "./kind-registry-DFvNDb81.mjs";
6
+ import { a as Adjustment, i as Checkout, n as IdempotencyRecord, r as Draft, t as Reservation } from "./reservation.entity-CLRqLD6X.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-B_ozUaqV.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-kYeQzpCy.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-BkYl0cjc.mjs";
10
10
  import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-DzgWy8sy.mjs";
11
11
  import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
12
- import { A as buildReservationSchema, C as DraftRepositoryDeps, D as DefineCartModelsConfig, E as CartModels, F as CheckoutDocument, I as buildCheckoutSchema, M as buildIdempotencySchema, N as DraftDocument, O as defineCartModels, P as buildDraftSchema, S as DraftRepository, T as CartModelName, _ as ReservationRepository, a as defineCart, b as CheckoutRepositoryDeps, c as CartEngine, d as CartShape, f as ResolvedCartConfig, g as createCartRepositories, h as CreateCartRepositoriesConfig, i as createCartDomain, j as IdempotencyDocument, k as ReservationDocument, l as CartLogger, m as CartRepositoryPluginBundle, n as CartBlueprint, o as CartBridges, p as CartRepositories, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime, v as IdempotencyRepository, w as CartEventPublisherDeps, x as DEFAULT_STALE_OPEN_CHECKOUT_MS, y as CheckoutRepository } from "./internal-event-bus-BA-WrtE0.mjs";
13
- import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "./variant.kind-CClf8MTF.mjs";
12
+ import { A as buildReservationSchema, C as DraftRepositoryDeps, D as DefineCartModelsConfig, E as CartModels, F as CheckoutDocument, I as buildCheckoutSchema, M as buildIdempotencySchema, N as DraftDocument, O as defineCartModels, P as buildDraftSchema, S as DraftRepository, T as CartModelName, _ as ReservationRepository, a as defineCart, b as CheckoutRepositoryDeps, c as CartEngine, d as CartShape, f as ResolvedCartConfig, g as createCartRepositories, h as CreateCartRepositoriesConfig, i as createCartDomain, j as IdempotencyDocument, k as ReservationDocument, l as CartLogger, m as CartRepositoryPluginBundle, n as CartBlueprint, o as CartBridges, p as CartRepositories, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime, v as IdempotencyRepository, w as CartEventPublisherDeps, x as DEFAULT_STALE_OPEN_CHECKOUT_MS, y as CheckoutRepository } from "./internal-event-bus-CC0PxRhB.mjs";
13
+ import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "./variant.kind-BVmeGR6G.mjs";
14
14
  import { Money, Money as Money$1, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
15
15
  import { DomainEvent, EventHandler, EventTransport, EventTransport as EventTransport$1, PublishManyResult } from "@classytic/primitives/events";
16
16
  import { CurrencyCode } from "@classytic/primitives/currency";
package/dist/index.mjs CHANGED
@@ -7,10 +7,10 @@ import { t as StateTransitionError } from "./state-transition.error-BssJiRoW.mjs
7
7
  import { n as CartEvents, t as createCartEvent } from "./domain-event-DBFsiHNJ.mjs";
8
8
  import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "./outbox-store-DLxCPOUN.mjs";
9
9
  import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "./id.port-DYAnXbfV.mjs";
10
- import { _ as PENDING_EVENTS, a as ReservationRepository, c as runPricing, d as defineCartModels, f as buildReservationSchema, g as flushPending, h as buildCheckoutSchema, i as createCartRepositories, l as CheckoutRepository, m as buildDraftSchema, n as defineCart, o as IdempotencyRepository, p as buildIdempotencySchema, r as InProcessCartEventBus, s as DraftRepository, t as createCartDomain, u as DEFAULT_STALE_OPEN_CHECKOUT_MS } from "./define-cart-Cr9VMeVc.mjs";
10
+ import { _ as PENDING_EVENTS, a as ReservationRepository, c as runPricing, d as defineCartModels, f as buildReservationSchema, g as flushPending, h as buildCheckoutSchema, i as createCartRepositories, l as CheckoutRepository, m as buildDraftSchema, n as defineCart, o as IdempotencyRepository, p as buildIdempotencySchema, r as InProcessCartEventBus, s as DraftRepository, t as createCartDomain, u as DEFAULT_STALE_OPEN_CHECKOUT_MS } from "./define-cart-DESSv8Rt.mjs";
11
11
  import { t as createKindRegistry } from "./kind-registry-DQYqRQZU.mjs";
12
12
  import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition } from "./state-transitions-wunwhjap.mjs";
13
- import { a as skuKind, c as serviceFeePayloadSchema, i as timeslotPayloadSchema, l as bundleKind, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as serviceFeeKind, t as variantKind, u as bundlePayloadSchema } from "./variant.kind-NmWSslu-.mjs";
13
+ import { a as skuKind, c as serviceFeePayloadSchema, i as timeslotPayloadSchema, l as bundleKind, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as serviceFeeKind, t as variantKind, u as bundlePayloadSchema } from "./variant.kind-CquIUes6.mjs";
14
14
  import { cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
15
15
  import { addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
16
16
  //#region src/services/abandonment.service.ts
@@ -1,7 +1,7 @@
1
1
  import { b as CartEventName, d as OutboxStore, h as CartDomainEvent, x as CartEventPayload } from "./outbox-store-Br7MHuOz.mjs";
2
2
  import { C as OperationContext, c as TaxBridge, d as InventoryBridge, m as CatalogBridge, r as ShippingBridge, t as ClockPort, y as PromotionsBridge } from "./clock.port-DrSBrsit.mjs";
3
- import { l as LineDisplay, r as LineKind } from "./line-kind-BW2zLNSr.mjs";
4
- import { c as LineItem, i as IdempotencyIdentity, t as KindRegistry } from "./kind-registry-DFvNDb81.mjs";
3
+ import { l as LineDisplay, r as LineKind } from "./line-kind-kYeQzpCy.mjs";
4
+ import { c as LineItem, i as IdempotencyIdentity, t as KindRegistry } from "./kind-registry-BkYl0cjc.mjs";
5
5
  import { t as IdPort } from "./id.port-DzgWy8sy.mjs";
6
6
  import { CartConfigShape } from "./engine/cart-config.schema.mjs";
7
7
  import { Money } from "@classytic/primitives/money";
@@ -321,6 +321,20 @@ declare class DraftRepository extends Repository<DraftDocument> {
321
321
  markAbandoned(draftId: Types.ObjectId | string, ctx: OperationContext, opts?: {
322
322
  expectedVersion?: number;
323
323
  }): Promise<DraftDocument | null>;
324
+ /**
325
+ * Mark this ACTOR's active draft converted, if they have one.
326
+ *
327
+ * For hosts that place an order without freezing a checkout first — there is
328
+ * then no `checkout.draftId` for `markConverted` to key on, and the draft
329
+ * stays `active` with its lines intact. The abandonment sweep selects exactly
330
+ * that shape (`status: 'active'` + `lines.0` exists), so a purchased cart
331
+ * becomes an abandoned-cart email.
332
+ *
333
+ * Returns whether anything was converted, so a caller can log the miss rather
334
+ * than assume. Best-effort like `markConverted`: the order is already placed
335
+ * and nothing here may fail it.
336
+ */
337
+ markActiveConvertedForActor(actorRef: string, ctx: OperationContext): Promise<boolean>;
324
338
  /**
325
339
  * Mark a draft as converted (called from CheckoutRepository.commit).
326
340
  * Best-effort: a missed update is reconciled by the next getOrCreate.
@@ -1,4 +1,4 @@
1
- import { l as LineDisplay, r as LineKind } from "./line-kind-BW2zLNSr.mjs";
1
+ import { l as LineDisplay, r as LineKind } from "./line-kind-kYeQzpCy.mjs";
2
2
  import { Money } from "@classytic/primitives/money";
3
3
  //#region src/domain/entities/line-item.entity.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "../variant.kind-CClf8MTF.mjs";
1
+ import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "../variant.kind-BVmeGR6G.mjs";
2
2
  export { type BundleComponent, type BundlePayload, type ServiceFeePayload, type SkuPayload, type TimeslotPayload, type VariantPayload, bundleKind, bundlePayloadSchema, serviceFeeKind, serviceFeePayloadSchema, skuKind, skuPayloadSchema, timeslotKind, timeslotPayloadSchema, variantKind, variantPayloadSchema };
@@ -1,2 +1,2 @@
1
- import { a as skuKind, c as serviceFeePayloadSchema, i as timeslotPayloadSchema, l as bundleKind, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as serviceFeeKind, t as variantKind, u as bundlePayloadSchema } from "../variant.kind-NmWSslu-.mjs";
1
+ import { a as skuKind, c as serviceFeePayloadSchema, i as timeslotPayloadSchema, l as bundleKind, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as serviceFeeKind, t as variantKind, u as bundlePayloadSchema } from "../variant.kind-CquIUes6.mjs";
2
2
  export { bundleKind, bundlePayloadSchema, serviceFeeKind, serviceFeePayloadSchema, skuKind, skuPayloadSchema, timeslotKind, timeslotPayloadSchema, variantKind, variantPayloadSchema };
@@ -39,6 +39,23 @@ interface LineDisplay {
39
39
  variantLabel?: string;
40
40
  /** Compare-at price for strikethrough display. */
41
41
  compareAtPrice?: Money;
42
+ /**
43
+ * Per-unit shipping weight in GRAMS, captured with the rest of the snapshot.
44
+ *
45
+ * Unlike the cosmetic fields around it, this one feeds a PRICE: a checkout
46
+ * pricing delivery by weight tiers sums `weightGrams x quantity` across the
47
+ * cart, and without it every cart looks unweighable and falls back to the flat
48
+ * charge. Carried here so a cart can be priced with no catalog round-trip per
49
+ * line — the whole point of this snapshot.
50
+ *
51
+ * Display drift is tolerated for name and image; for this the SERVER re-derives
52
+ * it at placement from the order's own line snapshot, so a stale or tampered
53
+ * value can never become the charged amount.
54
+ *
55
+ * Absent means UNWEIGHED, never zero — a zone with weight steps must fall back
56
+ * to its flat charge rather than price the cheapest step.
57
+ */
58
+ weightGrams?: number;
42
59
  /**
43
60
  * Timestamp when this snapshot was captured. The UI may show a "refresh"
44
61
  * affordance if the snapshot is older than some threshold.
@@ -1,7 +1,7 @@
1
1
  import { n as DraftStatus, r as ReservationStatus, t as CheckoutState } from "./cart-status.vo-BoVPaSXX.mjs";
2
2
  import { E as PricingSnapshot, g as AdjustmentSpec } from "./clock.port-DrSBrsit.mjs";
3
- import { o as CheckoutFlowState } from "./state-transitions-BQ2Nhxnb.mjs";
4
- import { a as IdempotencyReplay, c as LineItem, o as OperationName } from "./kind-registry-DFvNDb81.mjs";
3
+ import { o as CheckoutFlowState } from "./state-transitions-B_ozUaqV.mjs";
4
+ import { a as IdempotencyReplay, c as LineItem, o as OperationName } from "./kind-registry-BkYl0cjc.mjs";
5
5
  import { Money } from "@classytic/primitives/money";
6
6
  //#region src/domain/entities/adjustment.entity.d.ts
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import { t as CheckoutState } from "./cart-status.vo-BoVPaSXX.mjs";
2
2
  import { C as OperationContext, t as ClockPort } from "./clock.port-DrSBrsit.mjs";
3
- import { t as KindBridges } from "./line-kind-BW2zLNSr.mjs";
3
+ import { t as KindBridges } from "./line-kind-kYeQzpCy.mjs";
4
4
  import { t as IdPort } from "./id.port-DzgWy8sy.mjs";
5
5
  //#region src/domain/saga/saga-steps.d.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { r as LineKind } from "./line-kind-BW2zLNSr.mjs";
1
+ import { r as LineKind } from "./line-kind-kYeQzpCy.mjs";
2
2
  import { Money } from "@classytic/primitives/money";
3
3
  import { CurrencyCode } from "@classytic/primitives/currency";
4
4
  import { z } from "zod";
@@ -256,6 +256,15 @@ const skuKind = {
256
256
  slug: product.slug,
257
257
  variantLabel: product.variantLabel,
258
258
  compareAtPrice: product.compareAtPrice,
259
+ /**
260
+ * From the catalog bridge, which has carried `weightGrams` all along — the
261
+ * snapshot simply never captured it, so every checkout pricing delivery by
262
+ * weight saw an unweighable cart and fell back to the flat charge.
263
+ *
264
+ * Emitted only when real and positive: absent means unweighed, and a zero
265
+ * would select the cheapest weight step instead of the safe fallback.
266
+ */
267
+ ...typeof product.weightGrams === "number" && product.weightGrams > 0 ? { weightGrams: product.weightGrams } : {},
259
268
  capturedAt: ctx.clock?.now() ?? /* @__PURE__ */ new Date()
260
269
  };
261
270
  }
@@ -428,6 +437,15 @@ const variantKind = {
428
437
  slug: product.slug,
429
438
  variantLabel: product.variantLabel,
430
439
  compareAtPrice: product.compareAtPrice,
440
+ /**
441
+ * From the catalog bridge, which has carried `weightGrams` all along — the
442
+ * snapshot simply never captured it, so every checkout pricing delivery by
443
+ * weight saw an unweighable cart and fell back to the flat charge.
444
+ *
445
+ * Emitted only when real and positive: absent means unweighed, and a zero
446
+ * would select the cheapest weight step instead of the safe fallback.
447
+ */
448
+ ...typeof product.weightGrams === "number" && product.weightGrams > 0 ? { weightGrams: product.weightGrams } : {},
431
449
  capturedAt: ctx.clock?.now() ?? /* @__PURE__ */ new Date()
432
450
  };
433
451
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/cart",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
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",
@@ -83,18 +83,18 @@
83
83
  "release": "npm run push -- main && npm run release:tag && npm publish"
84
84
  },
85
85
  "peerDependencies": {
86
- "@classytic/mongokit": ">=3.33.0",
87
- "@classytic/primitives": ">=0.23.0",
88
- "@classytic/repo-core": ">=0.24.0",
86
+ "@classytic/mongokit": ">=3.36.0",
87
+ "@classytic/primitives": ">=0.26.4",
88
+ "@classytic/repo-core": ">=0.26.0",
89
89
  "mongoose": ">=9.4.1",
90
90
  "zod": ">=4.0.0"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@biomejs/biome": "^2.4.13",
94
94
  "@classytic/dev-tools": "^0.2.0",
95
- "@classytic/mongokit": "^3.33.0",
96
- "@classytic/primitives": ">=0.23.0",
97
- "@classytic/repo-core": ">=0.24.0",
95
+ "@classytic/mongokit": "^3.36.0",
96
+ "@classytic/primitives": "^0.26.4",
97
+ "@classytic/repo-core": "^0.26.0",
98
98
  "@types/node": "^25.5.0",
99
99
  "knip": "^6.7.0",
100
100
  "mongodb-memory-server": "^10.2.3",