@saasicat/nest 1.0.0-rc.2 → 1.0.0-rc.21

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 (154) hide show
  1. package/README.md +44 -8
  2. package/dist/.build-stamp +1 -1
  3. package/dist/_entries.cjs +10214 -4796
  4. package/dist/admin/index.d.cts +5 -4
  5. package/dist/admin/index.d.ts +5 -4
  6. package/dist/admin/index.js +13 -9
  7. package/dist/{admin-resources.module-CpvzcfCc.d.cts → admin-resources.module-B4XNvdH-.d.cts} +1 -2
  8. package/dist/{admin-resources.module-DF5_Q7RD.d.ts → admin-resources.module-CWqdI9BV.d.ts} +1 -2
  9. package/dist/{admin-stats.service-TYiSUwIR.d.ts → admin-stats.service-CsLNt19Z.d.ts} +11 -7
  10. package/dist/{admin-stats.service-DfKupywR.d.cts → admin-stats.service-DrZrU8IJ.d.cts} +11 -7
  11. package/dist/{aggregation-B3CD0v_d.d.cts → aggregation-ChpZDh0g.d.ts} +39 -6
  12. package/dist/{aggregation-BFzW07DE.d.ts → aggregation-OpnhwzF5.d.cts} +39 -6
  13. package/dist/billing/index.d.cts +448 -108
  14. package/dist/billing/index.d.ts +448 -108
  15. package/dist/billing/index.js +108 -41
  16. package/dist/catalog/index.d.cts +74 -45
  17. package/dist/catalog/index.d.ts +74 -45
  18. package/dist/catalog/index.js +21 -13
  19. package/dist/catalog.module-C9O7BxRq.d.ts +180 -0
  20. package/dist/catalog.module-T-I5Ricz.d.cts +180 -0
  21. package/dist/checkout-offer/index.d.cts +17 -22
  22. package/dist/checkout-offer/index.d.ts +17 -22
  23. package/dist/checkout-offer/index.js +21 -7
  24. package/dist/checkout-offer.module-DFhGy6JO.d.cts +58 -0
  25. package/dist/checkout-offer.module-x7SP_dX4.d.ts +58 -0
  26. package/dist/checkout-offer.service-BeHgYikI.d.ts +242 -0
  27. package/dist/checkout-offer.service-CCVxG9b2.d.cts +242 -0
  28. package/dist/chunk-34XVPR6P.js +222 -0
  29. package/dist/{chunk-AOQJEYOL.js → chunk-3QVGA6JX.js} +3 -1
  30. package/dist/chunk-3RLWML2S.js +896 -0
  31. package/dist/{chunk-TXC3LHHB.js → chunk-4SDSYV4A.js} +21 -13
  32. package/dist/chunk-55QEDAMX.js +946 -0
  33. package/dist/chunk-5CKC7O52.js +140 -0
  34. package/dist/chunk-6PJE7EWO.js +185 -0
  35. package/dist/chunk-7NJKVC5X.js +353 -0
  36. package/dist/{chunk-RUNZ3X4C.js → chunk-AOS2JPDD.js} +1263 -185
  37. package/dist/{chunk-WOVQPXV4.js → chunk-CQ2ZZMTD.js} +702 -725
  38. package/dist/{chunk-NA6O63B7.js → chunk-F5X66HF5.js} +5 -5
  39. package/dist/chunk-FEQZCWUL.js +174 -0
  40. package/dist/{chunk-VIJ5NJWC.js → chunk-G6EZWECL.js} +107 -31
  41. package/dist/chunk-G7RQO2XO.js +0 -0
  42. package/dist/{chunk-N3L3AICU.js → chunk-GPQWGA6B.js} +5 -6
  43. package/dist/chunk-GZTL64QK.js +7 -0
  44. package/dist/{chunk-SABTXESR.js → chunk-J7NJRK3K.js} +17 -1
  45. package/dist/{chunk-SEPN52AD.js → chunk-JBCC6C3M.js} +566 -307
  46. package/dist/{chunk-I7GTA3RX.js → chunk-JQRA724W.js} +1 -1
  47. package/dist/{chunk-WXYJHZCN.js → chunk-JVAEKTJ4.js} +2 -14
  48. package/dist/chunk-KPEMTBOP.js +26 -0
  49. package/dist/chunk-LF6J4YYN.js +301 -0
  50. package/dist/{chunk-LTT736P3.js → chunk-LLYVYRGJ.js} +228 -387
  51. package/dist/{chunk-6Z7JR4EW.js → chunk-M47BNEY2.js} +1897 -633
  52. package/dist/{chunk-KFT5AIIH.js → chunk-NDLC5GYK.js} +206 -24
  53. package/dist/{chunk-O2J2HDXA.js → chunk-OOTEXP47.js} +3 -8
  54. package/dist/chunk-QPVDCKYS.js +702 -0
  55. package/dist/{chunk-NHVDCYK5.js → chunk-R5YCJBHY.js} +71 -106
  56. package/dist/{chunk-XBYAFEOR.js → chunk-S33SO5XX.js} +1 -1
  57. package/dist/chunk-SZ7RFPXA.js +10 -0
  58. package/dist/chunk-TBBZWZQT.js +98 -0
  59. package/dist/chunk-TOEFN7DN.js +295 -0
  60. package/dist/{chunk-7ZEGFL42.js → chunk-WHJSYKNC.js} +6 -6
  61. package/dist/chunk-WOEJ6K7M.js +55 -0
  62. package/dist/{chunk-AU3OOREM.js → chunk-XSSWYPP5.js} +16 -3
  63. package/dist/contract-line-item-money-B0Z3Ogur.d.cts +43 -0
  64. package/dist/contract-line-item-money-B0Z3Ogur.d.ts +43 -0
  65. package/dist/discovery/index.d.cts +2 -2
  66. package/dist/discovery/index.d.ts +2 -2
  67. package/dist/discovery/index.js +6 -6
  68. package/dist/{discovery.scanner-9cMqF95o.d.cts → discovery.scanner-DXKc6JkV.d.cts} +1 -1
  69. package/dist/{discovery.scanner-9cMqF95o.d.ts → discovery.scanner-DXKc6JkV.d.ts} +1 -1
  70. package/dist/{enforce-quota.interceptor-Df0e3OWe.d.cts → enforce-quota.interceptor-BFyVdWe8.d.cts} +6 -6
  71. package/dist/{enforce-quota.interceptor-DW3etVyI.d.ts → enforce-quota.interceptor-GaBXboGx.d.ts} +6 -6
  72. package/dist/entitlement/index.d.cts +27 -4
  73. package/dist/entitlement/index.d.ts +27 -4
  74. package/dist/entitlement/index.js +13 -8
  75. package/dist/index.d.cts +209 -28
  76. package/dist/index.d.ts +209 -28
  77. package/dist/index.js +285 -163
  78. package/dist/issuer-identity.check-CBO0vcsq.d.cts +197 -0
  79. package/dist/issuer-identity.check-Cz9CEMkZ.d.ts +197 -0
  80. package/dist/{module-options-COSEb0VW.d.ts → module-options-DmQ3G4sZ.d.ts} +135 -41
  81. package/dist/{module-options-BG3MzQva.d.cts → module-options-qAOwinHR.d.cts} +135 -41
  82. package/dist/payment-callback.service-CR84Xw1Z.d.cts +125 -0
  83. package/dist/payment-callback.service-CR84Xw1Z.d.ts +125 -0
  84. package/dist/payments/index.cjs +4 -0
  85. package/dist/payments/index.d.cts +187 -0
  86. package/dist/payments/index.d.ts +187 -0
  87. package/dist/payments/index.js +141 -0
  88. package/dist/payments.module-BdUq9ot_.d.cts +57 -0
  89. package/dist/payments.module-CQGv_VG7.d.ts +57 -0
  90. package/dist/plan-catalog-source-DWe-BGY1.d.cts +21 -0
  91. package/dist/plan-catalog-source-DWe-BGY1.d.ts +21 -0
  92. package/dist/{plan-resolution-Cgo_TR1H.d.cts → plan-resolution-CwUy_OqC.d.cts} +14 -0
  93. package/dist/{plan-resolution-Cgo_TR1H.d.ts → plan-resolution-CwUy_OqC.d.ts} +14 -0
  94. package/dist/{plan-versions.service-DChhbK6h.d.ts → plan-versions.service-C0N-Em2W.d.ts} +38 -64
  95. package/dist/{plan-versions.service-TPEtbN0r.d.cts → plan-versions.service-DARLh-qI.d.cts} +38 -64
  96. package/dist/platform/index.d.cts +52 -23
  97. package/dist/platform/index.d.ts +52 -23
  98. package/dist/platform/index.js +57 -36
  99. package/dist/promo/index.d.cts +23 -8
  100. package/dist/promo/index.d.ts +23 -8
  101. package/dist/promo/index.js +15 -7
  102. package/dist/{promo.module-DtvIycpt.d.cts → promo.module-CKkECmU8.d.cts} +9 -3
  103. package/dist/{promo.module-Z8h1PNX-.d.ts → promo.module-DuIJdK3U.d.ts} +9 -3
  104. package/dist/promo.service-BYBu6dy3.d.cts +215 -0
  105. package/dist/promo.service-CFjfF0Xm.d.ts +215 -0
  106. package/dist/registration/index.d.cts +104 -47
  107. package/dist/registration/index.d.ts +104 -47
  108. package/dist/registration/index.js +15 -9
  109. package/dist/subscriber/index.cjs +4 -0
  110. package/dist/subscriber/index.d.cts +28 -0
  111. package/dist/subscriber/index.d.ts +28 -0
  112. package/dist/subscriber/index.js +16 -0
  113. package/dist/subscriber.service-5W6Gi-1B.d.cts +68 -0
  114. package/dist/subscriber.service-5W6Gi-1B.d.ts +68 -0
  115. package/dist/subscription-contract/index.d.cts +4 -2
  116. package/dist/subscription-contract/index.d.ts +4 -2
  117. package/dist/subscription-contract/index.js +13 -5
  118. package/dist/{subscription-contract.module-fDFdQ0jm.d.ts → subscription-contract.module-BfIRpc1o.d.ts} +8 -2
  119. package/dist/{subscription-contract.module-CEK8HS5-.d.cts → subscription-contract.module-DTMuUJYd.d.cts} +8 -2
  120. package/dist/{subscription-contract.service-hD87MKyg.d.cts → subscription-contract.service-CPZrTM9C.d.ts} +32 -3
  121. package/dist/{subscription-contract.service-hD87MKyg.d.ts → subscription-contract.service-CfNApLuP.d.cts} +32 -3
  122. package/dist/tenant-billing.controller-BLqbsONe.d.ts +812 -0
  123. package/dist/tenant-billing.controller-DKbAqTbM.d.cts +812 -0
  124. package/dist/tenant-billing.module-ClbjzocC.d.cts +364 -0
  125. package/dist/tenant-billing.module-DohgJJ2m.d.ts +364 -0
  126. package/dist/tenant-billing.tokens-G-1xOlMr.d.cts +129 -0
  127. package/dist/tenant-billing.tokens-G-1xOlMr.d.ts +129 -0
  128. package/dist/testing/index.d.cts +44 -17
  129. package/dist/testing/index.d.ts +44 -17
  130. package/dist/testing/index.js +189 -40
  131. package/package.json +24 -4
  132. package/dist/catalog.module-BDDO6iwq.d.cts +0 -103
  133. package/dist/catalog.module-BTnMsE6u.d.ts +0 -103
  134. package/dist/checkout-offer.module-CMtiQJTT.d.ts +0 -39
  135. package/dist/checkout-offer.module-CVpWrzbe.d.cts +0 -39
  136. package/dist/checkout-offer.service-BLOv2HOo.d.cts +0 -49
  137. package/dist/checkout-offer.service-BLOv2HOo.d.ts +0 -49
  138. package/dist/chunk-57V6ZTI6.js +0 -22
  139. package/dist/chunk-BSK6YBLI.js +0 -87
  140. package/dist/chunk-DQKCK7DX.js +0 -217
  141. package/dist/chunk-VXEYLNIB.js +0 -632
  142. package/dist/chunk-WUDYIPYH.js +0 -715
  143. package/dist/define-saasicat-DROBe-b1.d.ts +0 -69
  144. package/dist/define-saasicat-vGBCkFys.d.cts +0 -69
  145. package/dist/promo.service-BJbKAmw3.d.cts +0 -112
  146. package/dist/promo.service-BJbKAmw3.d.ts +0 -112
  147. package/dist/tenant-billing.controller-BQ67mlmI.d.ts +0 -438
  148. package/dist/tenant-billing.controller-DS8kB8a7.d.cts +0 -438
  149. package/dist/tenant-billing.module-BznC3XtW.d.cts +0 -299
  150. package/dist/tenant-billing.module-wUbsQSFG.d.ts +0 -299
  151. /package/dist/{chunk-2FR6ZL7R.js → chunk-BHZOH2DY.js} +0 -0
  152. /package/dist/{chunk-2SLTRKXC.js → chunk-DFOW3JVO.js} +0 -0
  153. /package/dist/{chunk-DBZGV3HC.js → chunk-DU56UKEH.js} +0 -0
  154. /package/dist/{chunk-OYNHOY45.js → chunk-GAUEVIAE.js} +0 -0
@@ -0,0 +1,125 @@
1
+ import { PlanCatalogSettings, PaymentGateway, PaymentMethodType, PaymentEventLog, TransactionRunner, PaymentMethodSetupSubject, PaymentGatewayEvent, TransactionContext, PaymentGatewayCallback } from '@saasicat/core';
2
+
3
+ /** A configured account with the adapter bound for it. */
4
+ interface PaymentGatewayAccount {
5
+ name: string;
6
+ provider: string;
7
+ gateway: PaymentGateway;
8
+ }
9
+ /** The account new payment methods are taken at, with what its form offers. */
10
+ interface NewPaymentMethodAccount extends PaymentGatewayAccount {
11
+ methods: readonly PaymentMethodType[];
12
+ }
13
+ /**
14
+ * The gateway accounts `config/saas.yaml#payments` names, each with the adapter
15
+ * the application bound for it.
16
+ *
17
+ * Refuses to be built when the two disagree: a callback for an account nobody
18
+ * bound would be answered with an error until the gateway gave up, and a
19
+ * payment method taken at the wrong provider could not be charged.
20
+ */
21
+ declare class PaymentGatewayRegistry {
22
+ private readonly settings;
23
+ private readonly accounts;
24
+ private readonly takesNew;
25
+ constructor(settings: PlanCatalogSettings, gateways: Readonly<Record<string, PaymentGateway>>);
26
+ /** The account a callback names, or `null` when none is configured under it. */
27
+ account(name: string): PaymentGatewayAccount | null;
28
+ /** The accounts among `held` that are not configured, each once — references nothing can reach any more. */
29
+ unconfigured(held: readonly string[]): string[];
30
+ /** The origins a gateway's form may send a person back to. */
31
+ returnUrlOrigins(): readonly string[];
32
+ /** The account a new payment method is taken at, or `null` when none takes new ones. */
33
+ forNewPaymentMethods(): NewPaymentMethodAccount | null;
34
+ }
35
+
36
+ /** A confirmation of a payment method, as its handler receives it. */
37
+ type PaymentMethodConfirmedEvent = Extract<PaymentGatewayEvent, {
38
+ kind: 'payment-method-confirmed';
39
+ }>;
40
+ /** A setup the gateway reports as failed. */
41
+ type PaymentMethodSetupFailedEvent = Extract<PaymentGatewayEvent, {
42
+ kind: 'payment-method-setup-failed';
43
+ }>;
44
+ /** Where an event is handled: on the transaction its claim is written on. */
45
+ interface PaymentEventContext {
46
+ tx: TransactionContext;
47
+ gatewayAccount: string;
48
+ provider: string;
49
+ /**
50
+ * Runs `step` once the transaction committed — for what must not happen
51
+ * when it rolls back, such as a notice or deleting a record kept outside
52
+ * it. A step that fails is logged; the event stays handled.
53
+ */
54
+ afterCommit(step: () => Promise<void>): void;
55
+ }
56
+ /**
57
+ * What a handler did about a confirmation.
58
+ *
59
+ * `nothing-to-do` gives the session back: the confirmation named a setup
60
+ * nobody opened, or one that is complete, so a later event about that session
61
+ * has to be handled rather than answered as a duplicate.
62
+ */
63
+ type PaymentEventEffect = 'took-effect' | 'nothing-to-do';
64
+ /** What a sign-up or a subscriber does with the events about its setup. */
65
+ interface PaymentSetupEventHandler {
66
+ confirmed(event: PaymentMethodConfirmedEvent, context: PaymentEventContext): Promise<PaymentEventEffect>;
67
+ failed(event: PaymentMethodSetupFailedEvent, context: PaymentEventContext): Promise<void>;
68
+ }
69
+ /** How a callback ended. A duplicate and an event nobody acts on are both answered as received. */
70
+ type PaymentCallbackOutcome = 'handled' | 'duplicate' | 'unhandled';
71
+ /**
72
+ * Takes a gateway callback from the wire to its effect.
73
+ *
74
+ * The adapter verifies it first, so nothing unverified is read. The event is
75
+ * then claimed and handled on ONE transaction: a handler that fails rolls the
76
+ * claim back with its own writes, and the gateway's retry is handled instead of
77
+ * being discarded as a duplicate; a handler that succeeded leaves a claim that
78
+ * turns every later delivery into a duplicate.
79
+ */
80
+ declare class PaymentCallbackService {
81
+ private readonly registry;
82
+ private readonly log;
83
+ private readonly transactions;
84
+ private readonly logger;
85
+ private readonly handlers;
86
+ constructor(registry: PaymentGatewayRegistry, log: PaymentEventLog, transactions: TransactionRunner);
87
+ /**
88
+ * Names who handles the setups of one kind of subject. Each kind has one
89
+ * handler; a second is a wiring error, not a replacement.
90
+ */
91
+ handleSetupsOf(kind: PaymentMethodSetupSubject['kind'], handler: PaymentSetupEventHandler): void;
92
+ handle(account: string, callback: PaymentGatewayCallback): Promise<PaymentCallbackOutcome>;
93
+ /**
94
+ * Hands the confirmation to its handler, and names the one refusal that
95
+ * will never come out differently.
96
+ *
97
+ * A reference belongs to one subscriber for good (`SC-SEC-014`), so a
98
+ * confirmation refused for that reason is refused on every delivery. It
99
+ * still leaves by throwing, which rolls this transaction back: by the time
100
+ * it is raised a handler has written something that must not stand on its
101
+ * own — the setup marked complete on the tenant's path, the whole
102
+ * activation on the sign-up's. Answering the gateway anything else would
103
+ * commit one of those without the payment method that justifies it.
104
+ *
105
+ * The gateway therefore retries until it gives up, and the claim rolls back
106
+ * with everything else, so nothing durable is left to say why. This line is
107
+ * what says it.
108
+ *
109
+ * There is no terminal state for it, and that is worth knowing before an
110
+ * operator waits for one: the webhook route has no filter for this, so every
111
+ * redelivery is answered `500`, for as long as the provider keeps trying. A
112
+ * provider that disables an endpoint after sustained failures would take the
113
+ * account's other callbacks with it. Giving the event an end would mean
114
+ * keeping the claim while undoing what the handler wrote, which needs a
115
+ * savepoint the port does not have — so it is named here rather than
116
+ * implied. It names the account, the reference and the subject the
117
+ * event was about — never the subscriber the reference belongs to, which is
118
+ * on the other side of the boundary being refused.
119
+ */
120
+ private confirm;
121
+ private read;
122
+ private handlerFor;
123
+ }
124
+
125
+ export { type NewPaymentMethodAccount as N, PaymentGatewayRegistry as P, PaymentCallbackService as a, type PaymentCallbackOutcome as b, type PaymentEventContext as c, type PaymentGatewayAccount as d, type PaymentMethodConfirmedEvent as e, type PaymentMethodSetupFailedEvent as f, type PaymentSetupEventHandler as g };
@@ -0,0 +1,125 @@
1
+ import { PlanCatalogSettings, PaymentGateway, PaymentMethodType, PaymentEventLog, TransactionRunner, PaymentMethodSetupSubject, PaymentGatewayEvent, TransactionContext, PaymentGatewayCallback } from '@saasicat/core';
2
+
3
+ /** A configured account with the adapter bound for it. */
4
+ interface PaymentGatewayAccount {
5
+ name: string;
6
+ provider: string;
7
+ gateway: PaymentGateway;
8
+ }
9
+ /** The account new payment methods are taken at, with what its form offers. */
10
+ interface NewPaymentMethodAccount extends PaymentGatewayAccount {
11
+ methods: readonly PaymentMethodType[];
12
+ }
13
+ /**
14
+ * The gateway accounts `config/saas.yaml#payments` names, each with the adapter
15
+ * the application bound for it.
16
+ *
17
+ * Refuses to be built when the two disagree: a callback for an account nobody
18
+ * bound would be answered with an error until the gateway gave up, and a
19
+ * payment method taken at the wrong provider could not be charged.
20
+ */
21
+ declare class PaymentGatewayRegistry {
22
+ private readonly settings;
23
+ private readonly accounts;
24
+ private readonly takesNew;
25
+ constructor(settings: PlanCatalogSettings, gateways: Readonly<Record<string, PaymentGateway>>);
26
+ /** The account a callback names, or `null` when none is configured under it. */
27
+ account(name: string): PaymentGatewayAccount | null;
28
+ /** The accounts among `held` that are not configured, each once — references nothing can reach any more. */
29
+ unconfigured(held: readonly string[]): string[];
30
+ /** The origins a gateway's form may send a person back to. */
31
+ returnUrlOrigins(): readonly string[];
32
+ /** The account a new payment method is taken at, or `null` when none takes new ones. */
33
+ forNewPaymentMethods(): NewPaymentMethodAccount | null;
34
+ }
35
+
36
+ /** A confirmation of a payment method, as its handler receives it. */
37
+ type PaymentMethodConfirmedEvent = Extract<PaymentGatewayEvent, {
38
+ kind: 'payment-method-confirmed';
39
+ }>;
40
+ /** A setup the gateway reports as failed. */
41
+ type PaymentMethodSetupFailedEvent = Extract<PaymentGatewayEvent, {
42
+ kind: 'payment-method-setup-failed';
43
+ }>;
44
+ /** Where an event is handled: on the transaction its claim is written on. */
45
+ interface PaymentEventContext {
46
+ tx: TransactionContext;
47
+ gatewayAccount: string;
48
+ provider: string;
49
+ /**
50
+ * Runs `step` once the transaction committed — for what must not happen
51
+ * when it rolls back, such as a notice or deleting a record kept outside
52
+ * it. A step that fails is logged; the event stays handled.
53
+ */
54
+ afterCommit(step: () => Promise<void>): void;
55
+ }
56
+ /**
57
+ * What a handler did about a confirmation.
58
+ *
59
+ * `nothing-to-do` gives the session back: the confirmation named a setup
60
+ * nobody opened, or one that is complete, so a later event about that session
61
+ * has to be handled rather than answered as a duplicate.
62
+ */
63
+ type PaymentEventEffect = 'took-effect' | 'nothing-to-do';
64
+ /** What a sign-up or a subscriber does with the events about its setup. */
65
+ interface PaymentSetupEventHandler {
66
+ confirmed(event: PaymentMethodConfirmedEvent, context: PaymentEventContext): Promise<PaymentEventEffect>;
67
+ failed(event: PaymentMethodSetupFailedEvent, context: PaymentEventContext): Promise<void>;
68
+ }
69
+ /** How a callback ended. A duplicate and an event nobody acts on are both answered as received. */
70
+ type PaymentCallbackOutcome = 'handled' | 'duplicate' | 'unhandled';
71
+ /**
72
+ * Takes a gateway callback from the wire to its effect.
73
+ *
74
+ * The adapter verifies it first, so nothing unverified is read. The event is
75
+ * then claimed and handled on ONE transaction: a handler that fails rolls the
76
+ * claim back with its own writes, and the gateway's retry is handled instead of
77
+ * being discarded as a duplicate; a handler that succeeded leaves a claim that
78
+ * turns every later delivery into a duplicate.
79
+ */
80
+ declare class PaymentCallbackService {
81
+ private readonly registry;
82
+ private readonly log;
83
+ private readonly transactions;
84
+ private readonly logger;
85
+ private readonly handlers;
86
+ constructor(registry: PaymentGatewayRegistry, log: PaymentEventLog, transactions: TransactionRunner);
87
+ /**
88
+ * Names who handles the setups of one kind of subject. Each kind has one
89
+ * handler; a second is a wiring error, not a replacement.
90
+ */
91
+ handleSetupsOf(kind: PaymentMethodSetupSubject['kind'], handler: PaymentSetupEventHandler): void;
92
+ handle(account: string, callback: PaymentGatewayCallback): Promise<PaymentCallbackOutcome>;
93
+ /**
94
+ * Hands the confirmation to its handler, and names the one refusal that
95
+ * will never come out differently.
96
+ *
97
+ * A reference belongs to one subscriber for good (`SC-SEC-014`), so a
98
+ * confirmation refused for that reason is refused on every delivery. It
99
+ * still leaves by throwing, which rolls this transaction back: by the time
100
+ * it is raised a handler has written something that must not stand on its
101
+ * own — the setup marked complete on the tenant's path, the whole
102
+ * activation on the sign-up's. Answering the gateway anything else would
103
+ * commit one of those without the payment method that justifies it.
104
+ *
105
+ * The gateway therefore retries until it gives up, and the claim rolls back
106
+ * with everything else, so nothing durable is left to say why. This line is
107
+ * what says it.
108
+ *
109
+ * There is no terminal state for it, and that is worth knowing before an
110
+ * operator waits for one: the webhook route has no filter for this, so every
111
+ * redelivery is answered `500`, for as long as the provider keeps trying. A
112
+ * provider that disables an endpoint after sustained failures would take the
113
+ * account's other callbacks with it. Giving the event an end would mean
114
+ * keeping the claim while undoing what the handler wrote, which needs a
115
+ * savepoint the port does not have — so it is named here rather than
116
+ * implied. It names the account, the reference and the subject the
117
+ * event was about — never the subscriber the reference belongs to, which is
118
+ * on the other side of the boundary being refused.
119
+ */
120
+ private confirm;
121
+ private read;
122
+ private handlerFor;
123
+ }
124
+
125
+ export { type NewPaymentMethodAccount as N, PaymentGatewayRegistry as P, PaymentCallbackService as a, type PaymentCallbackOutcome as b, type PaymentEventContext as c, type PaymentGatewayAccount as d, type PaymentMethodConfirmedEvent as e, type PaymentMethodSetupFailedEvent as f, type PaymentSetupEventHandler as g };
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+ // Generated by scripts/build-cjs-stubs.mjs — do not edit.
3
+ // Thin re-export so every entry shares one set of class objects.
4
+ module.exports = require('../_entries.cjs').paymentsNs;
@@ -0,0 +1,187 @@
1
+ export { b as PaymentsModule, P as PaymentsModuleOptions, a as PaymentsTenantRoutesOptions } from '../payments.module-BdUq9ot_.cjs';
2
+ import { P as PaymentGatewayRegistry, a as PaymentCallbackService } from '../payment-callback.service-CR84Xw1Z.cjs';
3
+ export { N as NewPaymentMethodAccount, b as PaymentCallbackOutcome, c as PaymentEventContext, d as PaymentGatewayAccount, e as PaymentMethodConfirmedEvent, f as PaymentMethodSetupFailedEvent, g as PaymentSetupEventHandler } from '../payment-callback.service-CR84Xw1Z.cjs';
4
+ import { OnModuleInit, RawBodyRequest } from '@nestjs/common';
5
+ import { SubscriberPaymentMethodRepository, SubscriberPaymentMethodRecord, PaymentMethodType, PaymentGateway, StartPaymentMethodSetupInput, PaymentMethodSetupSession, PaymentGatewayCallback, PaymentGatewayEvent } from '@saasicat/core';
6
+ import { S as SubscriberService } from '../subscriber.service-5W6Gi-1B.cjs';
7
+ import { T as TenantIdResolver, U as UserEmailResolver } from '../tenant-billing.tokens-G-1xOlMr.cjs';
8
+ import '../di-CcNeq9v-.cjs';
9
+
10
+ interface StartPaymentMethodChange {
11
+ successUrl: string;
12
+ cancelUrl: string;
13
+ /** Where the gateway writes when the subscriber's record holds no invoice email: the requesting user's. */
14
+ fallbackEmail: string | null;
15
+ }
16
+ /**
17
+ * A subscriber's payment method: the one in use, and replacing it through the
18
+ * gateway's form.
19
+ *
20
+ * Nothing changes when the form is opened. The gateway confirms through its
21
+ * callback, and the confirmation is what records the new payment method —
22
+ * on the transaction that claims the callback.
23
+ */
24
+ declare class SubscriberPaymentMethodService implements OnModuleInit {
25
+ private readonly methods;
26
+ private readonly subscribers;
27
+ private readonly registry;
28
+ private readonly callbacks;
29
+ private readonly logger;
30
+ constructor(methods: SubscriberPaymentMethodRepository, subscribers: SubscriberService, registry: PaymentGatewayRegistry, callbacks: PaymentCallbackService);
31
+ onModuleInit(): void;
32
+ /** The payment method in use for the tenant's subscriber, or `null` when it has none. */
33
+ current(tenantId: string): Promise<SubscriberPaymentMethodRecord | null>;
34
+ /**
35
+ * Opens the gateway's form for a new payment method for the tenant's
36
+ * subscriber, and returns where to send the person.
37
+ *
38
+ * The customer the subscriber has at that account is reused, so the new
39
+ * payment method sits beside the ones the gateway already holds for it.
40
+ */
41
+ startChange(tenantId: string, input: StartPaymentMethodChange): Promise<{
42
+ redirectUrl: string;
43
+ }>;
44
+ private recordConfirmed;
45
+ }
46
+
47
+ /** Where the gateway's form sends the person — `POST /billing/payment-method/setup`. */
48
+ declare class StartPaymentMethodSetupDto {
49
+ successUrl: string;
50
+ cancelUrl: string;
51
+ }
52
+
53
+ /** How a payment method in use is shown: what tells it apart, and nothing that reaches it at the gateway. */
54
+ interface TenantPaymentMethodView {
55
+ type: PaymentMethodType;
56
+ brand: string | null;
57
+ last4: string;
58
+ expiryMonth: number | null;
59
+ expiryYear: number | null;
60
+ country: string | null;
61
+ mandateReference: string | null;
62
+ confirmedAt: string;
63
+ }
64
+ /**
65
+ * `GET /billing/payment-method` and `POST /billing/payment-method/setup` — the
66
+ * tenant's view of what its subscriber pays with, behind the billing
67
+ * permission for reading and changing alike.
68
+ */
69
+ declare class TenantPaymentMethodController {
70
+ private readonly paymentMethods;
71
+ private readonly tenantIdResolver;
72
+ private readonly userEmailResolver;
73
+ constructor(paymentMethods: SubscriberPaymentMethodService, tenantIdResolver: TenantIdResolver, userEmailResolver?: UserEmailResolver | null);
74
+ current(request: unknown): Promise<{
75
+ paymentMethod: TenantPaymentMethodView | null;
76
+ }>;
77
+ startSetup(request: unknown, body: StartPaymentMethodSetupDto): Promise<{
78
+ redirectUrl: string;
79
+ }>;
80
+ private tenantOf;
81
+ private emailOf;
82
+ }
83
+
84
+ /**
85
+ * A change of the subscriber's contact details — `PATCH /billing/details`. A
86
+ * field left out keeps its value.
87
+ *
88
+ * The legal name and the tax identifiers are declared so that they reach the
89
+ * service rather than being stripped by the application's `ValidationPipe`:
90
+ * a tenant that sends a new legal name is told it cannot change it there,
91
+ * instead of being told it succeeded.
92
+ */
93
+ declare class ChangeBillingDetailsDto {
94
+ addressLine1?: string | null;
95
+ addressLine2?: string | null;
96
+ postalCode?: string | null;
97
+ city?: string | null;
98
+ /** ISO 3166-1 alpha-2, e.g. `DE`; its form is checked where every detail is settled. */
99
+ country?: string | null;
100
+ invoiceEmail?: string | null;
101
+ legalName?: unknown;
102
+ vatId?: unknown;
103
+ taxNumber?: unknown;
104
+ }
105
+
106
+ /** The subscriber as its tenant sees it in its billing area. */
107
+ interface TenantBillingDetailsView {
108
+ customerNumber: string;
109
+ legalName: string;
110
+ vatId: string | null;
111
+ taxNumber: string | null;
112
+ addressLine1: string | null;
113
+ addressLine2: string | null;
114
+ postalCode: string | null;
115
+ city: string | null;
116
+ country: string | null;
117
+ invoiceEmail: string | null;
118
+ }
119
+ /**
120
+ * `GET /billing/details` and `PATCH /billing/details` — whom the tenant's
121
+ * subscription is billed to, behind the billing permission for reading and
122
+ * changing alike. The contact details change here; the legal name and the tax
123
+ * identifiers are shown and corrected by the operator (`SC-SUB-017`).
124
+ */
125
+ declare class TenantBillingDetailsController {
126
+ private readonly subscribers;
127
+ private readonly tenantIdResolver;
128
+ constructor(subscribers: SubscriberService, tenantIdResolver: TenantIdResolver);
129
+ current(request: unknown): Promise<{
130
+ details: TenantBillingDetailsView;
131
+ }>;
132
+ change(request: unknown, body: ChangeBillingDetailsDto): Promise<{
133
+ details: TenantBillingDetailsView;
134
+ }>;
135
+ private tenantOf;
136
+ }
137
+
138
+ interface CallbackRequest {
139
+ headers: Record<string, string | string[] | undefined>;
140
+ }
141
+ /**
142
+ * `POST /webhooks/payment/:account` — where a gateway account sends its
143
+ * callbacks, one route per account in `config/saas.yaml#payments.accounts`.
144
+ *
145
+ * Public, because the gateway has no session: what makes a callback genuine is
146
+ * its signature over the exact bytes it sent, which the account's adapter
147
+ * verifies before anything is read. That needs the body as it arrived, so the
148
+ * application is created with `rawBody: true`.
149
+ */
150
+ declare class PaymentWebhookController {
151
+ private readonly callbacks;
152
+ constructor(callbacks: PaymentCallbackService);
153
+ receive(account: string, request: RawBodyRequest<CallbackRequest>): Promise<{
154
+ received: true;
155
+ }>;
156
+ }
157
+
158
+ /** The provider name `config/saas.yaml` gives an account bound to this gateway. */
159
+ declare const DEV_PAYMENT_PROVIDER = "dev";
160
+ /**
161
+ * A payment gateway for development and tests, with no provider behind it.
162
+ *
163
+ * It opens no form: starting a setup confirms the first payment method the
164
+ * account offers straight away, as a callback signed with a key it holds in
165
+ * memory, which the platform handles like any other — verified, claimed and
166
+ * recorded on one transaction. The person is sent to the success URL.
167
+ *
168
+ * It takes no means of payment and charges nothing, which is why it refuses to
169
+ * be constructed with `NODE_ENV=production`.
170
+ */
171
+ declare class DevPaymentGateway implements PaymentGateway {
172
+ readonly provider = "dev";
173
+ private readonly key;
174
+ constructor();
175
+ startPaymentMethodSetup(input: StartPaymentMethodSetupInput): Promise<PaymentMethodSetupSession>;
176
+ readCallback(callback: PaymentGatewayCallback): Promise<PaymentGatewayEvent>;
177
+ private sign;
178
+ private verify;
179
+ }
180
+
181
+ /** The bound gateway adapters, by the account name `config/saas.yaml#payments.accounts` gives each. */
182
+ declare const PAYMENT_GATEWAYS_TOKEN: unique symbol;
183
+ declare const PAYMENT_EVENT_LOG_TOKEN: unique symbol;
184
+ declare const SUBSCRIBER_PAYMENT_METHOD_REPOSITORY_TOKEN: unique symbol;
185
+ declare const PAYMENT_TRANSACTION_RUNNER_TOKEN: unique symbol;
186
+
187
+ export { ChangeBillingDetailsDto, DEV_PAYMENT_PROVIDER, DevPaymentGateway, PAYMENT_EVENT_LOG_TOKEN, PAYMENT_GATEWAYS_TOKEN, PAYMENT_TRANSACTION_RUNNER_TOKEN, PaymentCallbackService, PaymentGatewayRegistry, PaymentWebhookController, SUBSCRIBER_PAYMENT_METHOD_REPOSITORY_TOKEN, type StartPaymentMethodChange, StartPaymentMethodSetupDto, SubscriberPaymentMethodService, TenantBillingDetailsController, type TenantBillingDetailsView, TenantPaymentMethodController, type TenantPaymentMethodView };
@@ -0,0 +1,187 @@
1
+ export { b as PaymentsModule, P as PaymentsModuleOptions, a as PaymentsTenantRoutesOptions } from '../payments.module-CQGv_VG7.js';
2
+ import { P as PaymentGatewayRegistry, a as PaymentCallbackService } from '../payment-callback.service-CR84Xw1Z.js';
3
+ export { N as NewPaymentMethodAccount, b as PaymentCallbackOutcome, c as PaymentEventContext, d as PaymentGatewayAccount, e as PaymentMethodConfirmedEvent, f as PaymentMethodSetupFailedEvent, g as PaymentSetupEventHandler } from '../payment-callback.service-CR84Xw1Z.js';
4
+ import { OnModuleInit, RawBodyRequest } from '@nestjs/common';
5
+ import { SubscriberPaymentMethodRepository, SubscriberPaymentMethodRecord, PaymentMethodType, PaymentGateway, StartPaymentMethodSetupInput, PaymentMethodSetupSession, PaymentGatewayCallback, PaymentGatewayEvent } from '@saasicat/core';
6
+ import { S as SubscriberService } from '../subscriber.service-5W6Gi-1B.js';
7
+ import { T as TenantIdResolver, U as UserEmailResolver } from '../tenant-billing.tokens-G-1xOlMr.js';
8
+ import '../di-CcNeq9v-.js';
9
+
10
+ interface StartPaymentMethodChange {
11
+ successUrl: string;
12
+ cancelUrl: string;
13
+ /** Where the gateway writes when the subscriber's record holds no invoice email: the requesting user's. */
14
+ fallbackEmail: string | null;
15
+ }
16
+ /**
17
+ * A subscriber's payment method: the one in use, and replacing it through the
18
+ * gateway's form.
19
+ *
20
+ * Nothing changes when the form is opened. The gateway confirms through its
21
+ * callback, and the confirmation is what records the new payment method —
22
+ * on the transaction that claims the callback.
23
+ */
24
+ declare class SubscriberPaymentMethodService implements OnModuleInit {
25
+ private readonly methods;
26
+ private readonly subscribers;
27
+ private readonly registry;
28
+ private readonly callbacks;
29
+ private readonly logger;
30
+ constructor(methods: SubscriberPaymentMethodRepository, subscribers: SubscriberService, registry: PaymentGatewayRegistry, callbacks: PaymentCallbackService);
31
+ onModuleInit(): void;
32
+ /** The payment method in use for the tenant's subscriber, or `null` when it has none. */
33
+ current(tenantId: string): Promise<SubscriberPaymentMethodRecord | null>;
34
+ /**
35
+ * Opens the gateway's form for a new payment method for the tenant's
36
+ * subscriber, and returns where to send the person.
37
+ *
38
+ * The customer the subscriber has at that account is reused, so the new
39
+ * payment method sits beside the ones the gateway already holds for it.
40
+ */
41
+ startChange(tenantId: string, input: StartPaymentMethodChange): Promise<{
42
+ redirectUrl: string;
43
+ }>;
44
+ private recordConfirmed;
45
+ }
46
+
47
+ /** Where the gateway's form sends the person — `POST /billing/payment-method/setup`. */
48
+ declare class StartPaymentMethodSetupDto {
49
+ successUrl: string;
50
+ cancelUrl: string;
51
+ }
52
+
53
+ /** How a payment method in use is shown: what tells it apart, and nothing that reaches it at the gateway. */
54
+ interface TenantPaymentMethodView {
55
+ type: PaymentMethodType;
56
+ brand: string | null;
57
+ last4: string;
58
+ expiryMonth: number | null;
59
+ expiryYear: number | null;
60
+ country: string | null;
61
+ mandateReference: string | null;
62
+ confirmedAt: string;
63
+ }
64
+ /**
65
+ * `GET /billing/payment-method` and `POST /billing/payment-method/setup` — the
66
+ * tenant's view of what its subscriber pays with, behind the billing
67
+ * permission for reading and changing alike.
68
+ */
69
+ declare class TenantPaymentMethodController {
70
+ private readonly paymentMethods;
71
+ private readonly tenantIdResolver;
72
+ private readonly userEmailResolver;
73
+ constructor(paymentMethods: SubscriberPaymentMethodService, tenantIdResolver: TenantIdResolver, userEmailResolver?: UserEmailResolver | null);
74
+ current(request: unknown): Promise<{
75
+ paymentMethod: TenantPaymentMethodView | null;
76
+ }>;
77
+ startSetup(request: unknown, body: StartPaymentMethodSetupDto): Promise<{
78
+ redirectUrl: string;
79
+ }>;
80
+ private tenantOf;
81
+ private emailOf;
82
+ }
83
+
84
+ /**
85
+ * A change of the subscriber's contact details — `PATCH /billing/details`. A
86
+ * field left out keeps its value.
87
+ *
88
+ * The legal name and the tax identifiers are declared so that they reach the
89
+ * service rather than being stripped by the application's `ValidationPipe`:
90
+ * a tenant that sends a new legal name is told it cannot change it there,
91
+ * instead of being told it succeeded.
92
+ */
93
+ declare class ChangeBillingDetailsDto {
94
+ addressLine1?: string | null;
95
+ addressLine2?: string | null;
96
+ postalCode?: string | null;
97
+ city?: string | null;
98
+ /** ISO 3166-1 alpha-2, e.g. `DE`; its form is checked where every detail is settled. */
99
+ country?: string | null;
100
+ invoiceEmail?: string | null;
101
+ legalName?: unknown;
102
+ vatId?: unknown;
103
+ taxNumber?: unknown;
104
+ }
105
+
106
+ /** The subscriber as its tenant sees it in its billing area. */
107
+ interface TenantBillingDetailsView {
108
+ customerNumber: string;
109
+ legalName: string;
110
+ vatId: string | null;
111
+ taxNumber: string | null;
112
+ addressLine1: string | null;
113
+ addressLine2: string | null;
114
+ postalCode: string | null;
115
+ city: string | null;
116
+ country: string | null;
117
+ invoiceEmail: string | null;
118
+ }
119
+ /**
120
+ * `GET /billing/details` and `PATCH /billing/details` — whom the tenant's
121
+ * subscription is billed to, behind the billing permission for reading and
122
+ * changing alike. The contact details change here; the legal name and the tax
123
+ * identifiers are shown and corrected by the operator (`SC-SUB-017`).
124
+ */
125
+ declare class TenantBillingDetailsController {
126
+ private readonly subscribers;
127
+ private readonly tenantIdResolver;
128
+ constructor(subscribers: SubscriberService, tenantIdResolver: TenantIdResolver);
129
+ current(request: unknown): Promise<{
130
+ details: TenantBillingDetailsView;
131
+ }>;
132
+ change(request: unknown, body: ChangeBillingDetailsDto): Promise<{
133
+ details: TenantBillingDetailsView;
134
+ }>;
135
+ private tenantOf;
136
+ }
137
+
138
+ interface CallbackRequest {
139
+ headers: Record<string, string | string[] | undefined>;
140
+ }
141
+ /**
142
+ * `POST /webhooks/payment/:account` — where a gateway account sends its
143
+ * callbacks, one route per account in `config/saas.yaml#payments.accounts`.
144
+ *
145
+ * Public, because the gateway has no session: what makes a callback genuine is
146
+ * its signature over the exact bytes it sent, which the account's adapter
147
+ * verifies before anything is read. That needs the body as it arrived, so the
148
+ * application is created with `rawBody: true`.
149
+ */
150
+ declare class PaymentWebhookController {
151
+ private readonly callbacks;
152
+ constructor(callbacks: PaymentCallbackService);
153
+ receive(account: string, request: RawBodyRequest<CallbackRequest>): Promise<{
154
+ received: true;
155
+ }>;
156
+ }
157
+
158
+ /** The provider name `config/saas.yaml` gives an account bound to this gateway. */
159
+ declare const DEV_PAYMENT_PROVIDER = "dev";
160
+ /**
161
+ * A payment gateway for development and tests, with no provider behind it.
162
+ *
163
+ * It opens no form: starting a setup confirms the first payment method the
164
+ * account offers straight away, as a callback signed with a key it holds in
165
+ * memory, which the platform handles like any other — verified, claimed and
166
+ * recorded on one transaction. The person is sent to the success URL.
167
+ *
168
+ * It takes no means of payment and charges nothing, which is why it refuses to
169
+ * be constructed with `NODE_ENV=production`.
170
+ */
171
+ declare class DevPaymentGateway implements PaymentGateway {
172
+ readonly provider = "dev";
173
+ private readonly key;
174
+ constructor();
175
+ startPaymentMethodSetup(input: StartPaymentMethodSetupInput): Promise<PaymentMethodSetupSession>;
176
+ readCallback(callback: PaymentGatewayCallback): Promise<PaymentGatewayEvent>;
177
+ private sign;
178
+ private verify;
179
+ }
180
+
181
+ /** The bound gateway adapters, by the account name `config/saas.yaml#payments.accounts` gives each. */
182
+ declare const PAYMENT_GATEWAYS_TOKEN: unique symbol;
183
+ declare const PAYMENT_EVENT_LOG_TOKEN: unique symbol;
184
+ declare const SUBSCRIBER_PAYMENT_METHOD_REPOSITORY_TOKEN: unique symbol;
185
+ declare const PAYMENT_TRANSACTION_RUNNER_TOKEN: unique symbol;
186
+
187
+ export { ChangeBillingDetailsDto, DEV_PAYMENT_PROVIDER, DevPaymentGateway, PAYMENT_EVENT_LOG_TOKEN, PAYMENT_GATEWAYS_TOKEN, PAYMENT_TRANSACTION_RUNNER_TOKEN, PaymentCallbackService, PaymentGatewayRegistry, PaymentWebhookController, SUBSCRIBER_PAYMENT_METHOD_REPOSITORY_TOKEN, type StartPaymentMethodChange, StartPaymentMethodSetupDto, SubscriberPaymentMethodService, TenantBillingDetailsController, type TenantBillingDetailsView, TenantPaymentMethodController, type TenantPaymentMethodView };