Skip to content

Commit ad1fd61

Browse files
committed
Drop IdOf
1 parent a166c9e commit ad1fd61

17 files changed

+38
-48
lines changed

src/common/types/id.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export const isIdLike = (value: unknown): value is ID =>
77
export type ID<Kind extends IDKindLike = any> = Tagged<string, 'ID'> &
88
IDTo<IDTag<Kind>>;
99

10-
/** @deprecated Use {@link ID} */
11-
export type IdOf<Kind extends IDKindLike> = ID<Kind>;
12-
1310
declare const IDTo: unique symbol;
1411
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
1512
type IDTo<T> = { readonly [IDTo]: T };

src/components/file/dto/file.dto.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
DateTimeField,
99
DbLabel,
1010
type ID,
11-
type IdOf,
1211
InputException,
1312
NameField,
1413
Resource,
@@ -169,7 +168,7 @@ export abstract class SecuredFileVersion extends SecuredProperty(FileVersion) {}
169168
*/
170169
export type DefinedFile = Secured<FileId>;
171170

172-
export type FileId = IdOf<'File'>;
171+
export type FileId = ID<'File'>;
173172

174173
export const isDirectory = (node: AnyFileNode): node is Directory =>
175174
node.type === FileNodeType.Directory;

src/components/file/media/media.dto.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
DbLabel,
1414
type ID,
1515
IdField,
16-
type IdOf,
1716
IntersectTypes,
1817
NameField,
1918
ServerException,
@@ -73,7 +72,7 @@ export class Media extends MediaUserMetadata {
7372
@IdField()
7473
readonly id: ID;
7574

76-
readonly file: IdOf<FileVersion>;
75+
readonly file: ID<FileVersion>;
7776

7877
/** The resource that holds the root file node that this media is attached to */
7978
readonly attachedTo: [resource: BaseNode, relation: string];

src/components/file/media/media.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ModuleRef } from '@nestjs/core';
33
import type { RequireAtLeastOne } from 'type-fest';
44
import {
55
createAndInject,
6-
type IdOf,
6+
type ID,
77
NotFoundException,
88
Polls,
99
ServerException,
@@ -31,7 +31,7 @@ export class MediaService {
3131
return null;
3232
}
3333
return await this.repo.save({
34-
file: file.id as IdOf<FileVersion>,
34+
file: file.id as ID<FileVersion>,
3535
mimeType: file.mimeType,
3636
...media,
3737
...metadata,

src/components/location/migrations/default-marketing-region.migration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mapEntries } from '@seedcompany/common';
22
import { node, relation } from 'cypher-query-builder';
33
import { type ValueOf } from 'type-fest';
4-
import { type ID, type IdOf } from '~/common';
4+
import { type ID } from '~/common';
55
import { BaseMigration, Migration } from '~/core/database';
66
import { ACTIVE } from '~/core/database/query';
77
import { type Location } from '../dto';
@@ -40,7 +40,7 @@ export class DefaultMarketingRegionMigration extends BaseMigration {
4040
node('locName', 'LocationName'),
4141
])
4242
.return<{
43-
id: IdOf<Location>;
43+
id: ID<Location>;
4444
name: ValueOf<typeof fieldRegionNameToMarketingRegionName>;
4545
}>(['location.id as id', 'locName.value as name'])
4646
.run();

src/components/progress-report/community-stories/progress-report-community-story.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ResolveField,
66
Resolver,
77
} from '@nestjs/graphql';
8-
import { IdArg, type IdOf } from '~/common';
8+
import { type ID, IdArg } from '~/common';
99
import { Loader, type LoaderOf } from '~/core';
1010
import { PeriodicReportLoader } from '../../periodic-report';
1111
import { type PeriodicReport } from '../../periodic-report/dto';
@@ -55,7 +55,7 @@ export class ProgressReportCommunityStoryResolver {
5555

5656
@Mutation(() => ProgressReport)
5757
async deleteProgressReportCommunityStory(
58-
@IdArg() id: IdOf<PromptVariantResponse>,
58+
@IdArg() id: ID<PromptVariantResponse>,
5959
@Loader(PeriodicReportLoader) reports: LoaderOf<PeriodicReportLoader>,
6060
): Promise<PeriodicReport> {
6161
const response = await this.service.delete(id);

src/components/progress-report/highlights/progress-report-highlights.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ResolveField,
66
Resolver,
77
} from '@nestjs/graphql';
8-
import { IdArg, type IdOf } from '~/common';
8+
import { type ID, IdArg } from '~/common';
99
import { Loader, type LoaderOf } from '~/core';
1010
import { PeriodicReportLoader } from '../../periodic-report';
1111
import { type PeriodicReport } from '../../periodic-report/dto';
@@ -55,7 +55,7 @@ export class ProgressReportHighlightsResolver {
5555

5656
@Mutation(() => ProgressReport)
5757
async deleteProgressReportHighlight(
58-
@IdArg() id: IdOf<PromptVariantResponse>,
58+
@IdArg() id: ID<PromptVariantResponse>,
5959
@Loader(PeriodicReportLoader) reports: LoaderOf<PeriodicReportLoader>,
6060
): Promise<PeriodicReport> {
6161
const response = await this.service.delete(id);

src/components/progress-report/media/dto/media.dto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import { setOf } from '@seedcompany/common';
33
import {
44
EnhancedResource,
5+
type ID,
56
IdField,
6-
type IdOf,
77
Resource,
88
Variant,
99
type VariantOf,
@@ -18,7 +18,7 @@ import { type ProgressReport } from '../../dto';
1818
import { ProgressReportHighlight } from '../../dto/highlights.dto';
1919
import { MediaCategory } from '../media-category.enum';
2020

21-
export type VariantGroup = IdOf<'ProgressReportMediaVariantGroup'>;
21+
export type VariantGroup = ID<'ProgressReportMediaVariantGroup'>;
2222

2323
@RegisterResource({ db: e.ProgressReport.Media })
2424
@InputType({ isAbstract: true })
@@ -41,15 +41,15 @@ export class ProgressReportMedia extends Resource {
4141
ProgressReportHighlight.Variants.slice(-1).map((v) => v.key),
4242
);
4343

44-
readonly report: IdOf<ProgressReport>;
44+
readonly report: ID<ProgressReport>;
4545

4646
@Field(() => Variant)
4747
readonly variant: Variant<MediaVariant> & SetDbType<MediaVariant>;
4848

4949
@Field(() => MediaCategory, { nullable: true })
5050
readonly category?: MediaCategory | null;
5151

52-
readonly media: IdOf<Media>;
52+
readonly media: ID<Media>;
5353
readonly file: FileId;
5454

5555
@IdField()

src/components/progress-report/media/progress-report-media.repository.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
CreationFailed,
55
generateId,
66
type ID,
7-
type IdOf,
87
InputException,
98
NotFoundException,
109
} from '~/common';
@@ -84,7 +83,7 @@ export class ProgressReportMediaRepository extends DtoRepository(ReportMedia) {
8483
.run();
8584
}
8685

87-
async readFeaturedOfReport(ids: ReadonlyArray<IdOf<Report>>) {
86+
async readFeaturedOfReport(ids: ReadonlyArray<ID<Report>>) {
8887
return await this.db
8988
.query()
9089
.matchNode('report', 'ProgressReport')

src/components/progress-report/media/progress-report-media.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@nestjs/common';
22
import {
33
generateId,
4-
type IdOf,
4+
type ID,
55
NotImplementedException,
66
type UnsecuredDto,
77
} from '~/common';
@@ -49,14 +49,14 @@ export class ProgressReportMediaService {
4949
throw new NotImplementedException().with(media);
5050
}
5151

52-
async readMany(ids: ReadonlyArray<IdOf<ReportMedia>>) {
52+
async readMany(ids: ReadonlyArray<ID<ReportMedia>>) {
5353
const row = await this.repo.readMany(ids);
5454
return row.map((row) =>
5555
this.privileges.for(ReportMedia).secure(this.dbRowToDto(row)),
5656
);
5757
}
5858

59-
async readFeaturedOfReport(ids: ReadonlyArray<IdOf<Report>>) {
59+
async readFeaturedOfReport(ids: ReadonlyArray<ID<Report>>) {
6060
const rows = await this.repo.readFeaturedOfReport(ids);
6161
return rows.map((row) =>
6262
this.privileges.for(ReportMedia).secure(this.dbRowToDto(row)),
@@ -109,7 +109,7 @@ export class ProgressReportMediaService {
109109
return updated;
110110
}
111111

112-
async delete(id: IdOf<ReportMedia>) {
112+
async delete(id: ID<ReportMedia>) {
113113
const media = await this.repo.readOne(id);
114114
this.privileges
115115
.for(ReportMedia, this.dbRowToDto(media))

0 commit comments

Comments
 (0)