@classytic/cart 0.2.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +75 -21
  3. package/dist/{cart-event-catalog-BxDJhtTM.d.mts → cart-event-catalog-Cokx0iOw.d.mts} +1 -2
  4. package/dist/cart.error-xi5OT4Sz.mjs +52 -0
  5. package/dist/{clock.port-CNu2wgdA.d.mts → clock.port-DrSBrsit.d.mts} +9 -5
  6. package/dist/{create-cart-BeW0xAqD.mjs → define-cart-BPq2kb_V.mjs} +344 -224
  7. package/dist/domain/errors/index.d.mts +2 -2
  8. package/dist/domain/errors/index.mjs +6 -6
  9. package/dist/domain/events/index.d.mts +2 -2
  10. package/dist/domain/events/index.mjs +2 -2
  11. package/dist/domain/index.d.mts +14 -11
  12. package/dist/domain/index.mjs +12 -12
  13. package/dist/domain/ports/index.d.mts +3 -3
  14. package/dist/domain/ports/index.mjs +1 -1
  15. package/dist/domain/saga/index.d.mts +1 -1
  16. package/dist/domain/saga/index.mjs +1 -1
  17. package/dist/engine/cart-config.schema.d.mts +3 -4
  18. package/dist/engine/cart-config.schema.mjs +7 -7
  19. package/dist/engine/index.d.mts +3 -3
  20. package/dist/engine/index.mjs +3 -3
  21. package/dist/{errors-7Pd0yATM.mjs → errors-Dj8itvAh.mjs} +1 -4
  22. package/dist/{id.port-BhbFZJPm.mjs → id.port-DYAnXbfV.mjs} +1 -1
  23. package/dist/{index-BB0XzkXF.d.mts → index-BTSo-RLv.d.mts} +41 -4
  24. package/dist/index.d.mts +75 -17
  25. package/dist/index.mjs +180 -15
  26. package/dist/{internal-event-bus-DhQKi9KS.d.mts → internal-event-bus-Bu7Xj7j6.d.mts} +203 -170
  27. package/dist/{kind-registry-DG2iCCH1.d.mts → kind-registry-DFvNDb81.d.mts} +3 -5
  28. package/dist/{kind-registry-Bvrj3P1Q.mjs → kind-registry-DQYqRQZU.mjs} +1 -1
  29. package/dist/{kind.error-DIaJpdUb.mjs → kind.error-BoyoVjKx.mjs} +1 -1
  30. package/dist/kinds/index.d.mts +1 -1
  31. package/dist/kinds/index.mjs +1 -1
  32. package/dist/{line-kind-B1mU1iJp.d.mts → line-kind-BW2zLNSr.d.mts} +3 -4
  33. package/dist/line-total-6VJQMjGV.mjs +24 -0
  34. package/dist/{outbox-store-CBt9fSYh.d.mts → outbox-store-Br7MHuOz.d.mts} +3 -18
  35. package/dist/{outbox-store-CWW8ppxS.mjs → outbox-store-DLxCPOUN.mjs} +2 -30
  36. package/dist/{reservation.entity-DLMxgpLE.d.mts → reservation.entity-BEeYbRUY.d.mts} +4 -5
  37. package/dist/{state-transition.error-2fRLh3p0.mjs → state-transition.error-BssJiRoW.mjs} +1 -1
  38. package/dist/{state-transitions-D19wZe-w.d.mts → state-transitions-BQ2Nhxnb.d.mts} +14 -11
  39. package/dist/{state-transitions-Defw8gAt.mjs → state-transitions-wunwhjap.mjs} +1 -1
  40. package/dist/{unmanaged-session.error-C9Z1Yh9j.mjs → unmanaged-session.error-DIRT2PR3.mjs} +31 -2
  41. package/dist/{variant.kind-q-yv-vnQ.d.mts → variant.kind-CClf8MTF.d.mts} +3 -3
  42. package/dist/{variant.kind-BHiivO9B.mjs → variant.kind-NmWSslu-.mjs} +23 -32
  43. package/package.json +10 -9
  44. package/dist/cart.error-BwWy4RlY.mjs +0 -27
  45. package/dist/index-2Ag-54t8.d.mts +0 -1
  46. /package/dist/{cart-status.vo-CNJw4aaB.d.mts → cart-status.vo-BoVPaSXX.d.mts} +0 -0
  47. /package/dist/{domain-event-CIEORKF6.mjs → domain-event-DBFsiHNJ.mjs} +0 -0
  48. /package/dist/{id.port-DitjeoHg.d.mts → id.port-DzgWy8sy.d.mts} +0 -0
  49. /package/dist/{idempotency-key.vo-D0lJsvGn.mjs → idempotency-key.vo-BoRvSIxx.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,60 @@
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.0.0 - 2026-07-29
7
+
8
+ ### Changed
9
+ - **License:** relicensed from MIT to the **Classytic Source-Available License** (Community & Commercial). Evaluation/development use remains free; production use now requires a commercial license from Classytic LLC. See `LICENSE`.
10
+ - Major bump marks the license change; versions published before 1.0.0 remain under their original MIT terms.
11
+
12
+ ## [0.3.3] — unpublished (2026-07-22)
13
+
14
+ ### Changed — event infra consolidated onto `@classytic/primitives/event-infra`
15
+
16
+ - `InProcessCartEventBus` is now a thin subclass of primitives' shared
17
+ `InProcessEventBus` (name `in-process-cart`, `logger: null` — cart's
18
+ silent-swallow dialect preserved: handler errors never propagate OR log).
19
+ Internal delivery detail: subscriptions are now Set-deduped per handler
20
+ across matching patterns (previously per-subscription array order) — no
21
+ cart code subscribes one handler under multiple patterns, so delivery is
22
+ unchanged in practice. `MemoryOutboxStore` is re-exported from
23
+ `@classytic/primitives/event-infra` instead of a local copy (gains
24
+ `all()` / `clear()` test helpers). No public API or event-shape changes.
25
+ - `@classytic/primitives` peer floor raised to `>=0.13.0` (the
26
+ `/event-infra` subpath).
27
+
28
+ ## [0.3.2] — unpublished (2026-07-22)
29
+
30
+ ### Fixed — `destroy()` was an empty no-op
31
+
32
+ - **`engine.destroy()` now actually tears down**: closes the self-created
33
+ `InProcessCartEventBus` (skipped when the host injected `eventTransport`).
34
+ - `destroy()` follows the fleet ownsBus convention (manufacturing/purchase
35
+ pattern): only what the engine itself created is closed; a host-injected
36
+ transport is the host's to close. Idempotent — a second call is a no-op.
37
+ Mongoose models/connection are untouched (host-owned).
38
+ - Lifecycle coverage in `tests/unit/engine-lifecycle.test.ts` (lite mode).
39
+
40
+ ## [0.3.1] — 2026-07-16
41
+
42
+ ### Fixed
43
+
44
+ - injectTenantField no longer force-indexes the tenant field: the compound
45
+ prepend makes the tenant the leading key of every index, so the bare single
46
+ was a redundant prefix paid on every insert (PACKAGE_RULES P11.1, fleet
47
+ index audit). A dedicated tenant index is still created when a schema
48
+ declares no compounds to prepend. Index-declaration change only.
49
+
50
+ ## [0.3.0] — unpublished (2026-07-15)
51
+
52
+ ### Changed — kit refresh (peer floors: mongokit >=3.22.0, repo-core >=0.13.0, primitives >=0.11.0)
53
+
54
+ - Verified against the mongokit 3.22 sweep. DEFERRED (design note, not a
55
+ drive-by): checkout `finalize`/`cancel` are assert-then-`updateWithVersion`
56
+ — the version CAS serializes writers, so the window is narrow; converting
57
+ to `applyTransition` (state+version compound CAS) needs a pass that
58
+ preserves the updateWithVersion helper's semantics.
59
+
6
60
  ## [0.2.1] - 2026-07-02
7
61
 
8
62
  ### Changed (behavioral) — 2026-07-05 addendum
package/LICENSE CHANGED
@@ -1,21 +1,75 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Classytic
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Classytic Source-Available License (Community & Commercial), Version 1.0
2
+
3
+ Copyright (c) 2026 Classytic LLC. All rights reserved.
4
+
5
+ This software is source-available, not open source. Please read this License
6
+ before using it.
7
+
8
+ 1. DEFINITIONS
9
+ "Software" means the contents of this package and any accompanying source
10
+ code, object code, or documentation, in any form.
11
+ "Licensor" means Classytic LLC, a limited liability company organized in the
12
+ United States.
13
+ "You" means the individual or legal entity exercising rights under this
14
+ License.
15
+ "Evaluation Use" means use for evaluation, development, testing,
16
+ experimentation, or internal non-commercial purposes only.
17
+ "Production Use" means any use of the Software that is live, commercial,
18
+ revenue-generating, or customer-facing, or any use other than Evaluation Use.
19
+ "Commercial License" means a separate written agreement executed with
20
+ Licensor that grants Production Use rights.
21
+
22
+ 2. OWNERSHIP
23
+ The Software is licensed, not sold. Licensor retains all right, title, and
24
+ interest in and to the Software, including all intellectual property rights.
25
+ All rights not expressly granted in this License are reserved by Licensor.
26
+
27
+ 3. EVALUATION GRANT
28
+ Subject to Your compliance with this License, Licensor grants You a
29
+ worldwide, royalty-free, non-exclusive, non-transferable, revocable license
30
+ to download, install, run, and modify the Software solely for Evaluation Use.
31
+
32
+ 4. PRODUCTION USE REQUIRES A COMMERCIAL LICENSE
33
+ Production Use of the Software is NOT permitted under this License and
34
+ requires a Commercial License from Licensor. A Commercial License may be
35
+ granted at Licensor's discretion, with or without a fee, and may confer
36
+ perpetual, irrevocable, and transferable Production Use rights as set out in
37
+ that agreement. Contact licensing@classytic.com to obtain one.
38
+
39
+ 5. RESTRICTIONS
40
+ You may not:
41
+ (a) make any Production Use of the Software without a Commercial License;
42
+ (b) redistribute, resell, rent, sublicense, or otherwise make the Software
43
+ (in whole or in part, original or modified) available to third parties as
44
+ a stand-alone product, framework, library, or hosted/managed service that
45
+ competes with the Software or with Licensor;
46
+ (c) remove, obscure, or alter any copyright, license, or attribution notice.
47
+
48
+ 6. FEEDBACK AND CONTRIBUTIONS
49
+ Any feedback, suggestions, or contributions You provide relating to the
50
+ Software may be used by Licensor for any purpose without obligation to You.
51
+
52
+ 7. TERMINATION
53
+ This License and the Evaluation Grant terminate automatically if You breach
54
+ any term. Upon termination You must cease all use of the Software and destroy
55
+ all copies in Your possession. Rights under a Commercial License are governed
56
+ by that agreement's own terms and survive termination of this License to the
57
+ extent stated there.
58
+
59
+ 8. DISCLAIMER OF WARRANTY
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62
+ FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
63
+
64
+ 9. LIMITATION OF LIABILITY
65
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL LICENSOR BE LIABLE
66
+ FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
67
+ TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE
68
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69
+
70
+ 10. GOVERNING LAW
71
+ This License is governed by the laws of the State of Delaware, United States,
72
+ without regard to its conflict-of-laws principles. (Adjust to Your LLC's state
73
+ of formation.)
74
+
75
+ For commercial licensing, contact: licensing@classytic.com
@@ -1,5 +1,4 @@
1
- import { _ as CartEventMeta, b as CartEventName, h as CartDomainEvent } from "./outbox-store-CBt9fSYh.mjs";
2
-
1
+ import { _ as CartEventMeta, b as CartEventName, h as CartDomainEvent } from "./outbox-store-Br7MHuOz.mjs";
3
2
  //#region src/domain/events/event-schema.d.ts
4
3
  /**
5
4
  * EventSchema — minimal JSON-schema-like shape for event payload validation.
@@ -0,0 +1,52 @@
1
+ //#region src/domain/errors/cart.error.ts
2
+ var CartError = class extends Error {
3
+ /** Optional structured context for logging / debugging. */
4
+ context;
5
+ /**
6
+ * Canonical `HttpError.status` (`@classytic/repo-core/errors`), DERIVED from
7
+ * {@link category} — the category already encodes exactly the distinction a
8
+ * status code makes, so deriving it keeps the two from ever disagreeing.
9
+ *
10
+ * Without a numeric `status`, arc's global handler has nothing to key on and
11
+ * serializes every cart error as `arc.internal_error` / 500 — `NotFoundError`
12
+ * answered 500 instead of 404, `ConcurrencyError` 500 instead of 409. That
13
+ * tells a client "the server broke, retrying is pointless" about outcomes
14
+ * that are neither broken nor unretryable, and it defeats `retryable` above:
15
+ * the field says "retry is reasonable" while the status says "don't bother".
16
+ *
17
+ * A subclass may still override with `readonly status = N` for a genuinely
18
+ * special case; nothing here depends on the mapping being total.
19
+ */
20
+ get status() {
21
+ switch (this.category) {
22
+ case "not_found": return 404;
23
+ case "concurrency":
24
+ case "state": return 409;
25
+ case "validation": return 422;
26
+ case "external": return 502;
27
+ default: return 500;
28
+ }
29
+ }
30
+ constructor(message, context) {
31
+ super(message);
32
+ this.name = new.target.name;
33
+ this.context = context;
34
+ Object.setPrototypeOf(this, new.target.prototype);
35
+ }
36
+ /**
37
+ * Serialize to a wire-safe shape. Suitable for HTTP error bodies and
38
+ * structured logging. Never includes stack frames.
39
+ */
40
+ toJSON() {
41
+ return {
42
+ name: this.name,
43
+ code: this.code,
44
+ category: this.category,
45
+ message: this.message,
46
+ retryable: this.retryable,
47
+ context: this.context
48
+ };
49
+ }
50
+ };
51
+ //#endregion
52
+ export { CartError as t };
@@ -2,7 +2,6 @@ import { Money } from "@classytic/primitives/money";
2
2
  import { ClientSession } from "mongoose";
3
3
  import { OperationContext } from "@classytic/primitives/context";
4
4
  import { ContactAddress as Address } from "@classytic/primitives/address";
5
-
6
5
  //#region src/domain/value-objects/pricing-snapshot.vo.d.ts
7
6
  /**
8
7
  * A priced line — the output of the pricing pipeline for a single LineItem.
@@ -77,10 +76,15 @@ interface PricingSnapshot {
77
76
  tax: Money;
78
77
  /** Final post-rounding totals from step 6. */
79
78
  totals: {
80
- /** Sum of all PricedLine.subtotals.prePromo. */subtotal: Money; /** Sum of all line discounts + orderDiscount. */
81
- discount: Money; /** Alias of `tax`. */
82
- taxTotal: Money; /** Alias of `shipping`. */
83
- shippingTotal: Money; /** Final order grand total after rounding. */
79
+ /** Sum of all PricedLine.subtotals.prePromo. */
80
+ subtotal: Money;
81
+ /** Sum of all line discounts + orderDiscount. */
82
+ discount: Money;
83
+ /** Alias of `tax`. */
84
+ taxTotal: Money;
85
+ /** Alias of `shipping`. */
86
+ shippingTotal: Money;
87
+ /** Final order grand total after rounding. */
84
88
  grandTotal: Money;
85
89
  };
86
90
  /**