Skip to content

Commit d709f70

Browse files
fix(lint): fix entity-linking.service.ts any type violations
1 parent 951296a commit d709f70

1 file changed

Lines changed: 35 additions & 18 deletions

File tree

app/backend/src/entity-linking/entity-linking.service.ts

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@ import {
55
BadRequestException,
66
} from '@nestjs/common';
77
import { PrismaService } from '../prisma/prisma.service';
8+
import { Prisma } from '@prisma/client';
89
import {
910
CreateEntityLinkDto,
1011
LinkEntityResult,
1112
EntityLinkQueryDto,
1213
RegistrySearchResult,
1314
} from './dto/entity-link.dto';
1415

16+
/** Fields that can be set on an EntityLink create input. */
17+
interface EntityLinkCreateInput {
18+
sourceType: string;
19+
sourceId: string;
20+
extractedName: string;
21+
extractedType: string;
22+
entityType: string;
23+
confidenceScore: number;
24+
matchMethod: string;
25+
metadata: Prisma.InputJsonValue | null;
26+
organizationId?: string;
27+
locationId?: string;
28+
assetId?: string;
29+
projectId?: string;
30+
}
31+
1532
@Injectable()
1633
export class EntityLinkingService {
1734
private readonly logger = new Logger(EntityLinkingService.name);
@@ -57,7 +74,7 @@ export class EntityLinkingService {
5774
}
5875

5976
// Create entity link
60-
const linkData: any = {
77+
const linkData: EntityLinkCreateInput = {
6178
sourceType: dto.sourceType,
6279
sourceId: dto.sourceId,
6380
extractedName: dto.extractedName,
@@ -110,7 +127,7 @@ export class EntityLinkingService {
110127
const limit = query.limit || 20;
111128
const skip = (page - 1) * limit;
112129

113-
const where: any = {};
130+
const where: Prisma.EntityLinkWhereInput = {};
114131

115132
if (query.sourceType) {
116133
where.sourceType = query.sourceType;
@@ -157,7 +174,7 @@ export class EntityLinkingService {
157174
campaignId: string,
158175
entityType?: string,
159176
): Promise<LinkEntityResult[]> {
160-
const where: any = {
177+
const where: Prisma.EntityLinkWhereInput = {
161178
sourceType: 'campaign',
162179
sourceId: campaignId,
163180
};
@@ -181,7 +198,7 @@ export class EntityLinkingService {
181198
claimId: string,
182199
entityType?: string,
183200
): Promise<LinkEntityResult[]> {
184-
const where: any = {
201+
const where: Prisma.EntityLinkWhereInput = {
185202
sourceType: 'claim',
186203
sourceId: claimId,
187204
};
@@ -205,7 +222,7 @@ export class EntityLinkingService {
205222
verificationId: string,
206223
entityType?: string,
207224
): Promise<LinkEntityResult[]> {
208-
const where: any = {
225+
const where: Prisma.EntityLinkWhereInput = {
209226
sourceType: 'verification',
210227
sourceId: verificationId,
211228
};
@@ -275,13 +292,13 @@ export class EntityLinkingService {
275292
id: org.id,
276293
registryId: org.registryId,
277294
name: org.name,
278-
entityType: 'organization',
295+
entityType: 'organization' as const,
279296
confidenceScore:
280297
org.name.toLowerCase() === query.toLowerCase() ? 1.0 : 0.8,
281298
matchMethod:
282299
org.name.toLowerCase() === query.toLowerCase()
283-
? 'exact'
284-
: 'fuzzy',
300+
? 'exact' as const
301+
: 'fuzzy' as const,
285302
})),
286303
);
287304
break;
@@ -305,13 +322,13 @@ export class EntityLinkingService {
305322
id: loc.id,
306323
registryId: loc.registryId,
307324
name: loc.name,
308-
entityType: 'location',
325+
entityType: 'location' as const,
309326
confidenceScore:
310327
loc.name.toLowerCase() === query.toLowerCase() ? 1.0 : 0.75,
311328
matchMethod:
312329
loc.name.toLowerCase() === query.toLowerCase()
313-
? 'exact'
314-
: 'fuzzy',
330+
? 'exact' as const
331+
: 'fuzzy' as const,
315332
})),
316333
);
317334
break;
@@ -334,13 +351,13 @@ export class EntityLinkingService {
334351
id: asset.id,
335352
registryId: asset.registryId,
336353
name: asset.name,
337-
entityType: 'asset',
354+
entityType: 'asset' as const,
338355
confidenceScore:
339356
asset.name.toLowerCase() === query.toLowerCase() ? 1.0 : 0.75,
340357
matchMethod:
341358
asset.name.toLowerCase() === query.toLowerCase()
342-
? 'exact'
343-
: 'fuzzy',
359+
? 'exact' as const
360+
: 'fuzzy' as const,
344361
})),
345362
);
346363
break;
@@ -362,13 +379,13 @@ export class EntityLinkingService {
362379
id: proj.id,
363380
registryId: proj.registryId,
364381
name: proj.name,
365-
entityType: 'project',
382+
entityType: 'project' as const,
366383
confidenceScore:
367384
proj.name.toLowerCase() === query.toLowerCase() ? 1.0 : 0.75,
368385
matchMethod:
369386
proj.name.toLowerCase() === query.toLowerCase()
370-
? 'exact'
371-
: 'fuzzy',
387+
? 'exact' as const
388+
: 'fuzzy' as const,
372389
})),
373390
);
374391
break;
@@ -529,7 +546,7 @@ export class EntityLinkingService {
529546
/**
530547
* Helper: Map Prisma entity link to result DTO
531548
*/
532-
private mapLinkResult(link: any): LinkEntityResult {
549+
private mapLinkResult(link: Prisma.EntityLinkGetPayload<{}>): LinkEntityResult {
533550
return {
534551
id: link.id,
535552
sourceType: link.sourceType,

0 commit comments

Comments
 (0)