mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 16:38:23 +01:00
wip!
This commit is contained in:
parent
dd175a8e6e
commit
70740c5e6d
1 changed files with 34 additions and 33 deletions
|
@ -32,20 +32,12 @@ type EventUnionFromMkJSTypes<
|
||||||
> = U[keyof U];
|
> = U[keyof U];
|
||||||
|
|
||||||
//#region Stream type-body definitions
|
//#region Stream type-body definitions
|
||||||
|
|
||||||
// internal
|
|
||||||
export interface InternalStreamTypes {
|
export interface InternalStreamTypes {
|
||||||
antennaCreated: Antenna;
|
antennaCreated: Antenna;
|
||||||
antennaDeleted: Antenna;
|
antennaDeleted: Antenna;
|
||||||
antennaUpdated: Antenna;
|
antennaUpdated: Antenna;
|
||||||
}
|
}
|
||||||
export type InternalStreams = EventUnionFromDictionary<InternalStreamTypes>;
|
|
||||||
|
|
||||||
// broadcast
|
|
||||||
export type BroadcastStreams = EventUnionFromMkJSTypes<StreamTypes.BroadcasrEvents>;
|
|
||||||
|
|
||||||
// user
|
|
||||||
export type UserEventName = `user:${User['id']}`;
|
|
||||||
export interface UserStreamTypes {
|
export interface UserStreamTypes {
|
||||||
terminate: {};
|
terminate: {};
|
||||||
followChannel: Channel;
|
followChannel: Channel;
|
||||||
|
@ -57,10 +49,7 @@ export interface UserStreamTypes {
|
||||||
unfollow: PackedUser;
|
unfollow: PackedUser;
|
||||||
userAdded: PackedUser;
|
userAdded: PackedUser;
|
||||||
}
|
}
|
||||||
export type UserStreams = EventUnionFromDictionary<UserStreamTypes>;
|
|
||||||
|
|
||||||
// main
|
|
||||||
export type mainStreamName = `mainStream:${User['id']}`;
|
|
||||||
export interface MainStreamTypes {
|
export interface MainStreamTypes {
|
||||||
notification: PackedNotification;
|
notification: PackedNotification;
|
||||||
mention: PackedNote;
|
mention: PackedNote;
|
||||||
|
@ -87,10 +76,7 @@ export interface MainStreamTypes {
|
||||||
unreadChannel: never;
|
unreadChannel: never;
|
||||||
myTokenRegenerated: never;
|
myTokenRegenerated: never;
|
||||||
}
|
}
|
||||||
export type mainStreams = EventUnionFromDictionary<MainStreamTypes>;
|
|
||||||
|
|
||||||
// drive
|
|
||||||
export type driveStreamName = `driveStream:${User['id']}`;
|
|
||||||
export interface DriveStreamTypes {
|
export interface DriveStreamTypes {
|
||||||
fileCreated: PackedDriveFile;
|
fileCreated: PackedDriveFile;
|
||||||
fileDeleted: DriveFile['id'];
|
fileDeleted: DriveFile['id'];
|
||||||
|
@ -99,10 +85,7 @@ export interface DriveStreamTypes {
|
||||||
folderDeleted: DriveFolder['id'];
|
folderDeleted: DriveFolder['id'];
|
||||||
folderUpdated: PackedDriveFolder;
|
folderUpdated: PackedDriveFolder;
|
||||||
}
|
}
|
||||||
export type driveStreams= EventUnionFromDictionary<DriveStreamTypes>;
|
|
||||||
|
|
||||||
// note
|
|
||||||
export type noteStreamName = `noteStream:${Note['id']}`;
|
|
||||||
export interface NoteStreamTypes {
|
export interface NoteStreamTypes {
|
||||||
pollVoted: {
|
pollVoted: {
|
||||||
id: Note['id'];
|
id: Note['id'];
|
||||||
|
@ -133,22 +116,40 @@ export interface NoteStreamTypes {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export type noteStreams = EventUnionFromDictionary<NoteStreamTypes>;
|
|
||||||
|
//#endregion
|
||||||
|
//#region 名前とメッセージのペアを中間生成
|
||||||
|
interface StreamMessages {
|
||||||
|
internal: {
|
||||||
|
name: 'internal';
|
||||||
|
spec: EventUnionFromDictionary<InternalStreamTypes>;
|
||||||
|
};
|
||||||
|
broadcast: {
|
||||||
|
name: 'bloadcast';
|
||||||
|
spec: EventUnionFromMkJSTypes<StreamTypes.BroadcasrEvents>;
|
||||||
|
};
|
||||||
|
user: {
|
||||||
|
name: `user:${User['id']}`;
|
||||||
|
spec: EventUnionFromDictionary<UserStreamTypes>;
|
||||||
|
};
|
||||||
|
main: {
|
||||||
|
name: `mainStream:${User['id']}`;
|
||||||
|
spec: EventUnionFromDictionary<MainStreamTypes>;
|
||||||
|
};
|
||||||
|
drive: {
|
||||||
|
name: `driveStream:${User['id']}`;
|
||||||
|
spec: EventUnionFromDictionary<DriveStreamTypes>;
|
||||||
|
};
|
||||||
|
note: {
|
||||||
|
name: `noteStream:${Note['id']}`;
|
||||||
|
spec: EventUnionFromDictionary<NoteStreamTypes>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region API event definitions
|
// API event definitions
|
||||||
interface StreamEvents {
|
type Events<T extends keyof S> = {
|
||||||
'broadcast': (e: BroadcastStreams) => void;
|
[x in S[T]['name']]: (e: S[T]['spec']) => void
|
||||||
'internal': (e: InternalStreams) => void;
|
};
|
||||||
}
|
export type StreamEventEmitter = Emitter<EventEmitter, Events<StreamMessages>>;
|
||||||
|
|
||||||
interface AuthenticatedStreamEvents {
|
|
||||||
[key: UserEventName]: (e: UserStreams) => void;
|
|
||||||
[key: mainStreamName]: (e: mainStreams) => void;
|
|
||||||
[key: driveStreamName]: (e: driveStreams) => void;
|
|
||||||
[key: noteStreamName]: (e: noteStreams) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type StreamEventEmitter = Emitter<EventEmitter, AuthenticatedStreamEvents & StreamEvents>;
|
|
||||||
//#endregion
|
|
||||||
|
|
Loading…
Reference in a new issue