@classytic/revenue 1.1.4 → 2.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 (82) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +638 -632
  3. package/dist/audit-B39B0Sdq.mjs +53 -0
  4. package/dist/audit-DZ0eTr9g.d.mts +89 -0
  5. package/dist/bridges/index.d.mts +2 -0
  6. package/dist/bridges/index.mjs +1 -0
  7. package/dist/context-DRqSeTPM.d.mts +35 -0
  8. package/dist/core/state-machines.d.mts +35 -0
  9. package/dist/core/state-machines.mjs +134 -0
  10. package/dist/engine-types-CcjIb4Fy.d.mts +611 -0
  11. package/dist/enums/index.d.mts +3 -157
  12. package/dist/enums/index.mjs +3 -55
  13. package/dist/errors-DHa8JVQ-.mjs +92 -0
  14. package/dist/escrow.schema-BBv9oVEW.mjs +322 -0
  15. package/dist/escrow.schema-CC8XuD46.d.mts +629 -0
  16. package/dist/event-constants-CEMitnIV.mjs +53 -0
  17. package/dist/events/index.d.mts +3 -0
  18. package/dist/events/index.mjs +4 -0
  19. package/dist/index.d.mts +77 -9
  20. package/dist/index.mjs +465 -29
  21. package/dist/monetization.enums-BtiU3t8o.mjs +39 -0
  22. package/dist/monetization.enums-D2xbxXJM.d.mts +34 -0
  23. package/dist/plugins/plugin.interface.d.mts +28 -0
  24. package/dist/plugins/plugin.interface.mjs +26 -0
  25. package/dist/providers/index.d.mts +2 -3
  26. package/dist/providers/index.mjs +2 -2
  27. package/dist/{base-DCoyIUj6.mjs → registry-DhFMsSn5.mjs} +34 -36
  28. package/dist/{base-CsTlVQJe.d.mts → registry-SvIGPAx_.d.mts} +73 -66
  29. package/dist/repositories/create-repositories.d.mts +21 -0
  30. package/dist/repositories/create-repositories.mjs +12 -0
  31. package/dist/revenue-bridges-sdlrR85c.d.mts +145 -0
  32. package/dist/revenue-event-catalog-BX3g7RUi.d.mts +823 -0
  33. package/dist/revenue-event-catalog-LqxPnsU_.mjs +388 -0
  34. package/dist/settlement.repository-Cy3mMWGH.mjs +771 -0
  35. package/dist/shared/index.d.mts +2 -0
  36. package/dist/shared/index.mjs +4 -0
  37. package/dist/split.enums-CQE3ekH1.mjs +172 -0
  38. package/dist/split.enums-Dw4zCrcZ.d.mts +154 -0
  39. package/dist/splits-BAfY-a9P.mjs +123 -0
  40. package/dist/validators/index.d.mts +2 -0
  41. package/dist/validators/index.mjs +3 -0
  42. package/package.json +33 -37
  43. package/dist/application/services/index.d.mts +0 -4
  44. package/dist/application/services/index.mjs +0 -3
  45. package/dist/category-resolver-DV83N8ok.mjs +0 -284
  46. package/dist/commission-split-BzB8cd39.mjs +0 -485
  47. package/dist/core/events.d.mts +0 -294
  48. package/dist/core/events.mjs +0 -100
  49. package/dist/core/index.d.mts +0 -9
  50. package/dist/core/index.mjs +0 -8
  51. package/dist/errors-rRdOqnWx.d.mts +0 -787
  52. package/dist/escrow.enums-CZGrrdg7.mjs +0 -101
  53. package/dist/escrow.enums-DwdLuuve.d.mts +0 -78
  54. package/dist/idempotency-DaYcUGY1.mjs +0 -172
  55. package/dist/index-Dsp7H5Wb.d.mts +0 -471
  56. package/dist/infrastructure/plugins/index.d.mts +0 -239
  57. package/dist/infrastructure/plugins/index.mjs +0 -345
  58. package/dist/money-CvrDOijQ.mjs +0 -271
  59. package/dist/money-DPG8AtJ8.d.mts +0 -112
  60. package/dist/payment.enums-HAuAS9Pp.d.mts +0 -70
  61. package/dist/payment.enums-tEFVa-Xp.mjs +0 -69
  62. package/dist/plugin-BbK0OVHy.d.mts +0 -327
  63. package/dist/plugin-Cd_V04Em.mjs +0 -210
  64. package/dist/reconciliation/index.d.mts +0 -193
  65. package/dist/reconciliation/index.mjs +0 -192
  66. package/dist/retry-HHCOXYdn.d.mts +0 -186
  67. package/dist/revenue-BhdS7nXh.mjs +0 -553
  68. package/dist/schemas/index.d.mts +0 -2665
  69. package/dist/schemas/index.mjs +0 -717
  70. package/dist/schemas/validation.d.mts +0 -375
  71. package/dist/schemas/validation.mjs +0 -325
  72. package/dist/settlement.enums-DFhkqZEY.d.mts +0 -132
  73. package/dist/settlement.schema-DnNSFpGd.d.mts +0 -344
  74. package/dist/settlement.service-DjzAjezU.d.mts +0 -594
  75. package/dist/settlement.service-DmdKv0Zu.mjs +0 -2511
  76. package/dist/split.enums-BrjabxIX.mjs +0 -86
  77. package/dist/split.enums-DmskfLOM.d.mts +0 -43
  78. package/dist/tax-BoCt5cEd.d.mts +0 -61
  79. package/dist/tax-EQ15DO81.mjs +0 -162
  80. package/dist/transaction.enums-pCyMFT4Z.mjs +0 -96
  81. package/dist/utils/index.d.mts +0 -428
  82. package/dist/utils/index.mjs +0 -346
package/CHANGELOG.md ADDED
@@ -0,0 +1,90 @@
1
+ # Changelog
2
+
3
+ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
+ adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [2.0.0] — major rewrite
7
+
8
+ Payment lifecycle engine refactored around unified transactions, an
9
+ explicit state-machine core, and a compact 9-subpath surface. The old
10
+ `src/application/services/*` indirection + `src/core/container.ts` /
11
+ `src/core/events.ts` / `src/core/revenue.ts` / `src/core/plugin.ts` /
12
+ `src/core/result.ts` layers are gone — repositories + the engine factory
13
+ are the surface.
14
+
15
+ ### Added
16
+
17
+ - **`/core` subpath** — exposes `state-machines.ts` (TRANSACTION/HOLD/SPLIT
18
+ transitions + the generic `StateMachine<TState>` runtime) and the
19
+ `StateChangeEvent` shape so hosts can wire audit trails without pulling
20
+ in the full engine.
21
+ - **`/bridges` subpath** — host-side integration bridges (pricing, credit,
22
+ catalog, etc.) as typed ports; no side effects, no runtime coupling.
23
+ - **`/providers` subpath** — payment-provider adapter contracts consumed
24
+ by concrete adapter packages (`@classytic/revenue-manual` today; Stripe,
25
+ SSLCommerz, bKash etc. as separate packages).
26
+ - **`/utils` subpath** — shared helpers (audit trail, context resolution,
27
+ money conversion).
28
+ - **Unified transaction model** — single `Transaction` document carries
29
+ payment, subscription, escrow hold, split, and settlement context.
30
+ Status transitions validated by the state-machine core.
31
+ - **Audit trail helpers** (`appendAuditEvent`, `getAuditTrail`,
32
+ `getLastStateChange`) in `/utils`. Every state change emits a typed
33
+ `StateChangeEvent` (resourceType, resourceId, fromState, toState,
34
+ changedAt, changedBy?, reason?, metadata?).
35
+ - **Split-payment + tax features** and bug fixes from the 1.1 line folded
36
+ into 2.0.
37
+ - **Multi-payment support** on a single transaction (partial capture,
38
+ retry-with-different-method).
39
+
40
+ ### Changed
41
+
42
+ - **Dropped `src/application/services/*`** (escrow/monetization/payment/
43
+ settlement/subscription/transaction services). Equivalent logic now
44
+ lives on the repositories or the engine factory.
45
+ - **Dropped `src/core/` scaffolding** (container.ts, events.ts,
46
+ plugin.ts, result.ts, revenue.ts, state-machine/ subdir) in favor of
47
+ the flatter `state-machines.ts` + engine factory shape.
48
+ - **Peer deps standardized on `>=`** — `@classytic/mongokit >=3.11.0`,
49
+ `@classytic/primitives >=0.1.0`, `@classytic/repo-core >=0.2.0`,
50
+ `mongoose >=9.4.1`, `zod >=4.0.0`.
51
+ - **DevDeps:** `@classytic/primitives` moved off `file:` link onto
52
+ `>=0.1.0` now that primitives ships on npm.
53
+ - **Build migrated to tsdown** — per `tsdown.config.ts`, nine entries
54
+ aligned with the subpath exports.
55
+
56
+ ### Removed
57
+
58
+ - `src/application/index.ts` + every service module under it.
59
+ - `src/core/container.ts`, `events.ts`, `plugin.ts`, `result.ts`,
60
+ `revenue.ts`, and the `state-machine/` subdirectory (replaced by
61
+ `state-machines.ts`).
62
+ - Internal barrels under `src/` — only `src/index.ts` re-exports now.
63
+
64
+ ### Peer compatibility
65
+
66
+ Consumers on 1.x that imported from `@classytic/revenue` root will need
67
+ to migrate:
68
+ - Any `services.transaction.*` / `services.payment.*` / `services.escrow.*`
69
+ / `services.settlement.*` / `services.subscription.*` / `services.monetization.*`
70
+ calls move to the engine repositories.
71
+ - Custom state transitions move from the old container-based events to
72
+ the `StateMachine<TState>` API in `/core`.
73
+ - Providers move to the `/providers` contract; the manual reference
74
+ implementation ships as `@classytic/revenue-manual`.
75
+
76
+ ### Tests
77
+
78
+ 252 tests across 25 files (unit + integration + scenarios), run via
79
+ `vitest` at the workspace root. `mongodb-memory-server` for integration.
80
+
81
+ ## [1.1.x]
82
+
83
+ Refinements on the 1.x line — split payment feature, tax feature, bug
84
+ fixes. Unified transaction shape landed here before the 2.0 restructure.
85
+
86
+ ## [1.0.0]
87
+
88
+ Initial stable release on npm. Payment lifecycle engine —
89
+ transactions, subscriptions, escrow, settlements, commissions.
90
+ MongoKit-powered, framework-agnostic, Arc-compatible event shape.