@saasicat/nest 0.18.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/_entries.cjs +1341 -590
  2. package/dist/admin/index.js +2 -1
  3. package/dist/billing/index.d.cts +10 -6
  4. package/dist/billing/index.d.ts +10 -6
  5. package/dist/billing/index.js +7 -6
  6. package/dist/catalog/index.js +4 -4
  7. package/dist/checkout-offer/index.js +2 -2
  8. package/dist/{chunk-RZVSKKXX.js → chunk-3DRZ5GCP.js} +56 -105
  9. package/dist/{chunk-GLLCB4BP.js → chunk-4O6R6ARQ.js} +23 -13
  10. package/dist/{chunk-7RRWI5LH.js → chunk-55QGAZRQ.js} +10 -10
  11. package/dist/{chunk-Z3FWN3HJ.js → chunk-5ZXBXYXU.js} +3 -3
  12. package/dist/{chunk-V34AA7C7.js → chunk-6WL6VQ7Z.js} +1 -1
  13. package/dist/{chunk-ABB2CRAS.js → chunk-74SCJ4HF.js} +1 -1
  14. package/dist/{chunk-EXOLOJFZ.js → chunk-AGOG5B77.js} +36 -9
  15. package/dist/{chunk-32EMXPU2.js → chunk-B7NRY2LV.js} +48 -17
  16. package/dist/{chunk-MDIZUVIK.js → chunk-BSK6YBLI.js} +1 -1
  17. package/dist/{chunk-R2QOSVAA.js → chunk-DQKCK7DX.js} +1 -1
  18. package/dist/chunk-EBJJNTW6.js +22 -0
  19. package/dist/{chunk-PLJEAUFU.js → chunk-FYWLPYBK.js} +79 -39
  20. package/dist/{chunk-P3DP6GJE.js → chunk-GC5AKN44.js} +487 -160
  21. package/dist/{chunk-5KH2O4SF.js → chunk-NZLAYCEX.js} +286 -110
  22. package/dist/{chunk-E7AJ42AB.js → chunk-VQQWF7MW.js} +172 -28
  23. package/dist/{chunk-GJBXOCRZ.js → chunk-XTVAFJ3P.js} +46 -17
  24. package/dist/{chunk-BOADBIGB.js → chunk-YYUXKLXK.js} +2 -2
  25. package/dist/{chunk-YITTE646.js → chunk-ZH5PYEMI.js} +41 -23
  26. package/dist/{define-saasicat-Rc0rXrYG.d.ts → define-saasicat-B20Ms8UC.d.ts} +1 -1
  27. package/dist/{define-saasicat-CeDBX9ji.d.cts → define-saasicat-Cf9DpEsY.d.cts} +1 -1
  28. package/dist/discovery/index.d.cts +2 -2
  29. package/dist/discovery/index.d.ts +2 -2
  30. package/dist/discovery/index.js +4 -4
  31. package/dist/{enforce-quota.interceptor-CmbWX39L.d.ts → enforce-quota.interceptor-CUyfR4cQ.d.ts} +1 -1
  32. package/dist/{enforce-quota.interceptor-DMw-bPyk.d.cts → enforce-quota.interceptor-Dtg5WdFj.d.cts} +1 -1
  33. package/dist/entitlement/index.js +3 -2
  34. package/dist/index.d.cts +27 -8
  35. package/dist/index.d.ts +27 -8
  36. package/dist/index.js +21 -17
  37. package/dist/{module-DgYJur6f.d.ts → module-BE17XFLg.d.ts} +1 -1
  38. package/dist/{module-CSN8j8Tp.d.cts → module-CHMIyWlf.d.cts} +1 -1
  39. package/dist/platform/index.d.cts +8 -8
  40. package/dist/platform/index.d.ts +8 -8
  41. package/dist/platform/index.js +14 -13
  42. package/dist/promo/index.d.cts +3 -3
  43. package/dist/promo/index.d.ts +3 -3
  44. package/dist/promo/index.js +4 -3
  45. package/dist/registration/index.js +2 -1
  46. package/dist/{saas-platform.module-D3rUTiho.d.cts → saas-platform.module-BfaYfL-G.d.cts} +1 -1
  47. package/dist/{saas-platform.module-DLhoqKNA.d.ts → saas-platform.module-DChhDrR-.d.ts} +1 -1
  48. package/dist/{service-DX8KbGXl.d.cts → service-D48clObR.d.cts} +3 -3
  49. package/dist/{service-DX8KbGXl.d.ts → service-D48clObR.d.ts} +3 -3
  50. package/dist/subscription-contract/index.js +2 -2
  51. package/dist/{tenant-billing.controller-CG4CaFUP.d.cts → tenant-billing.controller-BIF-mstX.d.cts} +2 -2
  52. package/dist/{tenant-billing.controller-BwZRnJ3q.d.ts → tenant-billing.controller-DT5UrnDX.d.ts} +2 -2
  53. package/dist/testing/index.d.cts +5 -5
  54. package/dist/testing/index.d.ts +5 -5
  55. package/dist/testing/index.js +34 -33
  56. package/package.json +3 -3
@@ -7,6 +7,9 @@ import {
7
7
  import {
8
8
  SaaSiCatPublicRoute
9
9
  } from "./chunk-YSC46BGM.js";
10
+ import {
11
+ codedError
12
+ } from "./chunk-EBJJNTW6.js";
10
13
  import {
11
14
  asProvider
12
15
  } from "./chunk-SABTXESR.js";
@@ -16,6 +19,7 @@ import {
16
19
 
17
20
  // src/admin/super-admin.guard.ts
18
21
  import { ForbiddenException, Injectable } from "@nestjs/common";
22
+ import { AUTH_ERROR_CODES } from "@saasicat/types";
19
23
  function _ts_decorate(decorators, target, key, desc) {
20
24
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
25
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -29,10 +33,18 @@ var SuperAdminGuard = class {
29
33
  }
30
34
  canActivate(context) {
31
35
  const request = context.switchToHttp().getRequest();
32
- if (!request.user) throw new ForbiddenException("Nicht authentifiziert");
36
+ if (!request.user) {
37
+ throw new ForbiddenException({
38
+ code: AUTH_ERROR_CODES.NOT_AUTHENTICATED,
39
+ message: "Not authenticated"
40
+ });
41
+ }
33
42
  const role = request.user.platformRole ?? request.user.role;
34
43
  if (role !== "SUPER_ADMIN") {
35
- throw new ForbiddenException("Nur SUPER_ADMIN-Rolle erlaubt");
44
+ throw new ForbiddenException({
45
+ code: AUTH_ERROR_CODES.SUPER_ADMIN_REQUIRED,
46
+ message: "Only the SUPER_ADMIN role is allowed"
47
+ });
36
48
  }
37
49
  return true;
38
50
  }
@@ -119,7 +131,7 @@ var MfaService = class _MfaService {
119
131
  return false;
120
132
  }
121
133
  const message = error instanceof Error ? error.message : String(error);
122
- this.logger.warn(`TOTP-Verify f\xFCr User ${input.userId} unerwartet fehlgeschlagen: ${message}`);
134
+ this.logger.warn(`TOTP verification for user ${input.userId} failed unexpectedly: ${message}`);
123
135
  return false;
124
136
  }
125
137
  }
@@ -146,6 +158,7 @@ MfaService = _ts_decorate2([
146
158
  // src/admin/mfa.guard.ts
147
159
  import { Inject as Inject2, Injectable as Injectable3, Logger as Logger2, SetMetadata, UnauthorizedException } from "@nestjs/common";
148
160
  import { Reflector } from "@nestjs/core";
161
+ import { AUTH_ERROR_CODES as AUTH_ERROR_CODES2 } from "@saasicat/types";
149
162
  function _ts_decorate3(decorators, target, key, desc) {
150
163
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
151
164
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -187,22 +200,30 @@ var MfaGuard = class _MfaGuard {
187
200
  }
188
201
  const request = context.switchToHttp().getRequest();
189
202
  const user = request.user;
190
- if (!user) throw new UnauthorizedException({
191
- reason: "NOT_AUTHENTICATED"
192
- });
203
+ if (!user) {
204
+ throw new UnauthorizedException({
205
+ ...codedError(AUTH_ERROR_CODES2.NOT_AUTHENTICATED),
206
+ // `reason` is superseded by `code` and will be removed.
207
+ reason: "NOT_AUTHENTICATED"
208
+ });
209
+ }
193
210
  const enabled = await this.mfaService.isEnabled(user.id);
194
211
  if (!enabled) {
195
212
  throw new UnauthorizedException({
213
+ code: AUTH_ERROR_CODES2.MFA_NOT_SET_UP,
214
+ // `reason` is superseded by `code` and will be removed.
196
215
  reason: "MFA_NOT_SET_UP",
197
- message: "Bitte zuerst MFA-Setup \xFCber das CLI ausf\xFChren."
216
+ message: "Run the MFA setup via the CLI first."
198
217
  });
199
218
  }
200
219
  const headerVal = request.headers?.["x-mfa-code"];
201
220
  const code = Array.isArray(headerVal) ? headerVal[0] : headerVal;
202
221
  if (!code) {
203
222
  throw new UnauthorizedException({
223
+ code: AUTH_ERROR_CODES2.MFA_REQUIRED,
224
+ // `reason` is superseded by `code` and will be removed.
204
225
  reason: "MFA_REQUIRED",
205
- message: "TOTP-Code im Header X-Mfa-Code erforderlich."
226
+ message: "TOTP code required in the X-Mfa-Code header."
206
227
  });
207
228
  }
208
229
  const valid = await this.mfaService.verify({
@@ -211,8 +232,10 @@ var MfaGuard = class _MfaGuard {
211
232
  });
212
233
  if (!valid) {
213
234
  throw new UnauthorizedException({
235
+ code: AUTH_ERROR_CODES2.MFA_FAILED,
236
+ // `reason` is superseded by `code` and will be removed.
214
237
  reason: "MFA_FAILED",
215
- message: "TOTP-Code ung\xFCltig."
238
+ message: "Invalid TOTP code."
216
239
  });
217
240
  }
218
241
  return true;
@@ -615,7 +638,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
615
638
  actions: [
616
639
  {
617
640
  id: "platform.tenants.suspend",
618
- label: "Mandant suspendieren",
641
+ label: "Suspend tenant",
619
642
  actionKey: "tenants.suspend",
620
643
  requiredCapability: "tenants.suspend",
621
644
  requiresMfa: true,
@@ -623,7 +646,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
623
646
  },
624
647
  {
625
648
  id: "platform.tenants.reactivate",
626
- label: "Mandant reaktivieren",
649
+ label: "Reactivate tenant",
627
650
  actionKey: "tenants.reactivate",
628
651
  requiredCapability: "tenants.reactivate",
629
652
  requiresMfa: true,
@@ -639,7 +662,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
639
662
  },
640
663
  {
641
664
  id: "platform.tenants.export",
642
- label: "DSGVO-Export",
665
+ label: "GDPR export",
643
666
  actionKey: "tenants.export",
644
667
  requiredCapability: "tenants.export",
645
668
  requiresMfa: true,
@@ -647,7 +670,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
647
670
  },
648
671
  {
649
672
  id: "platform.subscriptions.cancel",
650
- label: "Subscription k\xFCndigen",
673
+ label: "Cancel subscription",
651
674
  actionKey: "subscriptions.cancel",
652
675
  requiredCapability: "subscriptions.cancel",
653
676
  requiresMfa: true,
@@ -655,7 +678,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
655
678
  },
656
679
  {
657
680
  id: "platform.pilots.grant",
658
- label: "Pilot-Status setzen",
681
+ label: "Set pilot status",
659
682
  actionKey: "pilots.grant",
660
683
  requiredCapability: "pilots.grant",
661
684
  requiresMfa: true,
@@ -663,7 +686,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
663
686
  },
664
687
  {
665
688
  id: "platform.pilots.revoke",
666
- label: "Pilot-Status entziehen",
689
+ label: "Revoke pilot status",
667
690
  actionKey: "pilots.revoke",
668
691
  requiredCapability: "pilots.revoke",
669
692
  requiresMfa: true,
@@ -671,7 +694,7 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
671
694
  },
672
695
  {
673
696
  id: "platform.pilots.extend",
674
- label: "Pilot verl\xE4ngern",
697
+ label: "Extend pilot",
675
698
  actionKey: "pilots.extend",
676
699
  requiredCapability: "pilots.extend",
677
700
  requiresMfa: true,
@@ -683,102 +706,102 @@ var PLATFORM_CORE_MANIFEST_CONTRIBUTION = {
683
706
  actions: [
684
707
  {
685
708
  key: "TENANT_SUSPEND",
686
- label: "Mandant suspendiert",
709
+ label: "Tenant suspended",
687
710
  severity: "high"
688
711
  },
689
712
  {
690
713
  key: "TENANT_REACTIVATE",
691
- label: "Mandant reaktiviert",
714
+ label: "Tenant reactivated",
692
715
  severity: "medium"
693
716
  },
694
717
  {
695
718
  key: "TENANT_IMPERSONATE",
696
- label: "Impersonation gestartet",
719
+ label: "Impersonation started",
697
720
  severity: "high"
698
721
  },
699
722
  {
700
723
  key: "TENANT_EXPORT",
701
- label: "DSGVO-Export ausgel\xF6st",
724
+ label: "GDPR export triggered",
702
725
  severity: "medium"
703
726
  },
704
727
  {
705
728
  key: "PILOT_CREATE",
706
- label: "Pilot-Tenant angelegt",
729
+ label: "Pilot tenant created",
707
730
  severity: "medium"
708
731
  },
709
732
  {
710
733
  key: "PILOT_GRANT",
711
- label: "Pilot-Status gesetzt",
734
+ label: "Pilot status set",
712
735
  severity: "medium"
713
736
  },
714
737
  {
715
738
  key: "PILOT_REVOKE",
716
- label: "Pilot-Status entzogen",
739
+ label: "Pilot status revoked",
717
740
  severity: "medium"
718
741
  },
719
742
  {
720
743
  key: "PILOT_EXTEND",
721
- label: "Pilot verl\xE4ngert",
744
+ label: "Pilot extended",
722
745
  severity: "low"
723
746
  },
724
747
  {
725
748
  key: "PLAN_VERSION_PUBLISH",
726
- label: "Plan-Version freigegeben",
749
+ label: "Plan version approved",
727
750
  severity: "high"
728
751
  },
729
752
  {
730
753
  key: "PLAN_VERSION_TERMINATE",
731
- label: "Plan-Version terminiert",
754
+ label: "Plan version terminated",
732
755
  severity: "high"
733
756
  },
734
757
  {
735
758
  key: "SUBSCRIPTION_CANCEL",
736
- label: "Subscription gek\xFCndigt",
759
+ label: "Subscription cancelled",
737
760
  severity: "high"
738
761
  },
739
762
  {
740
763
  key: "USER_RESET_PASSWORD",
741
- label: "Passwort-Reset ausgel\xF6st",
764
+ label: "Password reset triggered",
742
765
  severity: "medium"
743
766
  },
744
767
  {
745
768
  key: "USER_DEACTIVATE",
746
- label: "User deaktiviert",
769
+ label: "User deactivated",
747
770
  severity: "high"
748
771
  },
749
772
  {
750
773
  key: "USER_REASSIGN_ADMIN",
751
- label: "Admin-Rolle \xFCbertragen",
774
+ label: "Admin role transferred",
752
775
  severity: "high"
753
776
  },
754
777
  {
755
778
  key: "PLATFORM_EMAIL_PROVIDER_CREATE",
756
- label: "Plattform-Absender angelegt",
779
+ label: "Platform sender created",
757
780
  severity: "medium"
758
781
  },
759
782
  {
760
783
  key: "PLATFORM_EMAIL_PROVIDER_UPDATE",
761
- label: "Plattform-Absender ge\xE4ndert",
784
+ label: "Platform sender changed",
762
785
  severity: "medium"
763
786
  },
764
787
  {
765
788
  key: "PLATFORM_EMAIL_PROVIDER_DELETE",
766
- label: "Plattform-Absender gel\xF6scht",
789
+ label: "Platform sender deleted",
767
790
  severity: "medium"
768
791
  },
769
792
  {
770
793
  key: "PLATFORM_EMAIL_PROVIDER_TEST",
771
- label: "Plattform-Absender Test-Versand",
794
+ label: "Platform sender test send",
772
795
  severity: "low"
773
796
  },
774
797
  {
775
798
  key: "EMAIL_HISTORY_DELETE",
776
- label: "Plattform-E-Mail aus Verlauf entfernt",
799
+ label: "Platform email removed from history",
777
800
  severity: "medium"
778
801
  },
779
802
  {
780
803
  key: "EMAIL_HISTORY_RESEND",
781
- label: "Plattform-E-Mail erneut versendet",
804
+ label: "Platform email resent",
782
805
  severity: "low"
783
806
  }
784
807
  ]
@@ -898,7 +921,7 @@ var AdminManifestModule = class _AdminManifestModule {
898
921
  ];
899
922
  if (includeManifestController) {
900
923
  if (options.guards === void 0) {
901
- throw new Error("AdminManifestModule.forRoot: `guards` ist Pflicht, wenn `includeManifestController` aktiv ist (Default `true`). Setze `guards: [JwtAuthGuard, SuperAdminGuard]` (oder analog) \u2014 oder `guards: []`, um den Endpoint absichtlich auth-frei zu betreiben. Alternative: `includeManifestController: false` und einen eigenen Wrapping-Controller registrieren.");
924
+ throw new Error("AdminManifestModule.forRoot: `guards` is required when `includeManifestController` is enabled (default `true`). Set `guards: [JwtAuthGuard, SuperAdminGuard]` (or equivalent) \u2014 or `guards: []` to deliberately leave the endpoint unauthenticated. Alternative: `includeManifestController: false` plus registering your own wrapping controller.");
902
925
  }
903
926
  controllers.push(buildManifestController(options.guards, options.reloadGuards ?? []));
904
927
  }
@@ -1135,6 +1158,7 @@ AdminStatsModule = _ts_decorate11([
1135
1158
  // src/admin/admin-resources.module.ts
1136
1159
  import { Body, Controller as Controller4, Get as Get4, Inject as Inject9, Injectable as Injectable7, Module as Module4, NotFoundException, Param, Post as Post2, Query, Req, UseGuards as UseGuards3 } from "@nestjs/common";
1137
1160
  import { IsOptional, IsString, MaxLength } from "class-validator";
1161
+ import { BILLING_ERROR_CODES } from "@saasicat/types";
1138
1162
  function _ts_decorate12(decorators, target, key, desc) {
1139
1163
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1140
1164
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1180,7 +1204,15 @@ var AdminResourcesService = class {
1180
1204
  }
1181
1205
  async getTenantDetail(slug) {
1182
1206
  const tenant = await this.resources.getTenantDetail(slug);
1183
- if (!tenant) throw new NotFoundException(`Tenant ${slug} not found`);
1207
+ if (!tenant) {
1208
+ throw new NotFoundException({
1209
+ code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
1210
+ message: `Tenant ${slug} not found`,
1211
+ params: {
1212
+ slug
1213
+ }
1214
+ });
1215
+ }
1184
1216
  return tenant;
1185
1217
  }
1186
1218
  listUsers(filter) {
@@ -1206,7 +1238,15 @@ var AdminResourcesService = class {
1206
1238
  }
1207
1239
  async setTenantActive(slug, active, subscriptionStatus, actor, audit) {
1208
1240
  const result = await this.resources.setTenantActive(slug, active, subscriptionStatus);
1209
- if (!result) throw new NotFoundException(`Tenant ${slug} not found`);
1241
+ if (!result) {
1242
+ throw new NotFoundException({
1243
+ code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
1244
+ message: `Tenant ${slug} not found`,
1245
+ params: {
1246
+ slug
1247
+ }
1248
+ });
1249
+ }
1210
1250
  await this.audit.log({
1211
1251
  actor,
1212
1252
  entity: "Tenant",