mezon-js 2.9.2 → 2.9.4
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +2 -0
- package/dist/api.gen.d.ts +1 -0
- package/dist/mezon-js.cjs.js +12 -6
- package/dist/mezon-js.esm.mjs +12 -6
- package/dist/socket.d.ts +4 -4
- package/dist/web_socket_adapter.d.ts +2 -2
- package/package.json +1 -1
- package/socket.ts +6 -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
|
};
|
@@ -5549,9 +5555,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5549
5555
|
return response.hashtag_dm_list_event;
|
5550
5556
|
});
|
5551
5557
|
}
|
5552
|
-
getPermissionByRoleIdChannelId(role_id, channel_id) {
|
5558
|
+
getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
|
5553
5559
|
return __async(this, null, function* () {
|
5554
|
-
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 } });
|
5555
5561
|
return response.permission_role_channel_list_event;
|
5556
5562
|
});
|
5557
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
|
};
|
@@ -5520,9 +5526,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5520
5526
|
return response.hashtag_dm_list_event;
|
5521
5527
|
});
|
5522
5528
|
}
|
5523
|
-
getPermissionByRoleIdChannelId(role_id, channel_id) {
|
5529
|
+
getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
|
5524
5530
|
return __async(this, null, function* () {
|
5525
|
-
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 } });
|
5526
5532
|
return response.permission_role_channel_list_event;
|
5527
5533
|
});
|
5528
5534
|
}
|
package/dist/socket.d.ts
CHANGED
@@ -642,7 +642,7 @@ export interface Socket {
|
|
642
642
|
/** Connection is Open */
|
643
643
|
isOpen(): boolean;
|
644
644
|
/** Connect to the server. */
|
645
|
-
connect(session: Session, createStatus: boolean): Promise<Session>;
|
645
|
+
connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
646
646
|
/** Disconnect from the server. */
|
647
647
|
disconnect(fireDisconnectEvent: boolean): void;
|
648
648
|
/** Subscribe to one or more users for their status updates. */
|
@@ -748,7 +748,7 @@ export interface Socket {
|
|
748
748
|
getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
|
749
749
|
getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
|
750
750
|
getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
|
751
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
751
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
752
752
|
getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
|
753
753
|
oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
|
754
754
|
oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
|
@@ -783,7 +783,7 @@ export declare class DefaultSocket implements Socket {
|
|
783
783
|
constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number);
|
784
784
|
generatecid(): string;
|
785
785
|
isOpen(): boolean;
|
786
|
-
connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number): Promise<Session>;
|
786
|
+
connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
787
787
|
disconnect(fireDisconnectEvent?: boolean): void;
|
788
788
|
setHeartbeatTimeoutMs(ms: number): void;
|
789
789
|
getHeartbeatTimeoutMs(): number;
|
@@ -853,7 +853,7 @@ export declare class DefaultSocket implements Socket {
|
|
853
853
|
listUserClansByUserId(): Promise<AllUserClans>;
|
854
854
|
listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
|
855
855
|
hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
|
856
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
856
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
857
857
|
listStickersByUserId(): Promise<StrickerListedEvent>;
|
858
858
|
getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
|
859
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
@@ -935,7 +935,7 @@ export interface Socket {
|
|
935
935
|
isOpen(): boolean;
|
936
936
|
|
937
937
|
/** Connect to the server. */
|
938
|
-
connect(session: Session, createStatus: boolean): Promise<Session>;
|
938
|
+
connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
|
939
939
|
|
940
940
|
/** Disconnect from the server. */
|
941
941
|
disconnect(fireDisconnectEvent: boolean): void;
|
@@ -1122,7 +1122,7 @@ export interface Socket {
|
|
1122
1122
|
|
1123
1123
|
getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
|
1124
1124
|
|
1125
|
-
getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
|
1125
|
+
getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
|
1126
1126
|
|
1127
1127
|
getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
|
1128
1128
|
|
@@ -1185,13 +1185,13 @@ export class DefaultSocket implements Socket {
|
|
1185
1185
|
return this.adapter.isOpen();
|
1186
1186
|
}
|
1187
1187
|
|
1188
|
-
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> {
|
1189
1189
|
if (this.adapter.isOpen()) {
|
1190
1190
|
return Promise.resolve(session);
|
1191
1191
|
}
|
1192
1192
|
|
1193
1193
|
const scheme = (this.useSSL) ? "wss://" : "ws://";
|
1194
|
-
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
|
1194
|
+
this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
|
1195
1195
|
|
1196
1196
|
this.adapter.onClose = (evt: Event) => {
|
1197
1197
|
this.ondisconnect(evt);
|
@@ -1828,8 +1828,8 @@ export class DefaultSocket implements Socket {
|
|
1828
1828
|
return response.hashtag_dm_list_event
|
1829
1829
|
}
|
1830
1830
|
|
1831
|
-
async getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
|
1832
|
-
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 }});
|
1833
1833
|
return response.permission_role_channel_list_event
|
1834
1834
|
}
|
1835
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
|
|