mezon-js 2.8.91 → 2.8.92

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -876,6 +876,30 @@ export interface ApiEvent {
876
876
  timestamp?: string;
877
877
  }
878
878
 
879
+ /** */
880
+ export interface ApiRegisterStreamingChannelRequest {
881
+ //
882
+ channel_id?: string;
883
+ //
884
+ clan_id?: string;
885
+ }
886
+
887
+ /** */
888
+ export interface ApiRegisterStreamingChannelResponse {
889
+ //
890
+ channel_id?: string;
891
+ //
892
+ clan_id?: string;
893
+ //
894
+ streaming_url?: string;
895
+ }
896
+
897
+ /** */
898
+ export interface ApiListStreamingChannelsResponse {
899
+ //
900
+ streaming_channels?: Array<ApiStreamingChannelResponse>;
901
+ }
902
+
879
903
  /** */
880
904
  export interface ApiEventList {
881
905
  //A list of event.
@@ -1493,6 +1517,36 @@ export interface ApiSortParam {
1493
1517
  order?: string;
1494
1518
  }
1495
1519
 
1520
+ /** */
1521
+ export interface ApiStreamingChannelResponse {
1522
+ //
1523
+ channel_id?: string;
1524
+ //
1525
+ clan_id?: string;
1526
+ //
1527
+ is_streaming?: boolean;
1528
+ //
1529
+ streaming_url?: string;
1530
+ }
1531
+
1532
+ /** A list of users belonging to a channel, along with their role. */
1533
+ export interface ApiStreamingChannelUser {
1534
+ //
1535
+ channel_id?: string;
1536
+ //
1537
+ id?: string;
1538
+ //
1539
+ participant?: string;
1540
+ //user for a channel.
1541
+ user_id?: string;
1542
+ }
1543
+
1544
+ /** A list of users belonging to a channel, along with their role. */
1545
+ export interface ApiStreamingChannelUserList {
1546
+ //
1547
+ streaming_channel_users?: Array<ApiStreamingChannelUser>;
1548
+ }
1549
+
1496
1550
  /** System message details. */
1497
1551
  export interface ApiSystemMessage {
1498
1552
  //
@@ -6298,6 +6352,118 @@ export class MezonApi {
6298
6352
  ]);
6299
6353
  }
6300
6354
 
6355
+ /** List streaming channels. */
6356
+ listStreamingChannels(bearerToken: string,
6357
+ clanId?:string,
6358
+ options: any = {}): Promise<ApiListStreamingChannelsResponse> {
6359
+
6360
+ const urlPath = "/v2/streaming-channels";
6361
+ const queryParams = new Map<string, any>();
6362
+ queryParams.set("clan_id", clanId);
6363
+
6364
+ let bodyJson : string = "";
6365
+
6366
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6367
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6368
+ if (bearerToken) {
6369
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6370
+ }
6371
+
6372
+ return Promise.race([
6373
+ fetch(fullUrl, fetchOptions).then((response) => {
6374
+ if (response.status == 204) {
6375
+ return response;
6376
+ } else if (response.status >= 200 && response.status < 300) {
6377
+ return response.json();
6378
+ } else {
6379
+ throw response;
6380
+ }
6381
+ }),
6382
+ new Promise((_, reject) =>
6383
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6384
+ ),
6385
+ ]);
6386
+ }
6387
+
6388
+ /** Register streaming in channel ( for bot - get streaming key) */
6389
+ registerStreamingChannel(bearerToken: string,
6390
+ body:ApiRegisterStreamingChannelRequest,
6391
+ options: any = {}): Promise<ApiRegisterStreamingChannelResponse> {
6392
+
6393
+ if (body === null || body === undefined) {
6394
+ throw new Error("'body' is a required parameter but is null or undefined.");
6395
+ }
6396
+ const urlPath = "/v2/streaming-channels";
6397
+ const queryParams = new Map<string, any>();
6398
+
6399
+ let bodyJson : string = "";
6400
+ bodyJson = JSON.stringify(body || {});
6401
+
6402
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6403
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
6404
+ if (bearerToken) {
6405
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6406
+ }
6407
+
6408
+ return Promise.race([
6409
+ fetch(fullUrl, fetchOptions).then((response) => {
6410
+ if (response.status == 204) {
6411
+ return response;
6412
+ } else if (response.status >= 200 && response.status < 300) {
6413
+ return response.json();
6414
+ } else {
6415
+ throw response;
6416
+ }
6417
+ }),
6418
+ new Promise((_, reject) =>
6419
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6420
+ ),
6421
+ ]);
6422
+ }
6423
+
6424
+ /** List all users that are part of a channel. */
6425
+ listStreamingChannelUsers(bearerToken: string,
6426
+ clanId?:string,
6427
+ channelId?:string,
6428
+ channelType?:number,
6429
+ limit?:number,
6430
+ state?:number,
6431
+ cursor?:string,
6432
+ options: any = {}): Promise<ApiStreamingChannelUserList> {
6433
+
6434
+ const urlPath = "/v2/streaming-channels/users";
6435
+ const queryParams = new Map<string, any>();
6436
+ queryParams.set("clan_id", clanId);
6437
+ queryParams.set("channel_id", channelId);
6438
+ queryParams.set("channel_type", channelType);
6439
+ queryParams.set("limit", limit);
6440
+ queryParams.set("state", state);
6441
+ queryParams.set("cursor", cursor);
6442
+
6443
+ let bodyJson : string = "";
6444
+
6445
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6446
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6447
+ if (bearerToken) {
6448
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6449
+ }
6450
+
6451
+ return Promise.race([
6452
+ fetch(fullUrl, fetchOptions).then((response) => {
6453
+ if (response.status == 204) {
6454
+ return response;
6455
+ } else if (response.status >= 200 && response.status < 300) {
6456
+ return response.json();
6457
+ } else {
6458
+ throw response;
6459
+ }
6460
+ }),
6461
+ new Promise((_, reject) =>
6462
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6463
+ ),
6464
+ ]);
6465
+ }
6466
+
6301
6467
  /** Get the list of system messages. */
6302
6468
  getSystemMessagesList(bearerToken: string,
6303
6469
  options: any = {}): Promise<ApiSystemMessagesList> {
package/client.ts CHANGED
@@ -102,6 +102,10 @@ import {
102
102
  MezonUpdateSystemMessageBody,
103
103
  ApiUpdateCategoryOrderRequest,
104
104
  ApiGiveCoffeeEvent,
105
+ ApiListStreamingChannelsResponse,
106
+ ApiStreamingChannelUserList,
107
+ ApiRegisterStreamingChannelRequest,
108
+ ApiRegisterStreamingChannelResponse,
105
109
  } from "./api.gen";
106
110
 
107
111
  import { Session } from "./session";
@@ -120,8 +124,9 @@ export enum ChannelType {
120
124
  CHANNEL_TYPE_DM = 3,
121
125
  CHANNEL_TYPE_VOICE = 4,
122
126
  CHANNEL_TYPE_FORUM = 5,
123
- CHANNEL_TYPE_ANNOUNCEMENT = 6,
127
+ CHANNEL_TYPE_STREAMING = 6,
124
128
  CHANNEL_TYPE_THREAD = 7,
129
+ CHANNEL_TYPE_ANNOUNCEMENT = 8,
125
130
  }
126
131
  export enum ChannelStreamMode {
127
132
  STREAM_MODE_CHANNEL = 2,
@@ -3464,4 +3469,88 @@ export class Client {
3464
3469
  return response !== undefined;
3465
3470
  });
3466
3471
  }
3472
+
3473
+ async listStreamingChannels(
3474
+ session: Session,
3475
+ clanId: string
3476
+ ): Promise<ApiListStreamingChannelsResponse> {
3477
+ if (
3478
+ this.autoRefreshSession &&
3479
+ session.refresh_token &&
3480
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3481
+ ) {
3482
+ await this.sessionRefresh(session);
3483
+ }
3484
+
3485
+ return this.apiClient
3486
+ .listStreamingChannels(session.token, clanId)
3487
+ .then((response: ApiListStreamingChannelsResponse) => {
3488
+ return Promise.resolve(response);
3489
+ });
3490
+ }
3491
+
3492
+ /** List a channel's users. */
3493
+ async listStreamingChannelUsers(
3494
+ session: Session,
3495
+ clanId: string,
3496
+ channelId: string,
3497
+ channelType: number,
3498
+ state?: number,
3499
+ limit?: number,
3500
+ cursor?: string
3501
+ ): Promise<ApiStreamingChannelUserList> {
3502
+ if (
3503
+ this.autoRefreshSession &&
3504
+ session.refresh_token &&
3505
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3506
+ ) {
3507
+ await this.sessionRefresh(session);
3508
+ }
3509
+
3510
+ return this.apiClient
3511
+ .listStreamingChannelUsers(
3512
+ session.token,
3513
+ clanId,
3514
+ channelId,
3515
+ channelType,
3516
+ limit,
3517
+ state,
3518
+ cursor
3519
+ )
3520
+ .then((response: ApiStreamingChannelUserList) => {
3521
+ var result: ApiStreamingChannelUserList = {
3522
+ streaming_channel_users: [],
3523
+ };
3524
+
3525
+ if (response.streaming_channel_users == null) {
3526
+ return Promise.resolve(result);
3527
+ }
3528
+
3529
+ response.streaming_channel_users!.forEach((gu) => {
3530
+ result.streaming_channel_users!.push({
3531
+ id: gu.id,
3532
+ channel_id: gu.channel_id,
3533
+ user_id: gu.user_id,
3534
+ participant: gu.participant,
3535
+ });
3536
+ });
3537
+ return Promise.resolve(result);
3538
+ });
3539
+ }
3540
+
3541
+ async registerStreamingChannel(session: Session, request: ApiRegisterStreamingChannelRequest) {
3542
+ if (
3543
+ this.autoRefreshSession &&
3544
+ session.refresh_token &&
3545
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3546
+ ) {
3547
+ await this.sessionRefresh(session);
3548
+ }
3549
+
3550
+ return this.apiClient
3551
+ .registerStreamingChannel(session.token, request)
3552
+ .then((response: ApiRegisterStreamingChannelResponse) => {
3553
+ return response !== undefined;
3554
+ });
3555
+ }
3467
3556
  }
package/dist/api.gen.d.ts CHANGED
@@ -503,6 +503,21 @@ export interface ApiEvent {
503
503
  timestamp?: string;
504
504
  }
505
505
  /** */
506
+ export interface ApiRegisterStreamingChannelRequest {
507
+ channel_id?: string;
508
+ clan_id?: string;
509
+ }
510
+ /** */
511
+ export interface ApiRegisterStreamingChannelResponse {
512
+ channel_id?: string;
513
+ clan_id?: string;
514
+ streaming_url?: string;
515
+ }
516
+ /** */
517
+ export interface ApiListStreamingChannelsResponse {
518
+ streaming_channels?: Array<ApiStreamingChannelResponse>;
519
+ }
520
+ /** */
506
521
  export interface ApiEventList {
507
522
  events?: Array<ApiEventManagement>;
508
523
  }
@@ -863,6 +878,24 @@ export interface ApiSortParam {
863
878
  field_name?: string;
864
879
  order?: string;
865
880
  }
881
+ /** */
882
+ export interface ApiStreamingChannelResponse {
883
+ channel_id?: string;
884
+ clan_id?: string;
885
+ is_streaming?: boolean;
886
+ streaming_url?: string;
887
+ }
888
+ /** A list of users belonging to a channel, along with their role. */
889
+ export interface ApiStreamingChannelUser {
890
+ channel_id?: string;
891
+ id?: string;
892
+ participant?: string;
893
+ user_id?: string;
894
+ }
895
+ /** A list of users belonging to a channel, along with their role. */
896
+ export interface ApiStreamingChannelUserList {
897
+ streaming_channel_users?: Array<ApiStreamingChannelUser>;
898
+ }
866
899
  /** System message details. */
867
900
  export interface ApiSystemMessage {
868
901
  boost_message?: string;
@@ -1257,6 +1290,12 @@ export declare class MezonApi {
1257
1290
  deleteClanStickerById(bearerToken: string, id: string, clanId?: string, options?: any): Promise<any>;
1258
1291
  /** Update a sticker by ID */
1259
1292
  updateClanStickerById(bearerToken: string, id: string, body: MezonUpdateClanStickerByIdBody, options?: any): Promise<any>;
1293
+ /** List streaming channels. */
1294
+ listStreamingChannels(bearerToken: string, clanId?: string, options?: any): Promise<ApiListStreamingChannelsResponse>;
1295
+ /** Register streaming in channel ( for bot - get streaming key) */
1296
+ registerStreamingChannel(bearerToken: string, body: ApiRegisterStreamingChannelRequest, options?: any): Promise<ApiRegisterStreamingChannelResponse>;
1297
+ /** List all users that are part of a channel. */
1298
+ listStreamingChannelUsers(bearerToken: string, clanId?: string, channelId?: string, channelType?: number, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiStreamingChannelUserList>;
1260
1299
  /** Get the list of system messages. */
1261
1300
  getSystemMessagesList(bearerToken: string, options?: any): Promise<ApiSystemMessagesList>;
1262
1301
  /** Create a system messages. */
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 } 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 } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -23,8 +23,9 @@ export declare enum ChannelType {
23
23
  CHANNEL_TYPE_DM = 3,
24
24
  CHANNEL_TYPE_VOICE = 4,
25
25
  CHANNEL_TYPE_FORUM = 5,
26
- CHANNEL_TYPE_ANNOUNCEMENT = 6,
27
- CHANNEL_TYPE_THREAD = 7
26
+ CHANNEL_TYPE_STREAMING = 6,
27
+ CHANNEL_TYPE_THREAD = 7,
28
+ CHANNEL_TYPE_ANNOUNCEMENT = 8
28
29
  }
29
30
  export declare enum ChannelStreamMode {
30
31
  STREAM_MODE_CHANNEL = 2,
@@ -551,4 +552,8 @@ export declare class Client {
551
552
  updateCategoryOrder(session: Session, request: ApiUpdateCategoryOrderRequest): Promise<any>;
552
553
  deleteCategoryOrder(session: Session, clanId: string): Promise<any>;
553
554
  givecoffee(session: Session, request: ApiGiveCoffeeEvent): Promise<boolean>;
555
+ listStreamingChannels(session: Session, clanId: string): Promise<ApiListStreamingChannelsResponse>;
556
+ /** List a channel's users. */
557
+ listStreamingChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiStreamingChannelUserList>;
558
+ registerStreamingChannel(session: Session, request: ApiRegisterStreamingChannelRequest): Promise<boolean>;
554
559
  }
@@ -4247,6 +4247,92 @@ var MezonApi = class {
4247
4247
  )
4248
4248
  ]);
4249
4249
  }
4250
+ /** List streaming channels. */
4251
+ listStreamingChannels(bearerToken, clanId, options = {}) {
4252
+ const urlPath = "/v2/streaming-channels";
4253
+ const queryParams = /* @__PURE__ */ new Map();
4254
+ queryParams.set("clan_id", clanId);
4255
+ let bodyJson = "";
4256
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4257
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4258
+ if (bearerToken) {
4259
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4260
+ }
4261
+ return Promise.race([
4262
+ fetch(fullUrl, fetchOptions).then((response) => {
4263
+ if (response.status == 204) {
4264
+ return response;
4265
+ } else if (response.status >= 200 && response.status < 300) {
4266
+ return response.json();
4267
+ } else {
4268
+ throw response;
4269
+ }
4270
+ }),
4271
+ new Promise(
4272
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4273
+ )
4274
+ ]);
4275
+ }
4276
+ /** Register streaming in channel ( for bot - get streaming key) */
4277
+ registerStreamingChannel(bearerToken, body, options = {}) {
4278
+ if (body === null || body === void 0) {
4279
+ throw new Error("'body' is a required parameter but is null or undefined.");
4280
+ }
4281
+ const urlPath = "/v2/streaming-channels";
4282
+ const queryParams = /* @__PURE__ */ new Map();
4283
+ let bodyJson = "";
4284
+ bodyJson = JSON.stringify(body || {});
4285
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4286
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4287
+ if (bearerToken) {
4288
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4289
+ }
4290
+ return Promise.race([
4291
+ fetch(fullUrl, fetchOptions).then((response) => {
4292
+ if (response.status == 204) {
4293
+ return response;
4294
+ } else if (response.status >= 200 && response.status < 300) {
4295
+ return response.json();
4296
+ } else {
4297
+ throw response;
4298
+ }
4299
+ }),
4300
+ new Promise(
4301
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4302
+ )
4303
+ ]);
4304
+ }
4305
+ /** List all users that are part of a channel. */
4306
+ listStreamingChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
4307
+ const urlPath = "/v2/streaming-channels/users";
4308
+ const queryParams = /* @__PURE__ */ new Map();
4309
+ queryParams.set("clan_id", clanId);
4310
+ queryParams.set("channel_id", channelId);
4311
+ queryParams.set("channel_type", channelType);
4312
+ queryParams.set("limit", limit);
4313
+ queryParams.set("state", state);
4314
+ queryParams.set("cursor", cursor);
4315
+ let bodyJson = "";
4316
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4317
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4318
+ if (bearerToken) {
4319
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4320
+ }
4321
+ return Promise.race([
4322
+ fetch(fullUrl, fetchOptions).then((response) => {
4323
+ if (response.status == 204) {
4324
+ return response;
4325
+ } else if (response.status >= 200 && response.status < 300) {
4326
+ return response.json();
4327
+ } else {
4328
+ throw response;
4329
+ }
4330
+ }),
4331
+ new Promise(
4332
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4333
+ )
4334
+ ]);
4335
+ }
4250
4336
  /** Get the list of system messages. */
4251
4337
  getSystemMessagesList(bearerToken, options = {}) {
4252
4338
  const urlPath = "/v2/systemmessages";
@@ -5487,8 +5573,9 @@ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
5487
5573
  ChannelType2[ChannelType2["CHANNEL_TYPE_DM"] = 3] = "CHANNEL_TYPE_DM";
5488
5574
  ChannelType2[ChannelType2["CHANNEL_TYPE_VOICE"] = 4] = "CHANNEL_TYPE_VOICE";
5489
5575
  ChannelType2[ChannelType2["CHANNEL_TYPE_FORUM"] = 5] = "CHANNEL_TYPE_FORUM";
5490
- ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 6] = "CHANNEL_TYPE_ANNOUNCEMENT";
5576
+ ChannelType2[ChannelType2["CHANNEL_TYPE_STREAMING"] = 6] = "CHANNEL_TYPE_STREAMING";
5491
5577
  ChannelType2[ChannelType2["CHANNEL_TYPE_THREAD"] = 7] = "CHANNEL_TYPE_THREAD";
5578
+ ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 8] = "CHANNEL_TYPE_ANNOUNCEMENT";
5492
5579
  return ChannelType2;
5493
5580
  })(ChannelType || {});
5494
5581
  var ChannelStreamMode = /* @__PURE__ */ ((ChannelStreamMode2) => {
@@ -7301,4 +7388,57 @@ var Client = class {
7301
7388
  });
7302
7389
  });
7303
7390
  }
7391
+ listStreamingChannels(session, clanId) {
7392
+ return __async(this, null, function* () {
7393
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7394
+ yield this.sessionRefresh(session);
7395
+ }
7396
+ return this.apiClient.listStreamingChannels(session.token, clanId).then((response) => {
7397
+ return Promise.resolve(response);
7398
+ });
7399
+ });
7400
+ }
7401
+ /** List a channel's users. */
7402
+ listStreamingChannelUsers(session, clanId, channelId, channelType, state, limit, cursor) {
7403
+ return __async(this, null, function* () {
7404
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7405
+ yield this.sessionRefresh(session);
7406
+ }
7407
+ return this.apiClient.listStreamingChannelUsers(
7408
+ session.token,
7409
+ clanId,
7410
+ channelId,
7411
+ channelType,
7412
+ limit,
7413
+ state,
7414
+ cursor
7415
+ ).then((response) => {
7416
+ var result = {
7417
+ streaming_channel_users: []
7418
+ };
7419
+ if (response.streaming_channel_users == null) {
7420
+ return Promise.resolve(result);
7421
+ }
7422
+ response.streaming_channel_users.forEach((gu) => {
7423
+ result.streaming_channel_users.push({
7424
+ id: gu.id,
7425
+ channel_id: gu.channel_id,
7426
+ user_id: gu.user_id,
7427
+ participant: gu.participant
7428
+ });
7429
+ });
7430
+ return Promise.resolve(result);
7431
+ });
7432
+ });
7433
+ }
7434
+ registerStreamingChannel(session, request) {
7435
+ return __async(this, null, function* () {
7436
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7437
+ yield this.sessionRefresh(session);
7438
+ }
7439
+ return this.apiClient.registerStreamingChannel(session.token, request).then((response) => {
7440
+ return response !== void 0;
7441
+ });
7442
+ });
7443
+ }
7304
7444
  };
@@ -4218,6 +4218,92 @@ var MezonApi = class {
4218
4218
  )
4219
4219
  ]);
4220
4220
  }
4221
+ /** List streaming channels. */
4222
+ listStreamingChannels(bearerToken, clanId, options = {}) {
4223
+ const urlPath = "/v2/streaming-channels";
4224
+ const queryParams = /* @__PURE__ */ new Map();
4225
+ queryParams.set("clan_id", clanId);
4226
+ let bodyJson = "";
4227
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4228
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4229
+ if (bearerToken) {
4230
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4231
+ }
4232
+ return Promise.race([
4233
+ fetch(fullUrl, fetchOptions).then((response) => {
4234
+ if (response.status == 204) {
4235
+ return response;
4236
+ } else if (response.status >= 200 && response.status < 300) {
4237
+ return response.json();
4238
+ } else {
4239
+ throw response;
4240
+ }
4241
+ }),
4242
+ new Promise(
4243
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4244
+ )
4245
+ ]);
4246
+ }
4247
+ /** Register streaming in channel ( for bot - get streaming key) */
4248
+ registerStreamingChannel(bearerToken, body, options = {}) {
4249
+ if (body === null || body === void 0) {
4250
+ throw new Error("'body' is a required parameter but is null or undefined.");
4251
+ }
4252
+ const urlPath = "/v2/streaming-channels";
4253
+ const queryParams = /* @__PURE__ */ new Map();
4254
+ let bodyJson = "";
4255
+ bodyJson = JSON.stringify(body || {});
4256
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4257
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4258
+ if (bearerToken) {
4259
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4260
+ }
4261
+ return Promise.race([
4262
+ fetch(fullUrl, fetchOptions).then((response) => {
4263
+ if (response.status == 204) {
4264
+ return response;
4265
+ } else if (response.status >= 200 && response.status < 300) {
4266
+ return response.json();
4267
+ } else {
4268
+ throw response;
4269
+ }
4270
+ }),
4271
+ new Promise(
4272
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4273
+ )
4274
+ ]);
4275
+ }
4276
+ /** List all users that are part of a channel. */
4277
+ listStreamingChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
4278
+ const urlPath = "/v2/streaming-channels/users";
4279
+ const queryParams = /* @__PURE__ */ new Map();
4280
+ queryParams.set("clan_id", clanId);
4281
+ queryParams.set("channel_id", channelId);
4282
+ queryParams.set("channel_type", channelType);
4283
+ queryParams.set("limit", limit);
4284
+ queryParams.set("state", state);
4285
+ queryParams.set("cursor", cursor);
4286
+ let bodyJson = "";
4287
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4288
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4289
+ if (bearerToken) {
4290
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4291
+ }
4292
+ return Promise.race([
4293
+ fetch(fullUrl, fetchOptions).then((response) => {
4294
+ if (response.status == 204) {
4295
+ return response;
4296
+ } else if (response.status >= 200 && response.status < 300) {
4297
+ return response.json();
4298
+ } else {
4299
+ throw response;
4300
+ }
4301
+ }),
4302
+ new Promise(
4303
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4304
+ )
4305
+ ]);
4306
+ }
4221
4307
  /** Get the list of system messages. */
4222
4308
  getSystemMessagesList(bearerToken, options = {}) {
4223
4309
  const urlPath = "/v2/systemmessages";
@@ -5458,8 +5544,9 @@ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
5458
5544
  ChannelType2[ChannelType2["CHANNEL_TYPE_DM"] = 3] = "CHANNEL_TYPE_DM";
5459
5545
  ChannelType2[ChannelType2["CHANNEL_TYPE_VOICE"] = 4] = "CHANNEL_TYPE_VOICE";
5460
5546
  ChannelType2[ChannelType2["CHANNEL_TYPE_FORUM"] = 5] = "CHANNEL_TYPE_FORUM";
5461
- ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 6] = "CHANNEL_TYPE_ANNOUNCEMENT";
5547
+ ChannelType2[ChannelType2["CHANNEL_TYPE_STREAMING"] = 6] = "CHANNEL_TYPE_STREAMING";
5462
5548
  ChannelType2[ChannelType2["CHANNEL_TYPE_THREAD"] = 7] = "CHANNEL_TYPE_THREAD";
5549
+ ChannelType2[ChannelType2["CHANNEL_TYPE_ANNOUNCEMENT"] = 8] = "CHANNEL_TYPE_ANNOUNCEMENT";
5463
5550
  return ChannelType2;
5464
5551
  })(ChannelType || {});
5465
5552
  var ChannelStreamMode = /* @__PURE__ */ ((ChannelStreamMode2) => {
@@ -7272,6 +7359,59 @@ var Client = class {
7272
7359
  });
7273
7360
  });
7274
7361
  }
7362
+ listStreamingChannels(session, clanId) {
7363
+ return __async(this, null, function* () {
7364
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7365
+ yield this.sessionRefresh(session);
7366
+ }
7367
+ return this.apiClient.listStreamingChannels(session.token, clanId).then((response) => {
7368
+ return Promise.resolve(response);
7369
+ });
7370
+ });
7371
+ }
7372
+ /** List a channel's users. */
7373
+ listStreamingChannelUsers(session, clanId, channelId, channelType, state, limit, cursor) {
7374
+ return __async(this, null, function* () {
7375
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7376
+ yield this.sessionRefresh(session);
7377
+ }
7378
+ return this.apiClient.listStreamingChannelUsers(
7379
+ session.token,
7380
+ clanId,
7381
+ channelId,
7382
+ channelType,
7383
+ limit,
7384
+ state,
7385
+ cursor
7386
+ ).then((response) => {
7387
+ var result = {
7388
+ streaming_channel_users: []
7389
+ };
7390
+ if (response.streaming_channel_users == null) {
7391
+ return Promise.resolve(result);
7392
+ }
7393
+ response.streaming_channel_users.forEach((gu) => {
7394
+ result.streaming_channel_users.push({
7395
+ id: gu.id,
7396
+ channel_id: gu.channel_id,
7397
+ user_id: gu.user_id,
7398
+ participant: gu.participant
7399
+ });
7400
+ });
7401
+ return Promise.resolve(result);
7402
+ });
7403
+ });
7404
+ }
7405
+ registerStreamingChannel(session, request) {
7406
+ return __async(this, null, function* () {
7407
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7408
+ yield this.sessionRefresh(session);
7409
+ }
7410
+ return this.apiClient.registerStreamingChannel(session.token, request).then((response) => {
7411
+ return response !== void 0;
7412
+ });
7413
+ });
7414
+ }
7275
7415
  };
7276
7416
  export {
7277
7417
  ChannelStreamMode,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.8.91",
4
+ "version": "2.8.92",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"