Skip to content

Commit

Permalink
refactor: 型合わせ
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective committed Jul 18, 2024
1 parent 67072e3 commit c22dd63
Showing 1 changed file with 55 additions and 40 deletions.
95 changes: 55 additions & 40 deletions packages/misskey-js/src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import type {
AbuseReportNotificationRecipient, Ad,
Announcement,
EmojiDetailed, InviteCode,
MetaDetailed,
Note,
Role, SystemWebhook, UserLite
} from "./autogen/models.js";
import { operations } from './autogen/types.js';

export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'roleAssigned', 'achievementEarned'] as const;

export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;
Expand Down Expand Up @@ -135,12 +145,18 @@ export const moderationLogTypes = [
'unsetUserBanner',
] as const;

type AvatarDecoration = UserLite['avatarDecorations'][number];

type ReceivedAbuseReport = {
reportId: AbuseReportNotificationRecipient['id'];
report: operations['admin___abuse-user-reports']['responses'][200]['content']['application/json'];
forwarded: boolean;
};

export type ModerationLogPayloads = {
updateServerSettings: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
before: any | null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
after: any | null;
before: MetaDetailed | null;
after: MetaDetailed | null;
};
suspend: {
userId: string;
Expand All @@ -161,17 +177,16 @@ export type ModerationLogPayloads = {
};
addCustomEmoji: {
emojiId: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
emoji: any;
emoji: EmojiDetailed;
};
updateCustomEmoji: {
emojiId: string;
before: any;
after: any;
before: EmojiDetailed;
after: EmojiDetailed;
};
deleteCustomEmoji: {
emojiId: string;
emoji: any;
emoji: EmojiDetailed;
};
assignRole: {
userId: string;
Expand All @@ -190,16 +205,16 @@ export type ModerationLogPayloads = {
};
createRole: {
roleId: string;
role: any;
role: Role;
};
updateRole: {
roleId: string;
before: any;
after: any;
before: Role;
after: Role;
};
deleteRole: {
roleId: string;
role: any;
role: Role;
};
clearQueue: Record<string, never>;
promoteQueue: Record<string, never>;
Expand All @@ -214,39 +229,39 @@ export type ModerationLogPayloads = {
noteUserId: string;
noteUserUsername: string;
noteUserHost: string | null;
note: any;
note: Note;
};
createGlobalAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
};
createUserAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
};
updateGlobalAnnouncement: {
announcementId: string;
before: any;
after: any;
before: Announcement;
after: Announcement;
};
updateUserAnnouncement: {
announcementId: string;
before: any;
after: any;
before: Announcement;
after: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
};
deleteGlobalAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
};
deleteUserAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
Expand Down Expand Up @@ -284,37 +299,37 @@ export type ModerationLogPayloads = {
};
resolveAbuseReport: {
reportId: string;
report: any;
report: ReceivedAbuseReport;
forwarded: boolean;
};
createInvitation: {
invitations: any[];
invitations: InviteCode[];
};
createAd: {
adId: string;
ad: any;
ad: Ad;
};
updateAd: {
adId: string;
before: any;
after: any;
before: Ad;
after: Ad;
};
deleteAd: {
adId: string;
ad: any;
ad: Ad;
};
createAvatarDecoration: {
avatarDecorationId: string;
avatarDecoration: any;
avatarDecoration: AvatarDecoration;
};
updateAvatarDecoration: {
avatarDecorationId: string;
before: any;
after: any;
before: AvatarDecoration;
after: AvatarDecoration;
};
deleteAvatarDecoration: {
avatarDecorationId: string;
avatarDecoration: any;
avatarDecoration: AvatarDecoration;
};
unsetUserAvatar: {
userId: string;
Expand All @@ -330,28 +345,28 @@ export type ModerationLogPayloads = {
};
createSystemWebhook: {
systemWebhookId: string;
webhook: any;
webhook: SystemWebhook;
};
updateSystemWebhook: {
systemWebhookId: string;
before: any;
after: any;
before: SystemWebhook;
after: SystemWebhook;
};
deleteSystemWebhook: {
systemWebhookId: string;
webhook: any;
webhook: SystemWebhook;
};
createAbuseReportNotificationRecipient: {
recipientId: string;
recipient: any;
recipient: AbuseReportNotificationRecipient;
};
updateAbuseReportNotificationRecipient: {
recipientId: string;
before: any;
after: any;
before: AbuseReportNotificationRecipient;
after: AbuseReportNotificationRecipient;
};
deleteAbuseReportNotificationRecipient: {
recipientId: string;
recipient: any;
recipient: AbuseReportNotificationRecipient;
};
};

0 comments on commit c22dd63

Please sign in to comment.