mezon-js 2.9.5 → 2.9.7

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -428,6 +428,11 @@ export interface ApiCategoryOrderUpdate {
428
428
  order?: number;
429
429
  }
430
430
 
431
+ export interface ApiListChannelAppsResponse {
432
+ //
433
+ channel_apps?: Array<ApiChannelAppResponse>;
434
+ }
435
+
431
436
  /** Update fields in a given channel. */
432
437
  export interface ApiChangeChannelPrivateRequest {
433
438
  //The ID of the channel to update.
@@ -440,6 +445,20 @@ export interface ApiChangeChannelPrivateRequest {
440
445
  user_ids?: Array<string>;
441
446
  }
442
447
 
448
+ /** */
449
+ export interface ApiChannelAppResponse {
450
+ //
451
+ app_id?: string;
452
+ //
453
+ channel_id?: string;
454
+ //
455
+ clan_id?: string;
456
+ //
457
+ id?: string;
458
+ //
459
+ url?: string;
460
+ }
461
+
443
462
  /** */
444
463
  export interface ApiChannelAttachment {
445
464
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the group was created.
@@ -732,6 +751,8 @@ export interface ApiCreateCategoryDescRequest {
732
751
 
733
752
  /** Create a channel within clan. */
734
753
  export interface ApiCreateChannelDescRequest {
754
+ //
755
+ app_url?: string;
735
756
  //
736
757
  category_id?: string;
737
758
  //The channel this message belongs to.
@@ -3413,6 +3434,39 @@ export class MezonApi {
3413
3434
  ]);
3414
3435
  }
3415
3436
 
3437
+ /** List channel apps. */
3438
+ listChannelApps(bearerToken: string,
3439
+ clanId?:string,
3440
+ options: any = {}): Promise<ApiListChannelAppsResponse> {
3441
+
3442
+ const urlPath = "/v2/channel-apps";
3443
+ const queryParams = new Map<string, any>();
3444
+ queryParams.set("clan_id", clanId);
3445
+
3446
+ let bodyJson : string = "";
3447
+
3448
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3449
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3450
+ if (bearerToken) {
3451
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3452
+ }
3453
+
3454
+ return Promise.race([
3455
+ fetch(fullUrl, fetchOptions).then((response) => {
3456
+ if (response.status == 204) {
3457
+ return response;
3458
+ } else if (response.status >= 200 && response.status < 300) {
3459
+ return response.json();
3460
+ } else {
3461
+ throw response;
3462
+ }
3463
+ }),
3464
+ new Promise((_, reject) =>
3465
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
3466
+ ),
3467
+ ]);
3468
+ }
3469
+
3416
3470
  /** List a channel's message history. */
3417
3471
  listChannelMessages(bearerToken: string,
3418
3472
  channelId:string,
package/client.ts CHANGED
@@ -107,6 +107,7 @@ import {
107
107
  ApiRegisterStreamingChannelRequest,
108
108
  ApiRegisterStreamingChannelResponse,
109
109
  ApiRoleList,
110
+ ApiListChannelAppsResponse,
110
111
  } from "./api.gen";
111
112
 
112
113
  import { Session } from "./session";
@@ -126,7 +127,7 @@ export enum ChannelType {
126
127
  CHANNEL_TYPE_VOICE = 4,
127
128
  CHANNEL_TYPE_FORUM = 5,
128
129
  CHANNEL_TYPE_STREAMING = 6,
129
- CHANNEL_TYPE_THREAD = 7,
130
+ CHANNEL_TYPE_APP = 7,
130
131
  CHANNEL_TYPE_ANNOUNCEMENT = 8,
131
132
  }
132
133
  export enum ChannelStreamMode {
@@ -1064,7 +1065,7 @@ export class Client {
1064
1065
  async deleteCategoryDesc(
1065
1066
  session: Session,
1066
1067
  categoryId: string,
1067
- clanId: string,
1068
+ clanId: string
1068
1069
  ): Promise<boolean> {
1069
1070
  if (
1070
1071
  this.autoRefreshSession &&
@@ -3540,7 +3541,10 @@ export class Client {
3540
3541
  });
3541
3542
  }
3542
3543
 
3543
- async registerStreamingChannel(session: Session, request: ApiRegisterStreamingChannelRequest) {
3544
+ async registerStreamingChannel(
3545
+ session: Session,
3546
+ request: ApiRegisterStreamingChannelRequest
3547
+ ) {
3544
3548
  if (
3545
3549
  this.autoRefreshSession &&
3546
3550
  session.refresh_token &&
@@ -3555,4 +3559,41 @@ export class Client {
3555
3559
  return response !== undefined;
3556
3560
  });
3557
3561
  }
3562
+
3563
+ /** List a channel's users. */
3564
+ async listChannelApps(
3565
+ session: Session,
3566
+ clanId: string
3567
+ ): Promise<ApiListChannelAppsResponse> {
3568
+ if (
3569
+ this.autoRefreshSession &&
3570
+ session.refresh_token &&
3571
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3572
+ ) {
3573
+ await this.sessionRefresh(session);
3574
+ }
3575
+
3576
+ return this.apiClient
3577
+ .listChannelApps(session.token, clanId)
3578
+ .then((response: ApiListChannelAppsResponse) => {
3579
+ var result: ApiListChannelAppsResponse = {
3580
+ channel_apps: [],
3581
+ };
3582
+
3583
+ if (response.channel_apps == null) {
3584
+ return Promise.resolve(result);
3585
+ }
3586
+
3587
+ response.channel_apps!.forEach((gu) => {
3588
+ result.channel_apps!.push({
3589
+ id: gu.id,
3590
+ channel_id: gu.channel_id,
3591
+ app_id: gu.app_id,
3592
+ clan_id: gu.clan_id,
3593
+ url: gu.url,
3594
+ });
3595
+ });
3596
+ return Promise.resolve(result);
3597
+ });
3598
+ }
3558
3599
  }
package/dist/api.gen.d.ts CHANGED
@@ -249,6 +249,9 @@ export interface ApiCategoryOrderUpdate {
249
249
  category_id?: string;
250
250
  order?: number;
251
251
  }
252
+ export interface ApiListChannelAppsResponse {
253
+ channel_apps?: Array<ApiChannelAppResponse>;
254
+ }
252
255
  /** Update fields in a given channel. */
253
256
  export interface ApiChangeChannelPrivateRequest {
254
257
  channel_id?: string;
@@ -257,6 +260,14 @@ export interface ApiChangeChannelPrivateRequest {
257
260
  user_ids?: Array<string>;
258
261
  }
259
262
  /** */
263
+ export interface ApiChannelAppResponse {
264
+ app_id?: string;
265
+ channel_id?: string;
266
+ clan_id?: string;
267
+ id?: string;
268
+ url?: string;
269
+ }
270
+ /** */
260
271
  export interface ApiChannelAttachment {
261
272
  create_time?: string;
262
273
  filename?: string;
@@ -420,6 +431,7 @@ export interface ApiCreateCategoryDescRequest {
420
431
  }
421
432
  /** Create a channel within clan. */
422
433
  export interface ApiCreateChannelDescRequest {
434
+ app_url?: string;
423
435
  category_id?: string;
424
436
  channel_id?: string;
425
437
  channel_label?: string;
@@ -1137,6 +1149,8 @@ export declare class MezonApi {
1137
1149
  updateCategoryOrder(bearerToken: string, body: ApiUpdateCategoryOrderRequest, options?: any): Promise<any>;
1138
1150
  /** */
1139
1151
  listCategoryDescs(bearerToken: string, clanId: string, creatorId?: string, categoryName?: string, categoryId?: string, categoryOrder?: number, options?: any): Promise<ApiCategoryDescList>;
1152
+ /** List channel apps. */
1153
+ listChannelApps(bearerToken: string, clanId?: string, options?: any): Promise<ApiListChannelAppsResponse>;
1140
1154
  /** List a channel's message history. */
1141
1155
  listChannelMessages(bearerToken: string, channelId: string, messageId?: string, direction?: number, limit?: number, options?: any): Promise<ApiChannelMessageList>;
1142
1156
  /** Add users to a channel. */
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 } 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 } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -24,7 +24,7 @@ export declare enum ChannelType {
24
24
  CHANNEL_TYPE_VOICE = 4,
25
25
  CHANNEL_TYPE_FORUM = 5,
26
26
  CHANNEL_TYPE_STREAMING = 6,
27
- CHANNEL_TYPE_THREAD = 7,
27
+ CHANNEL_TYPE_APP = 7,
28
28
  CHANNEL_TYPE_ANNOUNCEMENT = 8
29
29
  }
30
30
  export declare enum ChannelStreamMode {
@@ -557,4 +557,6 @@ export declare class Client {
557
557
  /** List a channel's users. */
558
558
  listStreamingChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiStreamingChannelUserList>;
559
559
  registerStreamingChannel(session: Session, request: ApiRegisterStreamingChannelRequest): Promise<boolean>;
560
+ /** List a channel's users. */
561
+ listChannelApps(session: Session, clanId: string): Promise<ApiListChannelAppsResponse>;
560
562
  }
@@ -1946,6 +1946,32 @@ var MezonApi = class {
1946
1946
  )
1947
1947
  ]);
1948
1948
  }
1949
+ /** List channel apps. */
1950
+ listChannelApps(bearerToken, clanId, options = {}) {
1951
+ const urlPath = "/v2/channel-apps";
1952
+ const queryParams = /* @__PURE__ */ new Map();
1953
+ queryParams.set("clan_id", clanId);
1954
+ let bodyJson = "";
1955
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
1956
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
1957
+ if (bearerToken) {
1958
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
1959
+ }
1960
+ return Promise.race([
1961
+ fetch(fullUrl, fetchOptions).then((response) => {
1962
+ if (response.status == 204) {
1963
+ return response;
1964
+ } else if (response.status >= 200 && response.status < 300) {
1965
+ return response.json();
1966
+ } else {
1967
+ throw response;
1968
+ }
1969
+ }),
1970
+ new Promise(
1971
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
1972
+ )
1973
+ ]);
1974
+ }
1949
1975
  /** List a channel's message history. */
1950
1976
  listChannelMessages(bearerToken, channelId, messageId, direction, limit, options = {}) {
1951
1977
  if (channelId === null || channelId === void 0) {
@@ -5637,7 +5663,7 @@ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
5637
5663
  ChannelType2[ChannelType2["CHANNEL_TYPE_VOICE"] = 4] = "CHANNEL_TYPE_VOICE";
5638
5664
  ChannelType2[ChannelType2["CHANNEL_TYPE_FORUM"] = 5] = "CHANNEL_TYPE_FORUM";
5639
5665
  ChannelType2[ChannelType2["CHANNEL_TYPE_STREAMING"] = 6] = "CHANNEL_TYPE_STREAMING";
5640
- ChannelType2[ChannelType2["CHANNEL_TYPE_THREAD"] = 7] = "CHANNEL_TYPE_THREAD";
5666
+ ChannelType2[ChannelType2["CHANNEL_TYPE_APP"] = 7] = "CHANNEL_TYPE_APP";
5641
5667
  ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 8] = "CHANNEL_TYPE_ANNOUNCEMENT";
5642
5668
  return ChannelType2;
5643
5669
  })(ChannelType || {});
@@ -7504,4 +7530,30 @@ var Client = class {
7504
7530
  });
7505
7531
  });
7506
7532
  }
7533
+ /** List a channel's users. */
7534
+ listChannelApps(session, clanId) {
7535
+ return __async(this, null, function* () {
7536
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7537
+ yield this.sessionRefresh(session);
7538
+ }
7539
+ return this.apiClient.listChannelApps(session.token, clanId).then((response) => {
7540
+ var result = {
7541
+ channel_apps: []
7542
+ };
7543
+ if (response.channel_apps == null) {
7544
+ return Promise.resolve(result);
7545
+ }
7546
+ response.channel_apps.forEach((gu) => {
7547
+ result.channel_apps.push({
7548
+ id: gu.id,
7549
+ channel_id: gu.channel_id,
7550
+ app_id: gu.app_id,
7551
+ clan_id: gu.clan_id,
7552
+ url: gu.url
7553
+ });
7554
+ });
7555
+ return Promise.resolve(result);
7556
+ });
7557
+ });
7558
+ }
7507
7559
  };
@@ -1917,6 +1917,32 @@ var MezonApi = class {
1917
1917
  )
1918
1918
  ]);
1919
1919
  }
1920
+ /** List channel apps. */
1921
+ listChannelApps(bearerToken, clanId, options = {}) {
1922
+ const urlPath = "/v2/channel-apps";
1923
+ const queryParams = /* @__PURE__ */ new Map();
1924
+ queryParams.set("clan_id", clanId);
1925
+ let bodyJson = "";
1926
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
1927
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
1928
+ if (bearerToken) {
1929
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
1930
+ }
1931
+ return Promise.race([
1932
+ fetch(fullUrl, fetchOptions).then((response) => {
1933
+ if (response.status == 204) {
1934
+ return response;
1935
+ } else if (response.status >= 200 && response.status < 300) {
1936
+ return response.json();
1937
+ } else {
1938
+ throw response;
1939
+ }
1940
+ }),
1941
+ new Promise(
1942
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
1943
+ )
1944
+ ]);
1945
+ }
1920
1946
  /** List a channel's message history. */
1921
1947
  listChannelMessages(bearerToken, channelId, messageId, direction, limit, options = {}) {
1922
1948
  if (channelId === null || channelId === void 0) {
@@ -5608,7 +5634,7 @@ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
5608
5634
  ChannelType2[ChannelType2["CHANNEL_TYPE_VOICE"] = 4] = "CHANNEL_TYPE_VOICE";
5609
5635
  ChannelType2[ChannelType2["CHANNEL_TYPE_FORUM"] = 5] = "CHANNEL_TYPE_FORUM";
5610
5636
  ChannelType2[ChannelType2["CHANNEL_TYPE_STREAMING"] = 6] = "CHANNEL_TYPE_STREAMING";
5611
- ChannelType2[ChannelType2["CHANNEL_TYPE_THREAD"] = 7] = "CHANNEL_TYPE_THREAD";
5637
+ ChannelType2[ChannelType2["CHANNEL_TYPE_APP"] = 7] = "CHANNEL_TYPE_APP";
5612
5638
  ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 8] = "CHANNEL_TYPE_ANNOUNCEMENT";
5613
5639
  return ChannelType2;
5614
5640
  })(ChannelType || {});
@@ -7475,6 +7501,32 @@ var Client = class {
7475
7501
  });
7476
7502
  });
7477
7503
  }
7504
+ /** List a channel's users. */
7505
+ listChannelApps(session, clanId) {
7506
+ return __async(this, null, function* () {
7507
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7508
+ yield this.sessionRefresh(session);
7509
+ }
7510
+ return this.apiClient.listChannelApps(session.token, clanId).then((response) => {
7511
+ var result = {
7512
+ channel_apps: []
7513
+ };
7514
+ if (response.channel_apps == null) {
7515
+ return Promise.resolve(result);
7516
+ }
7517
+ response.channel_apps.forEach((gu) => {
7518
+ result.channel_apps.push({
7519
+ id: gu.id,
7520
+ channel_id: gu.channel_id,
7521
+ app_id: gu.app_id,
7522
+ clan_id: gu.clan_id,
7523
+ url: gu.url
7524
+ });
7525
+ });
7526
+ return Promise.resolve(result);
7527
+ });
7528
+ });
7529
+ }
7478
7530
  };
7479
7531
  export {
7480
7532
  ChannelStreamMode,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.9.5",
4
+ "version": "2.9.7",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"