mezon-js 2.7.2 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +92 -0
- package/client.ts +26 -0
- package/dist/api.gen.d.ts +16 -0
- package/dist/client.d.ts +5 -1
- package/dist/mezon-js.cjs.js +96 -2
- package/dist/mezon-js.esm.mjs +96 -2
- package/dist/socket.d.ts +22 -1
- package/package.json +1 -1
- package/socket.ts +55 -3
package/api.gen.ts
CHANGED
@@ -146,6 +146,14 @@ export interface ApiAccountSteam {
|
|
146
146
|
vars?: Record<string, string>;
|
147
147
|
}
|
148
148
|
|
149
|
+
/** Add a role for channel. */
|
150
|
+
export interface ApiAddRoleChannelDescRequest {
|
151
|
+
//
|
152
|
+
channel_id?: string;
|
153
|
+
//
|
154
|
+
role_ids?: Array<string>;
|
155
|
+
}
|
156
|
+
|
149
157
|
/** */
|
150
158
|
export interface ApiCategoryDesc {
|
151
159
|
//
|
@@ -398,6 +406,14 @@ export interface ApiCreateRoleRequest {
|
|
398
406
|
title?: string;
|
399
407
|
}
|
400
408
|
|
409
|
+
/** Delete a role the user has access to. */
|
410
|
+
export interface ApiDeleteRoleRequest {
|
411
|
+
//
|
412
|
+
channel_id?: string;
|
413
|
+
//The id of a role.
|
414
|
+
role_id?: string;
|
415
|
+
}
|
416
|
+
|
401
417
|
/** Storage objects to delete. */
|
402
418
|
export interface ApiDeleteStorageObjectId {
|
403
419
|
//The collection which stores the object.
|
@@ -654,6 +670,10 @@ export interface ApiRole {
|
|
654
670
|
slug?: string;
|
655
671
|
//
|
656
672
|
title?: string;
|
673
|
+
//
|
674
|
+
role_channel_active?: string;
|
675
|
+
//
|
676
|
+
channel_id?: string;
|
657
677
|
}
|
658
678
|
|
659
679
|
/** A list of role description, usually a result of a list operation. */
|
@@ -3462,6 +3482,78 @@ export class MezonApi {
|
|
3462
3482
|
]);
|
3463
3483
|
}
|
3464
3484
|
|
3485
|
+
/** */
|
3486
|
+
addRolesChannelDesc(bearerToken: string,
|
3487
|
+
body:ApiAddRoleChannelDescRequest,
|
3488
|
+
options: any = {}): Promise<any> {
|
3489
|
+
|
3490
|
+
if (body === null || body === undefined) {
|
3491
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
3492
|
+
}
|
3493
|
+
const urlPath = "/v2/rolechannel/addrole";
|
3494
|
+
const queryParams = new Map<string, any>();
|
3495
|
+
|
3496
|
+
let bodyJson : string = "";
|
3497
|
+
bodyJson = JSON.stringify(body || {});
|
3498
|
+
|
3499
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3500
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3501
|
+
if (bearerToken) {
|
3502
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3503
|
+
}
|
3504
|
+
|
3505
|
+
return Promise.race([
|
3506
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3507
|
+
if (response.status == 204) {
|
3508
|
+
return response;
|
3509
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3510
|
+
return response.json();
|
3511
|
+
} else {
|
3512
|
+
throw response;
|
3513
|
+
}
|
3514
|
+
}),
|
3515
|
+
new Promise((_, reject) =>
|
3516
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3517
|
+
),
|
3518
|
+
]);
|
3519
|
+
}
|
3520
|
+
|
3521
|
+
/** Update a role when Delete a role by ID. */
|
3522
|
+
deleteRoleChannelDesc(bearerToken: string,
|
3523
|
+
body:ApiDeleteRoleRequest,
|
3524
|
+
options: any = {}): Promise<any> {
|
3525
|
+
|
3526
|
+
if (body === null || body === undefined) {
|
3527
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
3528
|
+
}
|
3529
|
+
const urlPath = "/v2/rolechannel/delete";
|
3530
|
+
const queryParams = new Map<string, any>();
|
3531
|
+
|
3532
|
+
let bodyJson : string = "";
|
3533
|
+
bodyJson = JSON.stringify(body || {});
|
3534
|
+
|
3535
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3536
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
3537
|
+
if (bearerToken) {
|
3538
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3539
|
+
}
|
3540
|
+
|
3541
|
+
return Promise.race([
|
3542
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3543
|
+
if (response.status == 204) {
|
3544
|
+
return response;
|
3545
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3546
|
+
return response.json();
|
3547
|
+
} else {
|
3548
|
+
throw response;
|
3549
|
+
}
|
3550
|
+
}),
|
3551
|
+
new Promise((_, reject) =>
|
3552
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3553
|
+
),
|
3554
|
+
]);
|
3555
|
+
}
|
3556
|
+
|
3465
3557
|
/** List user roles */
|
3466
3558
|
listRoles(bearerToken: string,
|
3467
3559
|
limit?:number,
|
package/client.ts
CHANGED
@@ -28,6 +28,7 @@ import {
|
|
28
28
|
ApiChannelDescList,
|
29
29
|
ApiChannelDescription,
|
30
30
|
ApiCreateChannelDescRequest,
|
31
|
+
ApiDeleteRoleRequest,
|
31
32
|
ApiClanDescList,
|
32
33
|
ApiCreateClanDescRequest,
|
33
34
|
ApiClanDesc,
|
@@ -38,6 +39,7 @@ import {
|
|
38
39
|
ApiRoleUserList,
|
39
40
|
ApiRole,
|
40
41
|
ApiCreateRoleRequest,
|
42
|
+
ApiAddRoleChannelDescRequest,
|
41
43
|
ApiCreateCategoryDescRequest,
|
42
44
|
ApiUpdateCategoryDescRequest,
|
43
45
|
ApiDeleteStorageObjectsRequest,
|
@@ -733,6 +735,30 @@ export class Client {
|
|
733
735
|
});
|
734
736
|
}
|
735
737
|
|
738
|
+
/** add role for channel. */
|
739
|
+
async addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean> {
|
740
|
+
if (this.autoRefreshSession && session.refresh_token &&
|
741
|
+
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
742
|
+
await this.sessionRefresh(session);
|
743
|
+
}
|
744
|
+
|
745
|
+
return this.apiClient.addRolesChannelDesc(session.token, request).then((response: ApiRole) => {
|
746
|
+
return response !== undefined;
|
747
|
+
});
|
748
|
+
}
|
749
|
+
|
750
|
+
/** Update action role when delete role */
|
751
|
+
async deleteRoleChannelDesc(session: Session, request:ApiDeleteRoleRequest): Promise<boolean> {
|
752
|
+
if (this.autoRefreshSession && session.refresh_token &&
|
753
|
+
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
754
|
+
await this.sessionRefresh(session);
|
755
|
+
}
|
756
|
+
|
757
|
+
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response: any) => {
|
758
|
+
return response !== undefined;
|
759
|
+
});
|
760
|
+
}
|
761
|
+
|
736
762
|
/** A socket created with the client's configuration. */
|
737
763
|
createSocket(useSSL = false, verbose: boolean = false, adapter : WebSocketAdapter = new WebSocketAdapterText(), sendTimeoutMs : number = DefaultSocket.DefaultSendTimeoutMs): Socket {
|
738
764
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
package/dist/api.gen.d.ts
CHANGED
@@ -83,6 +83,11 @@ export interface ApiAccountSteam {
|
|
83
83
|
token?: string;
|
84
84
|
vars?: Record<string, string>;
|
85
85
|
}
|
86
|
+
/** Add a role for channel. */
|
87
|
+
export interface ApiAddRoleChannelDescRequest {
|
88
|
+
channel_id?: string;
|
89
|
+
role_ids?: Array<string>;
|
90
|
+
}
|
86
91
|
/** */
|
87
92
|
export interface ApiCategoryDesc {
|
88
93
|
category_id?: string;
|
@@ -226,6 +231,11 @@ export interface ApiCreateRoleRequest {
|
|
226
231
|
role_icon?: string;
|
227
232
|
title?: string;
|
228
233
|
}
|
234
|
+
/** Delete a role the user has access to. */
|
235
|
+
export interface ApiDeleteRoleRequest {
|
236
|
+
channel_id?: string;
|
237
|
+
role_id?: string;
|
238
|
+
}
|
229
239
|
/** Storage objects to delete. */
|
230
240
|
export interface ApiDeleteStorageObjectId {
|
231
241
|
collection?: string;
|
@@ -375,6 +385,8 @@ export interface ApiRole {
|
|
375
385
|
role_user_list?: ApiRoleUserList;
|
376
386
|
slug?: string;
|
377
387
|
title?: string;
|
388
|
+
role_channel_active?: string;
|
389
|
+
channel_id?: string;
|
378
390
|
}
|
379
391
|
/** A list of role description, usually a result of a list operation. */
|
380
392
|
export interface ApiRoleList {
|
@@ -675,6 +687,10 @@ export declare class MezonApi {
|
|
675
687
|
listNotifications(bearerToken: string, limit?: number, cacheableCursor?: string, options?: any): Promise<ApiNotificationList>;
|
676
688
|
/** */
|
677
689
|
GetPermissionOfUserInTheClan(bearerToken: string, clanId: string, options?: any): Promise<ApiPermissionList>;
|
690
|
+
/** */
|
691
|
+
addRolesChannelDesc(bearerToken: string, body: ApiAddRoleChannelDescRequest, options?: any): Promise<any>;
|
692
|
+
/** Update a role when Delete a role by ID. */
|
693
|
+
deleteRoleChannelDesc(bearerToken: string, body: ApiDeleteRoleRequest, options?: any): Promise<any>;
|
678
694
|
/** List user roles */
|
679
695
|
listRoles(bearerToken: string, limit?: number, state?: number, cursor?: string, clanId?: string, options?: any): Promise<ApiRoleList>;
|
680
696
|
/** Create a new role for clan. */
|
package/dist/client.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList } from "./api.gen";
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -389,6 +389,10 @@ export declare class Client {
|
|
389
389
|
createCategoryDesc(session: Session, request: ApiCreateCategoryDescRequest): Promise<ApiCategoryDesc>;
|
390
390
|
/** Create a new role for clan. */
|
391
391
|
createRole(session: Session, request: ApiCreateRoleRequest): Promise<ApiRole>;
|
392
|
+
/** add role for channel. */
|
393
|
+
addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean>;
|
394
|
+
/** Update action role when delete role */
|
395
|
+
deleteRoleChannelDesc(session: Session, request: ApiDeleteRoleRequest): Promise<boolean>;
|
392
396
|
/** A socket created with the client's configuration. */
|
393
397
|
createSocket(useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number): Socket;
|
394
398
|
/** Delete one or more users by ID or username. */
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -2643,6 +2643,64 @@ var MezonApi = class {
|
|
2643
2643
|
)
|
2644
2644
|
]);
|
2645
2645
|
}
|
2646
|
+
/** */
|
2647
|
+
addRolesChannelDesc(bearerToken, body, options = {}) {
|
2648
|
+
if (body === null || body === void 0) {
|
2649
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2650
|
+
}
|
2651
|
+
const urlPath = "/v2/rolechannel/addrole";
|
2652
|
+
const queryParams = /* @__PURE__ */ new Map();
|
2653
|
+
let bodyJson = "";
|
2654
|
+
bodyJson = JSON.stringify(body || {});
|
2655
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2656
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2657
|
+
if (bearerToken) {
|
2658
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2659
|
+
}
|
2660
|
+
return Promise.race([
|
2661
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2662
|
+
if (response.status == 204) {
|
2663
|
+
return response;
|
2664
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2665
|
+
return response.json();
|
2666
|
+
} else {
|
2667
|
+
throw response;
|
2668
|
+
}
|
2669
|
+
}),
|
2670
|
+
new Promise(
|
2671
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2672
|
+
)
|
2673
|
+
]);
|
2674
|
+
}
|
2675
|
+
/** Update a role when Delete a role by ID. */
|
2676
|
+
deleteRoleChannelDesc(bearerToken, body, options = {}) {
|
2677
|
+
if (body === null || body === void 0) {
|
2678
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2679
|
+
}
|
2680
|
+
const urlPath = "/v2/rolechannel/delete";
|
2681
|
+
const queryParams = /* @__PURE__ */ new Map();
|
2682
|
+
let bodyJson = "";
|
2683
|
+
bodyJson = JSON.stringify(body || {});
|
2684
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2685
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2686
|
+
if (bearerToken) {
|
2687
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2688
|
+
}
|
2689
|
+
return Promise.race([
|
2690
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2691
|
+
if (response.status == 204) {
|
2692
|
+
return response;
|
2693
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2694
|
+
return response.json();
|
2695
|
+
} else {
|
2696
|
+
throw response;
|
2697
|
+
}
|
2698
|
+
}),
|
2699
|
+
new Promise(
|
2700
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2701
|
+
)
|
2702
|
+
]);
|
2703
|
+
}
|
2646
2704
|
/** List user roles */
|
2647
2705
|
listRoles(bearerToken, limit, state, cursor, clanId, options = {}) {
|
2648
2706
|
const urlPath = "/v2/roles";
|
@@ -3456,6 +3514,10 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3456
3514
|
this.onvoicejoined(message.voice_joined_event);
|
3457
3515
|
} else if (message.voice_leaved_event) {
|
3458
3516
|
this.onvoiceleaved(message.voice_leaved_event);
|
3517
|
+
} else if (message.channel_created_event) {
|
3518
|
+
this.onchannelcreated(message.channel_created_event);
|
3519
|
+
} else if (message.channel_deleted_event) {
|
3520
|
+
this.onchanneldeleted(message.channel_deleted_event);
|
3459
3521
|
} else if (message.status_presence_event) {
|
3460
3522
|
this.onstatuspresence(message.status_presence_event);
|
3461
3523
|
} else if (message.stream_presence_event) {
|
@@ -3650,6 +3712,16 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3650
3712
|
console.log(voiceParticipant);
|
3651
3713
|
}
|
3652
3714
|
}
|
3715
|
+
onchannelcreated(channelCreated) {
|
3716
|
+
if (this.verbose && window && window.console) {
|
3717
|
+
console.log(channelCreated);
|
3718
|
+
}
|
3719
|
+
}
|
3720
|
+
onchanneldeleted(channelDeleted) {
|
3721
|
+
if (this.verbose && window && window.console) {
|
3722
|
+
console.log(channelDeleted);
|
3723
|
+
}
|
3724
|
+
}
|
3653
3725
|
onstreampresence(streamPresence) {
|
3654
3726
|
if (this.verbose && window && window.console) {
|
3655
3727
|
console.log(streamPresence);
|
@@ -3806,9 +3878,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3806
3878
|
unfollowUsers(user_ids) {
|
3807
3879
|
return this.send({ status_unfollow: { user_ids } });
|
3808
3880
|
}
|
3809
|
-
updateChatMessage(channel_id, message_id, content) {
|
3881
|
+
updateChatMessage(channel_id, channel_label, mode, message_id, content) {
|
3810
3882
|
return __async(this, null, function* () {
|
3811
|
-
const response = yield this.send({ channel_message_update: { channel_id, message_id, content } });
|
3883
|
+
const response = yield this.send({ channel_message_update: { channel_id, channel_label, message_id, content, mode } });
|
3812
3884
|
return response.channel_message_ack;
|
3813
3885
|
});
|
3814
3886
|
}
|
@@ -4136,6 +4208,28 @@ var Client = class {
|
|
4136
4208
|
});
|
4137
4209
|
});
|
4138
4210
|
}
|
4211
|
+
/** add role for channel. */
|
4212
|
+
addRolesChannelDesc(session, request) {
|
4213
|
+
return __async(this, null, function* () {
|
4214
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4215
|
+
yield this.sessionRefresh(session);
|
4216
|
+
}
|
4217
|
+
return this.apiClient.addRolesChannelDesc(session.token, request).then((response) => {
|
4218
|
+
return response !== void 0;
|
4219
|
+
});
|
4220
|
+
});
|
4221
|
+
}
|
4222
|
+
/** Update action role when delete role */
|
4223
|
+
deleteRoleChannelDesc(session, request) {
|
4224
|
+
return __async(this, null, function* () {
|
4225
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4226
|
+
yield this.sessionRefresh(session);
|
4227
|
+
}
|
4228
|
+
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response) => {
|
4229
|
+
return response !== void 0;
|
4230
|
+
});
|
4231
|
+
});
|
4232
|
+
}
|
4139
4233
|
/** A socket created with the client's configuration. */
|
4140
4234
|
createSocket(useSSL = false, verbose = false, adapter = new WebSocketAdapterText(), sendTimeoutMs = DefaultSocket.DefaultSendTimeoutMs) {
|
4141
4235
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -2615,6 +2615,64 @@ var MezonApi = class {
|
|
2615
2615
|
)
|
2616
2616
|
]);
|
2617
2617
|
}
|
2618
|
+
/** */
|
2619
|
+
addRolesChannelDesc(bearerToken, body, options = {}) {
|
2620
|
+
if (body === null || body === void 0) {
|
2621
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2622
|
+
}
|
2623
|
+
const urlPath = "/v2/rolechannel/addrole";
|
2624
|
+
const queryParams = /* @__PURE__ */ new Map();
|
2625
|
+
let bodyJson = "";
|
2626
|
+
bodyJson = JSON.stringify(body || {});
|
2627
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2628
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2629
|
+
if (bearerToken) {
|
2630
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2631
|
+
}
|
2632
|
+
return Promise.race([
|
2633
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2634
|
+
if (response.status == 204) {
|
2635
|
+
return response;
|
2636
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2637
|
+
return response.json();
|
2638
|
+
} else {
|
2639
|
+
throw response;
|
2640
|
+
}
|
2641
|
+
}),
|
2642
|
+
new Promise(
|
2643
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2644
|
+
)
|
2645
|
+
]);
|
2646
|
+
}
|
2647
|
+
/** Update a role when Delete a role by ID. */
|
2648
|
+
deleteRoleChannelDesc(bearerToken, body, options = {}) {
|
2649
|
+
if (body === null || body === void 0) {
|
2650
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2651
|
+
}
|
2652
|
+
const urlPath = "/v2/rolechannel/delete";
|
2653
|
+
const queryParams = /* @__PURE__ */ new Map();
|
2654
|
+
let bodyJson = "";
|
2655
|
+
bodyJson = JSON.stringify(body || {});
|
2656
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2657
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2658
|
+
if (bearerToken) {
|
2659
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2660
|
+
}
|
2661
|
+
return Promise.race([
|
2662
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2663
|
+
if (response.status == 204) {
|
2664
|
+
return response;
|
2665
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2666
|
+
return response.json();
|
2667
|
+
} else {
|
2668
|
+
throw response;
|
2669
|
+
}
|
2670
|
+
}),
|
2671
|
+
new Promise(
|
2672
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2673
|
+
)
|
2674
|
+
]);
|
2675
|
+
}
|
2618
2676
|
/** List user roles */
|
2619
2677
|
listRoles(bearerToken, limit, state, cursor, clanId, options = {}) {
|
2620
2678
|
const urlPath = "/v2/roles";
|
@@ -3428,6 +3486,10 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3428
3486
|
this.onvoicejoined(message.voice_joined_event);
|
3429
3487
|
} else if (message.voice_leaved_event) {
|
3430
3488
|
this.onvoiceleaved(message.voice_leaved_event);
|
3489
|
+
} else if (message.channel_created_event) {
|
3490
|
+
this.onchannelcreated(message.channel_created_event);
|
3491
|
+
} else if (message.channel_deleted_event) {
|
3492
|
+
this.onchanneldeleted(message.channel_deleted_event);
|
3431
3493
|
} else if (message.status_presence_event) {
|
3432
3494
|
this.onstatuspresence(message.status_presence_event);
|
3433
3495
|
} else if (message.stream_presence_event) {
|
@@ -3622,6 +3684,16 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3622
3684
|
console.log(voiceParticipant);
|
3623
3685
|
}
|
3624
3686
|
}
|
3687
|
+
onchannelcreated(channelCreated) {
|
3688
|
+
if (this.verbose && window && window.console) {
|
3689
|
+
console.log(channelCreated);
|
3690
|
+
}
|
3691
|
+
}
|
3692
|
+
onchanneldeleted(channelDeleted) {
|
3693
|
+
if (this.verbose && window && window.console) {
|
3694
|
+
console.log(channelDeleted);
|
3695
|
+
}
|
3696
|
+
}
|
3625
3697
|
onstreampresence(streamPresence) {
|
3626
3698
|
if (this.verbose && window && window.console) {
|
3627
3699
|
console.log(streamPresence);
|
@@ -3778,9 +3850,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3778
3850
|
unfollowUsers(user_ids) {
|
3779
3851
|
return this.send({ status_unfollow: { user_ids } });
|
3780
3852
|
}
|
3781
|
-
updateChatMessage(channel_id, message_id, content) {
|
3853
|
+
updateChatMessage(channel_id, channel_label, mode, message_id, content) {
|
3782
3854
|
return __async(this, null, function* () {
|
3783
|
-
const response = yield this.send({ channel_message_update: { channel_id, message_id, content } });
|
3855
|
+
const response = yield this.send({ channel_message_update: { channel_id, channel_label, message_id, content, mode } });
|
3784
3856
|
return response.channel_message_ack;
|
3785
3857
|
});
|
3786
3858
|
}
|
@@ -4108,6 +4180,28 @@ var Client = class {
|
|
4108
4180
|
});
|
4109
4181
|
});
|
4110
4182
|
}
|
4183
|
+
/** add role for channel. */
|
4184
|
+
addRolesChannelDesc(session, request) {
|
4185
|
+
return __async(this, null, function* () {
|
4186
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4187
|
+
yield this.sessionRefresh(session);
|
4188
|
+
}
|
4189
|
+
return this.apiClient.addRolesChannelDesc(session.token, request).then((response) => {
|
4190
|
+
return response !== void 0;
|
4191
|
+
});
|
4192
|
+
});
|
4193
|
+
}
|
4194
|
+
/** Update action role when delete role */
|
4195
|
+
deleteRoleChannelDesc(session, request) {
|
4196
|
+
return __async(this, null, function* () {
|
4197
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4198
|
+
yield this.sessionRefresh(session);
|
4199
|
+
}
|
4200
|
+
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response) => {
|
4201
|
+
return response !== void 0;
|
4202
|
+
});
|
4203
|
+
});
|
4204
|
+
}
|
4111
4205
|
/** A socket created with the client's configuration. */
|
4112
4206
|
createSocket(useSSL = false, verbose = false, adapter = new WebSocketAdapterText(), sendTimeoutMs = DefaultSocket.DefaultSendTimeoutMs) {
|
4113
4207
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
package/dist/socket.d.ts
CHANGED
@@ -215,10 +215,14 @@ interface ChannelMessageUpdate {
|
|
215
215
|
channel_message_update: {
|
216
216
|
/** The server-assigned channel ID. */
|
217
217
|
channel_id: string;
|
218
|
+
/** The server-assigned channel label. */
|
219
|
+
channel_label: string;
|
218
220
|
/** A unique ID for the chat message to be updated. */
|
219
221
|
message_id: string;
|
220
222
|
/** The content payload. */
|
221
223
|
content: any;
|
224
|
+
/** The mode payload. */
|
225
|
+
mode: number;
|
222
226
|
};
|
223
227
|
}
|
224
228
|
/** Remove a message previously sent to a realtime chat channel. */
|
@@ -260,6 +264,19 @@ export interface VoiceJoinedEvent {
|
|
260
264
|
voice_channel_id: string;
|
261
265
|
last_screenshot: string;
|
262
266
|
}
|
267
|
+
export interface ChannelCreatedEvent {
|
268
|
+
clan_id: string;
|
269
|
+
category_id: string;
|
270
|
+
creator_id: string;
|
271
|
+
channel_id: string;
|
272
|
+
channel_label: string;
|
273
|
+
}
|
274
|
+
export interface ChannelDeletedEvent {
|
275
|
+
clan_id: string;
|
276
|
+
category_id: string;
|
277
|
+
channel_id: string;
|
278
|
+
deletor: string;
|
279
|
+
}
|
263
280
|
/** Stream identifier */
|
264
281
|
export interface StreamId {
|
265
282
|
/** The type of stream (e.g. chat). */
|
@@ -587,6 +604,8 @@ export interface Socket {
|
|
587
604
|
onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
|
588
605
|
onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
|
589
606
|
onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
|
607
|
+
onchannelcreated: (channelCreated: ChannelCreatedEvent) => void;
|
608
|
+
onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
|
590
609
|
setHeartbeatTimeoutMs(ms: number): void;
|
591
610
|
getHeartbeatTimeoutMs(): number;
|
592
611
|
}
|
@@ -635,6 +654,8 @@ export declare class DefaultSocket implements Socket {
|
|
635
654
|
onstatuspresence(statusPresence: StatusPresenceEvent): void;
|
636
655
|
onvoicejoined(voiceParticipant: VoiceJoinedEvent): void;
|
637
656
|
onvoiceleaved(voiceParticipant: VoiceLeavedEvent): void;
|
657
|
+
onchannelcreated(channelCreated: ChannelCreatedEvent): void;
|
658
|
+
onchanneldeleted(channelDeleted: ChannelDeletedEvent): void;
|
638
659
|
onstreampresence(streamPresence: StreamPresenceEvent): void;
|
639
660
|
onstreamdata(streamData: StreamData): void;
|
640
661
|
onheartbeattimeout(): void;
|
@@ -655,7 +676,7 @@ export declare class DefaultSocket implements Socket {
|
|
655
676
|
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
|
656
677
|
sendPartyData(party_id: string, op_code: number, data: string | Uint8Array): Promise<void>;
|
657
678
|
unfollowUsers(user_ids: string[]): Promise<void>;
|
658
|
-
updateChatMessage(channel_id: string, message_id: string, content: any): Promise<ChannelMessageAck>;
|
679
|
+
updateChatMessage(channel_id: string, channel_label: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
|
659
680
|
updateStatus(status?: string): Promise<void>;
|
660
681
|
writeChatMessage(clan_id: string, channel_id: string, channel_label: string, mode: number, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>): Promise<ChannelMessageAck>;
|
661
682
|
writeMessageReaction(id: string, channel_id: string, channel_label: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -295,10 +295,14 @@ interface ChannelMessageUpdate {
|
|
295
295
|
channel_message_update: {
|
296
296
|
/** The server-assigned channel ID. */
|
297
297
|
channel_id: string,
|
298
|
+
/** The server-assigned channel label. */
|
299
|
+
channel_label: string,
|
298
300
|
/** A unique ID for the chat message to be updated. */
|
299
301
|
message_id: string,
|
300
302
|
/** The content payload. */
|
301
|
-
content: any
|
303
|
+
content: any,
|
304
|
+
/** The mode payload. */
|
305
|
+
mode: number;
|
302
306
|
};
|
303
307
|
}
|
304
308
|
|
@@ -360,6 +364,32 @@ export interface VoiceJoinedEvent {
|
|
360
364
|
last_screenshot: string;
|
361
365
|
}
|
362
366
|
|
367
|
+
|
368
|
+
export interface ChannelCreatedEvent {
|
369
|
+
// clan id
|
370
|
+
clan_id: string;
|
371
|
+
// category
|
372
|
+
category_id: string;
|
373
|
+
// creator
|
374
|
+
creator_id: string;
|
375
|
+
// channel id
|
376
|
+
channel_id: string;
|
377
|
+
// channel label
|
378
|
+
channel_label: string;
|
379
|
+
}
|
380
|
+
|
381
|
+
export interface ChannelDeletedEvent {
|
382
|
+
// clan id
|
383
|
+
clan_id: string;
|
384
|
+
// category
|
385
|
+
category_id: string;
|
386
|
+
// channel id
|
387
|
+
channel_id: string;
|
388
|
+
// deletor
|
389
|
+
deletor: string;
|
390
|
+
}
|
391
|
+
|
392
|
+
|
363
393
|
/** Stream identifier */
|
364
394
|
export interface StreamId {
|
365
395
|
/** The type of stream (e.g. chat). */
|
@@ -758,6 +788,12 @@ export interface Socket {
|
|
758
788
|
// when someone join to voice room
|
759
789
|
onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
|
760
790
|
|
791
|
+
// when channel is created
|
792
|
+
onchannelcreated: (channelCreated: ChannelCreatedEvent) => void;
|
793
|
+
|
794
|
+
// when channel is created
|
795
|
+
onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
|
796
|
+
|
761
797
|
/* Set the heartbeat timeout used by the socket to detect if it has lost connectivity to the server. */
|
762
798
|
setHeartbeatTimeoutMs(ms : number) : void;
|
763
799
|
|
@@ -834,6 +870,10 @@ export class DefaultSocket implements Socket {
|
|
834
870
|
this.onvoicejoined(message.voice_joined_event)
|
835
871
|
} else if (message.voice_leaved_event) {
|
836
872
|
this.onvoiceleaved(message.voice_leaved_event)
|
873
|
+
} else if (message.channel_created_event) {
|
874
|
+
this.onchannelcreated(message.channel_created_event)
|
875
|
+
} else if (message.channel_deleted_event) {
|
876
|
+
this.onchanneldeleted(message.channel_deleted_event)
|
837
877
|
} else if (message.status_presence_event) {
|
838
878
|
this.onstatuspresence(<StatusPresenceEvent>message.status_presence_event);
|
839
879
|
} else if (message.stream_presence_event) {
|
@@ -1058,6 +1098,18 @@ export class DefaultSocket implements Socket {
|
|
1058
1098
|
}
|
1059
1099
|
}
|
1060
1100
|
|
1101
|
+
onchannelcreated(channelCreated: ChannelCreatedEvent) {
|
1102
|
+
if (this.verbose && window && window.console) {
|
1103
|
+
console.log(channelCreated);
|
1104
|
+
}
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
onchanneldeleted(channelDeleted: ChannelDeletedEvent) {
|
1108
|
+
if (this.verbose && window && window.console) {
|
1109
|
+
console.log(channelDeleted);
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
|
1061
1113
|
onstreampresence(streamPresence: StreamPresenceEvent) {
|
1062
1114
|
if (this.verbose && window && window.console) {
|
1063
1115
|
console.log(streamPresence);
|
@@ -1229,8 +1281,8 @@ export class DefaultSocket implements Socket {
|
|
1229
1281
|
return this.send({status_unfollow: {user_ids: user_ids}});
|
1230
1282
|
}
|
1231
1283
|
|
1232
|
-
async updateChatMessage(channel_id: string, message_id : string, content: any): Promise<ChannelMessageAck> {
|
1233
|
-
const response = await this.send({channel_message_update: {channel_id: channel_id, message_id: message_id, content: content}});
|
1284
|
+
async updateChatMessage(channel_id: string, channel_label: string, mode: number, message_id : string, content: any): Promise<ChannelMessageAck> {
|
1285
|
+
const response = await this.send({channel_message_update: {channel_id: channel_id,channel_label:channel_label, message_id: message_id, content: content, mode: mode}});
|
1234
1286
|
return response.channel_message_ack;
|
1235
1287
|
}
|
1236
1288
|
|