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/api.gen.ts +3 -241
- package/client.ts +2 -106
- package/dist/api.gen.d.ts +1 -37
- package/dist/api1.gen.d.ts +1157 -0
- package/dist/client.d.ts +1 -9
- package/dist/mezon-js.cjs.js +10 -250
- package/dist/mezon-js.esm.mjs +10 -250
- package/dist/socket.d.ts +37 -7
- package/package.json +1 -1
- package/socket.ts +73 -21
package/dist/mezon-js.esm.mjs
CHANGED
@@ -2389,14 +2389,15 @@ var MezonApi = class {
|
|
2389
2389
|
]);
|
2390
2390
|
}
|
2391
2391
|
/** Delete a emoji by ID. */
|
2392
|
-
|
2392
|
+
deleteClanEmojiById(bearerToken, id, clanId, options = {}) {
|
2393
2393
|
if (id === null || id === void 0) {
|
2394
2394
|
throw new Error("'id' is a required parameter but is null or undefined.");
|
2395
2395
|
}
|
2396
2396
|
const urlPath = "/v2/emoji/{id}".replace("{id}", encodeURIComponent(String(id)));
|
2397
2397
|
const queryParams = /* @__PURE__ */ new Map();
|
2398
2398
|
queryParams.set("clan_id", clanId);
|
2399
|
-
|
2399
|
+
const body = { clan_id: clanId };
|
2400
|
+
let bodyJson = JSON.stringify(body || {});
|
2400
2401
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2401
2402
|
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
2402
2403
|
if (bearerToken) {
|
@@ -4044,157 +4045,6 @@ var MezonApi = class {
|
|
4044
4045
|
)
|
4045
4046
|
]);
|
4046
4047
|
}
|
4047
|
-
/** Get storage objects. */
|
4048
|
-
readStorageObjects(bearerToken, body, options = {}) {
|
4049
|
-
if (body === null || body === void 0) {
|
4050
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
4051
|
-
}
|
4052
|
-
const urlPath = "/v2/storage";
|
4053
|
-
const queryParams = /* @__PURE__ */ new Map();
|
4054
|
-
let bodyJson = "";
|
4055
|
-
bodyJson = JSON.stringify(body || {});
|
4056
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
4057
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
4058
|
-
if (bearerToken) {
|
4059
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
4060
|
-
}
|
4061
|
-
return Promise.race([
|
4062
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
4063
|
-
if (response.status == 204) {
|
4064
|
-
return response;
|
4065
|
-
} else if (response.status >= 200 && response.status < 300) {
|
4066
|
-
return response.json();
|
4067
|
-
} else {
|
4068
|
-
throw response;
|
4069
|
-
}
|
4070
|
-
}),
|
4071
|
-
new Promise(
|
4072
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
4073
|
-
)
|
4074
|
-
]);
|
4075
|
-
}
|
4076
|
-
/** Write objects into the storage engine. */
|
4077
|
-
writeStorageObjects(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("PUT", 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
|
-
/** Delete one or more objects by ID or username. */
|
4106
|
-
deleteStorageObjects(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/delete";
|
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
|
-
/** List publicly readable storage objects in a given collection. */
|
4135
|
-
listStorageObjects(bearerToken, collection, userId, limit, cursor, options = {}) {
|
4136
|
-
if (collection === null || collection === void 0) {
|
4137
|
-
throw new Error("'collection' is a required parameter but is null or undefined.");
|
4138
|
-
}
|
4139
|
-
const urlPath = "/v2/storage/{collection}".replace("{collection}", encodeURIComponent(String(collection)));
|
4140
|
-
const queryParams = /* @__PURE__ */ new Map();
|
4141
|
-
queryParams.set("user_id", userId);
|
4142
|
-
queryParams.set("limit", limit);
|
4143
|
-
queryParams.set("cursor", cursor);
|
4144
|
-
let bodyJson = "";
|
4145
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
4146
|
-
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
4147
|
-
if (bearerToken) {
|
4148
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
4149
|
-
}
|
4150
|
-
return Promise.race([
|
4151
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
4152
|
-
if (response.status == 204) {
|
4153
|
-
return response;
|
4154
|
-
} else if (response.status >= 200 && response.status < 300) {
|
4155
|
-
return response.json();
|
4156
|
-
} else {
|
4157
|
-
throw response;
|
4158
|
-
}
|
4159
|
-
}),
|
4160
|
-
new Promise(
|
4161
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
4162
|
-
)
|
4163
|
-
]);
|
4164
|
-
}
|
4165
|
-
/** List publicly readable storage objects in a given collection. */
|
4166
|
-
listStorageObjects2(bearerToken, collection, userId, limit, cursor, options = {}) {
|
4167
|
-
if (collection === null || collection === void 0) {
|
4168
|
-
throw new Error("'collection' is a required parameter but is null or undefined.");
|
4169
|
-
}
|
4170
|
-
if (userId === null || userId === void 0) {
|
4171
|
-
throw new Error("'userId' is a required parameter but is null or undefined.");
|
4172
|
-
}
|
4173
|
-
const urlPath = "/v2/storage/{collection}/{userId}".replace("{collection}", encodeURIComponent(String(collection))).replace("{userId}", encodeURIComponent(String(userId)));
|
4174
|
-
const queryParams = /* @__PURE__ */ new Map();
|
4175
|
-
queryParams.set("limit", limit);
|
4176
|
-
queryParams.set("cursor", cursor);
|
4177
|
-
let bodyJson = "";
|
4178
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
4179
|
-
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
4180
|
-
if (bearerToken) {
|
4181
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
4182
|
-
}
|
4183
|
-
return Promise.race([
|
4184
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
4185
|
-
if (response.status == 204) {
|
4186
|
-
return response;
|
4187
|
-
} else if (response.status >= 200 && response.status < 300) {
|
4188
|
-
return response.json();
|
4189
|
-
} else {
|
4190
|
-
throw response;
|
4191
|
-
}
|
4192
|
-
}),
|
4193
|
-
new Promise(
|
4194
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
4195
|
-
)
|
4196
|
-
]);
|
4197
|
-
}
|
4198
4048
|
/** Update fields in a given category. */
|
4199
4049
|
updateCategory(bearerToken, body, options = {}) {
|
4200
4050
|
if (body === null || body === void 0) {
|
@@ -5064,9 +4914,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5064
4914
|
unfollowUsers(user_ids) {
|
5065
4915
|
return this.send({ status_unfollow: { user_ids } });
|
5066
4916
|
}
|
5067
|
-
updateChatMessage(clan_id, channel_id, mode, message_id, content, mentions) {
|
4917
|
+
updateChatMessage(clan_id, channel_id, mode, message_id, content, mentions, attachments) {
|
5068
4918
|
return __async(this, null, function* () {
|
5069
|
-
const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mentions, mode } });
|
4919
|
+
const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mentions, attachments, mode } });
|
5070
4920
|
return response.channel_message_ack;
|
5071
4921
|
});
|
5072
4922
|
}
|
@@ -5129,14 +4979,14 @@ var _DefaultSocket = class _DefaultSocket {
|
|
5129
4979
|
}
|
5130
4980
|
listClanEmojiByClanId(clan_id) {
|
5131
4981
|
return __async(this, null, function* () {
|
5132
|
-
const response = yield this.send({
|
5133
|
-
return response.
|
4982
|
+
const response = yield this.send({ emojis_listed_event: { clan_id } });
|
4983
|
+
return response.emojis_listed_event;
|
5134
4984
|
});
|
5135
4985
|
}
|
5136
4986
|
listClanStickersByClanId(clan_id) {
|
5137
4987
|
return __async(this, null, function* () {
|
5138
|
-
const response = yield this.send({
|
5139
|
-
return response.
|
4988
|
+
const response = yield this.send({ sticker_listed_event: { clan_id } });
|
4989
|
+
return response.sticker_listed_event;
|
5140
4990
|
});
|
5141
4991
|
}
|
5142
4992
|
pingPong() {
|
@@ -5517,17 +5367,6 @@ var Client = class {
|
|
5517
5367
|
});
|
5518
5368
|
});
|
5519
5369
|
}
|
5520
|
-
/** Delete one or more storage objects */
|
5521
|
-
deleteStorageObjects(session, request) {
|
5522
|
-
return __async(this, null, function* () {
|
5523
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
5524
|
-
yield this.sessionRefresh(session);
|
5525
|
-
}
|
5526
|
-
return this.apiClient.deleteStorageObjects(session.token, request).then((response) => {
|
5527
|
-
return Promise.resolve(response != void 0);
|
5528
|
-
});
|
5529
|
-
});
|
5530
|
-
}
|
5531
5370
|
/** Delete a role by ID. */
|
5532
5371
|
deleteRole(session, roleId) {
|
5533
5372
|
return __async(this, null, function* () {
|
@@ -6219,65 +6058,6 @@ var Client = class {
|
|
6219
6058
|
});
|
6220
6059
|
});
|
6221
6060
|
}
|
6222
|
-
/** List storage objects. */
|
6223
|
-
listStorageObjects(session, collection, userId, limit, cursor) {
|
6224
|
-
return __async(this, null, function* () {
|
6225
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
6226
|
-
yield this.sessionRefresh(session);
|
6227
|
-
}
|
6228
|
-
return this.apiClient.listStorageObjects(session.token, collection, userId, limit, cursor).then((response) => {
|
6229
|
-
var result = {
|
6230
|
-
objects: [],
|
6231
|
-
cursor: response.cursor
|
6232
|
-
};
|
6233
|
-
if (response.objects == null) {
|
6234
|
-
return Promise.resolve(result);
|
6235
|
-
}
|
6236
|
-
response.objects.forEach((o) => {
|
6237
|
-
result.objects.push({
|
6238
|
-
collection: o.collection,
|
6239
|
-
key: o.key,
|
6240
|
-
permission_read: o.permission_read ? Number(o.permission_read) : 0,
|
6241
|
-
permission_write: o.permission_write ? Number(o.permission_write) : 0,
|
6242
|
-
value: o.value ? JSON.parse(o.value) : void 0,
|
6243
|
-
version: o.version,
|
6244
|
-
user_id: o.user_id,
|
6245
|
-
create_time: o.create_time,
|
6246
|
-
update_time: o.update_time
|
6247
|
-
});
|
6248
|
-
});
|
6249
|
-
return Promise.resolve(result);
|
6250
|
-
});
|
6251
|
-
});
|
6252
|
-
}
|
6253
|
-
/** Fetch storage objects. */
|
6254
|
-
readStorageObjects(session, request) {
|
6255
|
-
return __async(this, null, function* () {
|
6256
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
6257
|
-
yield this.sessionRefresh(session);
|
6258
|
-
}
|
6259
|
-
return this.apiClient.readStorageObjects(session.token, request).then((response) => {
|
6260
|
-
var result = { objects: [] };
|
6261
|
-
if (response.objects == null) {
|
6262
|
-
return Promise.resolve(result);
|
6263
|
-
}
|
6264
|
-
response.objects.forEach((o) => {
|
6265
|
-
result.objects.push({
|
6266
|
-
collection: o.collection,
|
6267
|
-
key: o.key,
|
6268
|
-
permission_read: o.permission_read ? Number(o.permission_read) : 0,
|
6269
|
-
permission_write: o.permission_write ? Number(o.permission_write) : 0,
|
6270
|
-
value: o.value ? JSON.parse(o.value) : void 0,
|
6271
|
-
version: o.version,
|
6272
|
-
user_id: o.user_id,
|
6273
|
-
create_time: o.create_time,
|
6274
|
-
update_time: o.update_time
|
6275
|
-
});
|
6276
|
-
});
|
6277
|
-
return Promise.resolve(result);
|
6278
|
-
});
|
6279
|
-
});
|
6280
|
-
}
|
6281
6061
|
/** Execute an RPC function on the server. */
|
6282
6062
|
rpc(session, basicAuthUsername, basicAuthPassword, id, input) {
|
6283
6063
|
return __async(this, null, function* () {
|
@@ -6564,26 +6344,6 @@ var Client = class {
|
|
6564
6344
|
});
|
6565
6345
|
});
|
6566
6346
|
}
|
6567
|
-
/** Write storage objects. */
|
6568
|
-
writeStorageObjects(session, objects) {
|
6569
|
-
return __async(this, null, function* () {
|
6570
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
6571
|
-
yield this.sessionRefresh(session);
|
6572
|
-
}
|
6573
|
-
var request = { objects: [] };
|
6574
|
-
objects.forEach((o) => {
|
6575
|
-
request.objects.push({
|
6576
|
-
collection: o.collection,
|
6577
|
-
key: o.key,
|
6578
|
-
permission_read: o.permission_read,
|
6579
|
-
permission_write: o.permission_write,
|
6580
|
-
value: JSON.stringify(o.value),
|
6581
|
-
version: o.version
|
6582
|
-
});
|
6583
|
-
});
|
6584
|
-
return this.apiClient.writeStorageObjects(session.token, request);
|
6585
|
-
});
|
6586
|
-
}
|
6587
6347
|
/** Set default notification clan*/
|
6588
6348
|
setNotificationClan(session, request) {
|
6589
6349
|
return __async(this, null, function* () {
|
@@ -6816,7 +6576,7 @@ var Client = class {
|
|
6816
6576
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
6817
6577
|
yield this.sessionRefresh(session);
|
6818
6578
|
}
|
6819
|
-
return this.apiClient.
|
6579
|
+
return this.apiClient.deleteClanEmojiById(session.token, id, clan_id).then((response) => {
|
6820
6580
|
return response !== void 0;
|
6821
6581
|
});
|
6822
6582
|
});
|
package/dist/socket.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 {
|
16
|
+
import { ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiRpc } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Notification } from "./client";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -270,6 +270,8 @@ interface ChannelMessageUpdate {
|
|
270
270
|
content: any;
|
271
271
|
/** mentions */
|
272
272
|
mentions?: Array<MessageMentionEvent>;
|
273
|
+
/** attachments */
|
274
|
+
attachments?: Array<MessageAttachmentEvent>;
|
273
275
|
/** The mode payload. */
|
274
276
|
mode: number;
|
275
277
|
};
|
@@ -441,6 +443,34 @@ interface StatusUpdate {
|
|
441
443
|
export interface ClanNameExistedEvent {
|
442
444
|
clan_name: string;
|
443
445
|
}
|
446
|
+
/** */
|
447
|
+
export interface StrickerListedEvent {
|
448
|
+
clan_id: string;
|
449
|
+
stickers?: Array<ClanSticker>;
|
450
|
+
}
|
451
|
+
/** */
|
452
|
+
export interface ClanSticker {
|
453
|
+
category?: string;
|
454
|
+
clan_id?: string;
|
455
|
+
create_time?: string;
|
456
|
+
creator_id?: string;
|
457
|
+
id?: string;
|
458
|
+
shortname?: string;
|
459
|
+
source?: string;
|
460
|
+
}
|
461
|
+
/** */
|
462
|
+
export interface EmojiListedEvent {
|
463
|
+
clan_id: string;
|
464
|
+
emoji_list?: Array<ClanEmoji>;
|
465
|
+
}
|
466
|
+
/** */
|
467
|
+
export interface ClanEmoji {
|
468
|
+
category?: string;
|
469
|
+
creator_id?: string;
|
470
|
+
id?: string;
|
471
|
+
shortname?: string;
|
472
|
+
src?: string;
|
473
|
+
}
|
444
474
|
/** A socket connection to Mezon server. */
|
445
475
|
export interface Socket {
|
446
476
|
/** Connection is Open */
|
@@ -464,7 +494,7 @@ export interface Socket {
|
|
464
494
|
/** Unfollow one or more users from their status updates. */
|
465
495
|
unfollowUsers(user_ids: string[]): Promise<void>;
|
466
496
|
/** Update a chat message on a chat channel in the server. */
|
467
|
-
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any, mentions?: Array<ApiMessageMention>): Promise<ChannelMessageAck>;
|
497
|
+
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>): Promise<ChannelMessageAck>;
|
468
498
|
/** Update the status for the current user online. */
|
469
499
|
updateStatus(status?: string): Promise<void>;
|
470
500
|
/** Send a chat message to a chat channel on the server. */
|
@@ -533,8 +563,8 @@ export interface Socket {
|
|
533
563
|
setHeartbeatTimeoutMs(ms: number): void;
|
534
564
|
getHeartbeatTimeoutMs(): number;
|
535
565
|
checkDuplicateClanName(clan_name: string): Promise<ClanNameExistedEvent>;
|
536
|
-
listClanEmojiByClanId(clan_id: string): Promise<
|
537
|
-
listClanStickersByClanId(clan_id: string): Promise<
|
566
|
+
listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent>;
|
567
|
+
listClanStickersByClanId(clan_id: string): Promise<StrickerListedEvent>;
|
538
568
|
}
|
539
569
|
/** Reports an error received from a socket message. */
|
540
570
|
export interface SocketError {
|
@@ -600,7 +630,7 @@ export declare class DefaultSocket implements Socket {
|
|
600
630
|
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
|
601
631
|
sendPartyData(party_id: string, op_code: number, data: string | Uint8Array): Promise<void>;
|
602
632
|
unfollowUsers(user_ids: string[]): Promise<void>;
|
603
|
-
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any, mentions?: Array<ApiMessageMention>): Promise<ChannelMessageAck>;
|
633
|
+
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>): Promise<ChannelMessageAck>;
|
604
634
|
updateStatus(status?: string): Promise<void>;
|
605
635
|
writeChatMessage(clan_id: string, channel_id: string, mode: number, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>, anonymous_message?: boolean, mention_everyone?: Boolean, notifi_content?: any): Promise<ChannelMessageAck>;
|
606
636
|
writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
|
@@ -611,8 +641,8 @@ export declare class DefaultSocket implements Socket {
|
|
611
641
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
612
642
|
writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
|
613
643
|
checkDuplicateClanName(clan_name: string): Promise<ClanNameExistedEvent>;
|
614
|
-
listClanEmojiByClanId(clan_id: string): Promise<
|
615
|
-
listClanStickersByClanId(clan_id: string): Promise<
|
644
|
+
listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent>;
|
645
|
+
listClanStickersByClanId(clan_id: string): Promise<StrickerListedEvent>;
|
616
646
|
private pingPong;
|
617
647
|
}
|
618
648
|
export {};
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import {
|
17
|
+
import {ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiRpc} from "./api.gen";
|
18
18
|
import {Session} from "./session";
|
19
19
|
import {Notification} from "./client";
|
20
20
|
import {WebSocketAdapter, WebSocketAdapterText} from "./web_socket_adapter"
|
@@ -381,6 +381,8 @@ interface ChannelMessageUpdate {
|
|
381
381
|
content: any,
|
382
382
|
/** mentions */
|
383
383
|
mentions?: Array<MessageMentionEvent>;
|
384
|
+
/** attachments */
|
385
|
+
attachments?: Array<MessageAttachmentEvent>;
|
384
386
|
/** The mode payload. */
|
385
387
|
mode: number;
|
386
388
|
};
|
@@ -623,6 +625,56 @@ interface StatusUpdate {
|
|
623
625
|
export interface ClanNameExistedEvent {
|
624
626
|
clan_name: string;
|
625
627
|
}
|
628
|
+
|
629
|
+
|
630
|
+
/** */
|
631
|
+
export interface StrickerListedEvent {
|
632
|
+
// clan id
|
633
|
+
clan_id: string;
|
634
|
+
// sticker data
|
635
|
+
stickers?: Array<ClanSticker>;
|
636
|
+
}
|
637
|
+
|
638
|
+
/** */
|
639
|
+
export interface ClanSticker {
|
640
|
+
//
|
641
|
+
category?: string;
|
642
|
+
//
|
643
|
+
clan_id?: string;
|
644
|
+
//
|
645
|
+
create_time?: string;
|
646
|
+
//
|
647
|
+
creator_id?: string;
|
648
|
+
//
|
649
|
+
id?: string;
|
650
|
+
//
|
651
|
+
shortname?: string;
|
652
|
+
//
|
653
|
+
source?: string;
|
654
|
+
}
|
655
|
+
|
656
|
+
/** */
|
657
|
+
export interface EmojiListedEvent {
|
658
|
+
// clan id
|
659
|
+
clan_id: string;
|
660
|
+
// emoji data
|
661
|
+
emoji_list?: Array<ClanEmoji>;
|
662
|
+
}
|
663
|
+
|
664
|
+
/** */
|
665
|
+
export interface ClanEmoji {
|
666
|
+
//
|
667
|
+
category?: string;
|
668
|
+
//
|
669
|
+
creator_id?: string;
|
670
|
+
//
|
671
|
+
id?: string;
|
672
|
+
//
|
673
|
+
shortname?: string;
|
674
|
+
//
|
675
|
+
src?: string;
|
676
|
+
}
|
677
|
+
|
626
678
|
/** A socket connection to Mezon server. */
|
627
679
|
export interface Socket {
|
628
680
|
/** Connection is Open */
|
@@ -656,7 +708,7 @@ export interface Socket {
|
|
656
708
|
unfollowUsers(user_ids : string[]) : Promise<void>;
|
657
709
|
|
658
710
|
/** Update a chat message on a chat channel in the server. */
|
659
|
-
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any, mentions?: Array<ApiMessageMention>) : Promise<ChannelMessageAck>;
|
711
|
+
updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>) : Promise<ChannelMessageAck>;
|
660
712
|
|
661
713
|
/** Update the status for the current user online. */
|
662
714
|
updateStatus(status? : string) : Promise<void>;
|
@@ -775,9 +827,9 @@ export interface Socket {
|
|
775
827
|
|
776
828
|
checkDuplicateClanName(clan_name: string): Promise<ClanNameExistedEvent>;
|
777
829
|
|
778
|
-
listClanEmojiByClanId(clan_id: string): Promise<
|
830
|
+
listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent>;
|
779
831
|
|
780
|
-
listClanStickersByClanId(clan_id: string): Promise<
|
832
|
+
listClanStickersByClanId(clan_id: string): Promise<StrickerListedEvent>;
|
781
833
|
}
|
782
834
|
|
783
835
|
/** Reports an error received from a socket message. */
|
@@ -1241,7 +1293,7 @@ export class DefaultSocket implements Socket {
|
|
1241
1293
|
}});
|
1242
1294
|
}
|
1243
1295
|
|
1244
|
-
async rpc(id?: string, payload?: string, http_key?: string)
|
1296
|
+
async rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc> {
|
1245
1297
|
const response = await this.send(
|
1246
1298
|
{
|
1247
1299
|
rpc: {
|
@@ -1262,8 +1314,8 @@ export class DefaultSocket implements Socket {
|
|
1262
1314
|
return this.send({status_unfollow: {user_ids: user_ids}});
|
1263
1315
|
}
|
1264
1316
|
|
1265
|
-
async updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any, mentions?: Array<ApiMessageMention>): Promise<ChannelMessageAck> {
|
1266
|
-
const response = await this.send({channel_message_update: {clan_id: clan_id, channel_id: channel_id, message_id: message_id, content: content, mentions: mentions, mode: mode}});
|
1317
|
+
async updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>): Promise<ChannelMessageAck> {
|
1318
|
+
const response = await this.send({channel_message_update: {clan_id: clan_id, channel_id: channel_id, message_id: message_id, content: content, mentions: mentions, attachments: attachments, mode: mode}});
|
1267
1319
|
return response.channel_message_ack;
|
1268
1320
|
}
|
1269
1321
|
|
@@ -1276,37 +1328,37 @@ export class DefaultSocket implements Socket {
|
|
1276
1328
|
return response.channel_message_ack;
|
1277
1329
|
}
|
1278
1330
|
|
1279
|
-
async writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean)
|
1331
|
+
async writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent> {
|
1280
1332
|
const response = await this.send({message_reaction_event: {id: id, clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, emoji_id: emoji_id, emoji: emoji, count: count, message_sender_id: message_sender_id, action: action_delete}});
|
1281
1333
|
return response.message_reaction_event
|
1282
1334
|
}
|
1283
1335
|
|
1284
|
-
async writeMessageTyping(clan_id: string, channel_id: string, mode: number)
|
1336
|
+
async writeMessageTyping(clan_id: string, channel_id: string, mode: number): Promise<MessageTypingEvent> {
|
1285
1337
|
const response = await this.send({message_typing_event: {clan_id: clan_id, channel_id: channel_id, mode:mode}});
|
1286
1338
|
return response.message_typing_event
|
1287
1339
|
}
|
1288
1340
|
|
1289
|
-
async writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string)
|
1341
|
+
async writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent> {
|
1290
1342
|
const response = await this.send({last_seen_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp}});
|
1291
1343
|
return response.last_seen_message_event
|
1292
1344
|
}
|
1293
1345
|
|
1294
|
-
async writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number)
|
1346
|
+
async writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent> {
|
1295
1347
|
const response = await this.send({last_pin_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp, operation: operation}});
|
1296
1348
|
return response.last_pin_message_event
|
1297
1349
|
}
|
1298
1350
|
|
1299
|
-
async writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string)
|
1351
|
+
async writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent> {
|
1300
1352
|
const response = await this.send({voice_joined_event: {clan_id: clanId, clan_name: clanName, id: id, participant: participant, voice_channel_id: voiceChannelId, voice_channel_label: voiceChannelLabel, last_screenshot: lastScreenshot}});
|
1301
1353
|
return response.voice_joined_event
|
1302
1354
|
}
|
1303
1355
|
|
1304
|
-
async writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string)
|
1356
|
+
async writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent> {
|
1305
1357
|
const response = await this.send({voice_leaved_event: {id: id, clan_id: clanId, voice_channel_id: voiceChannelId, voice_user_id: voiceUserId}});
|
1306
1358
|
return response.voice_leaved_event
|
1307
1359
|
}
|
1308
1360
|
|
1309
|
-
async writeCustomStatus(clan_id: string, status: string)
|
1361
|
+
async writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent> {
|
1310
1362
|
const response = await this.send({custom_status_event: {clan_id: clan_id, status: status}});
|
1311
1363
|
return response.custom_status_event
|
1312
1364
|
}
|
@@ -1316,17 +1368,17 @@ export class DefaultSocket implements Socket {
|
|
1316
1368
|
return response.clan_name_existed_event
|
1317
1369
|
}
|
1318
1370
|
|
1319
|
-
async listClanEmojiByClanId(clan_id: string): Promise<
|
1320
|
-
const response = await this.send({
|
1321
|
-
return response.
|
1371
|
+
async listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent> {
|
1372
|
+
const response = await this.send({emojis_listed_event: {clan_id: clan_id}});
|
1373
|
+
return response.emojis_listed_event
|
1322
1374
|
}
|
1323
1375
|
|
1324
|
-
async listClanStickersByClanId(clan_id: string): Promise<
|
1325
|
-
const response = await this.send({
|
1326
|
-
return response.
|
1376
|
+
async listClanStickersByClanId(clan_id: string): Promise<StrickerListedEvent> {
|
1377
|
+
const response = await this.send({sticker_listed_event: {clan_id: clan_id}});
|
1378
|
+
return response.sticker_listed_event
|
1327
1379
|
}
|
1328
1380
|
|
1329
|
-
private async pingPong()
|
1381
|
+
private async pingPong(): Promise<void> {
|
1330
1382
|
if (!this.adapter.isOpen()) {
|
1331
1383
|
return;
|
1332
1384
|
}
|