mezon-js 2.9.1 → 2.9.4
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/api.gen.ts +2 -0
- package/dist/api.gen.d.ts +1 -0
- package/dist/mezon-js.cjs.js +18 -6
- package/dist/mezon-js.esm.mjs +18 -6
- package/dist/socket.d.ts +9 -4
- package/dist/web_socket_adapter.d.ts +2 -2
- package/package.json +1 -1
- package/socket.ts +17 -6
- package/web_socket_adapter.ts +17 -13
package/api.gen.ts
CHANGED
@@ -1638,6 +1638,8 @@ export interface ApiUpdateRoleChannelRequest {
|
|
1638
1638
|
permission_update?: Array<ApiPermissionUpdate>;
|
1639
1639
|
//The ID of the role to update.
|
1640
1640
|
role_id?: string;
|
1641
|
+
//
|
1642
|
+
user_id?: string;
|
1641
1643
|
}
|
1642
1644
|
|
1643
1645
|
/** Fetch a batch of zero or more users from the server. */
|
package/dist/api.gen.d.ts
CHANGED
@@ -949,6 +949,7 @@ export interface ApiUpdateRoleChannelRequest {
|
|
949
949
|
max_permission_id: string;
|
950
950
|
permission_update?: Array<ApiPermissionUpdate>;
|
951
951
|
role_id?: string;
|
952
|
+
user_id?: string;
|
952
953
|
}
|
953
954
|
/** Fetch a batch of zero or more users from the server. */
|
954
955
|
export interface ApiUpdateUsersRequest {
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -4916,12 +4916,18 @@ var WebSocketAdapterText = class {
|
|
4916
4916
|
var _a;
|
4917
4917
|
return ((_a = this._socket) == null ? void 0 : _a.readyState) == WebSocket.OPEN;
|
4918
4918
|
}
|
4919
|
-
connect(scheme, host, port, createStatus, token) {
|
4919
|
+
connect(scheme, host, port, createStatus, token, signal) {
|
4920
|
+
if (signal) {
|
4921
|
+
signal.addEventListener("abort", () => {
|
4922
|
+
this.close();
|
4923
|
+
});
|
4924
|
+
}
|
4920
4925
|
const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
|
4921
4926
|
this._socket = new WebSocket(url);
|
4922
4927
|
}
|
4923
4928
|
close() {
|
4924
|
-
|
4929
|
+
var _a;
|
4930
|
+
(_a = this._socket) == null ? void 0 : _a.close();
|
4925
4931
|
this._socket = void 0;
|
4926
4932
|
}
|
4927
4933
|
send(msg) {
|
@@ -4959,12 +4965,12 @@ var _DefaultSocket = class _DefaultSocket {
|
|
4959
4965
|
isOpen() {
|
4960
4966
|
return this.adapter.isOpen();
|
4961
4967
|
}
|
4962
|
-
connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs) {
|
4968
|
+
connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs, signal) {
|
4963
4969
|
if (this.adapter.isOpen()) {
|
4964
4970
|
return Promise.resolve(session);
|
4965
4971
|
}
|
4966
4972
|
const scheme = this.useSSL ? "wss://" : "ws://";
|
4967
|
-
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
|
4973
|
+
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
|
4968
4974
|
this.adapter.onClose = (evt) => {
|
4969
4975
|
this.ondisconnect(evt);
|
4970
4976
|
};
|
@@ -5537,15 +5543,21 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5537
5543
|
return response.all_user_clans;
|
5538
5544
|
});
|
5539
5545
|
}
|
5546
|
+
listUsersAddChannelByChannelId(channelId, limit) {
|
5547
|
+
return __async(this, null, function* () {
|
5548
|
+
const response = yield this.send({ all_users_add_channel_event: { channel_id: channelId, limit } });
|
5549
|
+
return response.all_users_add_channel_event;
|
5550
|
+
});
|
5551
|
+
}
|
5540
5552
|
hashtagDMList(user_id, limit) {
|
5541
5553
|
return __async(this, null, function* () {
|
5542
5554
|
const response = yield this.send({ hashtag_dm_list_event: { user_id, limit } });
|
5543
5555
|
return response.hashtag_dm_list_event;
|
5544
5556
|
});
|
5545
5557
|
}
|
5546
|
-
getPermissionByRoleIdChannelId(role_id, channel_id) {
|
5558
|
+
getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
|
5547
5559
|
return __async(this, null, function* () {
|
5548
|
-
const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
|
5560
|
+
const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id, user_id } });
|
5549
5561
|
return response.permission_role_channel_list_event;
|
5550
5562
|
});
|
5551
5563
|
}
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -4887,12 +4887,18 @@ var WebSocketAdapterText = class {
|
|
4887
4887
|
var _a;
|
4888
4888
|
return ((_a = this._socket) == null ? void 0 : _a.readyState) == WebSocket.OPEN;
|
4889
4889
|
}
|
4890
|
-
connect(scheme, host, port, createStatus, token) {
|
4890
|
+
connect(scheme, host, port, createStatus, token, signal) {
|
4891
|
+
if (signal) {
|
4892
|
+
signal.addEventListener("abort", () => {
|
4893
|
+
this.close();
|
4894
|
+
});
|
4895
|
+
}
|
4891
4896
|
const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
|
4892
4897
|
this._socket = new WebSocket(url);
|
4893
4898
|
}
|
4894
4899
|
close() {
|
4895
|
-
|
4900
|
+
var _a;
|
4901
|
+
(_a = this._socket) == null ? void 0 : _a.close();
|
4896
4902
|
this._socket = void 0;
|
4897
4903
|
}
|
4898
4904
|
send(msg) {
|
@@ -4930,12 +4936,12 @@ var _DefaultSocket = class _DefaultSocket {
|
|
4930
4936
|
isOpen() {
|
4931
4937
|
return this.adapter.isOpen();
|
4932
4938
|
}
|
4933
|
-
connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs) {
|
4939
|
+
connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs, signal) {
|
4934
4940
|
if (this.adapter.isOpen()) {
|
4935
4941
|
return Promise.resolve(session);
|
4936
4942
|
}
|
4937
4943
|
const scheme = this.useSSL ? "wss://" : "ws://";
|
4938
|
-
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
|
4944
|
+
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
|
4939
4945
|
this.adapter.onClose = (evt) => {
|
4940
4946
|
this.ondisconnect(evt);
|
4941
4947
|
};
|
@@ -5508,15 +5514,21 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5508
5514
|
return response.all_user_clans;
|
5509
5515
|
});
|
5510
5516
|
}
|
5517
|
+
listUsersAddChannelByChannelId(channelId, limit) {
|
5518
|
+
return __async(this, null, function* () {
|
5519
|
+
const response = yield this.send({ all_users_add_channel_event: { channel_id: channelId, limit } });
|
5520
|
+
return response.all_users_add_channel_event;
|
5521
|
+
});
|
5522
|
+
}
|
5511
5523
|
hashtagDMList(user_id, limit) {
|
5512
5524
|
return __async(this, null, function* () {
|
5513
5525
|
const response = yield this.send({ hashtag_dm_list_event: { user_id, limit } });
|
5514
5526
|
return response.hashtag_dm_list_event;
|
5515
5527
|
});
|
5516
5528
|
}
|
5517
|
-
getPermissionByRoleIdChannelId(role_id, channel_id) {
|
5529
|
+
getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
|
5518
5530
|
return __async(this, null, function* () {
|
5519
|
-
const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
|
5531
|
+
const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id, user_id } });
|
5520
5532
|
return response.permission_role_channel_list_event;
|
5521
5533
|
});
|
5522
5534
|
}
|
package/dist/socket.d.ts
CHANGED
@@ -462,6 +462,9 @@ export interface RoleEvent {
|
|
462
462
|
status: number;
|
463
463
|
user_id: string;
|
464
464
|
}
|
465
|
+
export interface AllUsersAddChannelEvent {
|
466
|
+
user_ids: Array<string>;
|
467
|
+
}
|
465
468
|
export interface EventEmoji {
|
466
469
|
id: string;
|
467
470
|
clan_id: string;
|
@@ -639,7 +642,7 @@ export interface Socket {
|
|
639
642
|
/** Connection is Open */
|
640
643
|
isOpen(): boolean;
|
641
644
|
/** Connect to the server. */
|
642
|
-
connect(session: Session, createStatus: boolean): Promise<Session>;
|
645
|
+
connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
643
646
|
/** Disconnect from the server. */
|
644
647
|
disconnect(fireDisconnectEvent: boolean): void;
|
645
648
|
/** Subscribe to one or more users for their status updates. */
|
@@ -739,12 +742,13 @@ export interface Socket {
|
|
739
742
|
listStickersByUserId(): Promise<StrickerListedEvent>;
|
740
743
|
listChannelByUserId(): Promise<ChannelDescListEvent>;
|
741
744
|
listUserClansByUserId(): Promise<AllUserClans>;
|
745
|
+
listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
|
742
746
|
hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
|
743
747
|
getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
|
744
748
|
getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
|
745
749
|
getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
|
746
750
|
getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
|
747
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
751
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
748
752
|
getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
|
749
753
|
oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
|
750
754
|
oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
|
@@ -779,7 +783,7 @@ export declare class DefaultSocket implements Socket {
|
|
779
783
|
constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number);
|
780
784
|
generatecid(): string;
|
781
785
|
isOpen(): boolean;
|
782
|
-
connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number): Promise<Session>;
|
786
|
+
connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
783
787
|
disconnect(fireDisconnectEvent?: boolean): void;
|
784
788
|
setHeartbeatTimeoutMs(ms: number): void;
|
785
789
|
getHeartbeatTimeoutMs(): number;
|
@@ -847,8 +851,9 @@ export declare class DefaultSocket implements Socket {
|
|
847
851
|
listRoles(ClanId: string, Limit: number, State: number, Cursor: string): Promise<RoleListEvent>;
|
848
852
|
listChannelByUserId(): Promise<ChannelDescListEvent>;
|
849
853
|
listUserClansByUserId(): Promise<AllUserClans>;
|
854
|
+
listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
|
850
855
|
hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
|
851
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
856
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
852
857
|
listStickersByUserId(): Promise<StrickerListedEvent>;
|
853
858
|
getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
|
854
859
|
getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
|
@@ -35,7 +35,7 @@ export interface WebSocketAdapter {
|
|
35
35
|
onOpen: SocketOpenHandler | null;
|
36
36
|
isOpen(): boolean;
|
37
37
|
close(): void;
|
38
|
-
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void;
|
38
|
+
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
|
39
39
|
send(message: any): void;
|
40
40
|
}
|
41
41
|
/**
|
@@ -77,7 +77,7 @@ export declare class WebSocketAdapterText implements WebSocketAdapter {
|
|
77
77
|
get onOpen(): SocketOpenHandler | null;
|
78
78
|
set onOpen(value: SocketOpenHandler | null);
|
79
79
|
isOpen(): boolean;
|
80
|
-
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void;
|
80
|
+
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
|
81
81
|
close(): void;
|
82
82
|
send(msg: any): void;
|
83
83
|
}
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -672,6 +672,10 @@ export interface RoleEvent {
|
|
672
672
|
user_id: string;
|
673
673
|
}
|
674
674
|
|
675
|
+
export interface AllUsersAddChannelEvent {
|
676
|
+
user_ids: Array<string>;
|
677
|
+
}
|
678
|
+
|
675
679
|
export interface EventEmoji {
|
676
680
|
id : string
|
677
681
|
clan_id: string
|
@@ -931,7 +935,7 @@ export interface Socket {
|
|
931
935
|
isOpen(): boolean;
|
932
936
|
|
933
937
|
/** Connect to the server. */
|
934
|
-
connect(session: Session, createStatus: boolean): Promise<Session>;
|
938
|
+
connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
935
939
|
|
936
940
|
/** Disconnect from the server. */
|
937
941
|
disconnect(fireDisconnectEvent: boolean): void;
|
@@ -1105,6 +1109,8 @@ export interface Socket {
|
|
1105
1109
|
listChannelByUserId(): Promise<ChannelDescListEvent>;
|
1106
1110
|
|
1107
1111
|
listUserClansByUserId(): Promise<AllUserClans>;
|
1112
|
+
|
1113
|
+
listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
|
1108
1114
|
|
1109
1115
|
hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
|
1110
1116
|
|
@@ -1116,7 +1122,7 @@ export interface Socket {
|
|
1116
1122
|
|
1117
1123
|
getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
|
1118
1124
|
|
1119
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
1125
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
1120
1126
|
|
1121
1127
|
getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
|
1122
1128
|
|
@@ -1179,13 +1185,13 @@ export class DefaultSocket implements Socket {
|
|
1179
1185
|
return this.adapter.isOpen();
|
1180
1186
|
}
|
1181
1187
|
|
1182
|
-
connect(session: Session, createStatus: boolean = false, connectTimeoutMs: number = DefaultSocket.DefaultConnectTimeoutMs): Promise<Session> {
|
1188
|
+
connect(session: Session, createStatus: boolean = false, connectTimeoutMs: number = DefaultSocket.DefaultConnectTimeoutMs, signal?: AbortSignal): Promise<Session> {
|
1183
1189
|
if (this.adapter.isOpen()) {
|
1184
1190
|
return Promise.resolve(session);
|
1185
1191
|
}
|
1186
1192
|
|
1187
1193
|
const scheme = (this.useSSL) ? "wss://" : "ws://";
|
1188
|
-
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
|
1194
|
+
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
|
1189
1195
|
|
1190
1196
|
this.adapter.onClose = (evt: Event) => {
|
1191
1197
|
this.ondisconnect(evt);
|
@@ -1812,13 +1818,18 @@ export class DefaultSocket implements Socket {
|
|
1812
1818
|
return response.all_user_clans
|
1813
1819
|
}
|
1814
1820
|
|
1821
|
+
async listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent> {
|
1822
|
+
const response = await this.send({all_users_add_channel_event: {channel_id: channelId, limit: limit}});
|
1823
|
+
return response.all_users_add_channel_event
|
1824
|
+
}
|
1825
|
+
|
1815
1826
|
async hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent> {
|
1816
1827
|
const response = await this.send({hashtag_dm_list_event: {user_id: user_id, limit: limit }});
|
1817
1828
|
return response.hashtag_dm_list_event
|
1818
1829
|
}
|
1819
1830
|
|
1820
|
-
async getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
|
1821
|
-
const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id }});
|
1831
|
+
async getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent> {
|
1832
|
+
const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id, user_id: user_id }});
|
1822
1833
|
return response.permission_role_channel_list_event
|
1823
1834
|
}
|
1824
1835
|
|
package/web_socket_adapter.ts
CHANGED
@@ -25,34 +25,34 @@ export interface WebSocketAdapter {
|
|
25
25
|
/**
|
26
26
|
* Dispatched when the web socket closes.
|
27
27
|
*/
|
28
|
-
onClose
|
28
|
+
onClose: SocketCloseHandler | null;
|
29
29
|
|
30
30
|
/**
|
31
31
|
* Dispatched when the web socket receives an error.
|
32
32
|
*/
|
33
|
-
onError
|
33
|
+
onError: SocketErrorHandler | null;
|
34
34
|
|
35
35
|
/**
|
36
36
|
* Dispatched when the web socket receives a normal message.
|
37
37
|
*/
|
38
|
-
onMessage
|
38
|
+
onMessage: SocketMessageHandler | null;
|
39
39
|
|
40
40
|
/**
|
41
41
|
* Dispatched when the web socket opens.
|
42
42
|
*/
|
43
|
-
onOpen
|
43
|
+
onOpen: SocketOpenHandler | null;
|
44
44
|
|
45
45
|
isOpen(): boolean;
|
46
|
-
close()
|
47
|
-
connect(scheme: string, host: string, port
|
48
|
-
send(message: any)
|
46
|
+
close(): void;
|
47
|
+
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
|
48
|
+
send(message: any): void;
|
49
49
|
}
|
50
50
|
|
51
51
|
/**
|
52
52
|
* SocketCloseHandler defines a lambda that handles WebSocket close events.
|
53
53
|
*/
|
54
54
|
export interface SocketCloseHandler {
|
55
|
-
(this
|
55
|
+
(this: WebSocket, evt: CloseEvent): void;
|
56
56
|
}
|
57
57
|
|
58
58
|
/**
|
@@ -60,7 +60,7 @@ export interface SocketCloseHandler {
|
|
60
60
|
* that indicate an error.
|
61
61
|
*/
|
62
62
|
export interface SocketErrorHandler {
|
63
|
-
(this
|
63
|
+
(this: WebSocket, evt: Event): void;
|
64
64
|
}
|
65
65
|
|
66
66
|
/**
|
@@ -74,7 +74,7 @@ export interface SocketMessageHandler {
|
|
74
74
|
* SocketOpenHandler defines a lambda that handles WebSocket open events.
|
75
75
|
*/
|
76
76
|
export interface SocketOpenHandler {
|
77
|
-
(this
|
77
|
+
(this: WebSocket, evt: Event): void
|
78
78
|
}
|
79
79
|
|
80
80
|
/**
|
@@ -107,7 +107,6 @@ export class WebSocketAdapterText implements WebSocketAdapter {
|
|
107
107
|
if (value) {
|
108
108
|
this._socket!.onmessage = (evt: MessageEvent) => {
|
109
109
|
const message: any = JSON.parse(evt.data);
|
110
|
-
|
111
110
|
if (message.party_data && message.party_data.data) {
|
112
111
|
message.party_data.data = new Uint8Array(decode(message.party_data.data));
|
113
112
|
}
|
@@ -132,13 +131,18 @@ export class WebSocketAdapterText implements WebSocketAdapter {
|
|
132
131
|
return this._socket?.readyState == WebSocket.OPEN;
|
133
132
|
}
|
134
133
|
|
135
|
-
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void {
|
134
|
+
connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void {
|
135
|
+
if (signal) {
|
136
|
+
signal.addEventListener('abort', () => {
|
137
|
+
this.close();
|
138
|
+
});
|
139
|
+
}
|
136
140
|
const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
|
137
141
|
this._socket = new WebSocket(url);
|
138
142
|
}
|
139
143
|
|
140
144
|
close() {
|
141
|
-
this._socket
|
145
|
+
this._socket?.close();
|
142
146
|
this._socket = undefined;
|
143
147
|
}
|
144
148
|
|