mezon-js 2.9.91 → 2.9.93
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 +196 -1
- package/client.ts +110 -9
- package/dist/api.gen.d.ts +37 -0
- package/dist/client.d.ts +6 -1
- package/dist/mezon-js.cjs.js +195 -2
- package/dist/mezon-js.esm.mjs +195 -2
- package/dist/socket.d.ts +36 -2
- package/package.json +1 -1
- package/socket.ts +56 -1
package/api.gen.ts
CHANGED
@@ -1158,6 +1158,14 @@ export interface ApiCreateRoleRequest {
|
|
1158
1158
|
title?: string;
|
1159
1159
|
}
|
1160
1160
|
|
1161
|
+
/** */
|
1162
|
+
export interface ApiCustomDisplay {
|
1163
|
+
//
|
1164
|
+
logo?: string;
|
1165
|
+
//
|
1166
|
+
splash_screen?: string;
|
1167
|
+
}
|
1168
|
+
|
1161
1169
|
/** Delete a channel the user has access to. */
|
1162
1170
|
export interface ApiDeleteChannelDescRequest {
|
1163
1171
|
//The id of a channel.
|
@@ -1718,6 +1726,25 @@ export interface ApiOssrsHttpCallbackResponse {
|
|
1718
1726
|
//
|
1719
1727
|
msg?: string;
|
1720
1728
|
}
|
1729
|
+
|
1730
|
+
/** A list of users belonging to a channel, along with their role. */
|
1731
|
+
export interface ApiPTTChannelUser {
|
1732
|
+
//
|
1733
|
+
channel_id?: string;
|
1734
|
+
//
|
1735
|
+
id?: string;
|
1736
|
+
//
|
1737
|
+
participant?: string;
|
1738
|
+
//user for a channel.
|
1739
|
+
user_id?: string;
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
/** A list of users belonging to a channel, along with their role. */
|
1743
|
+
export interface ApiPTTChannelUserList {
|
1744
|
+
//
|
1745
|
+
ptt_channel_users?: Array<ApiPTTChannelUser>;
|
1746
|
+
}
|
1747
|
+
|
1721
1748
|
/** */
|
1722
1749
|
export interface ApiPermission {
|
1723
1750
|
//
|
@@ -2382,6 +2409,28 @@ export interface ApiVoiceChannelUserList {
|
|
2382
2409
|
voice_channel_users?: Array<ApiVoiceChannelUser>;
|
2383
2410
|
}
|
2384
2411
|
|
2412
|
+
/** */
|
2413
|
+
export interface ApiWalletLedger {
|
2414
|
+
//
|
2415
|
+
create_time?: string;
|
2416
|
+
//
|
2417
|
+
id?: string;
|
2418
|
+
//
|
2419
|
+
user_id?: string;
|
2420
|
+
//
|
2421
|
+
value?: number;
|
2422
|
+
}
|
2423
|
+
|
2424
|
+
/** */
|
2425
|
+
export interface ApiWalletLedgerList {
|
2426
|
+
//
|
2427
|
+
next_cursor?: string;
|
2428
|
+
//
|
2429
|
+
prev_cursor?: string;
|
2430
|
+
//
|
2431
|
+
wallet_ledger?: Array<ApiWalletLedger>;
|
2432
|
+
}
|
2433
|
+
|
2385
2434
|
/** */
|
2386
2435
|
export interface ApiWebhook {
|
2387
2436
|
//
|
@@ -5859,7 +5908,74 @@ export class MezonApi {
|
|
5859
5908
|
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5860
5909
|
),
|
5861
5910
|
]);
|
5862
|
-
|
5911
|
+
}
|
5912
|
+
|
5913
|
+
/** */
|
5914
|
+
getCustomDisplay(bearerToken: string,
|
5915
|
+
options: any = {}): Promise<ApiCustomDisplay> {
|
5916
|
+
|
5917
|
+
const urlPath = "/v2/customdisplay";
|
5918
|
+
const queryParams = new Map<string, any>();
|
5919
|
+
|
5920
|
+
let bodyJson : string = "";
|
5921
|
+
|
5922
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5923
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
5924
|
+
if (bearerToken) {
|
5925
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5926
|
+
}
|
5927
|
+
|
5928
|
+
return Promise.race([
|
5929
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5930
|
+
if (response.status == 204) {
|
5931
|
+
return response;
|
5932
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5933
|
+
return response.json();
|
5934
|
+
} else {
|
5935
|
+
throw response;
|
5936
|
+
}
|
5937
|
+
}),
|
5938
|
+
new Promise((_, reject) =>
|
5939
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5940
|
+
),
|
5941
|
+
]);
|
5942
|
+
}
|
5943
|
+
|
5944
|
+
/** */
|
5945
|
+
updateCustomDisplay(bearerToken: string,
|
5946
|
+
body:ApiCustomDisplay,
|
5947
|
+
options: any = {}): Promise<any> {
|
5948
|
+
|
5949
|
+
if (body === null || body === undefined) {
|
5950
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
5951
|
+
}
|
5952
|
+
const urlPath = "/v2/customdisplay";
|
5953
|
+
const queryParams = new Map<string, any>();
|
5954
|
+
|
5955
|
+
let bodyJson : string = "";
|
5956
|
+
bodyJson = JSON.stringify(body || {});
|
5957
|
+
|
5958
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5959
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
5960
|
+
if (bearerToken) {
|
5961
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5962
|
+
}
|
5963
|
+
|
5964
|
+
return Promise.race([
|
5965
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5966
|
+
if (response.status == 204) {
|
5967
|
+
return response;
|
5968
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5969
|
+
return response.json();
|
5970
|
+
} else {
|
5971
|
+
throw response;
|
5972
|
+
}
|
5973
|
+
}),
|
5974
|
+
new Promise((_, reject) =>
|
5975
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5976
|
+
),
|
5977
|
+
]);
|
5978
|
+
}
|
5863
5979
|
|
5864
5980
|
/** */
|
5865
5981
|
deleteCategoryDesc(
|
@@ -7897,6 +8013,49 @@ export class MezonApi {
|
|
7897
8013
|
]);
|
7898
8014
|
}
|
7899
8015
|
|
8016
|
+
/** List all users in ptt channel. */
|
8017
|
+
listPTTChannelUsers(bearerToken: string,
|
8018
|
+
clanId?:string,
|
8019
|
+
channelId?:string,
|
8020
|
+
channelType?:number,
|
8021
|
+
limit?:number,
|
8022
|
+
state?:number,
|
8023
|
+
cursor?:string,
|
8024
|
+
options: any = {}): Promise<ApiPTTChannelUserList> {
|
8025
|
+
|
8026
|
+
const urlPath = "/v2/ptt_channels/users";
|
8027
|
+
const queryParams = new Map<string, any>();
|
8028
|
+
queryParams.set("clan_id", clanId);
|
8029
|
+
queryParams.set("channel_id", channelId);
|
8030
|
+
queryParams.set("channel_type", channelType);
|
8031
|
+
queryParams.set("limit", limit);
|
8032
|
+
queryParams.set("state", state);
|
8033
|
+
queryParams.set("cursor", cursor);
|
8034
|
+
|
8035
|
+
let bodyJson : string = "";
|
8036
|
+
|
8037
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
8038
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
8039
|
+
if (bearerToken) {
|
8040
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
8041
|
+
}
|
8042
|
+
|
8043
|
+
return Promise.race([
|
8044
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
8045
|
+
if (response.status == 204) {
|
8046
|
+
return response;
|
8047
|
+
} else if (response.status >= 200 && response.status < 300) {
|
8048
|
+
return response.json();
|
8049
|
+
} else {
|
8050
|
+
throw response;
|
8051
|
+
}
|
8052
|
+
}),
|
8053
|
+
new Promise((_, reject) =>
|
8054
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
8055
|
+
),
|
8056
|
+
]);
|
8057
|
+
}
|
8058
|
+
|
7900
8059
|
/** get pubkey */
|
7901
8060
|
getPubKeys(bearerToken: string,
|
7902
8061
|
userIds?:Array<string>,
|
@@ -9522,6 +9681,42 @@ pushPubKey(bearerToken: string,
|
|
9522
9681
|
]);
|
9523
9682
|
}
|
9524
9683
|
|
9684
|
+
/** Get user status */
|
9685
|
+
listWalletLedger(
|
9686
|
+
bearerToken: string,
|
9687
|
+
limit?: number,
|
9688
|
+
cursor?: string,
|
9689
|
+
options: any = {}
|
9690
|
+
): Promise<ApiWalletLedgerList> {
|
9691
|
+
const urlPath = "/v2/walletledger";
|
9692
|
+
const queryParams = new Map<string, any>();
|
9693
|
+
queryParams.set("limit", limit);
|
9694
|
+
queryParams.set("cursor", cursor);
|
9695
|
+
|
9696
|
+
let bodyJson: string = "";
|
9697
|
+
|
9698
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
9699
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
9700
|
+
if (bearerToken) {
|
9701
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
9702
|
+
}
|
9703
|
+
|
9704
|
+
return Promise.race([
|
9705
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
9706
|
+
if (response.status == 204) {
|
9707
|
+
return response;
|
9708
|
+
} else if (response.status >= 200 && response.status < 300) {
|
9709
|
+
return response.json();
|
9710
|
+
} else {
|
9711
|
+
throw response;
|
9712
|
+
}
|
9713
|
+
}),
|
9714
|
+
new Promise((_, reject) =>
|
9715
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
9716
|
+
),
|
9717
|
+
]);
|
9718
|
+
}
|
9719
|
+
|
9525
9720
|
/** create webhook */
|
9526
9721
|
generateWebhook(
|
9527
9722
|
bearerToken: string,
|
package/client.ts
CHANGED
@@ -153,6 +153,9 @@ import {
|
|
153
153
|
ApiUserStatus,
|
154
154
|
ApiListOnboardingStepResponse,
|
155
155
|
MezonUpdateOnboardingStepByClanIdBody,
|
156
|
+
ApiPTTChannelUserList,
|
157
|
+
ApiCustomDisplay,
|
158
|
+
ApiWalletLedgerList,
|
156
159
|
} from "./api.gen";
|
157
160
|
|
158
161
|
import { Session } from "./session";
|
@@ -4633,7 +4636,7 @@ export class Client {
|
|
4633
4636
|
session: Session,
|
4634
4637
|
clan_id?: string,
|
4635
4638
|
limit?: number,
|
4636
|
-
page
|
4639
|
+
page?: number
|
4637
4640
|
): Promise<ApiListOnboardingStepResponse> {
|
4638
4641
|
if (
|
4639
4642
|
this.autoRefreshSession &&
|
@@ -4672,10 +4675,7 @@ export class Client {
|
|
4672
4675
|
}
|
4673
4676
|
|
4674
4677
|
//**update status */
|
4675
|
-
async updateUserStatus(
|
4676
|
-
session: Session,
|
4677
|
-
request: ApiUserStatusUpdate
|
4678
|
-
) {
|
4678
|
+
async updateUserStatus(session: Session, request: ApiUserStatusUpdate) {
|
4679
4679
|
if (
|
4680
4680
|
this.autoRefreshSession &&
|
4681
4681
|
session.refresh_token &&
|
@@ -4692,9 +4692,7 @@ export class Client {
|
|
4692
4692
|
}
|
4693
4693
|
|
4694
4694
|
//**get user status */
|
4695
|
-
async getUserStatus(
|
4696
|
-
session: Session
|
4697
|
-
): Promise<ApiUserStatus> {
|
4695
|
+
async getUserStatus(session: Session): Promise<ApiUserStatus> {
|
4698
4696
|
if (
|
4699
4697
|
this.autoRefreshSession &&
|
4700
4698
|
session.refresh_token &&
|
@@ -4709,5 +4707,108 @@ export class Client {
|
|
4709
4707
|
return Promise.resolve(response);
|
4710
4708
|
});
|
4711
4709
|
}
|
4712
|
-
|
4710
|
+
|
4711
|
+
/** List a ptt channel's users. */
|
4712
|
+
async listPTTChannelUsers(
|
4713
|
+
session: Session,
|
4714
|
+
clanId: string,
|
4715
|
+
channelId: string,
|
4716
|
+
channelType: number,
|
4717
|
+
state?: number,
|
4718
|
+
limit?: number,
|
4719
|
+
cursor?: string
|
4720
|
+
): Promise<ApiPTTChannelUserList> {
|
4721
|
+
if (
|
4722
|
+
this.autoRefreshSession &&
|
4723
|
+
session.refresh_token &&
|
4724
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
4725
|
+
) {
|
4726
|
+
await this.sessionRefresh(session);
|
4727
|
+
}
|
4728
|
+
|
4729
|
+
return this.apiClient
|
4730
|
+
.listPTTChannelUsers(
|
4731
|
+
session.token,
|
4732
|
+
clanId,
|
4733
|
+
channelId,
|
4734
|
+
channelType,
|
4735
|
+
limit,
|
4736
|
+
state,
|
4737
|
+
cursor
|
4738
|
+
)
|
4739
|
+
.then((response: ApiPTTChannelUserList) => {
|
4740
|
+
var result: ApiPTTChannelUserList = {
|
4741
|
+
ptt_channel_users: [],
|
4742
|
+
};
|
4743
|
+
|
4744
|
+
if (response.ptt_channel_users == null) {
|
4745
|
+
return Promise.resolve(result);
|
4746
|
+
}
|
4747
|
+
|
4748
|
+
response.ptt_channel_users!.forEach((gu) => {
|
4749
|
+
result.ptt_channel_users!.push({
|
4750
|
+
id: gu.id,
|
4751
|
+
channel_id: gu.channel_id,
|
4752
|
+
user_id: gu.user_id,
|
4753
|
+
participant: gu.participant,
|
4754
|
+
});
|
4755
|
+
});
|
4756
|
+
return Promise.resolve(result);
|
4757
|
+
});
|
4758
|
+
}
|
4759
|
+
|
4760
|
+
//**get custom display */
|
4761
|
+
async getCustomDisplay(session: Session): Promise<ApiCustomDisplay> {
|
4762
|
+
if (
|
4763
|
+
this.autoRefreshSession &&
|
4764
|
+
session.refresh_token &&
|
4765
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
4766
|
+
) {
|
4767
|
+
await this.sessionRefresh(session);
|
4768
|
+
}
|
4769
|
+
|
4770
|
+
return this.apiClient
|
4771
|
+
.getCustomDisplay(session.token)
|
4772
|
+
.then((response: ApiCustomDisplay) => {
|
4773
|
+
return Promise.resolve(response);
|
4774
|
+
});
|
4775
|
+
}
|
4776
|
+
|
4777
|
+
//**update custom display */
|
4778
|
+
async updateCustomDisplay(session: Session, request: ApiCustomDisplay) {
|
4779
|
+
if (
|
4780
|
+
this.autoRefreshSession &&
|
4781
|
+
session.refresh_token &&
|
4782
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
4783
|
+
) {
|
4784
|
+
await this.sessionRefresh(session);
|
4785
|
+
}
|
4786
|
+
|
4787
|
+
return this.apiClient
|
4788
|
+
.updateCustomDisplay(session.token, request)
|
4789
|
+
.then((response: any) => {
|
4790
|
+
return response !== undefined;
|
4791
|
+
});
|
4792
|
+
}
|
4793
|
+
|
4794
|
+
//**list wallet ledger */
|
4795
|
+
async listWalletLedger(
|
4796
|
+
session: Session,
|
4797
|
+
limit?: number,
|
4798
|
+
cursor?: string
|
4799
|
+
): Promise<ApiWalletLedgerList> {
|
4800
|
+
if (
|
4801
|
+
this.autoRefreshSession &&
|
4802
|
+
session.refresh_token &&
|
4803
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
4804
|
+
) {
|
4805
|
+
await this.sessionRefresh(session);
|
4806
|
+
}
|
4807
|
+
|
4808
|
+
return this.apiClient
|
4809
|
+
.listWalletLedger(session.token, limit, cursor)
|
4810
|
+
.then((response: ApiWalletLedgerList) => {
|
4811
|
+
return Promise.resolve(response);
|
4812
|
+
});
|
4813
|
+
}
|
4713
4814
|
}
|
package/dist/api.gen.d.ts
CHANGED
@@ -663,6 +663,11 @@ export interface ApiCreateRoleRequest {
|
|
663
663
|
role_icon?: string;
|
664
664
|
title?: string;
|
665
665
|
}
|
666
|
+
/** */
|
667
|
+
export interface ApiCustomDisplay {
|
668
|
+
logo?: string;
|
669
|
+
splash_screen?: string;
|
670
|
+
}
|
666
671
|
/** Delete a channel the user has access to. */
|
667
672
|
export interface ApiDeleteChannelDescRequest {
|
668
673
|
channel_id?: string;
|
@@ -998,6 +1003,17 @@ export interface ApiOssrsHttpCallbackResponse {
|
|
998
1003
|
code?: number;
|
999
1004
|
msg?: string;
|
1000
1005
|
}
|
1006
|
+
/** A list of users belonging to a channel, along with their role. */
|
1007
|
+
export interface ApiPTTChannelUser {
|
1008
|
+
channel_id?: string;
|
1009
|
+
id?: string;
|
1010
|
+
participant?: string;
|
1011
|
+
user_id?: string;
|
1012
|
+
}
|
1013
|
+
/** A list of users belonging to a channel, along with their role. */
|
1014
|
+
export interface ApiPTTChannelUserList {
|
1015
|
+
ptt_channel_users?: Array<ApiPTTChannelUser>;
|
1016
|
+
}
|
1001
1017
|
/** */
|
1002
1018
|
export interface ApiPermission {
|
1003
1019
|
active?: number;
|
@@ -1385,6 +1401,19 @@ export interface ApiVoiceChannelUserList {
|
|
1385
1401
|
voice_channel_users?: Array<ApiVoiceChannelUser>;
|
1386
1402
|
}
|
1387
1403
|
/** */
|
1404
|
+
export interface ApiWalletLedger {
|
1405
|
+
create_time?: string;
|
1406
|
+
id?: string;
|
1407
|
+
user_id?: string;
|
1408
|
+
value?: number;
|
1409
|
+
}
|
1410
|
+
/** */
|
1411
|
+
export interface ApiWalletLedgerList {
|
1412
|
+
next_cursor?: string;
|
1413
|
+
prev_cursor?: string;
|
1414
|
+
wallet_ledger?: Array<ApiWalletLedger>;
|
1415
|
+
}
|
1416
|
+
/** */
|
1388
1417
|
export interface ApiWebhook {
|
1389
1418
|
active?: number;
|
1390
1419
|
avatar?: string;
|
@@ -1708,6 +1737,10 @@ export declare class MezonApi {
|
|
1708
1737
|
/** */
|
1709
1738
|
createCategoryDesc(bearerToken: string, body: ApiCreateCategoryDescRequest, options?: any): Promise<ApiCategoryDesc>;
|
1710
1739
|
/** */
|
1740
|
+
getCustomDisplay(bearerToken: string, options?: any): Promise<ApiCustomDisplay>;
|
1741
|
+
/** */
|
1742
|
+
updateCustomDisplay(bearerToken: string, body: ApiCustomDisplay, options?: any): Promise<any>;
|
1743
|
+
/** */
|
1711
1744
|
deleteCategoryDesc(bearerToken: string, categoryId: string, clanId: string, options?: any): Promise<any>;
|
1712
1745
|
/** */
|
1713
1746
|
deleteCategoryOrder(bearerToken: string, clanId: string, options?: any): Promise<any>;
|
@@ -1815,6 +1848,8 @@ export declare class MezonApi {
|
|
1815
1848
|
getPinMessagesList(bearerToken: string, messageId?: string, channelId?: string, clanId?: string, options?: any): Promise<ApiPinMessagesList>;
|
1816
1849
|
/** set notification user channel. */
|
1817
1850
|
createPinMessage(bearerToken: string, body: ApiPinMessageRequest, options?: any): Promise<ApiChannelMessageHeader>;
|
1851
|
+
/** List all users in ptt channel. */
|
1852
|
+
listPTTChannelUsers(bearerToken: string, clanId?: string, channelId?: string, channelType?: number, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiPTTChannelUserList>;
|
1818
1853
|
/** get pubkey */
|
1819
1854
|
getPubKeys(bearerToken: string, userIds?: Array<string>, options?: any): Promise<ApiGetPubKeysResponse>;
|
1820
1855
|
/** store pubkey for e2ee */
|
@@ -1895,6 +1930,8 @@ export declare class MezonApi {
|
|
1895
1930
|
getUserStatus(bearerToken: string, options?: any): Promise<ApiUserStatus>;
|
1896
1931
|
/** Update user status */
|
1897
1932
|
updateUserStatus(bearerToken: string, body: ApiUserStatusUpdate, options?: any): Promise<any>;
|
1933
|
+
/** Get user status */
|
1934
|
+
listWalletLedger(bearerToken: string, limit?: number, cursor?: string, options?: any): Promise<ApiWalletLedgerList>;
|
1898
1935
|
/** create webhook */
|
1899
1936
|
generateWebhook(bearerToken: string, body: ApiWebhookCreateRequest, options?: any): Promise<any>;
|
1900
1937
|
/** update webhook name by id */
|
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, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent, MezonDeleteWebhookByIdBody, ApiWithdrawTokenRequest, ApiListOnboardingResponse, ApiCreateOnboardingRequest, MezonUpdateOnboardingBody, ApiOnboardingItem, ApiGenerateClanWebhookRequest, ApiGenerateClanWebhookResponse, ApiListClanWebhookResponse, MezonUpdateClanWebhookByIdBody, MezonUpdateClanDescBody, ApiUserStatusUpdate, ApiUserStatus, ApiListOnboardingStepResponse, MezonUpdateOnboardingStepByClanIdBody } from "./api.gen";
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent, MezonDeleteWebhookByIdBody, ApiWithdrawTokenRequest, ApiListOnboardingResponse, ApiCreateOnboardingRequest, MezonUpdateOnboardingBody, ApiOnboardingItem, ApiGenerateClanWebhookRequest, ApiGenerateClanWebhookResponse, ApiListClanWebhookResponse, MezonUpdateClanWebhookByIdBody, MezonUpdateClanDescBody, ApiUserStatusUpdate, ApiUserStatus, ApiListOnboardingStepResponse, MezonUpdateOnboardingStepByClanIdBody, ApiPTTChannelUserList, ApiCustomDisplay, ApiWalletLedgerList } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -627,4 +627,9 @@ export declare class Client {
|
|
627
627
|
updateOnboardingStepByClanId(session: Session, clan_id: string, request: MezonUpdateOnboardingStepByClanIdBody): Promise<boolean>;
|
628
628
|
updateUserStatus(session: Session, request: ApiUserStatusUpdate): Promise<boolean>;
|
629
629
|
getUserStatus(session: Session): Promise<ApiUserStatus>;
|
630
|
+
/** List a ptt channel's users. */
|
631
|
+
listPTTChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiPTTChannelUserList>;
|
632
|
+
getCustomDisplay(session: Session): Promise<ApiCustomDisplay>;
|
633
|
+
updateCustomDisplay(session: Session, request: ApiCustomDisplay): Promise<boolean>;
|
634
|
+
listWalletLedger(session: Session, limit?: number, cursor?: string): Promise<ApiWalletLedgerList>;
|
630
635
|
}
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -3188,6 +3188,60 @@ var MezonApi = class {
|
|
3188
3188
|
]);
|
3189
3189
|
}
|
3190
3190
|
/** */
|
3191
|
+
getCustomDisplay(bearerToken, options = {}) {
|
3192
|
+
const urlPath = "/v2/customdisplay";
|
3193
|
+
const queryParams = /* @__PURE__ */ new Map();
|
3194
|
+
let bodyJson = "";
|
3195
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3196
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
3197
|
+
if (bearerToken) {
|
3198
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3199
|
+
}
|
3200
|
+
return Promise.race([
|
3201
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3202
|
+
if (response.status == 204) {
|
3203
|
+
return response;
|
3204
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3205
|
+
return response.json();
|
3206
|
+
} else {
|
3207
|
+
throw response;
|
3208
|
+
}
|
3209
|
+
}),
|
3210
|
+
new Promise(
|
3211
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3212
|
+
)
|
3213
|
+
]);
|
3214
|
+
}
|
3215
|
+
/** */
|
3216
|
+
updateCustomDisplay(bearerToken, body, options = {}) {
|
3217
|
+
if (body === null || body === void 0) {
|
3218
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
3219
|
+
}
|
3220
|
+
const urlPath = "/v2/customdisplay";
|
3221
|
+
const queryParams = /* @__PURE__ */ new Map();
|
3222
|
+
let bodyJson = "";
|
3223
|
+
bodyJson = JSON.stringify(body || {});
|
3224
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3225
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
3226
|
+
if (bearerToken) {
|
3227
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3228
|
+
}
|
3229
|
+
return Promise.race([
|
3230
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3231
|
+
if (response.status == 204) {
|
3232
|
+
return response;
|
3233
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3234
|
+
return response.json();
|
3235
|
+
} else {
|
3236
|
+
throw response;
|
3237
|
+
}
|
3238
|
+
}),
|
3239
|
+
new Promise(
|
3240
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3241
|
+
)
|
3242
|
+
]);
|
3243
|
+
}
|
3244
|
+
/** */
|
3191
3245
|
deleteCategoryDesc(bearerToken, categoryId, clanId, options = {}) {
|
3192
3246
|
if (categoryId === null || categoryId === void 0) {
|
3193
3247
|
throw new Error(
|
@@ -4780,6 +4834,37 @@ var MezonApi = class {
|
|
4780
4834
|
)
|
4781
4835
|
]);
|
4782
4836
|
}
|
4837
|
+
/** List all users in ptt channel. */
|
4838
|
+
listPTTChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
|
4839
|
+
const urlPath = "/v2/ptt_channels/users";
|
4840
|
+
const queryParams = /* @__PURE__ */ new Map();
|
4841
|
+
queryParams.set("clan_id", clanId);
|
4842
|
+
queryParams.set("channel_id", channelId);
|
4843
|
+
queryParams.set("channel_type", channelType);
|
4844
|
+
queryParams.set("limit", limit);
|
4845
|
+
queryParams.set("state", state);
|
4846
|
+
queryParams.set("cursor", cursor);
|
4847
|
+
let bodyJson = "";
|
4848
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
4849
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
4850
|
+
if (bearerToken) {
|
4851
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
4852
|
+
}
|
4853
|
+
return Promise.race([
|
4854
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
4855
|
+
if (response.status == 204) {
|
4856
|
+
return response;
|
4857
|
+
} else if (response.status >= 200 && response.status < 300) {
|
4858
|
+
return response.json();
|
4859
|
+
} else {
|
4860
|
+
throw response;
|
4861
|
+
}
|
4862
|
+
}),
|
4863
|
+
new Promise(
|
4864
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
4865
|
+
)
|
4866
|
+
]);
|
4867
|
+
}
|
4783
4868
|
/** get pubkey */
|
4784
4869
|
getPubKeys(bearerToken, userIds, options = {}) {
|
4785
4870
|
const urlPath = "/v2/pubkey";
|
@@ -6059,6 +6144,33 @@ var MezonApi = class {
|
|
6059
6144
|
)
|
6060
6145
|
]);
|
6061
6146
|
}
|
6147
|
+
/** Get user status */
|
6148
|
+
listWalletLedger(bearerToken, limit, cursor, options = {}) {
|
6149
|
+
const urlPath = "/v2/walletledger";
|
6150
|
+
const queryParams = /* @__PURE__ */ new Map();
|
6151
|
+
queryParams.set("limit", limit);
|
6152
|
+
queryParams.set("cursor", cursor);
|
6153
|
+
let bodyJson = "";
|
6154
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6155
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
6156
|
+
if (bearerToken) {
|
6157
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6158
|
+
}
|
6159
|
+
return Promise.race([
|
6160
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
6161
|
+
if (response.status == 204) {
|
6162
|
+
return response;
|
6163
|
+
} else if (response.status >= 200 && response.status < 300) {
|
6164
|
+
return response.json();
|
6165
|
+
} else {
|
6166
|
+
throw response;
|
6167
|
+
}
|
6168
|
+
}),
|
6169
|
+
new Promise(
|
6170
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6171
|
+
)
|
6172
|
+
]);
|
6173
|
+
}
|
6062
6174
|
/** create webhook */
|
6063
6175
|
generateWebhook(bearerToken, body, options = {}) {
|
6064
6176
|
if (body === null || body === void 0) {
|
@@ -7064,6 +7176,10 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7064
7176
|
this.onjoinpttchannel(message.join_ptt_channel);
|
7065
7177
|
} else if (message.talk_ptt_channel) {
|
7066
7178
|
this.ontalkpttchannel(message.talk_ptt_channel);
|
7179
|
+
} else if (message.ptt_joined_event) {
|
7180
|
+
this.onpttchanneljoined(message.ptt_joined_event);
|
7181
|
+
} else if (message.ptt_leaved_event) {
|
7182
|
+
this.onpttchannelleaved(message.ptt_leaved_event);
|
7067
7183
|
} else {
|
7068
7184
|
if (this.verbose && window && window.console) {
|
7069
7185
|
console.log("Unrecognized message received: %o", message);
|
@@ -7321,6 +7437,16 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7321
7437
|
console.log(streaming_leaved_event);
|
7322
7438
|
}
|
7323
7439
|
}
|
7440
|
+
onpttchanneljoined(ptt_joined_event) {
|
7441
|
+
if (this.verbose && window && window.console) {
|
7442
|
+
console.log(ptt_joined_event);
|
7443
|
+
}
|
7444
|
+
}
|
7445
|
+
onpttchannelleaved(ptt_leaved_event) {
|
7446
|
+
if (this.verbose && window && window.console) {
|
7447
|
+
console.log(ptt_leaved_event);
|
7448
|
+
}
|
7449
|
+
}
|
7324
7450
|
onpermissionset(permission_set_event) {
|
7325
7451
|
if (this.verbose && window && window.console) {
|
7326
7452
|
console.log(permission_set_event);
|
@@ -7648,7 +7774,7 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7648
7774
|
handleDropdownBoxSelected(message_id, channel_id, selectbox_id, sender_id, user_id, value) {
|
7649
7775
|
return __async(this, null, function* () {
|
7650
7776
|
const response = yield this.send({
|
7651
|
-
|
7777
|
+
dropdown_box_selected: {
|
7652
7778
|
message_id,
|
7653
7779
|
channel_id,
|
7654
7780
|
selectbox_id,
|
@@ -7675,10 +7801,11 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7675
7801
|
return response.webrtc_signaling_fwd;
|
7676
7802
|
});
|
7677
7803
|
}
|
7678
|
-
joinPTTChannel(channelId, dataType, jsonData) {
|
7804
|
+
joinPTTChannel(clanId, channelId, dataType, jsonData) {
|
7679
7805
|
return __async(this, null, function* () {
|
7680
7806
|
const response = yield this.send({
|
7681
7807
|
join_ptt_channel: {
|
7808
|
+
clan_id: clanId,
|
7682
7809
|
channel_id: channelId,
|
7683
7810
|
data_type: dataType,
|
7684
7811
|
json_data: jsonData,
|
@@ -10232,4 +10359,70 @@ var Client = class {
|
|
10232
10359
|
});
|
10233
10360
|
});
|
10234
10361
|
}
|
10362
|
+
/** List a ptt channel's users. */
|
10363
|
+
listPTTChannelUsers(session, clanId, channelId, channelType, state, limit, cursor) {
|
10364
|
+
return __async(this, null, function* () {
|
10365
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10366
|
+
yield this.sessionRefresh(session);
|
10367
|
+
}
|
10368
|
+
return this.apiClient.listPTTChannelUsers(
|
10369
|
+
session.token,
|
10370
|
+
clanId,
|
10371
|
+
channelId,
|
10372
|
+
channelType,
|
10373
|
+
limit,
|
10374
|
+
state,
|
10375
|
+
cursor
|
10376
|
+
).then((response) => {
|
10377
|
+
var result = {
|
10378
|
+
ptt_channel_users: []
|
10379
|
+
};
|
10380
|
+
if (response.ptt_channel_users == null) {
|
10381
|
+
return Promise.resolve(result);
|
10382
|
+
}
|
10383
|
+
response.ptt_channel_users.forEach((gu) => {
|
10384
|
+
result.ptt_channel_users.push({
|
10385
|
+
id: gu.id,
|
10386
|
+
channel_id: gu.channel_id,
|
10387
|
+
user_id: gu.user_id,
|
10388
|
+
participant: gu.participant
|
10389
|
+
});
|
10390
|
+
});
|
10391
|
+
return Promise.resolve(result);
|
10392
|
+
});
|
10393
|
+
});
|
10394
|
+
}
|
10395
|
+
//**get custom display */
|
10396
|
+
getCustomDisplay(session) {
|
10397
|
+
return __async(this, null, function* () {
|
10398
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10399
|
+
yield this.sessionRefresh(session);
|
10400
|
+
}
|
10401
|
+
return this.apiClient.getCustomDisplay(session.token).then((response) => {
|
10402
|
+
return Promise.resolve(response);
|
10403
|
+
});
|
10404
|
+
});
|
10405
|
+
}
|
10406
|
+
//**update custom display */
|
10407
|
+
updateCustomDisplay(session, request) {
|
10408
|
+
return __async(this, null, function* () {
|
10409
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10410
|
+
yield this.sessionRefresh(session);
|
10411
|
+
}
|
10412
|
+
return this.apiClient.updateCustomDisplay(session.token, request).then((response) => {
|
10413
|
+
return response !== void 0;
|
10414
|
+
});
|
10415
|
+
});
|
10416
|
+
}
|
10417
|
+
//**list wallet ledger */
|
10418
|
+
listWalletLedger(session, limit, cursor) {
|
10419
|
+
return __async(this, null, function* () {
|
10420
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10421
|
+
yield this.sessionRefresh(session);
|
10422
|
+
}
|
10423
|
+
return this.apiClient.listWalletLedger(session.token, limit, cursor).then((response) => {
|
10424
|
+
return Promise.resolve(response);
|
10425
|
+
});
|
10426
|
+
});
|
10427
|
+
}
|
10235
10428
|
};
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -3158,6 +3158,60 @@ var MezonApi = class {
|
|
3158
3158
|
]);
|
3159
3159
|
}
|
3160
3160
|
/** */
|
3161
|
+
getCustomDisplay(bearerToken, options = {}) {
|
3162
|
+
const urlPath = "/v2/customdisplay";
|
3163
|
+
const queryParams = /* @__PURE__ */ new Map();
|
3164
|
+
let bodyJson = "";
|
3165
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3166
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
3167
|
+
if (bearerToken) {
|
3168
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3169
|
+
}
|
3170
|
+
return Promise.race([
|
3171
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3172
|
+
if (response.status == 204) {
|
3173
|
+
return response;
|
3174
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3175
|
+
return response.json();
|
3176
|
+
} else {
|
3177
|
+
throw response;
|
3178
|
+
}
|
3179
|
+
}),
|
3180
|
+
new Promise(
|
3181
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3182
|
+
)
|
3183
|
+
]);
|
3184
|
+
}
|
3185
|
+
/** */
|
3186
|
+
updateCustomDisplay(bearerToken, body, options = {}) {
|
3187
|
+
if (body === null || body === void 0) {
|
3188
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
3189
|
+
}
|
3190
|
+
const urlPath = "/v2/customdisplay";
|
3191
|
+
const queryParams = /* @__PURE__ */ new Map();
|
3192
|
+
let bodyJson = "";
|
3193
|
+
bodyJson = JSON.stringify(body || {});
|
3194
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3195
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
3196
|
+
if (bearerToken) {
|
3197
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3198
|
+
}
|
3199
|
+
return Promise.race([
|
3200
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
3201
|
+
if (response.status == 204) {
|
3202
|
+
return response;
|
3203
|
+
} else if (response.status >= 200 && response.status < 300) {
|
3204
|
+
return response.json();
|
3205
|
+
} else {
|
3206
|
+
throw response;
|
3207
|
+
}
|
3208
|
+
}),
|
3209
|
+
new Promise(
|
3210
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3211
|
+
)
|
3212
|
+
]);
|
3213
|
+
}
|
3214
|
+
/** */
|
3161
3215
|
deleteCategoryDesc(bearerToken, categoryId, clanId, options = {}) {
|
3162
3216
|
if (categoryId === null || categoryId === void 0) {
|
3163
3217
|
throw new Error(
|
@@ -4750,6 +4804,37 @@ var MezonApi = class {
|
|
4750
4804
|
)
|
4751
4805
|
]);
|
4752
4806
|
}
|
4807
|
+
/** List all users in ptt channel. */
|
4808
|
+
listPTTChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
|
4809
|
+
const urlPath = "/v2/ptt_channels/users";
|
4810
|
+
const queryParams = /* @__PURE__ */ new Map();
|
4811
|
+
queryParams.set("clan_id", clanId);
|
4812
|
+
queryParams.set("channel_id", channelId);
|
4813
|
+
queryParams.set("channel_type", channelType);
|
4814
|
+
queryParams.set("limit", limit);
|
4815
|
+
queryParams.set("state", state);
|
4816
|
+
queryParams.set("cursor", cursor);
|
4817
|
+
let bodyJson = "";
|
4818
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
4819
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
4820
|
+
if (bearerToken) {
|
4821
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
4822
|
+
}
|
4823
|
+
return Promise.race([
|
4824
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
4825
|
+
if (response.status == 204) {
|
4826
|
+
return response;
|
4827
|
+
} else if (response.status >= 200 && response.status < 300) {
|
4828
|
+
return response.json();
|
4829
|
+
} else {
|
4830
|
+
throw response;
|
4831
|
+
}
|
4832
|
+
}),
|
4833
|
+
new Promise(
|
4834
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
4835
|
+
)
|
4836
|
+
]);
|
4837
|
+
}
|
4753
4838
|
/** get pubkey */
|
4754
4839
|
getPubKeys(bearerToken, userIds, options = {}) {
|
4755
4840
|
const urlPath = "/v2/pubkey";
|
@@ -6029,6 +6114,33 @@ var MezonApi = class {
|
|
6029
6114
|
)
|
6030
6115
|
]);
|
6031
6116
|
}
|
6117
|
+
/** Get user status */
|
6118
|
+
listWalletLedger(bearerToken, limit, cursor, options = {}) {
|
6119
|
+
const urlPath = "/v2/walletledger";
|
6120
|
+
const queryParams = /* @__PURE__ */ new Map();
|
6121
|
+
queryParams.set("limit", limit);
|
6122
|
+
queryParams.set("cursor", cursor);
|
6123
|
+
let bodyJson = "";
|
6124
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6125
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
6126
|
+
if (bearerToken) {
|
6127
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6128
|
+
}
|
6129
|
+
return Promise.race([
|
6130
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
6131
|
+
if (response.status == 204) {
|
6132
|
+
return response;
|
6133
|
+
} else if (response.status >= 200 && response.status < 300) {
|
6134
|
+
return response.json();
|
6135
|
+
} else {
|
6136
|
+
throw response;
|
6137
|
+
}
|
6138
|
+
}),
|
6139
|
+
new Promise(
|
6140
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6141
|
+
)
|
6142
|
+
]);
|
6143
|
+
}
|
6032
6144
|
/** create webhook */
|
6033
6145
|
generateWebhook(bearerToken, body, options = {}) {
|
6034
6146
|
if (body === null || body === void 0) {
|
@@ -7034,6 +7146,10 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7034
7146
|
this.onjoinpttchannel(message.join_ptt_channel);
|
7035
7147
|
} else if (message.talk_ptt_channel) {
|
7036
7148
|
this.ontalkpttchannel(message.talk_ptt_channel);
|
7149
|
+
} else if (message.ptt_joined_event) {
|
7150
|
+
this.onpttchanneljoined(message.ptt_joined_event);
|
7151
|
+
} else if (message.ptt_leaved_event) {
|
7152
|
+
this.onpttchannelleaved(message.ptt_leaved_event);
|
7037
7153
|
} else {
|
7038
7154
|
if (this.verbose && window && window.console) {
|
7039
7155
|
console.log("Unrecognized message received: %o", message);
|
@@ -7291,6 +7407,16 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7291
7407
|
console.log(streaming_leaved_event);
|
7292
7408
|
}
|
7293
7409
|
}
|
7410
|
+
onpttchanneljoined(ptt_joined_event) {
|
7411
|
+
if (this.verbose && window && window.console) {
|
7412
|
+
console.log(ptt_joined_event);
|
7413
|
+
}
|
7414
|
+
}
|
7415
|
+
onpttchannelleaved(ptt_leaved_event) {
|
7416
|
+
if (this.verbose && window && window.console) {
|
7417
|
+
console.log(ptt_leaved_event);
|
7418
|
+
}
|
7419
|
+
}
|
7294
7420
|
onpermissionset(permission_set_event) {
|
7295
7421
|
if (this.verbose && window && window.console) {
|
7296
7422
|
console.log(permission_set_event);
|
@@ -7618,7 +7744,7 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7618
7744
|
handleDropdownBoxSelected(message_id, channel_id, selectbox_id, sender_id, user_id, value) {
|
7619
7745
|
return __async(this, null, function* () {
|
7620
7746
|
const response = yield this.send({
|
7621
|
-
|
7747
|
+
dropdown_box_selected: {
|
7622
7748
|
message_id,
|
7623
7749
|
channel_id,
|
7624
7750
|
selectbox_id,
|
@@ -7645,10 +7771,11 @@ var _DefaultSocket = class _DefaultSocket {
|
|
7645
7771
|
return response.webrtc_signaling_fwd;
|
7646
7772
|
});
|
7647
7773
|
}
|
7648
|
-
joinPTTChannel(channelId, dataType, jsonData) {
|
7774
|
+
joinPTTChannel(clanId, channelId, dataType, jsonData) {
|
7649
7775
|
return __async(this, null, function* () {
|
7650
7776
|
const response = yield this.send({
|
7651
7777
|
join_ptt_channel: {
|
7778
|
+
clan_id: clanId,
|
7652
7779
|
channel_id: channelId,
|
7653
7780
|
data_type: dataType,
|
7654
7781
|
json_data: jsonData,
|
@@ -10202,6 +10329,72 @@ var Client = class {
|
|
10202
10329
|
});
|
10203
10330
|
});
|
10204
10331
|
}
|
10332
|
+
/** List a ptt channel's users. */
|
10333
|
+
listPTTChannelUsers(session, clanId, channelId, channelType, state, limit, cursor) {
|
10334
|
+
return __async(this, null, function* () {
|
10335
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10336
|
+
yield this.sessionRefresh(session);
|
10337
|
+
}
|
10338
|
+
return this.apiClient.listPTTChannelUsers(
|
10339
|
+
session.token,
|
10340
|
+
clanId,
|
10341
|
+
channelId,
|
10342
|
+
channelType,
|
10343
|
+
limit,
|
10344
|
+
state,
|
10345
|
+
cursor
|
10346
|
+
).then((response) => {
|
10347
|
+
var result = {
|
10348
|
+
ptt_channel_users: []
|
10349
|
+
};
|
10350
|
+
if (response.ptt_channel_users == null) {
|
10351
|
+
return Promise.resolve(result);
|
10352
|
+
}
|
10353
|
+
response.ptt_channel_users.forEach((gu) => {
|
10354
|
+
result.ptt_channel_users.push({
|
10355
|
+
id: gu.id,
|
10356
|
+
channel_id: gu.channel_id,
|
10357
|
+
user_id: gu.user_id,
|
10358
|
+
participant: gu.participant
|
10359
|
+
});
|
10360
|
+
});
|
10361
|
+
return Promise.resolve(result);
|
10362
|
+
});
|
10363
|
+
});
|
10364
|
+
}
|
10365
|
+
//**get custom display */
|
10366
|
+
getCustomDisplay(session) {
|
10367
|
+
return __async(this, null, function* () {
|
10368
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10369
|
+
yield this.sessionRefresh(session);
|
10370
|
+
}
|
10371
|
+
return this.apiClient.getCustomDisplay(session.token).then((response) => {
|
10372
|
+
return Promise.resolve(response);
|
10373
|
+
});
|
10374
|
+
});
|
10375
|
+
}
|
10376
|
+
//**update custom display */
|
10377
|
+
updateCustomDisplay(session, request) {
|
10378
|
+
return __async(this, null, function* () {
|
10379
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10380
|
+
yield this.sessionRefresh(session);
|
10381
|
+
}
|
10382
|
+
return this.apiClient.updateCustomDisplay(session.token, request).then((response) => {
|
10383
|
+
return response !== void 0;
|
10384
|
+
});
|
10385
|
+
});
|
10386
|
+
}
|
10387
|
+
//**list wallet ledger */
|
10388
|
+
listWalletLedger(session, limit, cursor) {
|
10389
|
+
return __async(this, null, function* () {
|
10390
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10391
|
+
yield this.sessionRefresh(session);
|
10392
|
+
}
|
10393
|
+
return this.apiClient.listWalletLedger(session.token, limit, cursor).then((response) => {
|
10394
|
+
return Promise.resolve(response);
|
10395
|
+
});
|
10396
|
+
});
|
10397
|
+
}
|
10205
10398
|
};
|
10206
10399
|
export {
|
10207
10400
|
ChannelStreamMode,
|
package/dist/socket.d.ts
CHANGED
@@ -620,6 +620,8 @@ export interface JoinPTTChannel {
|
|
620
620
|
json_data: string;
|
621
621
|
/** receiver id */
|
622
622
|
receiver_id: string;
|
623
|
+
/** clan id */
|
624
|
+
clan_id: string;
|
623
625
|
}
|
624
626
|
export interface TalkPTTChannel {
|
625
627
|
channel_id: string;
|
@@ -627,6 +629,34 @@ export interface TalkPTTChannel {
|
|
627
629
|
json_data: string;
|
628
630
|
state: number;
|
629
631
|
}
|
632
|
+
/** PTT Joined event */
|
633
|
+
export interface PTTLeavedEvent {
|
634
|
+
/** id */
|
635
|
+
id: string;
|
636
|
+
/** The unique identifier of the chat clan. */
|
637
|
+
clan_id: string;
|
638
|
+
/** channel id */
|
639
|
+
channel_id: string;
|
640
|
+
/** user_id */
|
641
|
+
user_id: string;
|
642
|
+
}
|
643
|
+
/** PTT Joined event */
|
644
|
+
export interface PTTJoinedEvent {
|
645
|
+
/** The unique identifier of the chat clan. */
|
646
|
+
clan_id: string;
|
647
|
+
/** The clan_name */
|
648
|
+
clan_name: string;
|
649
|
+
/** id */
|
650
|
+
id: string;
|
651
|
+
/** ptt participant */
|
652
|
+
participant: string;
|
653
|
+
/** user id */
|
654
|
+
user_id: string;
|
655
|
+
/** channel label */
|
656
|
+
channel_label: string;
|
657
|
+
/** channel id */
|
658
|
+
channel_id: string;
|
659
|
+
}
|
630
660
|
export interface ListActivity {
|
631
661
|
acts: ApiUserActivity[];
|
632
662
|
}
|
@@ -672,7 +702,7 @@ export interface Socket {
|
|
672
702
|
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
673
703
|
/** send voice leaved */
|
674
704
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
675
|
-
joinPTTChannel(channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
|
705
|
+
joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
|
676
706
|
talkPTTChannel(channelId: string, dataType: number, jsonData: string, state: number): Promise<TalkPTTChannel>;
|
677
707
|
setHeartbeatTimeoutMs(ms: number): void;
|
678
708
|
getHeartbeatTimeoutMs(): number;
|
@@ -754,6 +784,8 @@ export interface Socket {
|
|
754
784
|
onactivityupdated: (list_activity: ListActivity) => void;
|
755
785
|
onjoinpttchannel: (join_ptt_channel: JoinPTTChannel) => void;
|
756
786
|
ontalkpttchannel: (talk_ptt_channel: TalkPTTChannel) => void;
|
787
|
+
onpttchanneljoined: (ptt_joined_event: PTTJoinedEvent) => void;
|
788
|
+
onpttchannelleaved: (ptt_leaved_event: PTTLeavedEvent) => void;
|
757
789
|
}
|
758
790
|
/** Reports an error received from a socket message. */
|
759
791
|
export interface SocketError {
|
@@ -824,6 +856,8 @@ export declare class DefaultSocket implements Socket {
|
|
824
856
|
onstreamingchannelended(streaming_ended_event: StreamingEndedEvent): void;
|
825
857
|
onstreamingchanneljoined(streaming_joined_event: StreamingJoinedEvent): void;
|
826
858
|
onstreamingchannelleaved(streaming_leaved_event: StreamingLeavedEvent): void;
|
859
|
+
onpttchanneljoined(ptt_joined_event: PTTJoinedEvent): void;
|
860
|
+
onpttchannelleaved(ptt_leaved_event: PTTLeavedEvent): void;
|
827
861
|
onpermissionset(permission_set_event: PermissionSet): void;
|
828
862
|
onpermissionchanged(permission_changed_event: PermissionChangedEvent): void;
|
829
863
|
onunmuteevent(unmute_event: UnmuteEvent): void;
|
@@ -857,7 +891,7 @@ export declare class DefaultSocket implements Socket {
|
|
857
891
|
makeCallPush(receiver_id: string, json_data: string, channel_id: string, caller_id: string): Promise<IncomingCallPush>;
|
858
892
|
handleDropdownBoxSelected(message_id: string, channel_id: string, selectbox_id: string, sender_id: string, user_id: string, value: Array<string>): Promise<DropdownBoxSelected>;
|
859
893
|
handleMessageButtonClick(message_id: string, channel_id: string, button_id: string, sender_id: string, user_id: string, extra_data: string): Promise<MessageButtonClicked>;
|
860
|
-
joinPTTChannel(channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
|
894
|
+
joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
|
861
895
|
talkPTTChannel(channelId: string, dataType: number, jsonData: string, state: number): Promise<TalkPTTChannel>;
|
862
896
|
private pingPong;
|
863
897
|
}
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -872,6 +872,8 @@ export interface JoinPTTChannel {
|
|
872
872
|
json_data: string;
|
873
873
|
/** receiver id */
|
874
874
|
receiver_id: string;
|
875
|
+
/** clan id */
|
876
|
+
clan_id: string;
|
875
877
|
}
|
876
878
|
|
877
879
|
export interface TalkPTTChannel {
|
@@ -885,6 +887,36 @@ export interface TalkPTTChannel {
|
|
885
887
|
state: number;
|
886
888
|
}
|
887
889
|
|
890
|
+
/** PTT Joined event */
|
891
|
+
export interface PTTLeavedEvent {
|
892
|
+
/** id */
|
893
|
+
id: string;
|
894
|
+
/** The unique identifier of the chat clan. */
|
895
|
+
clan_id: string;
|
896
|
+
/** channel id */
|
897
|
+
channel_id: string;
|
898
|
+
/** user_id */
|
899
|
+
user_id: string;
|
900
|
+
}
|
901
|
+
|
902
|
+
/** PTT Joined event */
|
903
|
+
export interface PTTJoinedEvent {
|
904
|
+
/** The unique identifier of the chat clan. */
|
905
|
+
clan_id: string;
|
906
|
+
/** The clan_name */
|
907
|
+
clan_name: string;
|
908
|
+
/** id */
|
909
|
+
id: string;
|
910
|
+
/** ptt participant */
|
911
|
+
participant: string;
|
912
|
+
/** user id */
|
913
|
+
user_id: string;
|
914
|
+
/** channel label */
|
915
|
+
channel_label: string;
|
916
|
+
/** channel id */
|
917
|
+
channel_id: string;
|
918
|
+
}
|
919
|
+
|
888
920
|
export interface ListActivity {
|
889
921
|
acts: ApiUserActivity[];
|
890
922
|
}
|
@@ -1044,6 +1076,7 @@ export interface Socket {
|
|
1044
1076
|
): Promise<VoiceLeavedEvent>;
|
1045
1077
|
|
1046
1078
|
joinPTTChannel(
|
1079
|
+
clanId: string,
|
1047
1080
|
channelId: string,
|
1048
1081
|
dataType: number,
|
1049
1082
|
jsonData: string
|
@@ -1246,6 +1279,10 @@ export interface Socket {
|
|
1246
1279
|
onjoinpttchannel: (join_ptt_channel: JoinPTTChannel) => void;
|
1247
1280
|
|
1248
1281
|
ontalkpttchannel: (talk_ptt_channel: TalkPTTChannel) => void;
|
1282
|
+
|
1283
|
+
onpttchanneljoined: (ptt_joined_event: PTTJoinedEvent) => void;
|
1284
|
+
|
1285
|
+
onpttchannelleaved: (ptt_leaved_event: PTTLeavedEvent) => void;
|
1249
1286
|
}
|
1250
1287
|
|
1251
1288
|
/** Reports an error received from a socket message. */
|
@@ -1514,6 +1551,10 @@ export class DefaultSocket implements Socket {
|
|
1514
1551
|
this.onjoinpttchannel(<JoinPTTChannel>message.join_ptt_channel);
|
1515
1552
|
} else if (message.talk_ptt_channel) {
|
1516
1553
|
this.ontalkpttchannel(<TalkPTTChannel>message.talk_ptt_channel);
|
1554
|
+
} else if (message.ptt_joined_event) {
|
1555
|
+
this.onpttchanneljoined(<PTTJoinedEvent>message.ptt_joined_event);
|
1556
|
+
} else if (message.ptt_leaved_event) {
|
1557
|
+
this.onpttchannelleaved(<PTTLeavedEvent>message.ptt_leaved_event);
|
1517
1558
|
} else {
|
1518
1559
|
if (this.verbose && window && window.console) {
|
1519
1560
|
console.log("Unrecognized message received: %o", message);
|
@@ -1821,6 +1862,18 @@ export class DefaultSocket implements Socket {
|
|
1821
1862
|
}
|
1822
1863
|
}
|
1823
1864
|
|
1865
|
+
onpttchanneljoined(ptt_joined_event: PTTJoinedEvent) {
|
1866
|
+
if (this.verbose && window && window.console) {
|
1867
|
+
console.log(ptt_joined_event);
|
1868
|
+
}
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
onpttchannelleaved(ptt_leaved_event: PTTLeavedEvent) {
|
1872
|
+
if (this.verbose && window && window.console) {
|
1873
|
+
console.log(ptt_leaved_event);
|
1874
|
+
}
|
1875
|
+
}
|
1876
|
+
|
1824
1877
|
onpermissionset(permission_set_event: PermissionSet) {
|
1825
1878
|
if (this.verbose && window && window.console) {
|
1826
1879
|
console.log(permission_set_event);
|
@@ -2281,7 +2334,7 @@ export class DefaultSocket implements Socket {
|
|
2281
2334
|
value: Array<string>
|
2282
2335
|
): Promise<DropdownBoxSelected> {
|
2283
2336
|
const response = await this.send({
|
2284
|
-
|
2337
|
+
dropdown_box_selected: {
|
2285
2338
|
message_id: message_id,
|
2286
2339
|
channel_id: channel_id,
|
2287
2340
|
selectbox_id: selectbox_id,
|
@@ -2315,12 +2368,14 @@ export class DefaultSocket implements Socket {
|
|
2315
2368
|
}
|
2316
2369
|
|
2317
2370
|
async joinPTTChannel(
|
2371
|
+
clanId: string,
|
2318
2372
|
channelId: string,
|
2319
2373
|
dataType: number,
|
2320
2374
|
jsonData: string
|
2321
2375
|
): Promise<JoinPTTChannel> {
|
2322
2376
|
const response = await this.send({
|
2323
2377
|
join_ptt_channel: {
|
2378
|
+
clan_id: clanId,
|
2324
2379
|
channel_id: channelId,
|
2325
2380
|
data_type: dataType,
|
2326
2381
|
json_data: jsonData,
|