@classytic/cart 1.1.1 → 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
@@ -1564,6 +1564,26 @@ var DraftRepository = class extends Repository {
1564
1564
  }
1565
1565
  }
1566
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
+ /**
1567
1587
  * Mark a draft as converted (called from CheckoutRepository.commit).
1568
1588
  * Best-effort: a missed update is reconciled by the next getOrCreate.
1569
1589
  */
@@ -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-Ci5Zpoqu.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-CYkjJdC7.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
@@ -9,7 +9,7 @@ import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineD
9
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-Ci5Zpoqu.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
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";
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ 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-CYkjJdC7.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
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";
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/cart",
3
- "version": "1.1.1",
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",