mezon-js 2.8.22 → 2.8.24

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/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, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiHashtagDmVoiceList, ApiPermissionRoleChannelList, ApiUpdateRoleChannelRequest } 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, 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, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiHashtagDmVoiceList, ApiPermissionRoleChannelList, ApiUpdateRoleChannelRequest } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -420,8 +420,6 @@ export declare class Client {
420
420
  deleteCategoryDesc(session: Session, creatorId: string): Promise<boolean>;
421
421
  /** Delete one or more notifications */
422
422
  deleteNotifications(session: Session, ids?: Array<string>): Promise<boolean>;
423
- /** Delete one or more storage objects */
424
- deleteStorageObjects(session: Session, request: ApiDeleteStorageObjectsRequest): Promise<boolean>;
425
423
  /** Delete a role by ID. */
426
424
  deleteRole(session: Session, roleId: string): Promise<boolean>;
427
425
  /** Delete a event by ID. */
@@ -498,10 +496,6 @@ export declare class Client {
498
496
  listFriends(session: Session, state?: number, limit?: number, cursor?: string): Promise<Friends>;
499
497
  /** Fetch list of notifications. */
500
498
  listNotifications(session: Session, clanId: string, limit?: number, cacheableCursor?: string): Promise<NotificationList>;
501
- /** List storage objects. */
502
- listStorageObjects(session: Session, collection: string, userId?: string, limit?: number, cursor?: string): Promise<StorageObjectList>;
503
- /** Fetch storage objects. */
504
- readStorageObjects(session: Session, request: ApiReadStorageObjectsRequest): Promise<StorageObjects>;
505
499
  /** Execute an RPC function on the server. */
506
500
  rpc(session: Session, basicAuthUsername: string, basicAuthPassword: string, id: string, input: object): Promise<RpcResponse>;
507
501
  /** Execute an RPC function on the server. */
@@ -551,8 +545,6 @@ export declare class Client {
551
545
  getPermissionOfUserInTheClan(session: Session, clanId: string): Promise<ApiPermissionList>;
552
546
  /** invite user */
553
547
  inviteUser(session: Session, inviteId: string): Promise<ApiInviteUserRes>;
554
- /** Write storage objects. */
555
- writeStorageObjects(session: Session, objects: Array<WriteStorageObject>): Promise<ApiStorageObjectAcks>;
556
548
  /** Set default notification clan*/
557
549
  setNotificationClan(session: Session, request: ApiSetDefaultNotificationRequest): Promise<boolean>;
558
550
  /** get default notification clan */
@@ -2418,14 +2418,15 @@ var MezonApi = class {
2418
2418
  ]);
2419
2419
  }
2420
2420
  /** Delete a emoji by ID. */
2421
- deleteByIdClanEmoji(bearerToken, id, clanId, options = {}) {
2421
+ deleteClanEmojiById(bearerToken, id, clanId, options = {}) {
2422
2422
  if (id === null || id === void 0) {
2423
2423
  throw new Error("'id' is a required parameter but is null or undefined.");
2424
2424
  }
2425
2425
  const urlPath = "/v2/emoji/{id}".replace("{id}", encodeURIComponent(String(id)));
2426
2426
  const queryParams = /* @__PURE__ */ new Map();
2427
2427
  queryParams.set("clan_id", clanId);
2428
- let bodyJson = "";
2428
+ const body = { clan_id: clanId };
2429
+ let bodyJson = JSON.stringify(body || {});
2429
2430
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2430
2431
  const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
2431
2432
  if (bearerToken) {
@@ -4073,157 +4074,6 @@ var MezonApi = class {
4073
4074
  )
4074
4075
  ]);
4075
4076
  }
4076
- /** Get storage objects. */
4077
- readStorageObjects(bearerToken, body, options = {}) {
4078
- if (body === null || body === void 0) {
4079
- throw new Error("'body' is a required parameter but is null or undefined.");
4080
- }
4081
- const urlPath = "/v2/storage";
4082
- const queryParams = /* @__PURE__ */ new Map();
4083
- let bodyJson = "";
4084
- bodyJson = JSON.stringify(body || {});
4085
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4086
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4087
- if (bearerToken) {
4088
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4089
- }
4090
- return Promise.race([
4091
- fetch(fullUrl, fetchOptions).then((response) => {
4092
- if (response.status == 204) {
4093
- return response;
4094
- } else if (response.status >= 200 && response.status < 300) {
4095
- return response.json();
4096
- } else {
4097
- throw response;
4098
- }
4099
- }),
4100
- new Promise(
4101
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4102
- )
4103
- ]);
4104
- }
4105
- /** Write objects into the storage engine. */
4106
- writeStorageObjects(bearerToken, body, options = {}) {
4107
- if (body === null || body === void 0) {
4108
- throw new Error("'body' is a required parameter but is null or undefined.");
4109
- }
4110
- const urlPath = "/v2/storage";
4111
- const queryParams = /* @__PURE__ */ new Map();
4112
- let bodyJson = "";
4113
- bodyJson = JSON.stringify(body || {});
4114
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4115
- const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
4116
- if (bearerToken) {
4117
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4118
- }
4119
- return Promise.race([
4120
- fetch(fullUrl, fetchOptions).then((response) => {
4121
- if (response.status == 204) {
4122
- return response;
4123
- } else if (response.status >= 200 && response.status < 300) {
4124
- return response.json();
4125
- } else {
4126
- throw response;
4127
- }
4128
- }),
4129
- new Promise(
4130
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4131
- )
4132
- ]);
4133
- }
4134
- /** Delete one or more objects by ID or username. */
4135
- deleteStorageObjects(bearerToken, body, options = {}) {
4136
- if (body === null || body === void 0) {
4137
- throw new Error("'body' is a required parameter but is null or undefined.");
4138
- }
4139
- const urlPath = "/v2/storage/delete";
4140
- const queryParams = /* @__PURE__ */ new Map();
4141
- let bodyJson = "";
4142
- bodyJson = JSON.stringify(body || {});
4143
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4144
- const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
4145
- if (bearerToken) {
4146
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4147
- }
4148
- return Promise.race([
4149
- fetch(fullUrl, fetchOptions).then((response) => {
4150
- if (response.status == 204) {
4151
- return response;
4152
- } else if (response.status >= 200 && response.status < 300) {
4153
- return response.json();
4154
- } else {
4155
- throw response;
4156
- }
4157
- }),
4158
- new Promise(
4159
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4160
- )
4161
- ]);
4162
- }
4163
- /** List publicly readable storage objects in a given collection. */
4164
- listStorageObjects(bearerToken, collection, userId, limit, cursor, options = {}) {
4165
- if (collection === null || collection === void 0) {
4166
- throw new Error("'collection' is a required parameter but is null or undefined.");
4167
- }
4168
- const urlPath = "/v2/storage/{collection}".replace("{collection}", encodeURIComponent(String(collection)));
4169
- const queryParams = /* @__PURE__ */ new Map();
4170
- queryParams.set("user_id", userId);
4171
- queryParams.set("limit", limit);
4172
- queryParams.set("cursor", cursor);
4173
- let bodyJson = "";
4174
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4175
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4176
- if (bearerToken) {
4177
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4178
- }
4179
- return Promise.race([
4180
- fetch(fullUrl, fetchOptions).then((response) => {
4181
- if (response.status == 204) {
4182
- return response;
4183
- } else if (response.status >= 200 && response.status < 300) {
4184
- return response.json();
4185
- } else {
4186
- throw response;
4187
- }
4188
- }),
4189
- new Promise(
4190
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4191
- )
4192
- ]);
4193
- }
4194
- /** List publicly readable storage objects in a given collection. */
4195
- listStorageObjects2(bearerToken, collection, userId, limit, cursor, options = {}) {
4196
- if (collection === null || collection === void 0) {
4197
- throw new Error("'collection' is a required parameter but is null or undefined.");
4198
- }
4199
- if (userId === null || userId === void 0) {
4200
- throw new Error("'userId' is a required parameter but is null or undefined.");
4201
- }
4202
- const urlPath = "/v2/storage/{collection}/{userId}".replace("{collection}", encodeURIComponent(String(collection))).replace("{userId}", encodeURIComponent(String(userId)));
4203
- const queryParams = /* @__PURE__ */ new Map();
4204
- queryParams.set("limit", limit);
4205
- queryParams.set("cursor", cursor);
4206
- let bodyJson = "";
4207
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4208
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4209
- if (bearerToken) {
4210
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4211
- }
4212
- return Promise.race([
4213
- fetch(fullUrl, fetchOptions).then((response) => {
4214
- if (response.status == 204) {
4215
- return response;
4216
- } else if (response.status >= 200 && response.status < 300) {
4217
- return response.json();
4218
- } else {
4219
- throw response;
4220
- }
4221
- }),
4222
- new Promise(
4223
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4224
- )
4225
- ]);
4226
- }
4227
4077
  /** Update fields in a given category. */
4228
4078
  updateCategory(bearerToken, body, options = {}) {
4229
4079
  if (body === null || body === void 0) {
@@ -5093,9 +4943,9 @@ var _DefaultSocket = class _DefaultSocket {
5093
4943
  unfollowUsers(user_ids) {
5094
4944
  return this.send({ status_unfollow: { user_ids } });
5095
4945
  }
5096
- updateChatMessage(clan_id, channel_id, mode, message_id, content, mentions) {
4946
+ updateChatMessage(clan_id, channel_id, mode, message_id, content, mentions, attachments) {
5097
4947
  return __async(this, null, function* () {
5098
- const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mentions, mode } });
4948
+ const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mentions, attachments, mode } });
5099
4949
  return response.channel_message_ack;
5100
4950
  });
5101
4951
  }
@@ -5158,14 +5008,14 @@ var _DefaultSocket = class _DefaultSocket {
5158
5008
  }
5159
5009
  listClanEmojiByClanId(clan_id) {
5160
5010
  return __async(this, null, function* () {
5161
- const response = yield this.send({ emojis_by_clan_id_request_event: { clan_id } });
5162
- return response.clan_emoji_list_event;
5011
+ const response = yield this.send({ emojis_listed_event: { clan_id } });
5012
+ return response.emojis_listed_event;
5163
5013
  });
5164
5014
  }
5165
5015
  listClanStickersByClanId(clan_id) {
5166
5016
  return __async(this, null, function* () {
5167
- const response = yield this.send({ clan_sticker_list_request_event: { clan_id } });
5168
- return response.clan_sticker_list_response_event;
5017
+ const response = yield this.send({ sticker_listed_event: { clan_id } });
5018
+ return response.sticker_listed_event;
5169
5019
  });
5170
5020
  }
5171
5021
  pingPong() {
@@ -5546,17 +5396,6 @@ var Client = class {
5546
5396
  });
5547
5397
  });
5548
5398
  }
5549
- /** Delete one or more storage objects */
5550
- deleteStorageObjects(session, request) {
5551
- return __async(this, null, function* () {
5552
- if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
5553
- yield this.sessionRefresh(session);
5554
- }
5555
- return this.apiClient.deleteStorageObjects(session.token, request).then((response) => {
5556
- return Promise.resolve(response != void 0);
5557
- });
5558
- });
5559
- }
5560
5399
  /** Delete a role by ID. */
5561
5400
  deleteRole(session, roleId) {
5562
5401
  return __async(this, null, function* () {
@@ -6248,65 +6087,6 @@ var Client = class {
6248
6087
  });
6249
6088
  });
6250
6089
  }
6251
- /** List storage objects. */
6252
- listStorageObjects(session, collection, userId, limit, cursor) {
6253
- return __async(this, null, function* () {
6254
- if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6255
- yield this.sessionRefresh(session);
6256
- }
6257
- return this.apiClient.listStorageObjects(session.token, collection, userId, limit, cursor).then((response) => {
6258
- var result = {
6259
- objects: [],
6260
- cursor: response.cursor
6261
- };
6262
- if (response.objects == null) {
6263
- return Promise.resolve(result);
6264
- }
6265
- response.objects.forEach((o) => {
6266
- result.objects.push({
6267
- collection: o.collection,
6268
- key: o.key,
6269
- permission_read: o.permission_read ? Number(o.permission_read) : 0,
6270
- permission_write: o.permission_write ? Number(o.permission_write) : 0,
6271
- value: o.value ? JSON.parse(o.value) : void 0,
6272
- version: o.version,
6273
- user_id: o.user_id,
6274
- create_time: o.create_time,
6275
- update_time: o.update_time
6276
- });
6277
- });
6278
- return Promise.resolve(result);
6279
- });
6280
- });
6281
- }
6282
- /** Fetch storage objects. */
6283
- readStorageObjects(session, request) {
6284
- return __async(this, null, function* () {
6285
- if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6286
- yield this.sessionRefresh(session);
6287
- }
6288
- return this.apiClient.readStorageObjects(session.token, request).then((response) => {
6289
- var result = { objects: [] };
6290
- if (response.objects == null) {
6291
- return Promise.resolve(result);
6292
- }
6293
- response.objects.forEach((o) => {
6294
- result.objects.push({
6295
- collection: o.collection,
6296
- key: o.key,
6297
- permission_read: o.permission_read ? Number(o.permission_read) : 0,
6298
- permission_write: o.permission_write ? Number(o.permission_write) : 0,
6299
- value: o.value ? JSON.parse(o.value) : void 0,
6300
- version: o.version,
6301
- user_id: o.user_id,
6302
- create_time: o.create_time,
6303
- update_time: o.update_time
6304
- });
6305
- });
6306
- return Promise.resolve(result);
6307
- });
6308
- });
6309
- }
6310
6090
  /** Execute an RPC function on the server. */
6311
6091
  rpc(session, basicAuthUsername, basicAuthPassword, id, input) {
6312
6092
  return __async(this, null, function* () {
@@ -6593,26 +6373,6 @@ var Client = class {
6593
6373
  });
6594
6374
  });
6595
6375
  }
6596
- /** Write storage objects. */
6597
- writeStorageObjects(session, objects) {
6598
- return __async(this, null, function* () {
6599
- if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6600
- yield this.sessionRefresh(session);
6601
- }
6602
- var request = { objects: [] };
6603
- objects.forEach((o) => {
6604
- request.objects.push({
6605
- collection: o.collection,
6606
- key: o.key,
6607
- permission_read: o.permission_read,
6608
- permission_write: o.permission_write,
6609
- value: JSON.stringify(o.value),
6610
- version: o.version
6611
- });
6612
- });
6613
- return this.apiClient.writeStorageObjects(session.token, request);
6614
- });
6615
- }
6616
6376
  /** Set default notification clan*/
6617
6377
  setNotificationClan(session, request) {
6618
6378
  return __async(this, null, function* () {
@@ -6845,7 +6605,7 @@ var Client = class {
6845
6605
  if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6846
6606
  yield this.sessionRefresh(session);
6847
6607
  }
6848
- return this.apiClient.deleteByIdClanEmoji(session.token, id, clan_id).then((response) => {
6608
+ return this.apiClient.deleteClanEmojiById(session.token, id, clan_id).then((response) => {
6849
6609
  return response !== void 0;
6850
6610
  });
6851
6611
  });