refactor(quick-260921-m34): Aufgabe 1 - Mandantenbindung entzaubert, 105 unnoetige any-Zusicherungen entfernt

- prisma-tenant.extension.ts: (prisma as any) und die Handannotation an
  $allOperations in forTenant()/forSystem() entfernt; Kopfkommentar
  unveraendert. .then((results: any[]) => ...) auf unknown[] umgestellt.
- 105 Aufrufstellen `const X = forTenant(...) as any` / `forSystem(...) as
  any` von der Zusicherung befreit, Zuweisungsform woertlich erhalten
  (rls-access-inventory.spec.ts bleibt scharf, 30/30 gruen einzeln
  geprueft).
- withTenantTransaction(): Prisma.TransactionClient fuer tx probiert,
  gemessen verworfen - bricht das Testdoppel in
  prisma-tenant.extension.spec.ts (TS2322 auf einem absichtlich
  unvollstaendigen Fake-Objekt). tx bleibt any, mit Begruendung am Typ.
- Gefolge des jetzt getypten Klienten entfernt: any[]-Annotationen und
  .map((x: any) => ...) in groups.service.ts, module-grants.service.ts,
  dkv.service.ts, ldap-config.service.ts, tenders.controller.ts:270.
- Befund (D-03): tender-matching.service.ts:159 trug eine Handannotation
  (match: { tender: unknown }), die den Wert nur deshalb auf unknown
  verengte, um TS7006 unter dem alten any-Klienten zu vermeiden - mit dem
  getypten Klienten war das falsch. Annotation geloescht, kein Ersatz
  durch Zusicherung.
- Zwei any bleiben gezielt in groups.service.ts (u/a in
  ensureDefaultGroup(), gefolge von tx: any) - Begruendung am Code.

noExplicitAny apps/api/src: 288 -> 149 (Schranke 155). type-check 4/4,
lint 5/5 (0 error). apps/api 72/1143 gruen, apps/web 73/531 gruen,
rls-access-inventory.spec.ts 30/30 gruen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TPPB4ApQxzSU1rwV2Ffj9J
This commit is contained in:
2026-09-21 16:19:16 +02:00
parent 8d845e732e
commit b188946e31
24 changed files with 147 additions and 148 deletions
+7 -7
View File
@@ -61,7 +61,7 @@ export class UserService {
* (Aufgabe 1, `user-gebunden-nur-eigener-mandant`).
*/
async findById(tenantId: string, id: string) {
const tenantPrisma = forTenant(this.prisma, tenantId) as any;
const tenantPrisma = forTenant(this.prisma, tenantId);
return tenantPrisma.user.findUnique({ where: { id } });
}
@@ -105,7 +105,7 @@ export class UserService {
ldapDn?: string;
}) {
const { password, ...rest } = data;
const tenantPrisma = forTenant(this.prisma, data.tenantId) as any;
const tenantPrisma = forTenant(this.prisma, data.tenantId);
let created: any;
try {
@@ -168,7 +168,7 @@ export class UserService {
updateData.passwordHash = await argon2.hash(password);
}
const tenantPrisma = forTenant(this.prisma, tenantId) as any;
const tenantPrisma = forTenant(this.prisma, tenantId);
try {
return await tenantPrisma.user.update({
where: { id },
@@ -189,7 +189,7 @@ export class UserService {
* Mandanten.
*/
async deactivate(tenantId: string, id: string) {
const tenantPrisma = forTenant(this.prisma, tenantId) as any;
const tenantPrisma = forTenant(this.prisma, tenantId);
return tenantPrisma.user.update({
where: { id },
data: { isActive: false },
@@ -200,7 +200,7 @@ export class UserService {
* Hard delete a user, gebunden an den uebergebenen Mandanten.
*/
async delete(tenantId: string, id: string) {
const tenantPrisma = forTenant(this.prisma, tenantId) as any;
const tenantPrisma = forTenant(this.prisma, tenantId);
return tenantPrisma.user.delete({ where: { id } });
}
@@ -233,7 +233,7 @@ export class UserService {
const results: any[] = [];
for (const tenant of tenants) {
const tenantPrisma = forTenant(this.prisma, tenant.id) as any;
const tenantPrisma = forTenant(this.prisma, tenant.id);
const users = await tenantPrisma.user.findMany({
where: { tenantId: tenant.id },
select: {
@@ -265,7 +265,7 @@ export class UserService {
const tenants = await this.prisma.tenant.findMany({ select: { id: true } });
for (const tenant of tenants) {
const tenantPrisma = forTenant(this.prisma, tenant.id) as any;
const tenantPrisma = forTenant(this.prisma, tenant.id);
const user = await tenantPrisma.user.findUnique({ where: { id } });
if (user) {
return user;