mezon-js 2.7.1 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -7
- package/api.gen.ts +0 -92
- package/client.ts +2 -28
- package/dist/api.gen.d.ts +0 -16
- package/dist/client.d.ts +1 -5
- package/dist/mezon-js.cjs.js +4 -84
- package/dist/mezon-js.esm.mjs +4 -84
- package/dist/socket.d.ts +1 -5
- package/package.json +4 -9
- package/socket.ts +3 -7
package/README.md
CHANGED
@@ -3,17 +3,17 @@ Mezon JavaScript client
|
|
3
3
|
|
4
4
|
> JavaScript client for Mezon server written in TypeScript. For browser and React Native projects.
|
5
5
|
|
6
|
-
[Mezon](https://github.com/heroiclabs/mezon) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much [more](https://
|
6
|
+
[Mezon](https://github.com/heroiclabs/mezon) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much [more](https://mezon.vn).
|
7
7
|
|
8
8
|
This client implements the full API and socket options with the server. It's written in TypeScript with minimal dependencies to be compatible with all modern browsers and React Native.
|
9
9
|
|
10
|
-
Full documentation is online - https://
|
10
|
+
Full documentation is online - https://mezon.vn/docs/javascript-client-guide
|
11
11
|
|
12
12
|
## Getting Started
|
13
13
|
|
14
14
|
You'll need to setup the server and database before you can connect with the client. The simplest way is to use Docker but have a look at the [server documentation](https://github.com/heroiclabs/mezon#getting-started) for other options.
|
15
15
|
|
16
|
-
1. Install and run the servers. Follow these [instructions](https://
|
16
|
+
1. Install and run the servers. Follow these [instructions](https://mezon.vn/docs/install-docker-quickstart).
|
17
17
|
|
18
18
|
2. Import the client into your project. It's [available on NPM](https://www.npmjs.com/package/@mezon/mezon-js) and can be also be added to a project with Bower or other package managers.
|
19
19
|
|
@@ -44,7 +44,7 @@ The client object has many methods to execute various features in the server or
|
|
44
44
|
|
45
45
|
### Authenticate
|
46
46
|
|
47
|
-
There's a variety of ways to [authenticate](https://
|
47
|
+
There's a variety of ways to [authenticate](https://mezon.vn/docs/authentication) with the server. Authentication can create a user if they don't already exist with those credentials. It's also easy to authenticate with a social profile from Google Play Games, Facebook, Game Center, etc.
|
48
48
|
|
49
49
|
```js
|
50
50
|
var email = "super@heroes.com";
|
@@ -171,7 +171,7 @@ try {
|
|
171
171
|
|
172
172
|
## Contribute
|
173
173
|
|
174
|
-
The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested in enhancing the code please open an issue to discuss the changes or drop in and discuss it in the [community forum](https://forum.
|
174
|
+
The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested in enhancing the code please open an issue to discuss the changes or drop in and discuss it in the [community forum](https://forum.mezon.vn).
|
175
175
|
|
176
176
|
### Source Builds
|
177
177
|
|
@@ -189,7 +189,7 @@ npm run build --workspace=@mezon/mezon-js
|
|
189
189
|
|
190
190
|
### Run Tests
|
191
191
|
|
192
|
-
To run tests you will need to run the server and database. Most tests are written as integration tests which execute against the server. A quick approach we use with our test workflow is to use the Docker compose file described in the [documentation](https://
|
192
|
+
To run tests you will need to run the server and database. Most tests are written as integration tests which execute against the server. A quick approach we use with our test workflow is to use the Docker compose file described in the [documentation](https://mezon.vn/docs/install-docker-quickstart).
|
193
193
|
|
194
194
|
Tests are run against each workspace bundle; if you have made source code changes, you should `npm run build --workspace=<workspace>` prior to running tests.
|
195
195
|
|
@@ -241,4 +241,4 @@ npm install && npm run docs
|
|
241
241
|
|
242
242
|
### License
|
243
243
|
|
244
|
-
This project is licensed under the [Apache-2 License](https://github.com/
|
244
|
+
This project is licensed under the [Apache-2 License](https://github.com/nccasia/mezon-js/blob/master/LICENSE).
|
package/api.gen.ts
CHANGED
@@ -146,14 +146,6 @@ export interface ApiAccountSteam {
|
|
146
146
|
vars?: Record<string, string>;
|
147
147
|
}
|
148
148
|
|
149
|
-
/** Add a role for channel. */
|
150
|
-
export interface ApiAddRoleChannelDescRequest {
|
151
|
-
//
|
152
|
-
channel_id?: string;
|
153
|
-
//
|
154
|
-
role_ids?: Array<string>;
|
155
|
-
}
|
156
|
-
|
157
149
|
/** */
|
158
150
|
export interface ApiCategoryDesc {
|
159
151
|
//
|
@@ -406,14 +398,6 @@ export interface ApiCreateRoleRequest {
|
|
406
398
|
title?: string;
|
407
399
|
}
|
408
400
|
|
409
|
-
/** Delete a role the user has access to. */
|
410
|
-
export interface ApiDeleteRoleRequest {
|
411
|
-
//
|
412
|
-
channel_id?: string;
|
413
|
-
//The id of a role.
|
414
|
-
role_id?: string;
|
415
|
-
}
|
416
|
-
|
417
401
|
/** Storage objects to delete. */
|
418
402
|
export interface ApiDeleteStorageObjectId {
|
419
403
|
//The collection which stores the object.
|
@@ -670,10 +654,6 @@ export interface ApiRole {
|
|
670
654
|
slug?: string;
|
671
655
|
//
|
672
656
|
title?: string;
|
673
|
-
//
|
674
|
-
role_channel_active?: string;
|
675
|
-
//
|
676
|
-
channel_id?: string;
|
677
657
|
}
|
678
658
|
|
679
659
|
/** A list of role description, usually a result of a list operation. */
|
@@ -3482,78 +3462,6 @@ export class MezonApi {
|
|
3482
3462
|
]);
|
3483
3463
|
}
|
3484
3464
|
|
3485
|
-
/** */
|
3486
|
-
addRolesChannelDesc(bearerToken: string,
|
3487
|
-
body:ApiAddRoleChannelDescRequest,
|
3488
|
-
options: any = {}): Promise<any> {
|
3489
|
-
|
3490
|
-
if (body === null || body === undefined) {
|
3491
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
3492
|
-
}
|
3493
|
-
const urlPath = "/v2/rolechannel/addrole";
|
3494
|
-
const queryParams = new Map<string, any>();
|
3495
|
-
|
3496
|
-
let bodyJson : string = "";
|
3497
|
-
bodyJson = JSON.stringify(body || {});
|
3498
|
-
|
3499
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3500
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3501
|
-
if (bearerToken) {
|
3502
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3503
|
-
}
|
3504
|
-
|
3505
|
-
return Promise.race([
|
3506
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
3507
|
-
if (response.status == 204) {
|
3508
|
-
return response;
|
3509
|
-
} else if (response.status >= 200 && response.status < 300) {
|
3510
|
-
return response.json();
|
3511
|
-
} else {
|
3512
|
-
throw response;
|
3513
|
-
}
|
3514
|
-
}),
|
3515
|
-
new Promise((_, reject) =>
|
3516
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3517
|
-
),
|
3518
|
-
]);
|
3519
|
-
}
|
3520
|
-
|
3521
|
-
/** Update a role when Delete a role by ID. */
|
3522
|
-
deleteRoleChannelDesc(bearerToken: string,
|
3523
|
-
body:ApiDeleteRoleRequest,
|
3524
|
-
options: any = {}): Promise<any> {
|
3525
|
-
|
3526
|
-
if (body === null || body === undefined) {
|
3527
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
3528
|
-
}
|
3529
|
-
const urlPath = "/v2/rolechannel/delete";
|
3530
|
-
const queryParams = new Map<string, any>();
|
3531
|
-
|
3532
|
-
let bodyJson : string = "";
|
3533
|
-
bodyJson = JSON.stringify(body || {});
|
3534
|
-
|
3535
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3536
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
3537
|
-
if (bearerToken) {
|
3538
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
3539
|
-
}
|
3540
|
-
|
3541
|
-
return Promise.race([
|
3542
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
3543
|
-
if (response.status == 204) {
|
3544
|
-
return response;
|
3545
|
-
} else if (response.status >= 200 && response.status < 300) {
|
3546
|
-
return response.json();
|
3547
|
-
} else {
|
3548
|
-
throw response;
|
3549
|
-
}
|
3550
|
-
}),
|
3551
|
-
new Promise((_, reject) =>
|
3552
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
3553
|
-
),
|
3554
|
-
]);
|
3555
|
-
}
|
3556
|
-
|
3557
3465
|
/** List user roles */
|
3558
3466
|
listRoles(bearerToken: string,
|
3559
3467
|
limit?:number,
|
package/client.ts
CHANGED
@@ -28,7 +28,6 @@ import {
|
|
28
28
|
ApiChannelDescList,
|
29
29
|
ApiChannelDescription,
|
30
30
|
ApiCreateChannelDescRequest,
|
31
|
-
ApiDeleteRoleRequest,
|
32
31
|
ApiClanDescList,
|
33
32
|
ApiCreateClanDescRequest,
|
34
33
|
ApiClanDesc,
|
@@ -39,7 +38,6 @@ import {
|
|
39
38
|
ApiRoleUserList,
|
40
39
|
ApiRole,
|
41
40
|
ApiCreateRoleRequest,
|
42
|
-
ApiAddRoleChannelDescRequest,
|
43
41
|
ApiCreateCategoryDescRequest,
|
44
42
|
ApiUpdateCategoryDescRequest,
|
45
43
|
ApiDeleteStorageObjectsRequest,
|
@@ -735,30 +733,6 @@ export class Client {
|
|
735
733
|
});
|
736
734
|
}
|
737
735
|
|
738
|
-
/** add role for channel. */
|
739
|
-
async addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean> {
|
740
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
741
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
742
|
-
await this.sessionRefresh(session);
|
743
|
-
}
|
744
|
-
|
745
|
-
return this.apiClient.addRolesChannelDesc(session.token, request).then((response: ApiRole) => {
|
746
|
-
return response !== undefined;
|
747
|
-
});
|
748
|
-
}
|
749
|
-
|
750
|
-
/** Update action role when delete role */
|
751
|
-
async deleteRoleChannelDesc(session: Session, request:ApiDeleteRoleRequest): Promise<boolean> {
|
752
|
-
if (this.autoRefreshSession && session.refresh_token &&
|
753
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
754
|
-
await this.sessionRefresh(session);
|
755
|
-
}
|
756
|
-
|
757
|
-
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response: any) => {
|
758
|
-
return response !== undefined;
|
759
|
-
});
|
760
|
-
}
|
761
|
-
|
762
736
|
/** A socket created with the client's configuration. */
|
763
737
|
createSocket(useSSL = false, verbose: boolean = false, adapter : WebSocketAdapter = new WebSocketAdapterText(), sendTimeoutMs : number = DefaultSocket.DefaultSendTimeoutMs): Socket {
|
764
738
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
@@ -1567,11 +1541,11 @@ export class Client {
|
|
1567
1541
|
}
|
1568
1542
|
|
1569
1543
|
if (session.created && session.expires_at! - session.created_at < 70) {
|
1570
|
-
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://
|
1544
|
+
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
1571
1545
|
}
|
1572
1546
|
|
1573
1547
|
if (session.created && session.refresh_expires_at! - session.created_at < 3700) {
|
1574
|
-
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://
|
1548
|
+
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
1575
1549
|
}
|
1576
1550
|
|
1577
1551
|
const apiSession = await this.apiClient.sessionRefresh(this.serverkey, "", {token: session.refresh_token, vars: vars});
|
package/dist/api.gen.d.ts
CHANGED
@@ -83,11 +83,6 @@ export interface ApiAccountSteam {
|
|
83
83
|
token?: string;
|
84
84
|
vars?: Record<string, string>;
|
85
85
|
}
|
86
|
-
/** Add a role for channel. */
|
87
|
-
export interface ApiAddRoleChannelDescRequest {
|
88
|
-
channel_id?: string;
|
89
|
-
role_ids?: Array<string>;
|
90
|
-
}
|
91
86
|
/** */
|
92
87
|
export interface ApiCategoryDesc {
|
93
88
|
category_id?: string;
|
@@ -231,11 +226,6 @@ export interface ApiCreateRoleRequest {
|
|
231
226
|
role_icon?: string;
|
232
227
|
title?: string;
|
233
228
|
}
|
234
|
-
/** Delete a role the user has access to. */
|
235
|
-
export interface ApiDeleteRoleRequest {
|
236
|
-
channel_id?: string;
|
237
|
-
role_id?: string;
|
238
|
-
}
|
239
229
|
/** Storage objects to delete. */
|
240
230
|
export interface ApiDeleteStorageObjectId {
|
241
231
|
collection?: string;
|
@@ -385,8 +375,6 @@ export interface ApiRole {
|
|
385
375
|
role_user_list?: ApiRoleUserList;
|
386
376
|
slug?: string;
|
387
377
|
title?: string;
|
388
|
-
role_channel_active?: string;
|
389
|
-
channel_id?: string;
|
390
378
|
}
|
391
379
|
/** A list of role description, usually a result of a list operation. */
|
392
380
|
export interface ApiRoleList {
|
@@ -687,10 +675,6 @@ export declare class MezonApi {
|
|
687
675
|
listNotifications(bearerToken: string, limit?: number, cacheableCursor?: string, options?: any): Promise<ApiNotificationList>;
|
688
676
|
/** */
|
689
677
|
GetPermissionOfUserInTheClan(bearerToken: string, clanId: string, options?: any): Promise<ApiPermissionList>;
|
690
|
-
/** */
|
691
|
-
addRolesChannelDesc(bearerToken: string, body: ApiAddRoleChannelDescRequest, options?: any): Promise<any>;
|
692
|
-
/** Update a role when Delete a role by ID. */
|
693
|
-
deleteRoleChannelDesc(bearerToken: string, body: ApiDeleteRoleRequest, options?: any): Promise<any>;
|
694
678
|
/** List user roles */
|
695
679
|
listRoles(bearerToken: string, limit?: number, state?: number, cursor?: string, clanId?: string, options?: any): Promise<ApiRoleList>;
|
696
680
|
/** Create a new role for clan. */
|
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,
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -389,10 +389,6 @@ export declare class Client {
|
|
389
389
|
createCategoryDesc(session: Session, request: ApiCreateCategoryDescRequest): Promise<ApiCategoryDesc>;
|
390
390
|
/** Create a new role for clan. */
|
391
391
|
createRole(session: Session, request: ApiCreateRoleRequest): Promise<ApiRole>;
|
392
|
-
/** add role for channel. */
|
393
|
-
addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean>;
|
394
|
-
/** Update action role when delete role */
|
395
|
-
deleteRoleChannelDesc(session: Session, request: ApiDeleteRoleRequest): Promise<boolean>;
|
396
392
|
/** A socket created with the client's configuration. */
|
397
393
|
createSocket(useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number): Socket;
|
398
394
|
/** Delete one or more users by ID or username. */
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -2643,64 +2643,6 @@ var MezonApi = class {
|
|
2643
2643
|
)
|
2644
2644
|
]);
|
2645
2645
|
}
|
2646
|
-
/** */
|
2647
|
-
addRolesChannelDesc(bearerToken, body, options = {}) {
|
2648
|
-
if (body === null || body === void 0) {
|
2649
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2650
|
-
}
|
2651
|
-
const urlPath = "/v2/rolechannel/addrole";
|
2652
|
-
const queryParams = /* @__PURE__ */ new Map();
|
2653
|
-
let bodyJson = "";
|
2654
|
-
bodyJson = JSON.stringify(body || {});
|
2655
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2656
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2657
|
-
if (bearerToken) {
|
2658
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2659
|
-
}
|
2660
|
-
return Promise.race([
|
2661
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2662
|
-
if (response.status == 204) {
|
2663
|
-
return response;
|
2664
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2665
|
-
return response.json();
|
2666
|
-
} else {
|
2667
|
-
throw response;
|
2668
|
-
}
|
2669
|
-
}),
|
2670
|
-
new Promise(
|
2671
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2672
|
-
)
|
2673
|
-
]);
|
2674
|
-
}
|
2675
|
-
/** Update a role when Delete a role by ID. */
|
2676
|
-
deleteRoleChannelDesc(bearerToken, body, options = {}) {
|
2677
|
-
if (body === null || body === void 0) {
|
2678
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2679
|
-
}
|
2680
|
-
const urlPath = "/v2/rolechannel/delete";
|
2681
|
-
const queryParams = /* @__PURE__ */ new Map();
|
2682
|
-
let bodyJson = "";
|
2683
|
-
bodyJson = JSON.stringify(body || {});
|
2684
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2685
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2686
|
-
if (bearerToken) {
|
2687
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2688
|
-
}
|
2689
|
-
return Promise.race([
|
2690
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2691
|
-
if (response.status == 204) {
|
2692
|
-
return response;
|
2693
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2694
|
-
return response.json();
|
2695
|
-
} else {
|
2696
|
-
throw response;
|
2697
|
-
}
|
2698
|
-
}),
|
2699
|
-
new Promise(
|
2700
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2701
|
-
)
|
2702
|
-
]);
|
2703
|
-
}
|
2704
2646
|
/** List user roles */
|
2705
2647
|
listRoles(bearerToken, limit, state, cursor, clanId, options = {}) {
|
2706
2648
|
const urlPath = "/v2/roles";
|
@@ -3864,9 +3806,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3864
3806
|
unfollowUsers(user_ids) {
|
3865
3807
|
return this.send({ status_unfollow: { user_ids } });
|
3866
3808
|
}
|
3867
|
-
updateChatMessage(channel_id,
|
3809
|
+
updateChatMessage(channel_id, message_id, content) {
|
3868
3810
|
return __async(this, null, function* () {
|
3869
|
-
const response = yield this.send({ channel_message_update: { channel_id,
|
3811
|
+
const response = yield this.send({ channel_message_update: { channel_id, message_id, content } });
|
3870
3812
|
return response.channel_message_ack;
|
3871
3813
|
});
|
3872
3814
|
}
|
@@ -4194,28 +4136,6 @@ var Client = class {
|
|
4194
4136
|
});
|
4195
4137
|
});
|
4196
4138
|
}
|
4197
|
-
/** add role for channel. */
|
4198
|
-
addRolesChannelDesc(session, request) {
|
4199
|
-
return __async(this, null, function* () {
|
4200
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4201
|
-
yield this.sessionRefresh(session);
|
4202
|
-
}
|
4203
|
-
return this.apiClient.addRolesChannelDesc(session.token, request).then((response) => {
|
4204
|
-
return response !== void 0;
|
4205
|
-
});
|
4206
|
-
});
|
4207
|
-
}
|
4208
|
-
/** Update action role when delete role */
|
4209
|
-
deleteRoleChannelDesc(session, request) {
|
4210
|
-
return __async(this, null, function* () {
|
4211
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4212
|
-
yield this.sessionRefresh(session);
|
4213
|
-
}
|
4214
|
-
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response) => {
|
4215
|
-
return response !== void 0;
|
4216
|
-
});
|
4217
|
-
});
|
4218
|
-
}
|
4219
4139
|
/** A socket created with the client's configuration. */
|
4220
4140
|
createSocket(useSSL = false, verbose = false, adapter = new WebSocketAdapterText(), sendTimeoutMs = DefaultSocket.DefaultSendTimeoutMs) {
|
4221
4141
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
@@ -4952,10 +4872,10 @@ var Client = class {
|
|
4952
4872
|
return session;
|
4953
4873
|
}
|
4954
4874
|
if (session.created && session.expires_at - session.created_at < 70) {
|
4955
|
-
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://
|
4875
|
+
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
4956
4876
|
}
|
4957
4877
|
if (session.created && session.refresh_expires_at - session.created_at < 3700) {
|
4958
|
-
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://
|
4878
|
+
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
4959
4879
|
}
|
4960
4880
|
const apiSession = yield this.apiClient.sessionRefresh(this.serverkey, "", { token: session.refresh_token, vars });
|
4961
4881
|
session.update(apiSession.token, apiSession.refresh_token);
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -2615,64 +2615,6 @@ var MezonApi = class {
|
|
2615
2615
|
)
|
2616
2616
|
]);
|
2617
2617
|
}
|
2618
|
-
/** */
|
2619
|
-
addRolesChannelDesc(bearerToken, body, options = {}) {
|
2620
|
-
if (body === null || body === void 0) {
|
2621
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2622
|
-
}
|
2623
|
-
const urlPath = "/v2/rolechannel/addrole";
|
2624
|
-
const queryParams = /* @__PURE__ */ new Map();
|
2625
|
-
let bodyJson = "";
|
2626
|
-
bodyJson = JSON.stringify(body || {});
|
2627
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2628
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2629
|
-
if (bearerToken) {
|
2630
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2631
|
-
}
|
2632
|
-
return Promise.race([
|
2633
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2634
|
-
if (response.status == 204) {
|
2635
|
-
return response;
|
2636
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2637
|
-
return response.json();
|
2638
|
-
} else {
|
2639
|
-
throw response;
|
2640
|
-
}
|
2641
|
-
}),
|
2642
|
-
new Promise(
|
2643
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2644
|
-
)
|
2645
|
-
]);
|
2646
|
-
}
|
2647
|
-
/** Update a role when Delete a role by ID. */
|
2648
|
-
deleteRoleChannelDesc(bearerToken, body, options = {}) {
|
2649
|
-
if (body === null || body === void 0) {
|
2650
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2651
|
-
}
|
2652
|
-
const urlPath = "/v2/rolechannel/delete";
|
2653
|
-
const queryParams = /* @__PURE__ */ new Map();
|
2654
|
-
let bodyJson = "";
|
2655
|
-
bodyJson = JSON.stringify(body || {});
|
2656
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2657
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2658
|
-
if (bearerToken) {
|
2659
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2660
|
-
}
|
2661
|
-
return Promise.race([
|
2662
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2663
|
-
if (response.status == 204) {
|
2664
|
-
return response;
|
2665
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2666
|
-
return response.json();
|
2667
|
-
} else {
|
2668
|
-
throw response;
|
2669
|
-
}
|
2670
|
-
}),
|
2671
|
-
new Promise(
|
2672
|
-
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2673
|
-
)
|
2674
|
-
]);
|
2675
|
-
}
|
2676
2618
|
/** List user roles */
|
2677
2619
|
listRoles(bearerToken, limit, state, cursor, clanId, options = {}) {
|
2678
2620
|
const urlPath = "/v2/roles";
|
@@ -3836,9 +3778,9 @@ var _DefaultSocket = class _DefaultSocket {
|
|
3836
3778
|
unfollowUsers(user_ids) {
|
3837
3779
|
return this.send({ status_unfollow: { user_ids } });
|
3838
3780
|
}
|
3839
|
-
updateChatMessage(channel_id,
|
3781
|
+
updateChatMessage(channel_id, message_id, content) {
|
3840
3782
|
return __async(this, null, function* () {
|
3841
|
-
const response = yield this.send({ channel_message_update: { channel_id,
|
3783
|
+
const response = yield this.send({ channel_message_update: { channel_id, message_id, content } });
|
3842
3784
|
return response.channel_message_ack;
|
3843
3785
|
});
|
3844
3786
|
}
|
@@ -4166,28 +4108,6 @@ var Client = class {
|
|
4166
4108
|
});
|
4167
4109
|
});
|
4168
4110
|
}
|
4169
|
-
/** add role for channel. */
|
4170
|
-
addRolesChannelDesc(session, request) {
|
4171
|
-
return __async(this, null, function* () {
|
4172
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4173
|
-
yield this.sessionRefresh(session);
|
4174
|
-
}
|
4175
|
-
return this.apiClient.addRolesChannelDesc(session.token, request).then((response) => {
|
4176
|
-
return response !== void 0;
|
4177
|
-
});
|
4178
|
-
});
|
4179
|
-
}
|
4180
|
-
/** Update action role when delete role */
|
4181
|
-
deleteRoleChannelDesc(session, request) {
|
4182
|
-
return __async(this, null, function* () {
|
4183
|
-
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4184
|
-
yield this.sessionRefresh(session);
|
4185
|
-
}
|
4186
|
-
return this.apiClient.deleteRoleChannelDesc(session.token, request).then((response) => {
|
4187
|
-
return response !== void 0;
|
4188
|
-
});
|
4189
|
-
});
|
4190
|
-
}
|
4191
4111
|
/** A socket created with the client's configuration. */
|
4192
4112
|
createSocket(useSSL = false, verbose = false, adapter = new WebSocketAdapterText(), sendTimeoutMs = DefaultSocket.DefaultSendTimeoutMs) {
|
4193
4113
|
return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
|
@@ -4924,10 +4844,10 @@ var Client = class {
|
|
4924
4844
|
return session;
|
4925
4845
|
}
|
4926
4846
|
if (session.created && session.expires_at - session.created_at < 70) {
|
4927
|
-
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://
|
4847
|
+
console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
4928
4848
|
}
|
4929
4849
|
if (session.created && session.refresh_expires_at - session.created_at < 3700) {
|
4930
|
-
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://
|
4850
|
+
console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session");
|
4931
4851
|
}
|
4932
4852
|
const apiSession = yield this.apiClient.sessionRefresh(this.serverkey, "", { token: session.refresh_token, vars });
|
4933
4853
|
session.update(apiSession.token, apiSession.refresh_token);
|
package/dist/socket.d.ts
CHANGED
@@ -215,14 +215,10 @@ interface ChannelMessageUpdate {
|
|
215
215
|
channel_message_update: {
|
216
216
|
/** The server-assigned channel ID. */
|
217
217
|
channel_id: string;
|
218
|
-
/** The server-assigned channel label. */
|
219
|
-
channel_label: string;
|
220
218
|
/** A unique ID for the chat message to be updated. */
|
221
219
|
message_id: string;
|
222
220
|
/** The content payload. */
|
223
221
|
content: any;
|
224
|
-
/** The mode payload. */
|
225
|
-
mode: number;
|
226
222
|
};
|
227
223
|
}
|
228
224
|
/** Remove a message previously sent to a realtime chat channel. */
|
@@ -659,7 +655,7 @@ export declare class DefaultSocket implements Socket {
|
|
659
655
|
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
|
660
656
|
sendPartyData(party_id: string, op_code: number, data: string | Uint8Array): Promise<void>;
|
661
657
|
unfollowUsers(user_ids: string[]): Promise<void>;
|
662
|
-
updateChatMessage(channel_id: string,
|
658
|
+
updateChatMessage(channel_id: string, message_id: string, content: any): Promise<ChannelMessageAck>;
|
663
659
|
updateStatus(status?: string): Promise<void>;
|
664
660
|
writeChatMessage(clan_id: string, channel_id: string, channel_label: string, mode: number, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>): Promise<ChannelMessageAck>;
|
665
661
|
writeMessageReaction(id: string, channel_id: string, channel_label: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mezon-js",
|
3
|
-
"version": "2.7.
|
3
|
+
"version": "2.7.2",
|
4
4
|
"scripts": {
|
5
5
|
"build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
|
6
6
|
},
|
@@ -26,17 +26,12 @@
|
|
26
26
|
],
|
27
27
|
"repository": {
|
28
28
|
"type": "git",
|
29
|
-
"url": "git+https://github.com/
|
29
|
+
"url": "git+https://github.com/nccasia/mezon-js.git"
|
30
30
|
},
|
31
|
-
"homepage": "https://
|
31
|
+
"homepage": "https://mezon.vn",
|
32
32
|
"bugs": {
|
33
|
-
"url": "https://github.com/
|
33
|
+
"url": "https://github.com/nccasia/mezon-js/issues"
|
34
34
|
},
|
35
|
-
"author": "Chris Molozian <chris@heroiclabs.com>",
|
36
|
-
"contributors": [
|
37
|
-
"Andrei Mihu <andrei@heroiclabs.com>",
|
38
|
-
"Mo Firouz <mo@heroiclabs.com>"
|
39
|
-
],
|
40
35
|
"license": "Apache-2.0",
|
41
36
|
"dependencies": {
|
42
37
|
"@scarf/scarf": "^1.1.1",
|
package/socket.ts
CHANGED
@@ -295,14 +295,10 @@ interface ChannelMessageUpdate {
|
|
295
295
|
channel_message_update: {
|
296
296
|
/** The server-assigned channel ID. */
|
297
297
|
channel_id: string,
|
298
|
-
/** The server-assigned channel label. */
|
299
|
-
channel_label: string,
|
300
298
|
/** A unique ID for the chat message to be updated. */
|
301
299
|
message_id: string,
|
302
300
|
/** The content payload. */
|
303
|
-
content: any
|
304
|
-
/** The mode payload. */
|
305
|
-
mode: number;
|
301
|
+
content: any;
|
306
302
|
};
|
307
303
|
}
|
308
304
|
|
@@ -1233,8 +1229,8 @@ export class DefaultSocket implements Socket {
|
|
1233
1229
|
return this.send({status_unfollow: {user_ids: user_ids}});
|
1234
1230
|
}
|
1235
1231
|
|
1236
|
-
async updateChatMessage(channel_id: string,
|
1237
|
-
const response = await this.send({channel_message_update: {channel_id: channel_id,
|
1232
|
+
async updateChatMessage(channel_id: string, message_id : string, content: any): Promise<ChannelMessageAck> {
|
1233
|
+
const response = await this.send({channel_message_update: {channel_id: channel_id, message_id: message_id, content: content}});
|
1238
1234
|
return response.channel_message_ack;
|
1239
1235
|
}
|
1240
1236
|
|