@omujs/chat 0.9.48 → 0.9.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/chat.d.ts +20 -0
- package/dist/dts/const.d.ts +2 -0
- package/dist/dts/event/event-types.d.ts +15 -0
- package/dist/dts/event/event.d.ts +33 -0
- package/{src/event/index.ts → dist/dts/event/index.d.ts} +0 -1
- package/dist/dts/models/author.d.ts +37 -0
- package/dist/dts/models/channel.d.ts +31 -0
- package/dist/dts/models/content.d.ts +24 -0
- package/dist/dts/models/gift.d.ts +23 -0
- package/{src/models/index.ts → dist/dts/models/index.d.ts} +0 -1
- package/dist/dts/models/message.d.ts +40 -0
- package/dist/dts/models/paid.d.ts +11 -0
- package/dist/dts/models/provider.d.ts +34 -0
- package/dist/dts/models/reaction.d.ts +21 -0
- package/dist/dts/models/role.d.ts +26 -0
- package/dist/dts/models/room.d.ts +44 -0
- package/dist/dts/models/vote.d.ts +33 -0
- package/dist/dts/permissions.d.ts +7 -0
- package/dist/esm/chat.js +7976 -0
- package/dist/esm/const.js +5060 -0
- package/dist/esm/event/event-types.js +76 -0
- package/dist/esm/event/event.js +106 -0
- package/dist/esm/event/index.js +115 -0
- package/dist/esm/index.js +8022 -0
- package/dist/esm/models/author.js +5136 -0
- package/dist/esm/models/channel.js +5102 -0
- package/dist/esm/models/content.js +39 -0
- package/dist/esm/models/gift.js +40 -0
- package/dist/esm/models/index.js +5499 -0
- package/dist/esm/models/message.js +5199 -0
- package/dist/esm/models/paid.js +25 -0
- package/dist/esm/models/provider.js +5106 -0
- package/dist/esm/models/reaction.js +5079 -0
- package/dist/esm/models/role.js +44 -0
- package/dist/esm/models/room.js +5102 -0
- package/dist/esm/models/vote.js +5098 -0
- package/dist/esm/permissions.js +5073 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +5 -2
- package/CHANGELOG.md +0 -1831
- package/src/chat.ts +0 -131
- package/src/const.ts +0 -3
- package/src/event/event-types.ts +0 -16
- package/src/event/event.ts +0 -102
- package/src/models/author.ts +0 -72
- package/src/models/channel.ts +0 -67
- package/src/models/content.ts +0 -62
- package/src/models/gift.ts +0 -49
- package/src/models/message.ts +0 -88
- package/src/models/paid.ts +0 -22
- package/src/models/provider.ts +0 -73
- package/src/models/reaction.ts +0 -39
- package/src/models/role.ts +0 -55
- package/src/models/room.ts +0 -82
- package/src/models/vote.ts +0 -67
- package/src/permissions.ts +0 -9
- package/tsconfig.json +0 -15
- /package/{src/index.ts → dist/dts/index.d.ts} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Omu } from '@omujs/omu';
|
|
2
|
+
import type { Signal } from '@omujs/omu/api/signal';
|
|
3
|
+
import type { Table } from '@omujs/omu/api/table';
|
|
4
|
+
import type { EventHandler, EventSource } from './event';
|
|
5
|
+
import { Author, Channel, Message, Provider, Reaction, Room, Vote } from './models';
|
|
6
|
+
export declare class Chat {
|
|
7
|
+
private readonly omu;
|
|
8
|
+
readonly messages: Table<Message>;
|
|
9
|
+
readonly authors: Table<Author>;
|
|
10
|
+
readonly channels: Table<Channel>;
|
|
11
|
+
readonly providers: Table<Provider>;
|
|
12
|
+
readonly rooms: Table<Room>;
|
|
13
|
+
readonly votes: Table<Vote>;
|
|
14
|
+
readonly reactionSignal: Signal<Reaction>;
|
|
15
|
+
private readonly eventRegistry;
|
|
16
|
+
private constructor();
|
|
17
|
+
static create(omu: Omu): Chat;
|
|
18
|
+
createChannelTree(url: string): Promise<Channel[]>;
|
|
19
|
+
on<P extends Array<any>>(event: EventSource<P>, handler: EventHandler<P>): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Author } from '../models/author.js';
|
|
2
|
+
import { Channel } from '../models/channel.js';
|
|
3
|
+
import { Message } from '../models/message.js';
|
|
4
|
+
import { Provider } from '../models/provider.js';
|
|
5
|
+
import { Room } from '../models/room.js';
|
|
6
|
+
import { Vote } from '../models/vote.js';
|
|
7
|
+
import { TableEvent } from './event.js';
|
|
8
|
+
export declare const events: {
|
|
9
|
+
Message: TableEvent<Message>;
|
|
10
|
+
Author: TableEvent<Author>;
|
|
11
|
+
Channel: TableEvent<Channel>;
|
|
12
|
+
Provider: TableEvent<Provider>;
|
|
13
|
+
Room: TableEvent<Room>;
|
|
14
|
+
Vote: TableEvent<Vote>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Table } from '@omujs/omu/api/table';
|
|
2
|
+
import type { Unlisten } from '@omujs/omu/event';
|
|
3
|
+
import { EventEmitter } from '@omujs/omu/event';
|
|
4
|
+
import type { Chat } from '../chat.js';
|
|
5
|
+
export type EventHandler<P extends Array<any>> = (...args: P) => Promise<void> | void;
|
|
6
|
+
export interface EventSource<P extends Array<any>> {
|
|
7
|
+
subscribe(handler: EventHandler<P>, chat: Chat): Unlisten;
|
|
8
|
+
}
|
|
9
|
+
export declare class ListenerEvent<P extends Array<any>> implements EventSource<P> {
|
|
10
|
+
private readonly getListener;
|
|
11
|
+
constructor(getListener: (chat: Chat) => EventEmitter<P>);
|
|
12
|
+
subscribe(handler: EventHandler<P>, chat: Chat): Unlisten;
|
|
13
|
+
}
|
|
14
|
+
export declare class TableEvent<T> extends ListenerEvent<[Map<string, T>]> {
|
|
15
|
+
private readonly getTable;
|
|
16
|
+
readonly AddBatch: ListenerEvent<[Map<string, T>]>;
|
|
17
|
+
readonly UpdateBatch: ListenerEvent<[Map<string, T>]>;
|
|
18
|
+
readonly RemoveBatch: ListenerEvent<[Map<string, T>]>;
|
|
19
|
+
readonly Add: EventSource<[T]>;
|
|
20
|
+
readonly Update: EventSource<[T]>;
|
|
21
|
+
readonly Remove: EventSource<[T]>;
|
|
22
|
+
readonly Clear: EventSource<[]>;
|
|
23
|
+
readonly wrappers: Record<string, Unlisten>;
|
|
24
|
+
constructor(getTable: (chat: Chat) => Table<T>);
|
|
25
|
+
private static createBatchWrapper;
|
|
26
|
+
private createBatchSubscriber;
|
|
27
|
+
}
|
|
28
|
+
export declare class EventRegistry {
|
|
29
|
+
private readonly chat;
|
|
30
|
+
private readonly events;
|
|
31
|
+
constructor(chat: Chat);
|
|
32
|
+
register<P extends Array<any>>(event: EventSource<P>, handler: EventHandler<P>): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
import type { RoleJson } from './role.js';
|
|
3
|
+
import { Role } from './role.js';
|
|
4
|
+
export type AuthorMetadata = {
|
|
5
|
+
url?: string;
|
|
6
|
+
screen_id?: string;
|
|
7
|
+
avatar_url?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
links?: string[];
|
|
10
|
+
};
|
|
11
|
+
export type AuthorJson = {
|
|
12
|
+
provider_id: string;
|
|
13
|
+
id: string;
|
|
14
|
+
metadata: AuthorMetadata;
|
|
15
|
+
name?: string;
|
|
16
|
+
avatar_url?: string;
|
|
17
|
+
roles?: RoleJson[];
|
|
18
|
+
};
|
|
19
|
+
export declare class Author {
|
|
20
|
+
providerId: Identifier;
|
|
21
|
+
id: Identifier;
|
|
22
|
+
metadata: AuthorMetadata;
|
|
23
|
+
name?: string;
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
roles?: Role[];
|
|
26
|
+
constructor(options: {
|
|
27
|
+
providerId: Identifier;
|
|
28
|
+
id: Identifier;
|
|
29
|
+
metadata?: AuthorMetadata;
|
|
30
|
+
name?: string;
|
|
31
|
+
avatarUrl?: string;
|
|
32
|
+
roles?: Role[];
|
|
33
|
+
});
|
|
34
|
+
static deserialize(info: AuthorJson): Author;
|
|
35
|
+
key(): string;
|
|
36
|
+
static serialize(item: Author): AuthorJson;
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export type ChannelJson = {
|
|
3
|
+
provider_id: string;
|
|
4
|
+
id: string;
|
|
5
|
+
url: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
active: boolean;
|
|
9
|
+
icon_url: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class Channel {
|
|
12
|
+
providerId: Identifier;
|
|
13
|
+
id: Identifier;
|
|
14
|
+
url: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
active: boolean;
|
|
18
|
+
iconUrl: string;
|
|
19
|
+
constructor(option: {
|
|
20
|
+
providerId: Identifier;
|
|
21
|
+
id: Identifier;
|
|
22
|
+
url: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
active: boolean;
|
|
26
|
+
iconUrl: string;
|
|
27
|
+
});
|
|
28
|
+
static deserialize(json: ChannelJson): Channel;
|
|
29
|
+
key(): string;
|
|
30
|
+
static serialize(item: Channel): ChannelJson;
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JsonType } from '@omujs/omu/serialize';
|
|
2
|
+
export type ComponentType<T extends string, D extends JsonType = JsonType> = {
|
|
3
|
+
type: T;
|
|
4
|
+
data: D;
|
|
5
|
+
};
|
|
6
|
+
export type Root = ComponentType<'root', Component[]>;
|
|
7
|
+
export type Text = ComponentType<'text', string>;
|
|
8
|
+
export type Image = ComponentType<'image', {
|
|
9
|
+
url: string;
|
|
10
|
+
id: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type Asset = ComponentType<'asset', {
|
|
14
|
+
id: string;
|
|
15
|
+
}>;
|
|
16
|
+
export type Link = ComponentType<'link', {
|
|
17
|
+
url: string;
|
|
18
|
+
children: Component[];
|
|
19
|
+
}>;
|
|
20
|
+
export type System = ComponentType<'system', Component[]>;
|
|
21
|
+
export type Component = Root | Text | Image | Asset | Link | System;
|
|
22
|
+
export declare function children(component: Component): Component[];
|
|
23
|
+
export declare function walk(component: Component): Iterable<Component>;
|
|
24
|
+
export declare function format(component: Component): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type GiftJson = {
|
|
2
|
+
id: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
amount?: number;
|
|
5
|
+
is_paid?: boolean;
|
|
6
|
+
image_url?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class Gift {
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
amount?: number;
|
|
12
|
+
isPaid?: boolean;
|
|
13
|
+
imageUrl?: string;
|
|
14
|
+
constructor(options: {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
amount?: number;
|
|
18
|
+
isPaid?: boolean;
|
|
19
|
+
imageUrl?: string;
|
|
20
|
+
});
|
|
21
|
+
static fromJson(options: GiftJson): Gift;
|
|
22
|
+
toJson(): GiftJson;
|
|
23
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
import * as content from './content.js';
|
|
3
|
+
import type { GiftJson } from './gift.js';
|
|
4
|
+
import { Gift } from './gift.js';
|
|
5
|
+
import type { PaidJson } from './paid.js';
|
|
6
|
+
import { Paid } from './paid.js';
|
|
7
|
+
export type MessageJson = {
|
|
8
|
+
room_id: string;
|
|
9
|
+
id: string;
|
|
10
|
+
created_at: string;
|
|
11
|
+
author_id?: string;
|
|
12
|
+
content?: content.Component;
|
|
13
|
+
paid?: PaidJson;
|
|
14
|
+
gifts?: GiftJson[];
|
|
15
|
+
deleted?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare class Message {
|
|
18
|
+
roomId: Identifier;
|
|
19
|
+
id: Identifier;
|
|
20
|
+
authorId?: Identifier;
|
|
21
|
+
content?: content.Component;
|
|
22
|
+
paid?: Paid;
|
|
23
|
+
gifts?: Gift[];
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
deleted?: boolean;
|
|
26
|
+
constructor(options: {
|
|
27
|
+
roomId: Identifier;
|
|
28
|
+
id: Identifier;
|
|
29
|
+
authorId?: Identifier;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
content?: content.Component;
|
|
32
|
+
paid?: Paid;
|
|
33
|
+
gifts?: Gift[];
|
|
34
|
+
deleted?: boolean;
|
|
35
|
+
});
|
|
36
|
+
static serialize(data: Message): MessageJson;
|
|
37
|
+
static deserialize(info: MessageJson): Message;
|
|
38
|
+
get text(): string;
|
|
39
|
+
key(): string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export type ProviderJson = {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
repository_url: string;
|
|
8
|
+
image_url?: string;
|
|
9
|
+
description: string;
|
|
10
|
+
regex: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class Provider {
|
|
13
|
+
id: Identifier;
|
|
14
|
+
url: string;
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
repositoryUrl: string;
|
|
18
|
+
imageUrl?: string;
|
|
19
|
+
description: string;
|
|
20
|
+
regex: string;
|
|
21
|
+
constructor(options: {
|
|
22
|
+
id: Identifier;
|
|
23
|
+
url: string;
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
repository_url: string;
|
|
27
|
+
image_url?: string;
|
|
28
|
+
description: string;
|
|
29
|
+
regex: string;
|
|
30
|
+
});
|
|
31
|
+
static serialize(item: Provider): ProviderJson;
|
|
32
|
+
static deserialize(data: ProviderJson): Provider;
|
|
33
|
+
key(): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export type ReactionJson = {
|
|
3
|
+
room_id: string;
|
|
4
|
+
reactions: {
|
|
5
|
+
[key: string]: number;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare class Reaction {
|
|
9
|
+
roomId: Identifier;
|
|
10
|
+
reactions: {
|
|
11
|
+
[key: string]: number;
|
|
12
|
+
};
|
|
13
|
+
constructor(options: {
|
|
14
|
+
roomId: Identifier;
|
|
15
|
+
reactions: {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
static deserialize(data: ReactionJson): Reaction;
|
|
20
|
+
static serialize(item: Reaction): ReactionJson;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type RoleJson = {
|
|
2
|
+
id?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
is_owner: boolean;
|
|
5
|
+
is_moderator: boolean;
|
|
6
|
+
icon_url?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class Role {
|
|
10
|
+
id?: string;
|
|
11
|
+
name: string;
|
|
12
|
+
isOwner: boolean;
|
|
13
|
+
isModerator: boolean;
|
|
14
|
+
iconUrl?: string;
|
|
15
|
+
color?: string;
|
|
16
|
+
constructor(options: {
|
|
17
|
+
id?: string;
|
|
18
|
+
name: string;
|
|
19
|
+
isOwner: boolean;
|
|
20
|
+
isModerator: boolean;
|
|
21
|
+
iconUrl?: string;
|
|
22
|
+
color?: string;
|
|
23
|
+
});
|
|
24
|
+
static fromJson(json: RoleJson): Role;
|
|
25
|
+
toJson(): RoleJson;
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export type MetadataJson = {
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
thumbnail?: string;
|
|
7
|
+
viewers?: number;
|
|
8
|
+
created_at?: string;
|
|
9
|
+
started_at?: string;
|
|
10
|
+
ended_at?: string;
|
|
11
|
+
first_message_id?: string;
|
|
12
|
+
last_message_id?: string;
|
|
13
|
+
};
|
|
14
|
+
export type Status = 'online' | 'reserved' | 'offline';
|
|
15
|
+
export type RoomJson = {
|
|
16
|
+
id: string;
|
|
17
|
+
provider_id: string;
|
|
18
|
+
connected: boolean;
|
|
19
|
+
status: Status;
|
|
20
|
+
metadata: MetadataJson;
|
|
21
|
+
channel_id?: string;
|
|
22
|
+
created_at: string;
|
|
23
|
+
};
|
|
24
|
+
export declare class Room {
|
|
25
|
+
id: Identifier;
|
|
26
|
+
providerId: Identifier;
|
|
27
|
+
connected: boolean;
|
|
28
|
+
status: Status;
|
|
29
|
+
metadata: MetadataJson;
|
|
30
|
+
channelId?: string;
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
constructor(options: {
|
|
33
|
+
id: Identifier;
|
|
34
|
+
providerId: Identifier;
|
|
35
|
+
connected: boolean;
|
|
36
|
+
status: Status;
|
|
37
|
+
metadata: MetadataJson;
|
|
38
|
+
channelId?: string;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
});
|
|
41
|
+
static deserialize(options: RoomJson): Room;
|
|
42
|
+
static serialize(item: Room): RoomJson;
|
|
43
|
+
key(): string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export type Choice = {
|
|
3
|
+
text: string;
|
|
4
|
+
ratio: number;
|
|
5
|
+
count?: number;
|
|
6
|
+
};
|
|
7
|
+
export type VoteJson = {
|
|
8
|
+
id: string;
|
|
9
|
+
room_id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
choices: Choice[];
|
|
12
|
+
ended: boolean;
|
|
13
|
+
total: number | null;
|
|
14
|
+
};
|
|
15
|
+
export declare class Vote {
|
|
16
|
+
readonly id: Identifier;
|
|
17
|
+
readonly roomId: Identifier;
|
|
18
|
+
title: string;
|
|
19
|
+
choices: Choice[];
|
|
20
|
+
ended: boolean;
|
|
21
|
+
total: number | null;
|
|
22
|
+
constructor(options: {
|
|
23
|
+
id: Identifier;
|
|
24
|
+
roomId: Identifier;
|
|
25
|
+
title: string;
|
|
26
|
+
choices: Choice[];
|
|
27
|
+
ended: boolean;
|
|
28
|
+
total: number | null;
|
|
29
|
+
});
|
|
30
|
+
static deserialize(options: VoteJson): Vote;
|
|
31
|
+
static serialize(item: Vote): VoteJson;
|
|
32
|
+
key(): string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Identifier } from '@omujs/omu';
|
|
2
|
+
export declare const CHAT_PERMISSION_ID: Identifier;
|
|
3
|
+
export declare const CHAT_READ_PERMISSION_ID: Identifier;
|
|
4
|
+
export declare const CHAT_WRITE_PERMISSION_ID: Identifier;
|
|
5
|
+
export declare const CHAT_SEND_PERMISSION_ID: Identifier;
|
|
6
|
+
export declare const CHAT_CHANNEL_TREE_PERMISSION_ID: Identifier;
|
|
7
|
+
export declare const CHAT_REACTION_PERMISSION_ID: Identifier;
|