@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
@@ -1,42 +1,37 @@
1
- export { C as CheckoutOfferService } from '../checkout-offer.service-BLOv2HOo.cjs';
1
+ export { C as CheckoutOfferPricing, a as CheckoutOfferPricingInput, b as CheckoutOfferService, c as ConcludeCheckoutOfferOptions, d as ConcludeCheckoutOfferWithin, e as ConcludedCheckoutOffer, P as PricedCheckoutOffer } from '../checkout-offer.service-CCVxG9b2.cjs';
2
2
  import { Type, CanActivate } from '@nestjs/common';
3
- export { C as CheckoutOfferControllerConfig, a as CheckoutOfferModule, b as CheckoutOfferModuleOptions } from '../checkout-offer.module-CVpWrzbe.cjs';
4
- import { CheckoutOfferPriceBreakdown, CheckoutOfferLineItem, CheckoutOfferPromotionSnapshot, CheckoutOfferPromoCodeSnapshot } from '@saasicat/core';
3
+ export { a as CheckoutOfferConclusionOptions, b as CheckoutOfferControllerConfig, c as CheckoutOfferModule, C as CheckoutOfferModuleOptions } from '../checkout-offer.module-DFhGy6JO.cjs';
4
+ import { CheckoutOfferSelection, CheckoutOfferSelectionUpdate } from '@saasicat/core';
5
+ import '../subscription-contract.service-CfNApLuP.cjs';
6
+ import '../subscriber.service-5W6Gi-1B.cjs';
7
+ import '../promo.service-BYBu6dy3.cjs';
8
+ import '../plan-catalog-source-DWe-BGY1.cjs';
5
9
  import '../di-CcNeq9v-.cjs';
6
10
 
7
11
  declare function buildCheckoutOfferController(guards: Array<Type<CanActivate>>): Type;
8
12
 
9
13
  /** Repository for `checkout_offers`. */
10
14
  declare const CHECKOUT_OFFER_REPOSITORY_TOKEN: unique symbol;
15
+ /**
16
+ * The transaction an offer is concluded in: consuming it, writing its contract
17
+ * and the application's own writes commit or roll back together.
18
+ */
19
+ declare const CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN: unique symbol;
11
20
 
12
- declare class CreateCheckoutOfferDto {
13
- projectKey: string;
21
+ declare class CreateCheckoutOfferDto implements CheckoutOfferSelection {
14
22
  planKey: string;
15
- planVersionId?: string | null;
16
23
  billingCycle: 'monthly' | 'yearly';
17
- promotionId?: string | null;
18
- promoCode?: string | null;
19
- bundles?: string[];
20
24
  bundleVersionIds?: string[];
21
- priceBreakdown: CheckoutOfferPriceBreakdown;
22
- lineItems?: CheckoutOfferLineItem[];
23
- promotionSnapshots?: CheckoutOfferPromotionSnapshot[];
24
- promoCodeSnapshot?: CheckoutOfferPromoCodeSnapshot | null;
25
+ promoCode?: string | null;
25
26
  locale?: string;
26
27
  validUntil?: string | null;
27
28
  }
28
- declare class UpdateCheckoutOfferDto {
29
+ declare class UpdateCheckoutOfferDto implements CheckoutOfferSelectionUpdate {
29
30
  billingCycle?: 'monthly' | 'yearly';
30
- promotionId?: string | null;
31
- promoCode?: string | null;
32
- bundles?: string[];
33
31
  bundleVersionIds?: string[];
34
- priceBreakdown?: CheckoutOfferPriceBreakdown;
35
- lineItems?: CheckoutOfferLineItem[];
36
- promotionSnapshots?: CheckoutOfferPromotionSnapshot[];
37
- promoCodeSnapshot?: CheckoutOfferPromoCodeSnapshot | null;
32
+ promoCode?: string | null;
38
33
  locale?: string;
39
34
  validUntil?: string | null;
40
35
  }
41
36
 
42
- export { CHECKOUT_OFFER_REPOSITORY_TOKEN, CreateCheckoutOfferDto, UpdateCheckoutOfferDto, buildCheckoutOfferController };
37
+ export { CHECKOUT_OFFER_REPOSITORY_TOKEN, CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN, CreateCheckoutOfferDto, UpdateCheckoutOfferDto, buildCheckoutOfferController };
@@ -1,42 +1,37 @@
1
- export { C as CheckoutOfferService } from '../checkout-offer.service-BLOv2HOo.js';
1
+ export { C as CheckoutOfferPricing, a as CheckoutOfferPricingInput, b as CheckoutOfferService, c as ConcludeCheckoutOfferOptions, d as ConcludeCheckoutOfferWithin, e as ConcludedCheckoutOffer, P as PricedCheckoutOffer } from '../checkout-offer.service-BeHgYikI.js';
2
2
  import { Type, CanActivate } from '@nestjs/common';
3
- export { C as CheckoutOfferControllerConfig, a as CheckoutOfferModule, b as CheckoutOfferModuleOptions } from '../checkout-offer.module-CMtiQJTT.js';
4
- import { CheckoutOfferPriceBreakdown, CheckoutOfferLineItem, CheckoutOfferPromotionSnapshot, CheckoutOfferPromoCodeSnapshot } from '@saasicat/core';
3
+ export { a as CheckoutOfferConclusionOptions, b as CheckoutOfferControllerConfig, c as CheckoutOfferModule, C as CheckoutOfferModuleOptions } from '../checkout-offer.module-x7SP_dX4.js';
4
+ import { CheckoutOfferSelection, CheckoutOfferSelectionUpdate } from '@saasicat/core';
5
+ import '../subscription-contract.service-CPZrTM9C.js';
6
+ import '../subscriber.service-5W6Gi-1B.js';
7
+ import '../promo.service-CFjfF0Xm.js';
8
+ import '../plan-catalog-source-DWe-BGY1.js';
5
9
  import '../di-CcNeq9v-.js';
6
10
 
7
11
  declare function buildCheckoutOfferController(guards: Array<Type<CanActivate>>): Type;
8
12
 
9
13
  /** Repository for `checkout_offers`. */
10
14
  declare const CHECKOUT_OFFER_REPOSITORY_TOKEN: unique symbol;
15
+ /**
16
+ * The transaction an offer is concluded in: consuming it, writing its contract
17
+ * and the application's own writes commit or roll back together.
18
+ */
19
+ declare const CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN: unique symbol;
11
20
 
12
- declare class CreateCheckoutOfferDto {
13
- projectKey: string;
21
+ declare class CreateCheckoutOfferDto implements CheckoutOfferSelection {
14
22
  planKey: string;
15
- planVersionId?: string | null;
16
23
  billingCycle: 'monthly' | 'yearly';
17
- promotionId?: string | null;
18
- promoCode?: string | null;
19
- bundles?: string[];
20
24
  bundleVersionIds?: string[];
21
- priceBreakdown: CheckoutOfferPriceBreakdown;
22
- lineItems?: CheckoutOfferLineItem[];
23
- promotionSnapshots?: CheckoutOfferPromotionSnapshot[];
24
- promoCodeSnapshot?: CheckoutOfferPromoCodeSnapshot | null;
25
+ promoCode?: string | null;
25
26
  locale?: string;
26
27
  validUntil?: string | null;
27
28
  }
28
- declare class UpdateCheckoutOfferDto {
29
+ declare class UpdateCheckoutOfferDto implements CheckoutOfferSelectionUpdate {
29
30
  billingCycle?: 'monthly' | 'yearly';
30
- promotionId?: string | null;
31
- promoCode?: string | null;
32
- bundles?: string[];
33
31
  bundleVersionIds?: string[];
34
- priceBreakdown?: CheckoutOfferPriceBreakdown;
35
- lineItems?: CheckoutOfferLineItem[];
36
- promotionSnapshots?: CheckoutOfferPromotionSnapshot[];
37
- promoCodeSnapshot?: CheckoutOfferPromoCodeSnapshot | null;
32
+ promoCode?: string | null;
38
33
  locale?: string;
39
34
  validUntil?: string | null;
40
35
  }
41
36
 
42
- export { CHECKOUT_OFFER_REPOSITORY_TOKEN, CreateCheckoutOfferDto, UpdateCheckoutOfferDto, buildCheckoutOfferController };
37
+ export { CHECKOUT_OFFER_REPOSITORY_TOKEN, CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN, CreateCheckoutOfferDto, UpdateCheckoutOfferDto, buildCheckoutOfferController };
@@ -1,20 +1,34 @@
1
- import "../chunk-DBZGV3HC.js";
1
+ import "../chunk-DFOW3JVO.js";
2
2
  import {
3
- CHECKOUT_OFFER_REPOSITORY_TOKEN,
4
3
  CheckoutOfferModule,
5
- CheckoutOfferService,
6
4
  CreateCheckoutOfferDto,
7
5
  UpdateCheckoutOfferDto,
8
6
  buildCheckoutOfferController
9
- } from "../chunk-WUDYIPYH.js";
10
- import "../chunk-BSK6YBLI.js";
7
+ } from "../chunk-TOEFN7DN.js";
8
+ import {
9
+ CHECKOUT_OFFER_REPOSITORY_TOKEN,
10
+ CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN,
11
+ CheckoutOfferPricing,
12
+ CheckoutOfferService
13
+ } from "../chunk-55QEDAMX.js";
14
+ import "../chunk-3RLWML2S.js";
15
+ import "../chunk-NDLC5GYK.js";
16
+ import "../chunk-KPEMTBOP.js";
17
+ import "../chunk-TBBZWZQT.js";
18
+ import "../chunk-VBRYPU7V.js";
19
+ import "../chunk-6PJE7EWO.js";
20
+ import "../chunk-3QVGA6JX.js";
21
+ import "../chunk-WOEJ6K7M.js";
22
+ import "../chunk-LF6J4YYN.js";
11
23
  import "../chunk-YSC46BGM.js";
12
- import "../chunk-AOQJEYOL.js";
13
- import "../chunk-SABTXESR.js";
24
+ import "../chunk-FEQZCWUL.js";
25
+ import "../chunk-J7NJRK3K.js";
14
26
  import "../chunk-SHUYVCID.js";
15
27
  export {
16
28
  CHECKOUT_OFFER_REPOSITORY_TOKEN,
29
+ CHECKOUT_OFFER_TRANSACTION_RUNNER_TOKEN,
17
30
  CheckoutOfferModule,
31
+ CheckoutOfferPricing,
18
32
  CheckoutOfferService,
19
33
  CreateCheckoutOfferDto,
20
34
  UpdateCheckoutOfferDto,
@@ -0,0 +1,58 @@
1
+ import { Type, CanActivate, DynamicModule, ForwardReference, Provider } from '@nestjs/common';
2
+ import { SubscriptionContractRepository, SubscriberRepository, TransactionRunner, CheckoutOfferRepository, BundleRepository, PlanRepository, PromotionRepository, CatalogEntryRepository } from '@saasicat/core';
3
+ import { P as ProviderSpec } from './di-CcNeq9v-.cjs';
4
+
5
+ interface CheckoutOfferControllerConfig {
6
+ /** Class-level guards; `[]` for auth-free public endpoints. */
7
+ guards: Array<Type<CanActivate>>;
8
+ }
9
+ /** What `CheckoutOfferService.conclude` writes through, and in one transaction. */
10
+ interface CheckoutOfferConclusionOptions {
11
+ /** Writes the contract an offer becomes, on the conclusion's transaction. */
12
+ subscriptionContractRepository: ProviderSpec<SubscriptionContractRepository>;
13
+ /** Finds the party the contract is with, or creates a sign-up's on the same transaction. */
14
+ subscriberRepository: ProviderSpec<SubscriberRepository>;
15
+ /** The transaction consuming the offer, the contract and the application's writes share. */
16
+ transactionRunner: ProviderSpec<TransactionRunner>;
17
+ }
18
+ interface CheckoutOfferModuleOptions {
19
+ checkoutOfferRepository: ProviderSpec<CheckoutOfferRepository>;
20
+ /**
21
+ * Bundle versions an offer can book: their prices, and whether they are
22
+ * still bookable on consume. Without it an offer carries no add-ons, and
23
+ * one that names a bundle version is refused.
24
+ */
25
+ bundleRepository?: ProviderSpec<BundleRepository>;
26
+ /**
27
+ * REQUIRED: the plan version on sale and its price, which every offer is
28
+ * priced from. Also the plan features for the requires validation.
29
+ */
30
+ planRepository: ProviderSpec<PlanRepository>;
31
+ /**
32
+ * The catalogue promotions an offer applies, the same ones the public
33
+ * catalogue shows. Without it an offer carries no promotion.
34
+ */
35
+ promotionRepository?: ProviderSpec<PromotionRepository>;
36
+ /**
37
+ * Optional for the requires validation (#35 P6): requires source =
38
+ * curated FeatureCatalogEntries. Without wiring, the validation is
39
+ * skipped (graceful).
40
+ */
41
+ catalogEntryRepository?: ProviderSpec<CatalogEntryRepository>;
42
+ /**
43
+ * Enables `CheckoutOfferService.conclude`, which consumes an offer and
44
+ * writes its contract in one transaction. Without it, `conclude` refuses
45
+ * to run rather than writing the two apart.
46
+ */
47
+ conclusion?: CheckoutOfferConclusionOptions;
48
+ /** Controller mount for `/public/checkout-offer`. Omitted = service only. */
49
+ controller?: CheckoutOfferControllerConfig;
50
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
51
+ extraProviders?: Provider[];
52
+ global?: boolean;
53
+ }
54
+ declare class CheckoutOfferModule {
55
+ static forRoot(options: CheckoutOfferModuleOptions): DynamicModule;
56
+ }
57
+
58
+ export { type CheckoutOfferModuleOptions as C, type CheckoutOfferConclusionOptions as a, type CheckoutOfferControllerConfig as b, CheckoutOfferModule as c };
@@ -0,0 +1,58 @@
1
+ import { Type, CanActivate, DynamicModule, ForwardReference, Provider } from '@nestjs/common';
2
+ import { SubscriptionContractRepository, SubscriberRepository, TransactionRunner, CheckoutOfferRepository, BundleRepository, PlanRepository, PromotionRepository, CatalogEntryRepository } from '@saasicat/core';
3
+ import { P as ProviderSpec } from './di-CcNeq9v-.js';
4
+
5
+ interface CheckoutOfferControllerConfig {
6
+ /** Class-level guards; `[]` for auth-free public endpoints. */
7
+ guards: Array<Type<CanActivate>>;
8
+ }
9
+ /** What `CheckoutOfferService.conclude` writes through, and in one transaction. */
10
+ interface CheckoutOfferConclusionOptions {
11
+ /** Writes the contract an offer becomes, on the conclusion's transaction. */
12
+ subscriptionContractRepository: ProviderSpec<SubscriptionContractRepository>;
13
+ /** Finds the party the contract is with, or creates a sign-up's on the same transaction. */
14
+ subscriberRepository: ProviderSpec<SubscriberRepository>;
15
+ /** The transaction consuming the offer, the contract and the application's writes share. */
16
+ transactionRunner: ProviderSpec<TransactionRunner>;
17
+ }
18
+ interface CheckoutOfferModuleOptions {
19
+ checkoutOfferRepository: ProviderSpec<CheckoutOfferRepository>;
20
+ /**
21
+ * Bundle versions an offer can book: their prices, and whether they are
22
+ * still bookable on consume. Without it an offer carries no add-ons, and
23
+ * one that names a bundle version is refused.
24
+ */
25
+ bundleRepository?: ProviderSpec<BundleRepository>;
26
+ /**
27
+ * REQUIRED: the plan version on sale and its price, which every offer is
28
+ * priced from. Also the plan features for the requires validation.
29
+ */
30
+ planRepository: ProviderSpec<PlanRepository>;
31
+ /**
32
+ * The catalogue promotions an offer applies, the same ones the public
33
+ * catalogue shows. Without it an offer carries no promotion.
34
+ */
35
+ promotionRepository?: ProviderSpec<PromotionRepository>;
36
+ /**
37
+ * Optional for the requires validation (#35 P6): requires source =
38
+ * curated FeatureCatalogEntries. Without wiring, the validation is
39
+ * skipped (graceful).
40
+ */
41
+ catalogEntryRepository?: ProviderSpec<CatalogEntryRepository>;
42
+ /**
43
+ * Enables `CheckoutOfferService.conclude`, which consumes an offer and
44
+ * writes its contract in one transaction. Without it, `conclude` refuses
45
+ * to run rather than writing the two apart.
46
+ */
47
+ conclusion?: CheckoutOfferConclusionOptions;
48
+ /** Controller mount for `/public/checkout-offer`. Omitted = service only. */
49
+ controller?: CheckoutOfferControllerConfig;
50
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
51
+ extraProviders?: Provider[];
52
+ global?: boolean;
53
+ }
54
+ declare class CheckoutOfferModule {
55
+ static forRoot(options: CheckoutOfferModuleOptions): DynamicModule;
56
+ }
57
+
58
+ export { type CheckoutOfferModuleOptions as C, type CheckoutOfferConclusionOptions as a, type CheckoutOfferControllerConfig as b, CheckoutOfferModule as c };
@@ -0,0 +1,242 @@
1
+ import { PlanCatalogSettings, PlanRepository, BundleRepository, PromotionRepository, CheckoutOfferPriceBreakdown, CheckoutOfferLineItem, CheckoutOfferPromotionSnapshot, CheckoutOfferPromoCodeSnapshot, CheckoutOfferRow, CheckoutOfferRepository, CatalogEntryRepository, TransactionRunner, CheckoutOfferFilter, CheckoutOfferSelection, CheckoutOfferSelectionUpdate, NewSubscriberDetails, TransactionContext, SubscriptionContractRecord } from '@saasicat/core';
2
+ import { S as SubscriptionContractService, C as CreateContractFromOfferOptions } from './subscription-contract.service-CPZrTM9C.js';
3
+ import { S as SubscriberService } from './subscriber.service-5W6Gi-1B.js';
4
+ import { a as PromoCodesService } from './promo.service-CFjfF0Xm.js';
5
+
6
+ type Cycle = 'monthly' | 'yearly';
7
+ /** What pricing needs to know about a selection. */
8
+ interface CheckoutOfferPricingInput {
9
+ planKey: string;
10
+ billingCycle: Cycle;
11
+ bundleVersionIds: readonly string[];
12
+ promoCode: string | null;
13
+ locale: string;
14
+ /**
15
+ * The offer when it is priced again. A slot of its promo code held for its
16
+ * checkout is its own, not counted against it.
17
+ */
18
+ checkoutOfferId?: string;
19
+ /**
20
+ * Priced as the offer is concluded: its held slot also keeps the code as it
21
+ * stood when the slot was taken.
22
+ */
23
+ concluding?: boolean;
24
+ }
25
+ /** The part of a stored offer the server computes. */
26
+ interface PricedCheckoutOffer {
27
+ planVersionId: string;
28
+ bundles: string[];
29
+ bundleVersionIds: string[];
30
+ promotionId: string | null;
31
+ promoCode: string | null;
32
+ priceBreakdown: CheckoutOfferPriceBreakdown;
33
+ lineItems: CheckoutOfferLineItem[];
34
+ promotionSnapshots: CheckoutOfferPromotionSnapshot[];
35
+ promoCodeSnapshot: CheckoutOfferPromoCodeSnapshot | null;
36
+ }
37
+ declare class CheckoutOfferPricing {
38
+ private readonly settings;
39
+ private readonly plans;
40
+ private readonly bundles;
41
+ private readonly promotions;
42
+ private readonly promoCodes;
43
+ constructor(settings: PlanCatalogSettings, plans: PlanRepository, bundles?: BundleRepository | null, promotions?: PromotionRepository | null, promoCodes?: PromoCodesService | null);
44
+ /** Prices a selection against the plan version on sale now. */
45
+ price(input: CheckoutOfferPricingInput, asOf?: Date): Promise<PricedCheckoutOffer>;
46
+ /**
47
+ * Throws unless the offer's stored amounts are what this pricing makes of
48
+ * its own selection: the plan and bundle versions it froze, and the
49
+ * promotions as they stood when it was last priced.
50
+ */
51
+ assertPricedByCatalogue(offer: CheckoutOfferRow): Promise<void>;
52
+ private compute;
53
+ /** The plan version on sale for new bookings, as the public catalogue resolves it. */
54
+ private planVersionOnSale;
55
+ /** A plan without a list price is not sold at one (`SC-PRIC-011`). */
56
+ private assertPlanPriced;
57
+ private bundleVersionsFor;
58
+ private pricePlan;
59
+ private priceBundle;
60
+ private line;
61
+ /**
62
+ * The promo code's discount on the plan, after its promotion.
63
+ *
64
+ * Eligibility is the promo module's to decide, and it decides on its own
65
+ * terms: status, validity, the plan and rhythm the code is limited to. Only
66
+ * the amount is computed here, on the price this offer actually carries.
67
+ */
68
+ private pricePromoCode;
69
+ }
70
+
71
+ /** What concluding an offer produced: the consumed offer and its contract. */
72
+ interface ConcludedCheckoutOffer {
73
+ offer: CheckoutOfferRow;
74
+ contract: SubscriptionContractRecord;
75
+ }
76
+ /** How an offer is concluded, and for whom. */
77
+ interface ConcludeCheckoutOfferOptions extends CreateContractFromOfferOptions {
78
+ /**
79
+ * The subscriber of a tenant that does not have one yet, created on the
80
+ * conclusion's transaction before its contract — what a sign-up passes,
81
+ * `subscriberFromRegistration(pending)` giving the details. Left out, the
82
+ * tenant's existing subscriber is the party; a tenant with neither is
83
+ * refused with `SUBSCRIBER_REQUIRED`, and one that already has a subscriber
84
+ * with `SUBSCRIBER_ALREADY_EXISTS`.
85
+ */
86
+ subscriber?: NewSubscriberDetails;
87
+ /**
88
+ * The transaction to conclude on, when the caller already holds one. A
89
+ * sign-up's activation does: the gateway's confirmation is claimed on it,
90
+ * and the offer, the subscriber, the contract and `within` are written on
91
+ * it and undone with it. Left out, the conclusion opens a transaction of
92
+ * its own.
93
+ */
94
+ tx?: TransactionContext;
95
+ }
96
+ /**
97
+ * The application's own writes that belong to concluding an offer, such as
98
+ * starting its subscription. They run on the same transaction, after the offer
99
+ * is consumed and its contract written; throwing undoes all of it.
100
+ */
101
+ type ConcludeCheckoutOfferWithin = (tx: TransactionContext, concluded: ConcludedCheckoutOffer) => Promise<void>;
102
+ declare class CheckoutOfferService {
103
+ private readonly repo;
104
+ private readonly pricing;
105
+ private readonly bundles;
106
+ private readonly plans;
107
+ private readonly catalogEntries;
108
+ private readonly contracts;
109
+ private readonly transactions;
110
+ private readonly subscribers;
111
+ private readonly promoCodes;
112
+ constructor(repo: CheckoutOfferRepository, pricing: CheckoutOfferPricing, bundles?: BundleRepository | null, plans?: PlanRepository | null, catalogEntries?: CatalogEntryRepository | null, contracts?: SubscriptionContractService | null, transactions?: TransactionRunner | null, subscribers?: SubscriberService | null, promoCodes?: PromoCodesService | null);
113
+ list(filter: CheckoutOfferFilter): Promise<CheckoutOfferRow[]>;
114
+ getById(id: string): Promise<CheckoutOfferRow>;
115
+ /** Prices what the caller chose and stores it as an open offer. */
116
+ create(selection: CheckoutOfferSelection): Promise<CheckoutOfferRow>;
117
+ /**
118
+ * Customization in onboarding — only while the offer is `open`. The plan
119
+ * stays; whatever else changes, the whole offer is priced again. A slot of
120
+ * its promo code held for its checkout stays with it while the code does,
121
+ * and is given back when the code is changed or removed.
122
+ */
123
+ update(id: string, change: CheckoutOfferSelectionUpdate): Promise<CheckoutOfferRow>;
124
+ /**
125
+ * Holds a slot of the offer's promo code for its checkout until `until` —
126
+ * what a sign-up does as its checkout starts, until a confirmation of its
127
+ * payment form can no longer arrive — so that the code cannot run out
128
+ * before the payment is confirmed and the offer concluded. A live slot the
129
+ * offer holds of that code already moves to `until`, never earlier. The
130
+ * conclusion turns the slot into the redemption; the slot goes back when
131
+ * the offer's code changes or `until` passes.
132
+ *
133
+ * Refused, and nothing held, when the offer is no longer open or its code
134
+ * cannot be held: `PROMO_CODE_NOT_REDEEMABLE` with the reason a preview
135
+ * gives, `EXHAUSTED` when every slot is redeemed or held. An offer without
136
+ * a code holds nothing.
137
+ */
138
+ holdPromoCode(id: string, hold: {
139
+ email?: string;
140
+ until: Date;
141
+ }): Promise<void>;
142
+ /**
143
+ * Gives back the slot held for the offer's checkout while it is still held
144
+ * until `heldUntil`, as the caller wrote it. A slot another start of the
145
+ * checkout moved later stays with the form that start opened.
146
+ */
147
+ releasePromoCodeHold(id: string, heldUntil: Date): Promise<void>;
148
+ /**
149
+ * Freezes the offer (`status = 'consumed'`). Returns the final
150
+ * snapshot — the caller (registration/billing) writes it
151
+ * as `Subscription.packageSnapshot`.
152
+ *
153
+ * Refused unless every add-on is still bookable and the stored amounts are
154
+ * what the catalogue makes of the offer's own selection, so an offer whose
155
+ * amounts were written by anything but the pricing never becomes a contract.
156
+ *
157
+ * The plan, the add-ons and the promotions are priced as they stood when the
158
+ * offer was priced; a promo code is checked with the promo module as it
159
+ * stands now. A code is redeemed when the contract is concluded, so one that
160
+ * has expired or run out of redemptions since refuses the offer with
161
+ * `CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED`; `CHECKOUT_OFFER_PRICE_NOT_CURRENT`
162
+ * is kept for amounts that no longer match.
163
+ */
164
+ consume(id: string): Promise<CheckoutOfferRow>;
165
+ /**
166
+ * Consumes an offer and creates its contract in one transaction, together
167
+ * with the application's own writes in `within`, so an offer is never
168
+ * consumed without its contract, and no contract is written for an offer
169
+ * that stays open.
170
+ *
171
+ * Everything that can refuse runs before the transaction: what `consume`
172
+ * checks, and the checks the contract the offer becomes is held to. Inside
173
+ * it, the offer is consumed on the condition that it is still open, the
174
+ * contract is written, and `within` runs; an error in any of them undoes
175
+ * the others, and the offer can be concluded again.
176
+ *
177
+ * An offer that is already concluded for the same tenant answers with its
178
+ * contract rather than a refusal, so a caller retrying after a lost answer,
179
+ * or losing a race to another call for that tenant, gets the conclusion that
180
+ * stands; `within` does not run again, its writes committed with it. A
181
+ * conclusion for another tenant is refused with
182
+ * `CHECKOUT_OFFER_ALREADY_CONSUMED`, and an offer changed between the checks
183
+ * and the transaction with `CHECKOUT_OFFER_CHANGED`, nothing written.
184
+ *
185
+ * The contract is between the tenant's subscriber and the configured
186
+ * issuer. A sign-up creates the tenant in `within` and has no subscriber
187
+ * yet, so it passes `subscriber`, which is created on the same transaction
188
+ * before the contract; whether one may be created, or whether the tenant
189
+ * has one, is asked before the transaction with the other checks.
190
+ *
191
+ * A promo code on the offer is redeemed in `within`, with
192
+ * `PromoCodesService.redeemInTransaction` on the same transaction. Before
193
+ * the transaction the code is only checked the way pricing checks it; the
194
+ * redemption checks the rest, the customer and the remaining redemptions,
195
+ * where a refusal still undoes everything. Nothing checks the code again
196
+ * after `within`, so a redemption that takes its last slot does not refuse
197
+ * the offer it was redeemed for.
198
+ *
199
+ * A slot held for the offer's checkout (`holdPromoCode`) is the offer's own
200
+ * throughout: the checks before the transaction do not count it against
201
+ * the code and accept the code as it stood when the slot was held, and the
202
+ * redemption in `within` takes that slot rather than a free one. A slot
203
+ * `within` did not redeem is given back before the conclusion commits.
204
+ */
205
+ conclude(id: string, options: ConcludeCheckoutOfferOptions, within?: ConcludeCheckoutOfferWithin): Promise<ConcludedCheckoutOffer>;
206
+ private assertConsumable;
207
+ /**
208
+ * The conclusion that stands for this tenant, if the offer has one. An offer
209
+ * carries no tenant and its id travels in a link, so a conclusion for
210
+ * another tenant is not an answer: that caller is refused as before.
211
+ */
212
+ private standingConclusion;
213
+ private conclusionPorts;
214
+ /**
215
+ * Before anything is written: the subscriber to create is one that may be
216
+ * created, or the tenant already has the party the contract is with.
217
+ */
218
+ private assertParty;
219
+ /**
220
+ * #35 P6 — server-side requires validation: the dependencies of all
221
+ * features (plan ∪ selected bundles) must be covered within the
222
+ * selection, otherwise an offer would be created whose features cannot
223
+ * work at the tenant (an app-specific validateModuleDependencies check is
224
+ * thereby replaced on the platform side). The requires source are the
225
+ * curated FeatureCatalogEntries; without CatalogEntryRepository it is
226
+ * skipped (graceful — no requires data available).
227
+ */
228
+ private assertFeatureRequiresSatisfied;
229
+ /**
230
+ * Plan features preferably from the server SSOT (PlanRepository); fallback
231
+ * is the frozen featuresSnapshot of the plan LineItem (adapter without
232
+ * PlanRepository wiring).
233
+ */
234
+ private resolvePlanFeatures;
235
+ /** Bundle features from the BundleVersions; fallback featuresSnapshot. */
236
+ private resolveBundleFeatures;
237
+ private assertBundleVersionsStillBookable;
238
+ private assertOpen;
239
+ private isExpired;
240
+ }
241
+
242
+ export { CheckoutOfferPricing as C, type PricedCheckoutOffer as P, type CheckoutOfferPricingInput as a, CheckoutOfferService as b, type ConcludeCheckoutOfferOptions as c, type ConcludeCheckoutOfferWithin as d, type ConcludedCheckoutOffer as e };