mezon-js 2.7.78 → 2.7.80

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -24,6 +24,9 @@ export interface ClanUserListClanUser {
24
24
  user?: ApiUser;
25
25
  }
26
26
 
27
+ /** */
28
+
29
+
27
30
  /** Update fields in a given channel. */
28
31
  export interface MezonUpdateChannelDescBody {
29
32
  //
@@ -124,6 +127,12 @@ export interface MezonUpdateUserProfileByClanBody {
124
127
  nick_name?: string;
125
128
  }
126
129
 
130
+ /** */
131
+ export interface MezonUpdateWebhookByIdBody {
132
+ //
133
+ webhook_name?: string;
134
+ }
135
+
127
136
  /** A single user-role pair. */
128
137
  export interface RoleUserListRoleUser {
129
138
  //A URL for an avatar image.
@@ -360,6 +369,8 @@ export interface ApiChannelDescription {
360
369
  type?: number;
361
370
  //
362
371
  user_id?: Array<string>;
372
+ //
373
+ usernames?: string;
363
374
  }
364
375
 
365
376
  /** A message sent on a channel. */
@@ -368,12 +379,16 @@ export interface ApiChannelMessage {
368
379
  attachments?: string;
369
380
  //
370
381
  avatar?: string;
382
+ //
383
+ category_name?: string;
371
384
  //The channel this message belongs to.
372
385
  channel_id: string;
373
386
  //The name of the chat room, or an empty string if this message was not sent through a chat room.
374
387
  channel_label: string;
375
388
  //The clan this message belong to.
376
389
  clan_id?: string;
390
+ //
391
+ clan_logo?: string;
377
392
  //The code representing a message type or category.
378
393
  code: number;
379
394
  //The content payload.
@@ -394,10 +409,6 @@ export interface ApiChannelMessage {
394
409
  sender_id: string;
395
410
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated.
396
411
  update_time?: string;
397
- //The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
398
- user_id_one?: string;
399
- //The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
400
- user_id_two?: string;
401
412
  //The username of the message sender, if any.
402
413
  username?: string;
403
414
  }
@@ -693,11 +704,15 @@ export interface ApiDirectChannelVoice {
693
704
  //
694
705
  channel_label?: string;
695
706
  //
707
+ channel_private?: number;
708
+ //
696
709
  clan_id?: string;
697
710
  //
698
711
  clan_name?: string;
699
712
  //
700
713
  meeting_code?: string;
714
+ //
715
+ type?: number;
701
716
  }
702
717
 
703
718
  /** Represents an event to be passed through the server to registered event handlers. */
@@ -1429,6 +1444,50 @@ export interface ApiVoiceChannelUserList {
1429
1444
  voice_channel_users?: Array<ApiVoiceChannelUser>;
1430
1445
  }
1431
1446
 
1447
+ /** */
1448
+ export interface ApiWebhook {
1449
+ //
1450
+ active?: number;
1451
+ //
1452
+ channel_id?: string;
1453
+ //
1454
+ create_time?: string;
1455
+ //
1456
+ creator_id?: string;
1457
+ //
1458
+ id?: string;
1459
+ //
1460
+ update_time?: string;
1461
+ //
1462
+ url?: string;
1463
+ //
1464
+ webhook_name?: string;
1465
+ }
1466
+
1467
+ /** */
1468
+ export interface ApiWebhookCreateRequest {
1469
+ //
1470
+ channel_id?: string;
1471
+ //
1472
+ webhook_name?: string;
1473
+ }
1474
+
1475
+ /** */
1476
+ export interface ApiWebhookGenerateResponse {
1477
+ //
1478
+ channel_id?: string;
1479
+ //
1480
+ hook_name?: string;
1481
+ //
1482
+ url?: string;
1483
+ }
1484
+
1485
+ /** */
1486
+ export interface ApiWebhookListResponse {
1487
+ //
1488
+ webhooks?: Array<ApiWebhook>;
1489
+ }
1490
+
1432
1491
  /** */
1433
1492
  export interface ApiWebhookResponse {
1434
1493
  //
@@ -5894,7 +5953,7 @@ export class MezonApi {
5894
5953
  /** */
5895
5954
  updateUserProfileByClan(bearerToken: string,
5896
5955
  clanId:string,
5897
- body:{},
5956
+ body:MezonUpdateUserProfileByClanBody,
5898
5957
  options: any = {}): Promise<any> {
5899
5958
 
5900
5959
  if (clanId === null || clanId === undefined) {
@@ -6077,6 +6136,156 @@ export class MezonApi {
6077
6136
  ]);
6078
6137
  }
6079
6138
 
6139
+ /** create webhook */
6140
+ generateWebhook(bearerToken: string,
6141
+ body:ApiWebhookCreateRequest,
6142
+ options: any = {}): Promise<any> {
6143
+
6144
+ if (body === null || body === undefined) {
6145
+ throw new Error("'body' is a required parameter but is null or undefined.");
6146
+ }
6147
+ const urlPath = "/v2/webhooks/generate";
6148
+ const queryParams = new Map<string, any>();
6149
+
6150
+ let bodyJson : string = "";
6151
+ bodyJson = JSON.stringify(body || {});
6152
+
6153
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6154
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
6155
+ if (bearerToken) {
6156
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6157
+ }
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((_, reject) =>
6170
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6171
+ ),
6172
+ ]);
6173
+ }
6174
+
6175
+ /** update webhook name by id */
6176
+ updateWebhookById(bearerToken: string,
6177
+ id:string,
6178
+ body:MezonUpdateWebhookByIdBody,
6179
+ options: any = {}): Promise<any> {
6180
+
6181
+ if (id === null || id === undefined) {
6182
+ throw new Error("'id' is a required parameter but is null or undefined.");
6183
+ }
6184
+ if (body === null || body === undefined) {
6185
+ throw new Error("'body' is a required parameter but is null or undefined.");
6186
+ }
6187
+ const urlPath = "/v2/webhooks/update/{id}"
6188
+ .replace("{id}", encodeURIComponent(String(id)));
6189
+ const queryParams = new Map<string, any>();
6190
+
6191
+ let bodyJson : string = "";
6192
+ bodyJson = JSON.stringify(body || {});
6193
+
6194
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6195
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
6196
+ if (bearerToken) {
6197
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6198
+ }
6199
+
6200
+ return Promise.race([
6201
+ fetch(fullUrl, fetchOptions).then((response) => {
6202
+ if (response.status == 204) {
6203
+ return response;
6204
+ } else if (response.status >= 200 && response.status < 300) {
6205
+ return response.json();
6206
+ } else {
6207
+ throw response;
6208
+ }
6209
+ }),
6210
+ new Promise((_, reject) =>
6211
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6212
+ ),
6213
+ ]);
6214
+ }
6215
+
6216
+ /** list webhook belong to the channel */
6217
+ listWebhookByChannelId(bearerToken: string,
6218
+ channelId:string,
6219
+ options: any = {}): Promise<ApiWebhookListResponse> {
6220
+
6221
+ if (channelId === null || channelId === undefined) {
6222
+ throw new Error("'channelId' is a required parameter but is null or undefined.");
6223
+ }
6224
+ const urlPath = "/v2/webhooks/{channelId}"
6225
+ .replace("{channelId}", encodeURIComponent(String(channelId)));
6226
+ const queryParams = new Map<string, any>();
6227
+
6228
+ let bodyJson : string = "";
6229
+
6230
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6231
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6232
+ if (bearerToken) {
6233
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6234
+ }
6235
+
6236
+ return Promise.race([
6237
+ fetch(fullUrl, fetchOptions).then((response) => {
6238
+ if (response.status == 204) {
6239
+ return response;
6240
+ } else if (response.status >= 200 && response.status < 300) {
6241
+ return response.json();
6242
+ } else {
6243
+ throw response;
6244
+ }
6245
+ }),
6246
+ new Promise((_, reject) =>
6247
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6248
+ ),
6249
+ ]);
6250
+ }
6251
+
6252
+ /** disabled webhook */
6253
+ deleteWebhookById(bearerToken: string,
6254
+ id:string,
6255
+ options: any = {}): Promise<any> {
6256
+
6257
+ if (id === null || id === undefined) {
6258
+ throw new Error("'id' is a required parameter but is null or undefined.");
6259
+ }
6260
+
6261
+ const urlPath = "/v2/webhooks/{id}"
6262
+ .replace("{id}", encodeURIComponent(String(id)));
6263
+ const queryParams = new Map<string, any>();
6264
+
6265
+ let bodyJson : string = "";
6266
+
6267
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6268
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
6269
+ if (bearerToken) {
6270
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6271
+ }
6272
+
6273
+ return Promise.race([
6274
+ fetch(fullUrl, fetchOptions).then((response) => {
6275
+ if (response.status == 204) {
6276
+ return response;
6277
+ } else if (response.status >= 200 && response.status < 300) {
6278
+ return response.json();
6279
+ } else {
6280
+ throw response;
6281
+ }
6282
+ }),
6283
+ new Promise((_, reject) =>
6284
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6285
+ ),
6286
+ ]);
6287
+ }
6288
+
6080
6289
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>) {
6081
6290
  let fullPath = basePath + fragment + "?";
6082
6291
 
package/client.ts CHANGED
@@ -97,7 +97,11 @@ import {
97
97
  ApiClanEmojiList,
98
98
  ApiClanEmojiCreateRequest,
99
99
  ApiChannelVoiceList,
100
- MezonUpdateClanEmojiByIdBody
100
+ MezonUpdateClanEmojiByIdBody,
101
+ ApiWebhookCreateRequest,
102
+ ApiWebhookListResponse,
103
+ MezonUpdateWebhookByIdBody,
104
+ ApiWebhookGenerateResponse,
101
105
  } from "./api.gen";
102
106
 
103
107
  import { Session } from "./session";
@@ -226,9 +230,9 @@ export interface ChannelMessage {
226
230
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated.
227
231
  update_time?: string;
228
232
  //The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
229
- user_id_one?: string;
233
+ clan_logo?: string;
230
234
  //The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
231
- user_id_two?: string;
235
+ category_name?: string;
232
236
  //The username of the message sender, if any.
233
237
  username?: string;
234
238
  }
@@ -1065,8 +1069,8 @@ export class Client {
1065
1069
  avatar: m.avatar,
1066
1070
  content: m.content ? JSON.parse(m.content) : undefined,
1067
1071
  channel_label: m.channel_label,
1068
- user_id_one: m.user_id_one,
1069
- user_id_two: m.user_id_two,
1072
+ clan_logo: m.clan_logo,
1073
+ category_name: m.category_name,
1070
1074
  attachments: m.attachments ? JSON.parse(m.attachments) : [],
1071
1075
  mentions: m.mentions ? JSON.parse(m.mentions) : [],
1072
1076
  reactions: m.reactions ? JSON.parse(m.reactions) : [],
@@ -2260,27 +2264,75 @@ async createClanEmoji(session: Session, request: ApiClanEmojiCreateRequest) {
2260
2264
  }
2261
2265
 
2262
2266
  //**update clan emoji by id */
2263
- async updateClanEmojiById(session :Session,id:string,request: MezonUpdateClanEmojiByIdBody) {
2267
+ async updateClanEmojiById(session: Session, id: string, request: MezonUpdateClanEmojiByIdBody) {
2264
2268
  if (this.autoRefreshSession && session.refresh_token &&
2265
2269
  session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2266
2270
  await this.sessionRefresh(session);
2267
2271
  }
2268
2272
 
2269
- return this.apiClient.updateClanEmojiById(session.token,id,request).then((response: any) => {
2273
+ return this.apiClient.updateClanEmojiById(session.token, id, request).then((response: any) => {
2270
2274
  return response !== undefined;
2271
2275
  });
2272
2276
  }
2273
2277
 
2274
2278
  //**delete clan emoji by id */
2275
- async deleteByIdClanEmoji(session:Session,id:string) {
2279
+ async deleteByIdClanEmoji(session: Session, id: string) {
2276
2280
  if (this.autoRefreshSession && session.refresh_token &&
2277
2281
  session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2278
2282
  await this.sessionRefresh(session);
2279
2283
  }
2280
2284
 
2281
- return this.apiClient.deleteByIdClanEmoji(session.token,id).then((response: any) => {
2285
+ return this.apiClient.deleteByIdClanEmoji(session.token, id).then((response: any) => {
2282
2286
  return response !== undefined;
2283
2287
  });
2284
2288
  }
2285
2289
 
2290
+ //**create webhook for chaneel */
2291
+ async generateWebhookLink(session: Session, request: ApiWebhookCreateRequest): Promise<ApiWebhookGenerateResponse> {
2292
+ if (this.autoRefreshSession && session.refresh_token &&
2293
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2294
+ await this.sessionRefresh(session);
2295
+ }
2296
+
2297
+ return this.apiClient.generateWebhook(session.token, request).then((response: any) => {
2298
+ return Promise.resolve(response);
2299
+ })
2300
+ }
2301
+
2302
+ //**list webhook belong to the channel */
2303
+ async listWebhookByChannelId(session: Session, channel_id: string): Promise<ApiWebhookListResponse> {
2304
+ if (this.autoRefreshSession && session.refresh_token &&
2305
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2306
+ await this.sessionRefresh(session);
2307
+ }
2308
+
2309
+ return this.apiClient.listWebhookByChannelId(session.token, channel_id).then((response: ApiWebhookListResponse) => {
2310
+ return Promise.resolve(response);
2311
+ })
2312
+ }
2313
+
2314
+ //**update webhook name by id */
2315
+ async updateWebhookById(session: Session, id: string, request: MezonUpdateWebhookByIdBody) {
2316
+ if (this.autoRefreshSession && session.refresh_token &&
2317
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2318
+ await this.sessionRefresh(session);
2319
+ }
2320
+
2321
+ return this.apiClient.updateWebhookById(session.token, id, request).then((response: any) => {
2322
+ return response !== undefined;
2323
+ })
2324
+ }
2325
+
2326
+ //**disabled webhook by id */
2327
+ async deleteWebhookById(session: Session, id: string) {
2328
+ if (this.autoRefreshSession && session.refresh_token &&
2329
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2330
+ await this.sessionRefresh(session);
2331
+ }
2332
+
2333
+ return this.apiClient.deleteWebhookById(session.token, id).then((response: any) => {
2334
+ return response !== undefined;
2335
+ })
2336
+ }
2337
+
2286
2338
  };
package/dist/api.gen.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface ClanUserListClanUser {
10
10
  role_id?: string;
11
11
  user?: ApiUser;
12
12
  }
13
+ /** */
13
14
  /** Update fields in a given channel. */
14
15
  export interface MezonUpdateChannelDescBody {
15
16
  category_id?: string;
@@ -68,6 +69,10 @@ export interface MezonUpdateUserProfileByClanBody {
68
69
  avatar?: string;
69
70
  nick_name?: string;
70
71
  }
72
+ /** */
73
+ export interface MezonUpdateWebhookByIdBody {
74
+ webhook_name?: string;
75
+ }
71
76
  /** A single user-role pair. */
72
77
  export interface RoleUserListRoleUser {
73
78
  avatar_url?: string;
@@ -206,14 +211,17 @@ export interface ApiChannelDescription {
206
211
  status?: number;
207
212
  type?: number;
208
213
  user_id?: Array<string>;
214
+ usernames?: string;
209
215
  }
210
216
  /** A message sent on a channel. */
211
217
  export interface ApiChannelMessage {
212
218
  attachments?: string;
213
219
  avatar?: string;
220
+ category_name?: string;
214
221
  channel_id: string;
215
222
  channel_label: string;
216
223
  clan_id?: string;
224
+ clan_logo?: string;
217
225
  code: number;
218
226
  content: string;
219
227
  create_time?: string;
@@ -224,8 +232,6 @@ export interface ApiChannelMessage {
224
232
  references?: string;
225
233
  sender_id: string;
226
234
  update_time?: string;
227
- user_id_one?: string;
228
- user_id_two?: string;
229
235
  username?: string;
230
236
  }
231
237
  /** */
@@ -398,9 +404,11 @@ export interface ApiDeleteStorageObjectsRequest {
398
404
  export interface ApiDirectChannelVoice {
399
405
  channel_id?: string;
400
406
  channel_label?: string;
407
+ channel_private?: number;
401
408
  clan_id?: string;
402
409
  clan_name?: string;
403
410
  meeting_code?: string;
411
+ type?: number;
404
412
  }
405
413
  /** Represents an event to be passed through the server to registered event handlers. */
406
414
  export interface ApiEvent {
@@ -826,6 +834,32 @@ export interface ApiVoiceChannelUserList {
826
834
  voice_channel_users?: Array<ApiVoiceChannelUser>;
827
835
  }
828
836
  /** */
837
+ export interface ApiWebhook {
838
+ active?: number;
839
+ channel_id?: string;
840
+ create_time?: string;
841
+ creator_id?: string;
842
+ id?: string;
843
+ update_time?: string;
844
+ url?: string;
845
+ webhook_name?: string;
846
+ }
847
+ /** */
848
+ export interface ApiWebhookCreateRequest {
849
+ channel_id?: string;
850
+ webhook_name?: string;
851
+ }
852
+ /** */
853
+ export interface ApiWebhookGenerateResponse {
854
+ channel_id?: string;
855
+ hook_name?: string;
856
+ url?: string;
857
+ }
858
+ /** */
859
+ export interface ApiWebhookListResponse {
860
+ webhooks?: Array<ApiWebhook>;
861
+ }
862
+ /** */
829
863
  export interface ApiWebhookResponse {
830
864
  channel_id?: string;
831
865
  hook_name?: string;
@@ -1099,7 +1133,7 @@ export declare class MezonApi {
1099
1133
  /** Update channel private. */
1100
1134
  updateChannelPrivate(bearerToken: string, body: ApiChangeChannelPrivateRequest, options?: any): Promise<any>;
1101
1135
  /** */
1102
- updateUserProfileByClan(bearerToken: string, clanId: string, body: {}, options?: any): Promise<any>;
1136
+ updateUserProfileByClan(bearerToken: string, clanId: string, body: MezonUpdateUserProfileByClanBody, options?: any): Promise<any>;
1103
1137
  /** Upload attachment */
1104
1138
  uploadAttachmentFile(bearerToken: string, body: ApiUploadAttachmentRequest, options?: any): Promise<ApiUploadAttachment>;
1105
1139
  /** Fetch zero or more users by ID and/or username. */
@@ -1108,5 +1142,13 @@ export declare class MezonApi {
1108
1142
  updateUser(bearerToken: string, body: ApiUpdateUsersRequest, options?: any): Promise<any>;
1109
1143
  /** Create webhook */
1110
1144
  createWebhookLink(bearerToken: string, body: ApiCreateWebhookRequest, options?: any): Promise<ApiWebhookResponse>;
1145
+ /** create webhook */
1146
+ generateWebhook(bearerToken: string, body: ApiWebhookCreateRequest, options?: any): Promise<any>;
1147
+ /** update webhook name by id */
1148
+ updateWebhookById(bearerToken: string, id: string, body: MezonUpdateWebhookByIdBody, options?: any): Promise<any>;
1149
+ /** list webhook belong to the channel */
1150
+ listWebhookByChannelId(bearerToken: string, channelId: string, options?: any): Promise<ApiWebhookListResponse>;
1151
+ /** disabled webhook */
1152
+ deleteWebhookById(bearerToken: string, id: string, options?: any): Promise<any>;
1111
1153
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
1112
1154
  }
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, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiCreateWebhookRequest, ApiWebhookResponse, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiList, ApiClanEmojiCreateRequest, ApiChannelVoiceList, MezonUpdateClanEmojiByIdBody } from "./api.gen";
16
+ import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiCreateWebhookRequest, ApiWebhookResponse, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiList, ApiClanEmojiCreateRequest, ApiChannelVoiceList, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -108,8 +108,8 @@ export interface ChannelMessage {
108
108
  persistent?: boolean;
109
109
  sender_id: string;
110
110
  update_time?: string;
111
- user_id_one?: string;
112
- user_id_two?: string;
111
+ clan_logo?: string;
112
+ category_name?: string;
113
113
  username?: string;
114
114
  }
115
115
  /** A list of channel messages, usually a result of a list operation. */
@@ -584,4 +584,8 @@ export declare class Client {
584
584
  createClanEmoji(session: Session, request: ApiClanEmojiCreateRequest): Promise<boolean>;
585
585
  updateClanEmojiById(session: Session, id: string, request: MezonUpdateClanEmojiByIdBody): Promise<boolean>;
586
586
  deleteByIdClanEmoji(session: Session, id: string): Promise<boolean>;
587
+ generateWebhookLink(session: Session, request: ApiWebhookCreateRequest): Promise<ApiWebhookGenerateResponse>;
588
+ listWebhookByChannelId(session: Session, channel_id: string): Promise<ApiWebhookListResponse>;
589
+ updateWebhookById(session: Session, id: string, request: MezonUpdateWebhookByIdBody): Promise<boolean>;
590
+ deleteWebhookById(session: Session, id: string): Promise<boolean>;
587
591
  }
@@ -4249,6 +4249,123 @@ var MezonApi = class {
4249
4249
  )
4250
4250
  ]);
4251
4251
  }
4252
+ /** create webhook */
4253
+ generateWebhook(bearerToken, body, options = {}) {
4254
+ if (body === null || body === void 0) {
4255
+ throw new Error("'body' is a required parameter but is null or undefined.");
4256
+ }
4257
+ const urlPath = "/v2/webhooks/generate";
4258
+ const queryParams = /* @__PURE__ */ new Map();
4259
+ let bodyJson = "";
4260
+ bodyJson = JSON.stringify(body || {});
4261
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4262
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4263
+ if (bearerToken) {
4264
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4265
+ }
4266
+ return Promise.race([
4267
+ fetch(fullUrl, fetchOptions).then((response) => {
4268
+ if (response.status == 204) {
4269
+ return response;
4270
+ } else if (response.status >= 200 && response.status < 300) {
4271
+ return response.json();
4272
+ } else {
4273
+ throw response;
4274
+ }
4275
+ }),
4276
+ new Promise(
4277
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4278
+ )
4279
+ ]);
4280
+ }
4281
+ /** update webhook name by id */
4282
+ updateWebhookById(bearerToken, id, body, options = {}) {
4283
+ if (id === null || id === void 0) {
4284
+ throw new Error("'id' is a required parameter but is null or undefined.");
4285
+ }
4286
+ if (body === null || body === void 0) {
4287
+ throw new Error("'body' is a required parameter but is null or undefined.");
4288
+ }
4289
+ const urlPath = "/v2/webhooks/update/{id}".replace("{id}", encodeURIComponent(String(id)));
4290
+ const queryParams = /* @__PURE__ */ new Map();
4291
+ let bodyJson = "";
4292
+ bodyJson = JSON.stringify(body || {});
4293
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4294
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
4295
+ if (bearerToken) {
4296
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4297
+ }
4298
+ return Promise.race([
4299
+ fetch(fullUrl, fetchOptions).then((response) => {
4300
+ if (response.status == 204) {
4301
+ return response;
4302
+ } else if (response.status >= 200 && response.status < 300) {
4303
+ return response.json();
4304
+ } else {
4305
+ throw response;
4306
+ }
4307
+ }),
4308
+ new Promise(
4309
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4310
+ )
4311
+ ]);
4312
+ }
4313
+ /** list webhook belong to the channel */
4314
+ listWebhookByChannelId(bearerToken, channelId, options = {}) {
4315
+ if (channelId === null || channelId === void 0) {
4316
+ throw new Error("'channelId' is a required parameter but is null or undefined.");
4317
+ }
4318
+ const urlPath = "/v2/webhooks/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
4319
+ const queryParams = /* @__PURE__ */ new Map();
4320
+ let bodyJson = "";
4321
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4322
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4323
+ if (bearerToken) {
4324
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4325
+ }
4326
+ return Promise.race([
4327
+ fetch(fullUrl, fetchOptions).then((response) => {
4328
+ if (response.status == 204) {
4329
+ return response;
4330
+ } else if (response.status >= 200 && response.status < 300) {
4331
+ return response.json();
4332
+ } else {
4333
+ throw response;
4334
+ }
4335
+ }),
4336
+ new Promise(
4337
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4338
+ )
4339
+ ]);
4340
+ }
4341
+ /** disabled webhook */
4342
+ deleteWebhookById(bearerToken, id, options = {}) {
4343
+ if (id === null || id === void 0) {
4344
+ throw new Error("'id' is a required parameter but is null or undefined.");
4345
+ }
4346
+ const urlPath = "/v2/webhooks/{id}".replace("{id}", encodeURIComponent(String(id)));
4347
+ const queryParams = /* @__PURE__ */ new Map();
4348
+ let bodyJson = "";
4349
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4350
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
4351
+ if (bearerToken) {
4352
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4353
+ }
4354
+ return Promise.race([
4355
+ fetch(fullUrl, fetchOptions).then((response) => {
4356
+ if (response.status == 204) {
4357
+ return response;
4358
+ } else if (response.status >= 200 && response.status < 300) {
4359
+ return response.json();
4360
+ } else {
4361
+ throw response;
4362
+ }
4363
+ }),
4364
+ new Promise(
4365
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4366
+ )
4367
+ ]);
4368
+ }
4252
4369
  buildFullUrl(basePath, fragment, queryParams) {
4253
4370
  let fullPath = basePath + fragment + "?";
4254
4371
  for (let [k, v] of queryParams) {
@@ -4498,8 +4615,8 @@ var _DefaultSocket = class _DefaultSocket {
4498
4615
  id: message.channel_message.message_id,
4499
4616
  sender_id: message.channel_message.sender_id,
4500
4617
  update_time: message.channel_message.update_time,
4501
- user_id_one: message.channel_message.user_id_one,
4502
- user_id_two: message.channel_message.user_id_two,
4618
+ clan_logo: message.channel_message.clan_logo,
4619
+ category_name: message.channel_message.category_name,
4503
4620
  username: message.channel_message.username,
4504
4621
  content,
4505
4622
  reactions,
@@ -5393,8 +5510,8 @@ var Client = class {
5393
5510
  avatar: m.avatar,
5394
5511
  content: m.content ? JSON.parse(m.content) : void 0,
5395
5512
  channel_label: m.channel_label,
5396
- user_id_one: m.user_id_one,
5397
- user_id_two: m.user_id_two,
5513
+ clan_logo: m.clan_logo,
5514
+ category_name: m.category_name,
5398
5515
  attachments: m.attachments ? JSON.parse(m.attachments) : [],
5399
5516
  mentions: m.mentions ? JSON.parse(m.mentions) : [],
5400
5517
  reactions: m.reactions ? JSON.parse(m.reactions) : [],
@@ -6504,4 +6621,48 @@ var Client = class {
6504
6621
  });
6505
6622
  });
6506
6623
  }
6624
+ //**create webhook for chaneel */
6625
+ generateWebhookLink(session, request) {
6626
+ return __async(this, null, function* () {
6627
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6628
+ yield this.sessionRefresh(session);
6629
+ }
6630
+ return this.apiClient.generateWebhook(session.token, request).then((response) => {
6631
+ return Promise.resolve(response);
6632
+ });
6633
+ });
6634
+ }
6635
+ //**list webhook belong to the channel */
6636
+ listWebhookByChannelId(session, channel_id) {
6637
+ return __async(this, null, function* () {
6638
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6639
+ yield this.sessionRefresh(session);
6640
+ }
6641
+ return this.apiClient.listWebhookByChannelId(session.token, channel_id).then((response) => {
6642
+ return Promise.resolve(response);
6643
+ });
6644
+ });
6645
+ }
6646
+ //**update webhook name by id */
6647
+ updateWebhookById(session, id, request) {
6648
+ return __async(this, null, function* () {
6649
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6650
+ yield this.sessionRefresh(session);
6651
+ }
6652
+ return this.apiClient.updateWebhookById(session.token, id, request).then((response) => {
6653
+ return response !== void 0;
6654
+ });
6655
+ });
6656
+ }
6657
+ //**disabled webhook by id */
6658
+ deleteWebhookById(session, id) {
6659
+ return __async(this, null, function* () {
6660
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6661
+ yield this.sessionRefresh(session);
6662
+ }
6663
+ return this.apiClient.deleteWebhookById(session.token, id).then((response) => {
6664
+ return response !== void 0;
6665
+ });
6666
+ });
6667
+ }
6507
6668
  };
@@ -4220,6 +4220,123 @@ var MezonApi = class {
4220
4220
  )
4221
4221
  ]);
4222
4222
  }
4223
+ /** create webhook */
4224
+ generateWebhook(bearerToken, body, options = {}) {
4225
+ if (body === null || body === void 0) {
4226
+ throw new Error("'body' is a required parameter but is null or undefined.");
4227
+ }
4228
+ const urlPath = "/v2/webhooks/generate";
4229
+ const queryParams = /* @__PURE__ */ new Map();
4230
+ let bodyJson = "";
4231
+ bodyJson = JSON.stringify(body || {});
4232
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4233
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4234
+ if (bearerToken) {
4235
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4236
+ }
4237
+ return Promise.race([
4238
+ fetch(fullUrl, fetchOptions).then((response) => {
4239
+ if (response.status == 204) {
4240
+ return response;
4241
+ } else if (response.status >= 200 && response.status < 300) {
4242
+ return response.json();
4243
+ } else {
4244
+ throw response;
4245
+ }
4246
+ }),
4247
+ new Promise(
4248
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4249
+ )
4250
+ ]);
4251
+ }
4252
+ /** update webhook name by id */
4253
+ updateWebhookById(bearerToken, id, body, options = {}) {
4254
+ if (id === null || id === void 0) {
4255
+ throw new Error("'id' is a required parameter but is null or undefined.");
4256
+ }
4257
+ if (body === null || body === void 0) {
4258
+ throw new Error("'body' is a required parameter but is null or undefined.");
4259
+ }
4260
+ const urlPath = "/v2/webhooks/update/{id}".replace("{id}", encodeURIComponent(String(id)));
4261
+ const queryParams = /* @__PURE__ */ new Map();
4262
+ let bodyJson = "";
4263
+ bodyJson = JSON.stringify(body || {});
4264
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4265
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
4266
+ if (bearerToken) {
4267
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4268
+ }
4269
+ return Promise.race([
4270
+ fetch(fullUrl, fetchOptions).then((response) => {
4271
+ if (response.status == 204) {
4272
+ return response;
4273
+ } else if (response.status >= 200 && response.status < 300) {
4274
+ return response.json();
4275
+ } else {
4276
+ throw response;
4277
+ }
4278
+ }),
4279
+ new Promise(
4280
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4281
+ )
4282
+ ]);
4283
+ }
4284
+ /** list webhook belong to the channel */
4285
+ listWebhookByChannelId(bearerToken, channelId, options = {}) {
4286
+ if (channelId === null || channelId === void 0) {
4287
+ throw new Error("'channelId' is a required parameter but is null or undefined.");
4288
+ }
4289
+ const urlPath = "/v2/webhooks/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
4290
+ const queryParams = /* @__PURE__ */ new Map();
4291
+ let bodyJson = "";
4292
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4293
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4294
+ if (bearerToken) {
4295
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4296
+ }
4297
+ return Promise.race([
4298
+ fetch(fullUrl, fetchOptions).then((response) => {
4299
+ if (response.status == 204) {
4300
+ return response;
4301
+ } else if (response.status >= 200 && response.status < 300) {
4302
+ return response.json();
4303
+ } else {
4304
+ throw response;
4305
+ }
4306
+ }),
4307
+ new Promise(
4308
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4309
+ )
4310
+ ]);
4311
+ }
4312
+ /** disabled webhook */
4313
+ deleteWebhookById(bearerToken, id, options = {}) {
4314
+ if (id === null || id === void 0) {
4315
+ throw new Error("'id' is a required parameter but is null or undefined.");
4316
+ }
4317
+ const urlPath = "/v2/webhooks/{id}".replace("{id}", encodeURIComponent(String(id)));
4318
+ const queryParams = /* @__PURE__ */ new Map();
4319
+ let bodyJson = "";
4320
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4321
+ const fetchOptions = buildFetchOptions("PATCH", options, bodyJson);
4322
+ if (bearerToken) {
4323
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4324
+ }
4325
+ return Promise.race([
4326
+ fetch(fullUrl, fetchOptions).then((response) => {
4327
+ if (response.status == 204) {
4328
+ return response;
4329
+ } else if (response.status >= 200 && response.status < 300) {
4330
+ return response.json();
4331
+ } else {
4332
+ throw response;
4333
+ }
4334
+ }),
4335
+ new Promise(
4336
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4337
+ )
4338
+ ]);
4339
+ }
4223
4340
  buildFullUrl(basePath, fragment, queryParams) {
4224
4341
  let fullPath = basePath + fragment + "?";
4225
4342
  for (let [k, v] of queryParams) {
@@ -4469,8 +4586,8 @@ var _DefaultSocket = class _DefaultSocket {
4469
4586
  id: message.channel_message.message_id,
4470
4587
  sender_id: message.channel_message.sender_id,
4471
4588
  update_time: message.channel_message.update_time,
4472
- user_id_one: message.channel_message.user_id_one,
4473
- user_id_two: message.channel_message.user_id_two,
4589
+ clan_logo: message.channel_message.clan_logo,
4590
+ category_name: message.channel_message.category_name,
4474
4591
  username: message.channel_message.username,
4475
4592
  content,
4476
4593
  reactions,
@@ -5364,8 +5481,8 @@ var Client = class {
5364
5481
  avatar: m.avatar,
5365
5482
  content: m.content ? JSON.parse(m.content) : void 0,
5366
5483
  channel_label: m.channel_label,
5367
- user_id_one: m.user_id_one,
5368
- user_id_two: m.user_id_two,
5484
+ clan_logo: m.clan_logo,
5485
+ category_name: m.category_name,
5369
5486
  attachments: m.attachments ? JSON.parse(m.attachments) : [],
5370
5487
  mentions: m.mentions ? JSON.parse(m.mentions) : [],
5371
5488
  reactions: m.reactions ? JSON.parse(m.reactions) : [],
@@ -6475,6 +6592,50 @@ var Client = class {
6475
6592
  });
6476
6593
  });
6477
6594
  }
6595
+ //**create webhook for chaneel */
6596
+ generateWebhookLink(session, request) {
6597
+ return __async(this, null, function* () {
6598
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6599
+ yield this.sessionRefresh(session);
6600
+ }
6601
+ return this.apiClient.generateWebhook(session.token, request).then((response) => {
6602
+ return Promise.resolve(response);
6603
+ });
6604
+ });
6605
+ }
6606
+ //**list webhook belong to the channel */
6607
+ listWebhookByChannelId(session, channel_id) {
6608
+ return __async(this, null, function* () {
6609
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6610
+ yield this.sessionRefresh(session);
6611
+ }
6612
+ return this.apiClient.listWebhookByChannelId(session.token, channel_id).then((response) => {
6613
+ return Promise.resolve(response);
6614
+ });
6615
+ });
6616
+ }
6617
+ //**update webhook name by id */
6618
+ updateWebhookById(session, id, request) {
6619
+ return __async(this, null, function* () {
6620
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6621
+ yield this.sessionRefresh(session);
6622
+ }
6623
+ return this.apiClient.updateWebhookById(session.token, id, request).then((response) => {
6624
+ return response !== void 0;
6625
+ });
6626
+ });
6627
+ }
6628
+ //**disabled webhook by id */
6629
+ deleteWebhookById(session, id) {
6630
+ return __async(this, null, function* () {
6631
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6632
+ yield this.sessionRefresh(session);
6633
+ }
6634
+ return this.apiClient.deleteWebhookById(session.token, id).then((response) => {
6635
+ return response !== void 0;
6636
+ });
6637
+ });
6638
+ }
6478
6639
  };
6479
6640
  export {
6480
6641
  ChannelStreamMode,
package/dist/socket.d.ts CHANGED
@@ -39,8 +39,8 @@ export interface Channel {
39
39
  presences: Presence[];
40
40
  /** The presence of the current user, i.e. yourself. */
41
41
  self: Presence;
42
- user_id_one: string;
43
- user_id_two: string;
42
+ clan_logo: string;
43
+ category_name: string;
44
44
  }
45
45
  export interface ClanJoin {
46
46
  clan_join: {
@@ -185,8 +185,8 @@ export interface ChannelMessageEvent {
185
185
  persistent?: boolean;
186
186
  sender_id: string;
187
187
  update_time: string;
188
- user_id_one: string;
189
- user_id_two: string;
188
+ clan_logo: string;
189
+ category_name: string;
190
190
  username: string;
191
191
  reactions?: Array<ApiMessageReaction>;
192
192
  mentions?: Array<ApiMessageMention>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.78",
3
+ "version": "2.7.80",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -49,9 +49,9 @@ export interface Channel {
49
49
  /** The presence of the current user, i.e. yourself. */
50
50
  self: Presence;
51
51
  // The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
52
- user_id_one: string;
52
+ clan_logo: string;
53
53
  // The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
54
- user_id_two: string;
54
+ category_name: string;
55
55
  }
56
56
 
57
57
  export interface ClanJoin {
@@ -254,9 +254,9 @@ export interface ChannelMessageEvent {
254
254
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated.
255
255
  update_time: string;
256
256
  //The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
257
- user_id_one: string;
257
+ clan_logo: string;
258
258
  //The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
259
- user_id_two: string;
259
+ category_name: string;
260
260
  //The username of the message sender, if any.
261
261
  username: string;
262
262
  //
@@ -795,8 +795,8 @@ export class DefaultSocket implements Socket {
795
795
  id: message.channel_message.message_id,
796
796
  sender_id: message.channel_message.sender_id,
797
797
  update_time: message.channel_message.update_time,
798
- user_id_one: message.channel_message.user_id_one,
799
- user_id_two: message.channel_message.user_id_two,
798
+ clan_logo: message.channel_message.clan_logo,
799
+ category_name: message.channel_message.category_name,
800
800
  username: message.channel_message.username,
801
801
  content: content,
802
802
  reactions: reactions,