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

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 (64) hide show
  1. package/dist/.build-stamp +1 -1
  2. package/dist/_entries.cjs +4887 -3609
  3. package/dist/admin/index.js +7 -5
  4. package/dist/{aggregation-ChpZDh0g.d.ts → aggregation-6fPkeV8i.d.ts} +39 -4
  5. package/dist/{aggregation-OpnhwzF5.d.cts → aggregation-DjQUc7yd.d.cts} +39 -4
  6. package/dist/billing/index.d.cts +68 -9
  7. package/dist/billing/index.d.ts +68 -9
  8. package/dist/billing/index.js +16 -5
  9. package/dist/checkout-offer/index.d.cts +2 -2
  10. package/dist/checkout-offer/index.d.ts +2 -2
  11. package/dist/checkout-offer/index.js +4 -4
  12. package/dist/{checkout-offer.service-CCVxG9b2.d.cts → checkout-offer.service-DmVGrT4v.d.cts} +1 -1
  13. package/dist/{checkout-offer.service-BeHgYikI.d.ts → checkout-offer.service-Yi30L4ry.d.ts} +1 -1
  14. package/dist/{chunk-WHJSYKNC.js → chunk-3U4N5UYD.js} +1 -1
  15. package/dist/{chunk-M47BNEY2.js → chunk-3YYLOYUT.js} +1373 -266
  16. package/dist/{chunk-G6EZWECL.js → chunk-B4YP7REK.js} +94 -26
  17. package/dist/{chunk-QPVDCKYS.js → chunk-ESEWSAOV.js} +4 -3
  18. package/dist/{chunk-NDLC5GYK.js → chunk-EU4N5LET.js} +4 -3
  19. package/dist/{chunk-LLYVYRGJ.js → chunk-F2PF4IXB.js} +1 -275
  20. package/dist/{chunk-AOS2JPDD.js → chunk-FJIOHAO5.js} +77 -41
  21. package/dist/{chunk-TOEFN7DN.js → chunk-FPMBQDW7.js} +2 -2
  22. package/dist/chunk-OSOP4KWL.js +288 -0
  23. package/dist/{chunk-3RLWML2S.js → chunk-QWKBOLBH.js} +35 -0
  24. package/dist/{chunk-JBCC6C3M.js → chunk-R3I5X262.js} +5 -4
  25. package/dist/{chunk-4SDSYV4A.js → chunk-T6WXDGIU.js} +1 -1
  26. package/dist/{chunk-R5YCJBHY.js → chunk-U5UPEFWC.js} +2 -2
  27. package/dist/{chunk-XSSWYPP5.js → chunk-UMZCOCT5.js} +1 -1
  28. package/dist/{chunk-7NJKVC5X.js → chunk-WQNOCOI2.js} +53 -6
  29. package/dist/{chunk-55QEDAMX.js → chunk-WTAS2CLM.js} +4 -9
  30. package/dist/{enforce-quota.interceptor-BFyVdWe8.d.cts → enforce-quota.interceptor-B9UhCBXx.d.cts} +2 -2
  31. package/dist/{enforce-quota.interceptor-GaBXboGx.d.ts → enforce-quota.interceptor-CR2waXNA.d.ts} +2 -2
  32. package/dist/entitlement/index.d.cts +1 -1
  33. package/dist/entitlement/index.d.ts +1 -1
  34. package/dist/entitlement/index.js +4 -2
  35. package/dist/index.d.cts +11 -11
  36. package/dist/index.d.ts +11 -11
  37. package/dist/index.js +36 -20
  38. package/dist/{issuer-identity.check-CBO0vcsq.d.cts → issuer-identity.check-BntcNdld.d.cts} +1 -1
  39. package/dist/{issuer-identity.check-Cz9CEMkZ.d.ts → issuer-identity.check-DFmS8whs.d.ts} +1 -1
  40. package/dist/{module-options-qAOwinHR.d.cts → module-options-C4S_StYF.d.cts} +2 -2
  41. package/dist/{module-options-DmQ3G4sZ.d.ts → module-options-DxJI-1iH.d.ts} +2 -2
  42. package/dist/payments/index.js +2 -2
  43. package/dist/platform/index.d.cts +25 -16
  44. package/dist/platform/index.d.ts +25 -16
  45. package/dist/platform/index.js +16 -14
  46. package/dist/promo/index.d.cts +11 -4
  47. package/dist/promo/index.d.ts +11 -4
  48. package/dist/promo/index.js +5 -3
  49. package/dist/{promo.module-CKkECmU8.d.cts → promo.module-Ddx-swUV.d.cts} +1 -1
  50. package/dist/{promo.module-DuIJdK3U.d.ts → promo.module-PsIvDcUp.d.ts} +1 -1
  51. package/dist/{promo.service-BYBu6dy3.d.cts → promo.service-BextPvx5.d.cts} +23 -1
  52. package/dist/{promo.service-CFjfF0Xm.d.ts → promo.service-Dqqh0JXn.d.ts} +23 -1
  53. package/dist/registration/index.d.cts +2 -2
  54. package/dist/registration/index.d.ts +2 -2
  55. package/dist/registration/index.js +5 -5
  56. package/dist/subscription-contract/index.js +2 -2
  57. package/dist/{tenant-billing.controller-DKbAqTbM.d.cts → tenant-billing.controller-BC6-S5cT.d.cts} +91 -10
  58. package/dist/{tenant-billing.controller-BLqbsONe.d.ts → tenant-billing.controller-BuQDQ76i.d.ts} +91 -10
  59. package/dist/{tenant-billing.module-ClbjzocC.d.cts → tenant-billing.module-C6MFfCKq.d.cts} +24 -1
  60. package/dist/{tenant-billing.module-DohgJJ2m.d.ts → tenant-billing.module-CUCQL0-k.d.ts} +24 -1
  61. package/dist/testing/index.d.cts +6 -6
  62. package/dist/testing/index.d.ts +6 -6
  63. package/dist/testing/index.js +33 -31
  64. package/package.json +3 -3
@@ -46,6 +46,10 @@ function filterActiveSubscriptionBundles(bundles, now) {
46
46
  return bundles.filter((b) => b.canceledEffectiveAt === null || b.canceledEffectiveAt > now);
47
47
  }
48
48
  __name(filterActiveSubscriptionBundles, "filterActiveSubscriptionBundles");
49
+ function isCancellationDeclared(booking) {
50
+ return booking.canceledEffectiveAt !== null;
51
+ }
52
+ __name(isCancellationDeclared, "isCancellationDeclared");
49
53
  function aggregateSubscriptionBundleQuotas(bundles) {
50
54
  const sums = {};
51
55
  for (const bundle of bundles) {
@@ -112,6 +116,10 @@ function contractBundleVersionIds(contract) {
112
116
  ids.add(item.sourceVersionId);
113
117
  }
114
118
  }
119
+ const leftOut = contract.entitlementSnapshot?.leftOutBundleVersionIds;
120
+ if (Array.isArray(leftOut)) {
121
+ for (const id of leftOut) ids.delete(id);
122
+ }
115
123
  return ids;
116
124
  }
117
125
  __name(contractBundleVersionIds, "contractBundleVersionIds");
@@ -390,20 +398,34 @@ var EntitlementService = class {
390
398
  const cached = this.readCache(tenantId, now.getTime());
391
399
  if (cached) return cached;
392
400
  }
393
- const sub = await this.subscriptions.findByTenantId(tenantId);
394
- if (!sub) {
395
- throw new NotFoundException({
396
- code: BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND,
397
- message: `No subscription for tenant ${tenantId}`,
398
- params: {
399
- tenantId
400
- }
401
- });
402
- }
403
- if (catalog) return this.limitsFor(sub, now, catalog);
404
- const limits = await this.limitsFor(sub, now, await this.catalogs.current());
405
- this.writeCache(tenantId, limits, now.getTime(), cancellationLandsAt(sub));
406
- return limits;
401
+ const sub = await this.requireSubscription(tenantId);
402
+ if (catalog) return (await this.answerFor(sub, now, catalog)).limits;
403
+ const answer = await this.answerFor(sub, now, await this.catalogs.current());
404
+ this.writeCache(tenantId, answer.limits, now.getTime(), firstAfter(now, [
405
+ cancellationLandsAt(sub),
406
+ answer.nextBookingEnd
407
+ ]));
408
+ return answer.limits;
409
+ }
410
+ /**
411
+ * What a contract frozen at `now` records as its entitlements: what
412
+ * `computeLimits` grants, less the add-ons whose cancellation is declared.
413
+ *
414
+ * Those are granted until their effective date by the booking rather than
415
+ * by the contract (`mergeSubscriptionBundlesIntoLimits`), so their end
416
+ * needs nobody to write the contract again. Frozen into the snapshot, they
417
+ * would be granted for as long as the contract runs. Never cached, like
418
+ * `computeLimits` with a catalogue.
419
+ */
420
+ async computeContractLimits(tenantId, now, catalog) {
421
+ const sub = await this.requireSubscription(tenantId);
422
+ const { limits, leftOutBundleVersionIds } = await this.answerFor(sub, now, catalog, void 0, {
423
+ leaveOutCancelled: true
424
+ });
425
+ return {
426
+ limits,
427
+ leftOutBundleVersionIds
428
+ };
407
429
  }
408
430
  /**
409
431
  * Clears a tenant's cache entry. MUST be called as soon as a mutation
@@ -423,7 +445,20 @@ var EntitlementService = class {
423
445
  * have a `SubscriptionRecord` (e.g. within a transaction).
424
446
  */
425
447
  async deriveLimits(sub, now, tx) {
426
- return this.limitsFor(sub, now, await this.catalogs.current(), tx);
448
+ return (await this.answerFor(sub, now, await this.catalogs.current(), tx)).limits;
449
+ }
450
+ async requireSubscription(tenantId) {
451
+ const sub = await this.subscriptions.findByTenantId(tenantId);
452
+ if (!sub) {
453
+ throw new NotFoundException({
454
+ code: BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND,
455
+ message: `No subscription for tenant ${tenantId}`,
456
+ params: {
457
+ tenantId
458
+ }
459
+ });
460
+ }
461
+ return sub;
427
462
  }
428
463
  /**
429
464
  * `deriveLimits` against a catalogue already read. The catalogue decides
@@ -431,38 +466,61 @@ var EntitlementService = class {
431
466
  * a caller holds, so that checking a limit does not wait for a second
432
467
  * connection while the subscription row is locked.
433
468
  */
434
- async limitsFor(sub, now, catalog, tx) {
469
+ async answerFor(sub, now, catalog, tx, options = {}) {
435
470
  if (cancellationHasLanded(sub, now)) {
436
471
  const floor = this.resolutionConfig?.canceledEntitlementPlan;
437
472
  if (floor === void 0) {
438
473
  return {
439
- plan: sub.plan,
440
- quotas: {},
441
- features: /* @__PURE__ */ new Set()
474
+ limits: {
475
+ plan: sub.plan,
476
+ quotas: {},
477
+ features: /* @__PURE__ */ new Set()
478
+ },
479
+ nextBookingEnd: null,
480
+ leftOutBundleVersionIds: []
442
481
  };
443
482
  }
444
483
  const floorVersion = await this.findActivePlanVersionOrFallback(floor, now, tx);
445
- return this.asGrantable(catalog, aggregateLimits({
484
+ const limits2 = this.asGrantable(catalog, aggregateLimits({
446
485
  plan: floor,
447
486
  planVersion: floorVersion,
448
487
  subscriptionBundles: [],
449
488
  customLimits: null
450
489
  }, catalog, now));
490
+ return {
491
+ limits: limits2,
492
+ nextBookingEnd: null,
493
+ leftOutBundleVersionIds: []
494
+ };
451
495
  }
496
+ const bundles = await this.loadSubscriptionBundleSnapshots(sub.id, now, tx);
497
+ const leftOut = options.leaveOutCancelled ? bundles.filter(isCancellationDeclared) : [];
498
+ const counted = bundles.filter((booking) => !leftOut.includes(booking));
499
+ const leftOutBundleVersionIds = leftOut.map((booking) => booking.bundleVersionId);
500
+ const nextBookingEnd = firstAfter(now, counted.map((booking) => booking.canceledEffectiveAt));
452
501
  const contract = await this.findActiveContract(sub.tenantId, now, tx);
453
502
  if (contract) {
454
- const bundles = await this.loadSubscriptionBundleSnapshots(sub.id, now, tx);
455
- return this.asGrantable(catalog, mergeSubscriptionBundlesIntoLimits(contractLimits(contract), bundles, contractBundleVersionIds(contract), catalog, now));
503
+ const covered = contractBundleVersionIds(contract);
504
+ const limits2 = this.asGrantable(catalog, mergeSubscriptionBundlesIntoLimits(contractLimits(contract), counted, covered, catalog, now));
505
+ return {
506
+ limits: limits2,
507
+ nextBookingEnd,
508
+ leftOutBundleVersionIds: leftOutBundleVersionIds.filter((id) => !covered.has(id))
509
+ };
456
510
  }
457
511
  const effectivePlan = resolveEntitlementPlan(sub, this.resolutionConfig ?? {}, now);
458
512
  const planVersion = effectivePlan === sub.plan ? sub.planVersion : await this.findActivePlanVersionOrFallback(effectivePlan, now, tx);
459
- const subscriptionBundles = await this.loadSubscriptionBundleSnapshots(sub.id, now, tx);
460
- return this.asGrantable(catalog, aggregateLimits({
513
+ const limits = this.asGrantable(catalog, aggregateLimits({
461
514
  plan: effectivePlan,
462
515
  planVersion,
463
- subscriptionBundles,
516
+ subscriptionBundles: counted,
464
517
  customLimits: sub.customLimits ?? null
465
518
  }, catalog, now));
519
+ return {
520
+ limits,
521
+ nextBookingEnd,
522
+ leftOutBundleVersionIds
523
+ };
466
524
  }
467
525
  /**
468
526
  * The last thing every path does, so that no path can skip it.
@@ -551,7 +609,7 @@ var EntitlementService = class {
551
609
  }
552
610
  });
553
611
  }
554
- const limits = await this.limitsFor(sub, now, catalog, tx);
612
+ const { limits } = await this.answerFor(sub, now, catalog, tx);
555
613
  const max = limits.quotas[input.dimension];
556
614
  if (max === void 0) {
557
615
  throw new InternalServerErrorException(codedError(BILLING_ERROR_CODES.QUOTA_DIMENSION_UNKNOWN, {
@@ -644,6 +702,15 @@ EntitlementService = _ts_decorate([
644
702
  Object
645
703
  ])
646
704
  ], EntitlementService);
705
+ function firstAfter(now, dates) {
706
+ let first = null;
707
+ for (const date of dates) {
708
+ if (date === null || date <= now) continue;
709
+ if (first === null || date < first) first = date;
710
+ }
711
+ return first;
712
+ }
713
+ __name(firstAfter, "firstAfter");
647
714
 
648
715
  export {
649
716
  SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN,
@@ -651,6 +718,7 @@ export {
651
718
  cancellationHasLanded,
652
719
  cancellationLandsAt,
653
720
  filterActiveSubscriptionBundles,
721
+ isCancellationDeclared,
654
722
  aggregateSubscriptionBundleQuotas,
655
723
  collectSubscriptionBundleFeatures,
656
724
  aggregateContractLineItemEntitlements,
@@ -5,8 +5,9 @@ import {
5
5
  PaymentCallbackService,
6
6
  PaymentGatewayRegistry,
7
7
  SUBSCRIBER_PAYMENT_METHOD_REPOSITORY_TOKEN,
8
+ openGatewayForm,
8
9
  refuseForeignReturnUrls
9
- } from "./chunk-7NJKVC5X.js";
10
+ } from "./chunk-WQNOCOI2.js";
10
11
  import {
11
12
  BillingPermissionGuard,
12
13
  ComposedTenantAuthGuard
@@ -175,7 +176,7 @@ var SubscriberPaymentMethodService = class _SubscriberPaymentMethodService {
175
176
  throw new ConflictException(codedError(PAYMENT_ERROR_CODES2.PAYMENTS_NOT_CONFIGURED));
176
177
  }
177
178
  const inUse = await this.methods.findActive(subscriber.id);
178
- const session = await account.gateway.startPaymentMethodSetup({
179
+ const session = await openGatewayForm(account, {
179
180
  subject: {
180
181
  kind: "subscriber",
181
182
  subscriberId: subscriber.id
@@ -184,7 +185,7 @@ var SubscriberPaymentMethodService = class _SubscriberPaymentMethodService {
184
185
  methods: account.methods,
185
186
  successUrl: input.successUrl,
186
187
  cancelUrl: input.cancelUrl
187
- });
188
+ }, this.logger);
188
189
  await this.methods.recordSetup({
189
190
  subscriberId: subscriber.id,
190
191
  gatewayAccount: account.name,
@@ -38,7 +38,7 @@ function linesWithDiscount(input) {
38
38
  }
39
39
  return [
40
40
  ...lineItemsWithoutGeneratedDiscount,
41
- createDiscountLineItem(input, discountNet)
41
+ generatedDiscountLine(input, discountNet)
42
42
  ];
43
43
  }
44
44
  __name(linesWithDiscount, "linesWithDiscount");
@@ -74,7 +74,7 @@ function withGrossShares(lines, vatRate) {
74
74
  });
75
75
  }
76
76
  __name(withGrossShares, "withGrossShares");
77
- function createDiscountLineItem(input, discountNet) {
77
+ function generatedDiscountLine(input, discountNet) {
78
78
  const promoCode = input.promoCodeSnapshot ?? null;
79
79
  const firstPromotion = input.promotionSnapshots?.[0] ?? null;
80
80
  return {
@@ -98,7 +98,7 @@ function createDiscountLineItem(input, discountNet) {
98
98
  }
99
99
  };
100
100
  }
101
- __name(createDiscountLineItem, "createDiscountLineItem");
101
+ __name(generatedDiscountLine, "generatedDiscountLine");
102
102
  function roundMoney(value) {
103
103
  return Math.round((value + Number.EPSILON) * 100) / 100;
104
104
  }
@@ -516,6 +516,7 @@ __name(lineItemKindPriority, "lineItemKindPriority");
516
516
 
517
517
  export {
518
518
  appendImplicitDiscountLineItem,
519
+ generatedDiscountLine,
519
520
  SubscriptionContractService,
520
521
  contractLineItemToInvoiceLineItem,
521
522
  subscriptionContractToInvoiceSnapshot,
@@ -1,5 +1,4 @@
1
1
  import {
2
- EnforceMfa,
3
2
  MfaGuard,
4
3
  MfaService
5
4
  } from "./chunk-34XVPR6P.js";
@@ -998,275 +997,6 @@ AdminStatsModule = _ts_decorate9([
998
997
  Module3({})
999
998
  ], AdminStatsModule);
1000
999
 
1001
- // src/admin/admin-resources.module.ts
1002
- import { Body, Controller as Controller4, Get as Get4, Inject as Inject7, Injectable as Injectable5, Module as Module4, NotFoundException, Param, Post as Post2, Query, Req, UseGuards as UseGuards3 } from "@nestjs/common";
1003
- import { IsOptional, IsString, MaxLength } from "class-validator";
1004
- import { BILLING_ERROR_CODES } from "@saasicat/core";
1005
- function _ts_decorate10(decorators, target, key, desc) {
1006
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1007
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1008
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1009
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1010
- }
1011
- __name(_ts_decorate10, "_ts_decorate");
1012
- function _ts_metadata7(k, v) {
1013
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1014
- }
1015
- __name(_ts_metadata7, "_ts_metadata");
1016
- function _ts_param7(paramIndex, decorator) {
1017
- return function(target, key) {
1018
- decorator(target, key, paramIndex);
1019
- };
1020
- }
1021
- __name(_ts_param7, "_ts_param");
1022
- var ADMIN_RESOURCES_PORT_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/nest/AdminResourcesPort");
1023
- var SuspendTenantDto = class {
1024
- static {
1025
- __name(this, "SuspendTenantDto");
1026
- }
1027
- reason;
1028
- };
1029
- _ts_decorate10([
1030
- IsOptional(),
1031
- IsString(),
1032
- MaxLength(500),
1033
- _ts_metadata7("design:type", String)
1034
- ], SuspendTenantDto.prototype, "reason", void 0);
1035
- var AdminResourcesService = class {
1036
- static {
1037
- __name(this, "AdminResourcesService");
1038
- }
1039
- resources;
1040
- audit;
1041
- constructor(resources, audit) {
1042
- this.resources = resources;
1043
- this.audit = audit;
1044
- }
1045
- listTenants(filter) {
1046
- return this.resources.listTenants(filter);
1047
- }
1048
- async getTenantDetail(slug) {
1049
- const tenant = await this.resources.getTenantDetail(slug);
1050
- if (!tenant) {
1051
- throw new NotFoundException({
1052
- code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
1053
- message: `Tenant ${slug} not found`,
1054
- params: {
1055
- slug
1056
- }
1057
- });
1058
- }
1059
- return tenant;
1060
- }
1061
- listUsers(filter) {
1062
- return this.resources.listUsers(filter);
1063
- }
1064
- listAudit(filter) {
1065
- return this.resources.listAudit(filter);
1066
- }
1067
- listSubscriptions() {
1068
- return this.resources.listSubscriptions();
1069
- }
1070
- suspendTenant(slug, reason, actor) {
1071
- return this.setTenantActive(slug, false, "PAST_DUE", actor, {
1072
- action: "TENANT_SUSPEND",
1073
- reason: reason ?? ""
1074
- });
1075
- }
1076
- reactivateTenant(slug, actor) {
1077
- return this.setTenantActive(slug, true, "ACTIVE", actor, {
1078
- action: "TENANT_REACTIVATE",
1079
- reason: ""
1080
- });
1081
- }
1082
- async setTenantActive(slug, active, subscriptionStatus, actor, audit) {
1083
- const result = await this.resources.setTenantActive(slug, active, subscriptionStatus);
1084
- if (!result) {
1085
- throw new NotFoundException({
1086
- code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
1087
- message: `Tenant ${slug} not found`,
1088
- params: {
1089
- slug
1090
- }
1091
- });
1092
- }
1093
- await this.audit.log({
1094
- actor,
1095
- entity: "Tenant",
1096
- entityId: result.id,
1097
- action: audit.action,
1098
- changes: {
1099
- slug,
1100
- reason: audit.reason
1101
- }
1102
- });
1103
- return result;
1104
- }
1105
- };
1106
- AdminResourcesService = _ts_decorate10([
1107
- Injectable5(),
1108
- _ts_param7(0, Inject7(ADMIN_RESOURCES_PORT_TOKEN)),
1109
- _ts_param7(1, Inject7(AdminAuditService)),
1110
- _ts_metadata7("design:type", Function),
1111
- _ts_metadata7("design:paramtypes", [
1112
- typeof AdminResourcesPort === "undefined" ? Object : AdminResourcesPort,
1113
- typeof AdminAuditService === "undefined" ? Object : AdminAuditService
1114
- ])
1115
- ], AdminResourcesService);
1116
- function actorFromRequest(request) {
1117
- const userId = request.user?.id ?? request.user?.userId ?? "unknown";
1118
- return {
1119
- userId,
1120
- email: request.user?.email ?? `${userId}@unknown`,
1121
- source: "web",
1122
- context: request.user?.sessionId ?? "unknown"
1123
- };
1124
- }
1125
- __name(actorFromRequest, "actorFromRequest");
1126
- function buildAdminResourcesController(guards) {
1127
- let GeneratedAdminResourcesController = class GeneratedAdminResourcesController {
1128
- static {
1129
- __name(this, "GeneratedAdminResourcesController");
1130
- }
1131
- resources;
1132
- constructor(resources) {
1133
- this.resources = resources;
1134
- }
1135
- listTenants(query) {
1136
- return this.resources.listTenants(query);
1137
- }
1138
- getTenant(slug) {
1139
- return this.resources.getTenantDetail(slug);
1140
- }
1141
- suspendTenant(request, slug, dto) {
1142
- return this.resources.suspendTenant(slug, dto.reason, actorFromRequest(request));
1143
- }
1144
- reactivateTenant(request, slug) {
1145
- return this.resources.reactivateTenant(slug, actorFromRequest(request));
1146
- }
1147
- listUsers(query) {
1148
- return this.resources.listUsers(query);
1149
- }
1150
- listAudit(query) {
1151
- return this.resources.listAudit({
1152
- actor: query.actor,
1153
- action: query.action,
1154
- entity: query.entity,
1155
- since: query.since,
1156
- limit: query.limit ? Number.parseInt(query.limit, 10) : void 0
1157
- });
1158
- }
1159
- listSubscriptions() {
1160
- return this.resources.listSubscriptions();
1161
- }
1162
- };
1163
- _ts_decorate10([
1164
- Get4("tenants"),
1165
- _ts_param7(0, Query()),
1166
- _ts_metadata7("design:type", Function),
1167
- _ts_metadata7("design:paramtypes", [
1168
- Object
1169
- ]),
1170
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1171
- ], GeneratedAdminResourcesController.prototype, "listTenants", null);
1172
- _ts_decorate10([
1173
- Get4("tenants/:slug"),
1174
- _ts_param7(0, Param("slug")),
1175
- _ts_metadata7("design:type", Function),
1176
- _ts_metadata7("design:paramtypes", [
1177
- String
1178
- ]),
1179
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1180
- ], GeneratedAdminResourcesController.prototype, "getTenant", null);
1181
- _ts_decorate10([
1182
- Post2("tenants/:slug/suspend"),
1183
- EnforceMfa(),
1184
- _ts_param7(0, Req()),
1185
- _ts_param7(1, Param("slug")),
1186
- _ts_param7(2, Body()),
1187
- _ts_metadata7("design:type", Function),
1188
- _ts_metadata7("design:paramtypes", [
1189
- typeof AdminRequest === "undefined" ? Object : AdminRequest,
1190
- String,
1191
- typeof SuspendTenantDto === "undefined" ? Object : SuspendTenantDto
1192
- ]),
1193
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1194
- ], GeneratedAdminResourcesController.prototype, "suspendTenant", null);
1195
- _ts_decorate10([
1196
- Post2("tenants/:slug/reactivate"),
1197
- EnforceMfa(),
1198
- _ts_param7(0, Req()),
1199
- _ts_param7(1, Param("slug")),
1200
- _ts_metadata7("design:type", Function),
1201
- _ts_metadata7("design:paramtypes", [
1202
- typeof AdminRequest === "undefined" ? Object : AdminRequest,
1203
- String
1204
- ]),
1205
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1206
- ], GeneratedAdminResourcesController.prototype, "reactivateTenant", null);
1207
- _ts_decorate10([
1208
- Get4("users"),
1209
- _ts_param7(0, Query()),
1210
- _ts_metadata7("design:type", Function),
1211
- _ts_metadata7("design:paramtypes", [
1212
- Object
1213
- ]),
1214
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1215
- ], GeneratedAdminResourcesController.prototype, "listUsers", null);
1216
- _ts_decorate10([
1217
- Get4("audit"),
1218
- _ts_param7(0, Query()),
1219
- _ts_metadata7("design:type", Function),
1220
- _ts_metadata7("design:paramtypes", [
1221
- Object
1222
- ]),
1223
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1224
- ], GeneratedAdminResourcesController.prototype, "listAudit", null);
1225
- _ts_decorate10([
1226
- Get4("subscriptions"),
1227
- _ts_metadata7("design:type", Function),
1228
- _ts_metadata7("design:paramtypes", []),
1229
- _ts_metadata7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1230
- ], GeneratedAdminResourcesController.prototype, "listSubscriptions", null);
1231
- GeneratedAdminResourcesController = _ts_decorate10([
1232
- Controller4("admin"),
1233
- UseGuards3(...guards),
1234
- _ts_param7(0, Inject7(AdminResourcesService)),
1235
- _ts_metadata7("design:type", Function),
1236
- _ts_metadata7("design:paramtypes", [
1237
- typeof AdminResourcesService === "undefined" ? Object : AdminResourcesService
1238
- ])
1239
- ], GeneratedAdminResourcesController);
1240
- return GeneratedAdminResourcesController;
1241
- }
1242
- __name(buildAdminResourcesController, "buildAdminResourcesController");
1243
- var AdminResourcesModule = class _AdminResourcesModule {
1244
- static {
1245
- __name(this, "AdminResourcesModule");
1246
- }
1247
- static forRoot(options) {
1248
- return {
1249
- module: _AdminResourcesModule,
1250
- global: options.global ?? false,
1251
- imports: options.imports ?? [],
1252
- controllers: [
1253
- buildAdminResourcesController(options.guards)
1254
- ],
1255
- providers: [
1256
- asProvider(ADMIN_RESOURCES_PORT_TOKEN, options.resources),
1257
- AdminResourcesService
1258
- ],
1259
- exports: [
1260
- ADMIN_RESOURCES_PORT_TOKEN,
1261
- AdminResourcesService
1262
- ]
1263
- };
1264
- }
1265
- };
1266
- AdminResourcesModule = _ts_decorate10([
1267
- Module4({})
1268
- ], AdminResourcesModule);
1269
-
1270
1000
  export {
1271
1001
  SuperAdminGuard,
1272
1002
  AdminBypassRlsInterceptor,
@@ -1284,9 +1014,5 @@ export {
1284
1014
  AdminStatsService,
1285
1015
  AdminStatsController,
1286
1016
  buildAdminStatsController,
1287
- AdminStatsModule,
1288
- ADMIN_RESOURCES_PORT_TOKEN,
1289
- SuspendTenantDto,
1290
- AdminResourcesService,
1291
- AdminResourcesModule
1017
+ AdminStatsModule
1292
1018
  };