mezon-js 2.8.23 → 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 -197
- package/client.ts +2 -106
- package/dist/api.gen.d.ts +1 -11
- package/dist/api1.gen.d.ts +1157 -0
- package/dist/client.d.ts +1 -9
- package/dist/mezon-js.cjs.js +6 -246
- package/dist/mezon-js.esm.mjs +6 -246
- package/dist/socket.d.ts +4 -2
- package/package.json +1 -1
- package/socket.ts +5 -3
package/api.gen.ts
CHANGED
@@ -3901,7 +3901,7 @@ export class MezonApi {
|
|
3901
3901
|
}
|
3902
3902
|
|
3903
3903
|
/** Delete a emoji by ID. */
|
3904
|
-
|
3904
|
+
deleteClanEmojiById(bearerToken: string,
|
3905
3905
|
id:string,
|
3906
3906
|
clanId?:string,
|
3907
3907
|
options: any = {}): Promise<any> {
|
@@ -3914,7 +3914,8 @@ export class MezonApi {
|
|
3914
3914
|
const queryParams = new Map<string, any>();
|
3915
3915
|
queryParams.set("clan_id", clanId);
|
3916
3916
|
|
3917
|
-
|
3917
|
+
const body = {clan_id: clanId}
|
3918
|
+
let bodyJson = JSON.stringify(body || {});
|
3918
3919
|
|
3919
3920
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3920
3921
|
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
@@ -6010,201 +6011,6 @@ export class MezonApi {
|
|
6010
6011
|
]);
|
6011
6012
|
}
|
6012
6013
|
|
6013
|
-
/** Get storage objects. */
|
6014
|
-
readStorageObjects(bearerToken: string,
|
6015
|
-
body:ApiReadStorageObjectsRequest,
|
6016
|
-
options: any = {}): Promise<ApiStorageObjects> {
|
6017
|
-
|
6018
|
-
if (body === null || body === undefined) {
|
6019
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
6020
|
-
}
|
6021
|
-
const urlPath = "/v2/storage";
|
6022
|
-
const queryParams = new Map<string, any>();
|
6023
|
-
|
6024
|
-
let bodyJson : string = "";
|
6025
|
-
bodyJson = JSON.stringify(body || {});
|
6026
|
-
|
6027
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6028
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
6029
|
-
if (bearerToken) {
|
6030
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6031
|
-
}
|
6032
|
-
|
6033
|
-
return Promise.race([
|
6034
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
6035
|
-
if (response.status == 204) {
|
6036
|
-
return response;
|
6037
|
-
} else if (response.status >= 200 && response.status < 300) {
|
6038
|
-
return response.json();
|
6039
|
-
} else {
|
6040
|
-
throw response;
|
6041
|
-
}
|
6042
|
-
}),
|
6043
|
-
new Promise((_, reject) =>
|
6044
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6045
|
-
),
|
6046
|
-
]);
|
6047
|
-
}
|
6048
|
-
|
6049
|
-
/** Write objects into the storage engine. */
|
6050
|
-
writeStorageObjects(bearerToken: string,
|
6051
|
-
body:ApiWriteStorageObjectsRequest,
|
6052
|
-
options: any = {}): Promise<ApiStorageObjectAcks> {
|
6053
|
-
|
6054
|
-
if (body === null || body === undefined) {
|
6055
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
6056
|
-
}
|
6057
|
-
const urlPath = "/v2/storage";
|
6058
|
-
const queryParams = new Map<string, any>();
|
6059
|
-
|
6060
|
-
let bodyJson : string = "";
|
6061
|
-
bodyJson = JSON.stringify(body || {});
|
6062
|
-
|
6063
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6064
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
6065
|
-
if (bearerToken) {
|
6066
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6067
|
-
}
|
6068
|
-
|
6069
|
-
return Promise.race([
|
6070
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
6071
|
-
if (response.status == 204) {
|
6072
|
-
return response;
|
6073
|
-
} else if (response.status >= 200 && response.status < 300) {
|
6074
|
-
return response.json();
|
6075
|
-
} else {
|
6076
|
-
throw response;
|
6077
|
-
}
|
6078
|
-
}),
|
6079
|
-
new Promise((_, reject) =>
|
6080
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6081
|
-
),
|
6082
|
-
]);
|
6083
|
-
}
|
6084
|
-
|
6085
|
-
/** Delete one or more objects by ID or username. */
|
6086
|
-
deleteStorageObjects(bearerToken: string,
|
6087
|
-
body:ApiDeleteStorageObjectsRequest,
|
6088
|
-
options: any = {}): Promise<any> {
|
6089
|
-
|
6090
|
-
if (body === null || body === undefined) {
|
6091
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
6092
|
-
}
|
6093
|
-
const urlPath = "/v2/storage/delete";
|
6094
|
-
const queryParams = new Map<string, any>();
|
6095
|
-
|
6096
|
-
let bodyJson : string = "";
|
6097
|
-
bodyJson = JSON.stringify(body || {});
|
6098
|
-
|
6099
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6100
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
6101
|
-
if (bearerToken) {
|
6102
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6103
|
-
}
|
6104
|
-
|
6105
|
-
return Promise.race([
|
6106
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
6107
|
-
if (response.status == 204) {
|
6108
|
-
return response;
|
6109
|
-
} else if (response.status >= 200 && response.status < 300) {
|
6110
|
-
return response.json();
|
6111
|
-
} else {
|
6112
|
-
throw response;
|
6113
|
-
}
|
6114
|
-
}),
|
6115
|
-
new Promise((_, reject) =>
|
6116
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6117
|
-
),
|
6118
|
-
]);
|
6119
|
-
}
|
6120
|
-
|
6121
|
-
/** List publicly readable storage objects in a given collection. */
|
6122
|
-
listStorageObjects(bearerToken: string,
|
6123
|
-
collection:string,
|
6124
|
-
userId?:string,
|
6125
|
-
limit?:number,
|
6126
|
-
cursor?:string,
|
6127
|
-
options: any = {}): Promise<ApiStorageObjectList> {
|
6128
|
-
|
6129
|
-
if (collection === null || collection === undefined) {
|
6130
|
-
throw new Error("'collection' is a required parameter but is null or undefined.");
|
6131
|
-
}
|
6132
|
-
const urlPath = "/v2/storage/{collection}"
|
6133
|
-
.replace("{collection}", encodeURIComponent(String(collection)));
|
6134
|
-
const queryParams = new Map<string, any>();
|
6135
|
-
queryParams.set("user_id", userId);
|
6136
|
-
queryParams.set("limit", limit);
|
6137
|
-
queryParams.set("cursor", cursor);
|
6138
|
-
|
6139
|
-
let bodyJson : string = "";
|
6140
|
-
|
6141
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6142
|
-
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
6143
|
-
if (bearerToken) {
|
6144
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6145
|
-
}
|
6146
|
-
|
6147
|
-
return Promise.race([
|
6148
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
6149
|
-
if (response.status == 204) {
|
6150
|
-
return response;
|
6151
|
-
} else if (response.status >= 200 && response.status < 300) {
|
6152
|
-
return response.json();
|
6153
|
-
} else {
|
6154
|
-
throw response;
|
6155
|
-
}
|
6156
|
-
}),
|
6157
|
-
new Promise((_, reject) =>
|
6158
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6159
|
-
),
|
6160
|
-
]);
|
6161
|
-
}
|
6162
|
-
|
6163
|
-
/** List publicly readable storage objects in a given collection. */
|
6164
|
-
listStorageObjects2(bearerToken: string,
|
6165
|
-
collection:string,
|
6166
|
-
userId:string,
|
6167
|
-
limit?:number,
|
6168
|
-
cursor?:string,
|
6169
|
-
options: any = {}): Promise<ApiStorageObjectList> {
|
6170
|
-
|
6171
|
-
if (collection === null || collection === undefined) {
|
6172
|
-
throw new Error("'collection' is a required parameter but is null or undefined.");
|
6173
|
-
}
|
6174
|
-
if (userId === null || userId === undefined) {
|
6175
|
-
throw new Error("'userId' is a required parameter but is null or undefined.");
|
6176
|
-
}
|
6177
|
-
const urlPath = "/v2/storage/{collection}/{userId}"
|
6178
|
-
.replace("{collection}", encodeURIComponent(String(collection)))
|
6179
|
-
.replace("{userId}", encodeURIComponent(String(userId)));
|
6180
|
-
const queryParams = new Map<string, any>();
|
6181
|
-
queryParams.set("limit", limit);
|
6182
|
-
queryParams.set("cursor", cursor);
|
6183
|
-
|
6184
|
-
let bodyJson : string = "";
|
6185
|
-
|
6186
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6187
|
-
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
6188
|
-
if (bearerToken) {
|
6189
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6190
|
-
}
|
6191
|
-
|
6192
|
-
return Promise.race([
|
6193
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
6194
|
-
if (response.status == 204) {
|
6195
|
-
return response;
|
6196
|
-
} else if (response.status >= 200 && response.status < 300) {
|
6197
|
-
return response.json();
|
6198
|
-
} else {
|
6199
|
-
throw response;
|
6200
|
-
}
|
6201
|
-
}),
|
6202
|
-
new Promise((_, reject) =>
|
6203
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6204
|
-
),
|
6205
|
-
]);
|
6206
|
-
}
|
6207
|
-
|
6208
6014
|
/** Update fields in a given category. */
|
6209
6015
|
updateCategory(bearerToken: string,
|
6210
6016
|
body:ApiUpdateCategoryDescRequest,
|
package/client.ts
CHANGED
@@ -42,18 +42,12 @@ import {
|
|
42
42
|
ApiAddRoleChannelDescRequest,
|
43
43
|
ApiCreateCategoryDescRequest,
|
44
44
|
ApiUpdateCategoryDescRequest,
|
45
|
-
ApiDeleteStorageObjectsRequest,
|
46
45
|
ApiEvent,
|
47
46
|
ApiFriendList,
|
48
47
|
ApiNotificationList,
|
49
|
-
ApiReadStorageObjectsRequest,
|
50
48
|
ApiRpc,
|
51
|
-
ApiStorageObjectAcks,
|
52
|
-
ApiStorageObjectList,
|
53
|
-
ApiStorageObjects,
|
54
49
|
ApiUpdateAccountRequest,
|
55
50
|
ApiUsers,
|
56
|
-
ApiWriteStorageObjectsRequest,
|
57
51
|
MezonApi,
|
58
52
|
ApiSession,
|
59
53
|
ApiAccountApple,
|
@@ -885,18 +879,6 @@ export class Client {
|
|
885
879
|
});
|
886
880
|
}
|
887
881
|
|
888
|
-
/** Delete one or more storage objects */
|
889
|
-
async deleteStorageObjects(session: Session, request: ApiDeleteStorageObjectsRequest): Promise<boolean> {
|
890
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
891
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
892
|
-
await this.sessionRefresh(session);
|
893
|
-
}
|
894
|
-
|
895
|
-
return this.apiClient.deleteStorageObjects(session.token, request).then((response: any) => {
|
896
|
-
return Promise.resolve(response != undefined);
|
897
|
-
});
|
898
|
-
}
|
899
|
-
|
900
882
|
/** Delete a role by ID. */
|
901
883
|
async deleteRole(session: Session, roleId: string): Promise<boolean> {
|
902
884
|
if (this.autoRefreshSession && session.refresh_token &&
|
@@ -1654,71 +1636,6 @@ export class Client {
|
|
1654
1636
|
});
|
1655
1637
|
}
|
1656
1638
|
|
1657
|
-
/** List storage objects. */
|
1658
|
-
async listStorageObjects(session: Session, collection: string, userId?: string, limit?: number, cursor?: string): Promise<StorageObjectList> {
|
1659
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
1660
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
1661
|
-
await this.sessionRefresh(session);
|
1662
|
-
}
|
1663
|
-
|
1664
|
-
return this.apiClient.listStorageObjects(session.token, collection, userId, limit, cursor).then((response: ApiStorageObjectList) => {
|
1665
|
-
var result: StorageObjectList = {
|
1666
|
-
objects: [],
|
1667
|
-
cursor: response.cursor
|
1668
|
-
};
|
1669
|
-
|
1670
|
-
if (response.objects == null) {
|
1671
|
-
return Promise.resolve(result);
|
1672
|
-
}
|
1673
|
-
|
1674
|
-
response.objects!.forEach(o => {
|
1675
|
-
result.objects.push({
|
1676
|
-
collection: o.collection,
|
1677
|
-
key: o.key,
|
1678
|
-
permission_read: o.permission_read ? Number(o.permission_read) : 0,
|
1679
|
-
permission_write: o.permission_write ? Number(o.permission_write) : 0,
|
1680
|
-
value: o.value ? JSON.parse(o.value) : undefined,
|
1681
|
-
version: o.version,
|
1682
|
-
user_id: o.user_id,
|
1683
|
-
create_time: o.create_time,
|
1684
|
-
update_time: o.update_time
|
1685
|
-
})
|
1686
|
-
});
|
1687
|
-
return Promise.resolve(result);
|
1688
|
-
});
|
1689
|
-
}
|
1690
|
-
|
1691
|
-
/** Fetch storage objects. */
|
1692
|
-
async readStorageObjects(session: Session, request: ApiReadStorageObjectsRequest): Promise<StorageObjects> {
|
1693
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
1694
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
1695
|
-
await this.sessionRefresh(session);
|
1696
|
-
}
|
1697
|
-
|
1698
|
-
return this.apiClient.readStorageObjects(session.token, request).then((response: ApiStorageObjects) => {
|
1699
|
-
var result: StorageObjects = {objects: []};
|
1700
|
-
|
1701
|
-
if (response.objects == null) {
|
1702
|
-
return Promise.resolve(result);
|
1703
|
-
}
|
1704
|
-
|
1705
|
-
response.objects!.forEach(o => {
|
1706
|
-
result.objects.push({
|
1707
|
-
collection: o.collection,
|
1708
|
-
key: o.key,
|
1709
|
-
permission_read: o.permission_read ? Number(o.permission_read) : 0,
|
1710
|
-
permission_write: o.permission_write ? Number(o.permission_write) : 0,
|
1711
|
-
value: o.value ? JSON.parse(o.value) : undefined,
|
1712
|
-
version: o.version,
|
1713
|
-
user_id: o.user_id,
|
1714
|
-
create_time: o.create_time,
|
1715
|
-
update_time: o.update_time
|
1716
|
-
})
|
1717
|
-
});
|
1718
|
-
return Promise.resolve(result);
|
1719
|
-
});
|
1720
|
-
}
|
1721
|
-
|
1722
1639
|
/** Execute an RPC function on the server. */
|
1723
1640
|
async rpc(session: Session, basicAuthUsername: string,
|
1724
1641
|
basicAuthPassword: string, id: string, input: object): Promise<RpcResponse> {
|
@@ -2036,29 +1953,8 @@ export class Client {
|
|
2036
1953
|
});
|
2037
1954
|
}
|
2038
1955
|
|
2039
|
-
/** Write storage objects. */
|
2040
|
-
async writeStorageObjects(session: Session, objects: Array<WriteStorageObject>): Promise<ApiStorageObjectAcks> {
|
2041
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
2042
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
2043
|
-
await this.sessionRefresh(session);
|
2044
|
-
}
|
2045
|
-
|
2046
|
-
var request: ApiWriteStorageObjectsRequest = {objects: []};
|
2047
|
-
objects.forEach(o => {
|
2048
|
-
request.objects!.push({
|
2049
|
-
collection: o.collection,
|
2050
|
-
key: o.key,
|
2051
|
-
permission_read: o.permission_read,
|
2052
|
-
permission_write: o.permission_write,
|
2053
|
-
value: JSON.stringify(o.value),
|
2054
|
-
version: o.version
|
2055
|
-
})
|
2056
|
-
})
|
2057
|
-
|
2058
|
-
return this.apiClient.writeStorageObjects(session.token, request);
|
2059
|
-
}
|
2060
1956
|
/** Set default notification clan*/
|
2061
|
-
async setNotificationClan(session: Session, request: ApiSetDefaultNotificationRequest): Promise<boolean> {
|
1957
|
+
async setNotificationClan(session: Session, request: ApiSetDefaultNotificationRequest): Promise<boolean> {
|
2062
1958
|
if (this.autoRefreshSession && session.refresh_token &&
|
2063
1959
|
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
2064
1960
|
await this.sessionRefresh(session);
|
@@ -2311,7 +2207,7 @@ async deleteByIdClanEmoji(session: Session, id: string, clan_id: string) {
|
|
2311
2207
|
await this.sessionRefresh(session);
|
2312
2208
|
}
|
2313
2209
|
|
2314
|
-
return this.apiClient.
|
2210
|
+
return this.apiClient.deleteClanEmojiById(session.token, id, clan_id).then((response: any) => {
|
2315
2211
|
return response !== undefined;
|
2316
2212
|
});
|
2317
2213
|
}
|
package/dist/api.gen.d.ts
CHANGED
@@ -1067,7 +1067,7 @@ export declare class MezonApi {
|
|
1067
1067
|
/** Post clan Emoji /v2/emoji/create */
|
1068
1068
|
createClanEmoji(bearerToken: string, body: ApiClanEmojiCreateRequest, options?: any): Promise<any>;
|
1069
1069
|
/** Delete a emoji by ID. */
|
1070
|
-
|
1070
|
+
deleteClanEmojiById(bearerToken: string, id: string, clanId?: string, options?: any): Promise<any>;
|
1071
1071
|
/** Update ClanEmoj By id */
|
1072
1072
|
updateClanEmojiById(bearerToken: string, id: string, body: MezonUpdateClanEmojiByIdBody, options?: any): Promise<any>;
|
1073
1073
|
/** Search message from elasticsearch service. */
|
@@ -1182,16 +1182,6 @@ export declare class MezonApi {
|
|
1182
1182
|
deleteClanStickerById(bearerToken: string, id: string, clanId?: string, options?: any): Promise<any>;
|
1183
1183
|
/** Update a sticker by ID */
|
1184
1184
|
updateClanStickerById(bearerToken: string, id: string, body: MezonUpdateClanStickerByIdBody, options?: any): Promise<any>;
|
1185
|
-
/** Get storage objects. */
|
1186
|
-
readStorageObjects(bearerToken: string, body: ApiReadStorageObjectsRequest, options?: any): Promise<ApiStorageObjects>;
|
1187
|
-
/** Write objects into the storage engine. */
|
1188
|
-
writeStorageObjects(bearerToken: string, body: ApiWriteStorageObjectsRequest, options?: any): Promise<ApiStorageObjectAcks>;
|
1189
|
-
/** Delete one or more objects by ID or username. */
|
1190
|
-
deleteStorageObjects(bearerToken: string, body: ApiDeleteStorageObjectsRequest, options?: any): Promise<any>;
|
1191
|
-
/** List publicly readable storage objects in a given collection. */
|
1192
|
-
listStorageObjects(bearerToken: string, collection: string, userId?: string, limit?: number, cursor?: string, options?: any): Promise<ApiStorageObjectList>;
|
1193
|
-
/** List publicly readable storage objects in a given collection. */
|
1194
|
-
listStorageObjects2(bearerToken: string, collection: string, userId: string, limit?: number, cursor?: string, options?: any): Promise<ApiStorageObjectList>;
|
1195
1185
|
/** Update fields in a given category. */
|
1196
1186
|
updateCategory(bearerToken: string, body: ApiUpdateCategoryDescRequest, options?: any): Promise<any>;
|
1197
1187
|
/** Update channel private. */
|