forked from mirror/misskey
refactor: fix type
This commit is contained in:
parent
7c3143b8e5
commit
d9d98f84bf
@ -18,31 +18,26 @@ import { Following, Role, RoleAssignment } from '@/models';
|
|||||||
import type Emitter from 'strict-event-emitter-types';
|
import type Emitter from 'strict-event-emitter-types';
|
||||||
import type { EventEmitter } from 'events';
|
import type { EventEmitter } from 'events';
|
||||||
|
|
||||||
// redis通すとDateのインスタンスはstringに変換されるので
|
|
||||||
type Serialized<T> = {
|
|
||||||
[K in keyof T]: T[K] extends Date ? string : T[K];
|
|
||||||
};
|
|
||||||
|
|
||||||
//#region Stream type-body definitions
|
//#region Stream type-body definitions
|
||||||
export interface InternalStreamTypes {
|
export interface InternalStreamTypes {
|
||||||
userChangeSuspendedState: Serialized<{ id: User['id']; isSuspended: User['isSuspended']; }>;
|
userChangeSuspendedState: { id: User['id']; isSuspended: User['isSuspended']; };
|
||||||
userTokenRegenerated: Serialized<{ id: User['id']; oldToken: User['token']; newToken: User['token']; }>;
|
userTokenRegenerated: { id: User['id']; oldToken: User['token']; newToken: User['token']; };
|
||||||
remoteUserUpdated: Serialized<{ id: User['id']; }>;
|
remoteUserUpdated: { id: User['id']; };
|
||||||
follow: Serialized<{ followerId: User['id']; followeeId: User['id']; }>;
|
follow: { followerId: User['id']; followeeId: User['id']; };
|
||||||
unfollow: Serialized<{ followerId: User['id']; followeeId: User['id']; }>;
|
unfollow: { followerId: User['id']; followeeId: User['id']; };
|
||||||
policiesUpdated: Serialized<Role['policies']>;
|
policiesUpdated: Role['policies'];
|
||||||
roleCreated: Serialized<Role>;
|
roleCreated: Role;
|
||||||
roleDeleted: Serialized<Role>;
|
roleDeleted: Role;
|
||||||
roleUpdated: Serialized<Role>;
|
roleUpdated: Role;
|
||||||
userRoleAssigned: Serialized<RoleAssignment>;
|
userRoleAssigned: RoleAssignment;
|
||||||
userRoleUnassigned: Serialized<RoleAssignment>;
|
userRoleUnassigned: RoleAssignment;
|
||||||
webhookCreated: Serialized<Webhook>;
|
webhookCreated: Webhook;
|
||||||
webhookDeleted: Serialized<Webhook>;
|
webhookDeleted: Webhook;
|
||||||
webhookUpdated: Serialized<Webhook>;
|
webhookUpdated: Webhook;
|
||||||
antennaCreated: Serialized<Antenna>;
|
antennaCreated: Antenna;
|
||||||
antennaDeleted: Serialized<Antenna>;
|
antennaDeleted: Antenna;
|
||||||
antennaUpdated: Serialized<Antenna>;
|
antennaUpdated: Antenna;
|
||||||
metaUpdated: Serialized<Meta>;
|
metaUpdated: Meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BroadcastTypes {
|
export interface BroadcastTypes {
|
||||||
@ -210,63 +205,72 @@ type EventUnionFromDictionary<
|
|||||||
U = Events<T>
|
U = Events<T>
|
||||||
> = U[keyof U];
|
> = U[keyof U];
|
||||||
|
|
||||||
|
// redis通すとDateのインスタンスはstringに変換されるので
|
||||||
|
type Serialized<T> = {
|
||||||
|
[K in keyof T]: T[K] extends Date ? string : T[K] extends Record<string, any> ? Serialized<T[K]> : T[K];
|
||||||
|
};
|
||||||
|
|
||||||
|
type SerializedAll<T> = {
|
||||||
|
[K in keyof T]: Serialized<T[K]>;
|
||||||
|
};
|
||||||
|
|
||||||
// name/messages(spec) pairs dictionary
|
// name/messages(spec) pairs dictionary
|
||||||
export type StreamMessages = {
|
export type StreamMessages = {
|
||||||
internal: {
|
internal: {
|
||||||
name: 'internal';
|
name: 'internal';
|
||||||
payload: EventUnionFromDictionary<InternalStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<InternalStreamTypes>>;
|
||||||
};
|
};
|
||||||
broadcast: {
|
broadcast: {
|
||||||
name: 'broadcast';
|
name: 'broadcast';
|
||||||
payload: EventUnionFromDictionary<BroadcastTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<BroadcastTypes>>;
|
||||||
};
|
};
|
||||||
user: {
|
user: {
|
||||||
name: `user:${User['id']}`;
|
name: `user:${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<UserStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<UserStreamTypes>>;
|
||||||
};
|
};
|
||||||
main: {
|
main: {
|
||||||
name: `mainStream:${User['id']}`;
|
name: `mainStream:${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<MainStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<MainStreamTypes>>;
|
||||||
};
|
};
|
||||||
drive: {
|
drive: {
|
||||||
name: `driveStream:${User['id']}`;
|
name: `driveStream:${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<DriveStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<DriveStreamTypes>>;
|
||||||
};
|
};
|
||||||
note: {
|
note: {
|
||||||
name: `noteStream:${Note['id']}`;
|
name: `noteStream:${Note['id']}`;
|
||||||
payload: EventUnionFromDictionary<NoteStreamEventTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<NoteStreamEventTypes>>;
|
||||||
};
|
};
|
||||||
channel: {
|
channel: {
|
||||||
name: `channelStream:${Channel['id']}`;
|
name: `channelStream:${Channel['id']}`;
|
||||||
payload: EventUnionFromDictionary<ChannelStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<ChannelStreamTypes>>;
|
||||||
};
|
};
|
||||||
userList: {
|
userList: {
|
||||||
name: `userListStream:${UserList['id']}`;
|
name: `userListStream:${UserList['id']}`;
|
||||||
payload: EventUnionFromDictionary<UserListStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<UserListStreamTypes>>;
|
||||||
};
|
};
|
||||||
antenna: {
|
antenna: {
|
||||||
name: `antennaStream:${Antenna['id']}`;
|
name: `antennaStream:${Antenna['id']}`;
|
||||||
payload: EventUnionFromDictionary<AntennaStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<AntennaStreamTypes>>;
|
||||||
};
|
};
|
||||||
messaging: {
|
messaging: {
|
||||||
name: `messagingStream:${User['id']}-${User['id']}`;
|
name: `messagingStream:${User['id']}-${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<MessagingStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<MessagingStreamTypes>>;
|
||||||
};
|
};
|
||||||
groupMessaging: {
|
groupMessaging: {
|
||||||
name: `messagingStream:${UserGroup['id']}`;
|
name: `messagingStream:${UserGroup['id']}`;
|
||||||
payload: EventUnionFromDictionary<GroupMessagingStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<GroupMessagingStreamTypes>>;
|
||||||
};
|
};
|
||||||
messagingIndex: {
|
messagingIndex: {
|
||||||
name: `messagingIndexStream:${User['id']}`;
|
name: `messagingIndexStream:${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<MessagingIndexStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<MessagingIndexStreamTypes>>;
|
||||||
};
|
};
|
||||||
admin: {
|
admin: {
|
||||||
name: `adminStream:${User['id']}`;
|
name: `adminStream:${User['id']}`;
|
||||||
payload: EventUnionFromDictionary<AdminStreamTypes>;
|
payload: EventUnionFromDictionary<SerializedAll<AdminStreamTypes>>;
|
||||||
};
|
};
|
||||||
notes: {
|
notes: {
|
||||||
name: 'notesStream';
|
name: 'notesStream';
|
||||||
payload: Packed<'Note'>;
|
payload: Serialized<Packed<'Note'>>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user