Skip to content

Commit 7bb5e0e

Browse files
committed
Convert ProgressReport workflow transition name to a runtime enum
1 parent 945ae18 commit 7bb5e0e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components/progress-report/workflow/transitions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { mapValues } from '@seedcompany/common';
1+
import { entries, mapValues } from '@seedcompany/common';
2+
import { EnumType, makeEnum } from '@seedcompany/nest';
23
import { createHash } from 'crypto';
34
import { ID, Many, maybeMany, Role } from '~/common';
45
import { TransitionType as Type } from '../../workflow/dto';
@@ -90,7 +91,8 @@ type TransitionInput = Omit<PublicTransition, 'id'> & {
9091
};
9192
};
9293

93-
export type TransitionName = keyof typeof Transitions;
94+
export type TransitionName = EnumType<typeof TransitionName>;
95+
export const TransitionName = makeEnum(entries(Transitions).map(([k]) => k));
9496

9597
export interface InternalTransition extends PublicTransition {
9698
id: ID;

src/core/config/config.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import { Duration, DurationLike } from 'luxon';
99
import { nanoid } from 'nanoid';
1010
import { Config as Neo4JDriverConfig } from 'neo4j-driver';
1111
import { BehaviorSubject } from 'rxjs';
12-
import { keys as keysOf } from 'ts-transformer-keys';
1312
import { Class, Merge, ReadonlyDeep } from 'type-fest';
1413
import { ID } from '~/common';
1514
import { parseUri } from '../../components/file/bucket/parse-uri';
1615
import { ProgressReportStatus } from '../../components/progress-report/dto/progress-report-status.enum';
17-
import type { TransitionName as ProgressReportTransitionName } from '../../components/progress-report/workflow/transitions';
16+
import { TransitionName as ProgressReportTransitionName } from '../../components/progress-report/workflow/transitions';
1817
import { DefaultTimezoneWrapper } from '../email/templates/formatted-date-time';
1918
import { FrontendUrlWrapper } from '../email/templates/frontend-url';
2019
import type { CookieOptions, CorsOptions, IRequest } from '../http';
@@ -133,7 +132,7 @@ export const makeConfig = (env: EnvironmentService) =>
133132
notifyExtraEmails: {
134133
forTransitions: env
135134
.map('PROGRESS_REPORT_EMAILS_FOR_TRANSITIONS', {
136-
parseKey: keysOf<Record<ProgressReportTransitionName, ''>>(),
135+
parseKey: ProgressReportTransitionName,
137136
parseValue: csv,
138137
})
139138
.optional({}),

0 commit comments

Comments
 (0)