Skip to content

Commit d309f04

Browse files
committed
feat: Support declaration merging in v1 and v2 entities
1 parent 848552f commit d309f04

24 files changed

+229
-115
lines changed

src/mastodon/entities/v1/account-warning.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import { type Account } from "./account.js";
22
import { type Appeal } from "./appeal.js";
33

4+
interface AccountWarningActionRegistry {
5+
none: never;
6+
disable: never;
7+
mark_statuses_as_sensitive: never;
8+
delete_statuses: never;
9+
sensitive: never;
10+
silence: never;
11+
suspend: never;
12+
}
13+
14+
export type AccountWarningAction = keyof AccountWarningActionRegistry;
15+
416
/**
517
* Moderation warning against a particular account.
618
*/
@@ -20,12 +32,3 @@ export interface AccountWarning {
2032
/** When the event took place. */
2133
createdAt: string;
2234
}
23-
24-
export type AccountWarningAction =
25-
| "none"
26-
| "disable"
27-
| "mark_statuses_as_sensitive"
28-
| "delete_statuses"
29-
| "sensitive"
30-
| "silence"
31-
| "suspend";

src/mastodon/entities/v1/admin/cohort.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export type CohortFrequency = "day" | "month";
1+
interface CohortFrequencyRegistry {
2+
day: never;
3+
month: never;
4+
}
5+
6+
export type CohortFrequency = keyof CohortFrequencyRegistry;
27

38
export interface CohortData {
49
/** The timestamp for the start of the bucket, at midnight. */

src/mastodon/entities/v1/admin/dimension.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ export interface DimensionData {
1111
humanValue?: string | null;
1212
}
1313

14-
export type DimensionKey =
15-
| "languages"
16-
| "sources"
17-
| "servers"
18-
| "space_usage"
19-
| "software_versions"
20-
| "tag_servers"
21-
| "tag_languages"
22-
| "instance_accounts"
23-
| "instance_languages";
14+
interface DimensionKeyRegistry {
15+
languages: never;
16+
sources: never;
17+
servers: never;
18+
space_usage: never;
19+
software_versions: never;
20+
tag_servers: never;
21+
tag_languages: never;
22+
instance_accounts: never;
23+
instance_languages: never;
24+
}
25+
26+
export type DimensionKey = keyof DimensionKeyRegistry;
2427

2528
/**
2629
* Represents qualitative data about the server.

src/mastodon/entities/v1/admin/domain-block.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
export type DomainBlockSeverity = "silence" | "suspend" | "noop";
1+
interface DomainBlockSeverityRegistry {
2+
silence: never;
3+
suspend: never;
4+
noop: never;
5+
}
6+
7+
export type DomainBlockSeverity = keyof DomainBlockSeverityRegistry;
28

39
export interface DomainBlock {
410
/** The ID of the domain block in the database. */

src/mastodon/entities/v1/admin/ip-block.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
export type IpBlockSeverity =
2-
| "sign_up_requires_approval"
3-
| "sign_up_block"
4-
| "no_access";
1+
interface IpBlockSeverityRegistry {
2+
sign_up_requires_approval: never;
3+
sign_up_block: never;
4+
no_access: never;
5+
}
6+
7+
export type IpBlockSeverity = keyof IpBlockSeverityRegistry;
58

69
export interface IpBlock {
710
/** The ID of the domain allow in the database. */

src/mastodon/entities/v1/admin/measure.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ export interface MeasureData {
55
value: string;
66
}
77

8+
interface MeasureKeyRegistry {
9+
active_users: never;
10+
new_users: never;
11+
interactions: never;
12+
opened_reports: never;
13+
resolved_reports: never;
14+
tag_accounts: never;
15+
tag_uses: never;
16+
tag_servers: never;
17+
instance_accounts: never;
18+
instance_media_attachments: never;
19+
instance_reports: never;
20+
instance_statuses: never;
21+
instance_follows: never;
22+
instance_followers: never;
23+
}
24+
825
/** @see https://docs.joinmastodon.org/entities/Admin_Measure/#key */
9-
export type MeasureKey =
10-
| "active_users"
11-
| "new_users"
12-
| "interactions"
13-
| "opened_reports"
14-
| "resolved_reports"
15-
| "tag_accounts"
16-
| "tag_uses"
17-
| "tag_servers"
18-
| "instance_accounts"
19-
| "instance_media_attachments"
20-
| "instance_reports"
21-
| "instance_statuses"
22-
| "instance_follows"
23-
| "instance_followers";
26+
export type MeasureKey = keyof MeasureKeyRegistry;
2427

2528
/**
2629
* Represents quantitative data about the server.

src/mastodon/entities/v1/appeal.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
interface AppealStateRegistry {
2+
approved: never;
3+
rejected: never;
4+
pending: never;
5+
}
6+
7+
export type AppealState = keyof AppealStateRegistry;
8+
19
/**
210
* Appeal against a moderation action.
311
*/
@@ -7,5 +15,3 @@ export interface Appeal {
715
/** State of the appeal. */
816
state: AppealState;
917
}
10-
11-
export type AppealState = "approved" | "rejected" | "pending";

src/mastodon/entities/v1/domain-block.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
interface DomainBlockSeverityRegistry {
2+
silence: never;
3+
suspend: never;
4+
}
5+
6+
export type DomainBlockSeverity = keyof DomainBlockSeverityRegistry;
7+
18
/**
29
* Represents a domain that is blocked by the instance.
310
*/
@@ -11,5 +18,3 @@ export interface DomainBlock {
1118
/** An optional reason for the domain block. */
1219
comment?: string | null;
1320
}
14-
15-
export type DomainBlockSeverity = "silence" | "suspend";

src/mastodon/entities/v1/filter.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
export type FilterContext =
2-
| "home"
3-
| "notifications"
4-
| "public"
5-
| "thread"
6-
| "account";
1+
interface FilterContextRegistry {
2+
home: never;
3+
notifications: never;
4+
public: never;
5+
thread: never;
6+
account: never;
7+
}
8+
9+
export type FilterContext = keyof FilterContextRegistry;
710

811
/**
912
* Represents a user-defined filter for determining which statuses should not be shown to the user.

src/mastodon/entities/v1/grouped-notifications.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,22 @@ export type SeveredRelationshipsNotificationGroup =
112112
export type ModerationWarningNotificationGroup =
113113
NotificationGroupWithModerationWarning<"moderation_warning">;
114114

115+
interface NotificationGroupRegistry {
116+
mention: MentionNotificationGroup;
117+
status: StatusNotificationGroup;
118+
reblog: ReblogNotificationGroup;
119+
follow: FollowNotificationGroup;
120+
follow_request: FollowRequestNotificationGroup;
121+
favourite: FavouriteNotificationGroup;
122+
poll: PollNotificationGroup;
123+
update: UpdateNotificationGroup;
124+
"admin.sign_up": AdminSignUpNotificationGroup;
125+
"admin.report": AdminReportNotificationGroup;
126+
severed_relationships: SeveredRelationshipsNotificationGroup;
127+
moderation_warning: ModerationWarningNotificationGroup;
128+
}
129+
115130
/** Group key identifying the grouped notifications. Should be treated as an opaque value. */
116131
export type NotificationGroup =
117-
| MentionNotificationGroup
118-
| StatusNotificationGroup
119-
| ReblogNotificationGroup
120-
| FollowNotificationGroup
121-
| FollowRequestNotificationGroup
122-
| FavouriteNotificationGroup
123-
| PollNotificationGroup
124-
| UpdateNotificationGroup
125-
| AdminSignUpNotificationGroup
126-
| AdminReportNotificationGroup
127-
| SeveredRelationshipsNotificationGroup
128-
| ModerationWarningNotificationGroup;
129-
132+
NotificationGroupRegistry[keyof NotificationGroupRegistry];
130133
export type NotificationGroupType = NotificationGroup["type"];

0 commit comments

Comments
 (0)