ncloudchat 1.0.23 → 1.0.31
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/LICENSE.md +1 -1
- package/deploy.sh +1 -1
- package/esm/CloudChat.d.ts +434 -10
- package/esm/CloudChat.js +975 -302
- package/esm/CloudChat.js.map +1 -1
- package/esm/CoreManager.d.ts +6 -0
- package/esm/CoreManager.js +13 -4
- package/esm/CoreManager.js.map +1 -1
- package/esm/Dispatcher.d.ts +16 -0
- package/esm/Dispatcher.js +19 -4
- package/esm/Dispatcher.js.map +1 -1
- package/esm/Network.d.ts +7 -0
- package/esm/Network.js +93 -0
- package/esm/Network.js.map +1 -0
- package/esm/Type.d.ts +43 -0
- package/esm/Type.js +16 -0
- package/esm/Type.js.map +1 -1
- package/esm/Util.d.ts +13 -0
- package/esm/Util.js +13 -0
- package/esm/Util.js.map +1 -1
- package/esm/graphql/channel.d.ts +13 -0
- package/esm/graphql/channel.js +16 -0
- package/esm/graphql/channel.js.map +1 -0
- package/esm/graphql/friend.d.ts +11 -0
- package/esm/graphql/friend.js +13 -0
- package/esm/graphql/friend.js.map +1 -0
- package/esm/graphql/invite.d.ts +7 -0
- package/esm/graphql/invite.js +8 -0
- package/esm/graphql/invite.js.map +1 -0
- package/esm/graphql/member.d.ts +11 -0
- package/esm/graphql/member.js +13 -0
- package/esm/graphql/member.js.map +1 -0
- package/esm/graphql/message.d.ts +11 -0
- package/esm/graphql/message.js +13 -0
- package/esm/graphql/message.js.map +1 -0
- package/esm/graphql/pin.d.ts +10 -0
- package/esm/graphql/pin.js +12 -0
- package/esm/graphql/pin.js.map +1 -0
- package/esm/graphql/project.d.ts +7 -0
- package/esm/graphql/project.js +8 -0
- package/esm/graphql/project.js.map +1 -0
- package/esm/graphql/subscription.d.ts +11 -0
- package/esm/graphql/subscription.js +13 -0
- package/esm/graphql/subscription.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/index.js.map +1 -1
- package/esm/logger.d.ts +9 -3
- package/esm/logger.js +6 -0
- package/esm/logger.js.map +1 -1
- package/esm/mutations/channel.d.ts +50 -0
- package/esm/mutations/channel.js +97 -187
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/friend.d.ts +38 -0
- package/esm/mutations/friend.js +57 -119
- package/esm/mutations/friend.js.map +1 -1
- package/esm/mutations/index.d.ts +5 -3
- package/esm/mutations/index.js +5 -3
- package/esm/mutations/index.js.map +1 -1
- package/esm/mutations/invite.d.ts +15 -0
- package/esm/mutations/invite.js +23 -32
- package/esm/mutations/invite.js.map +1 -1
- package/esm/mutations/member.d.ts +39 -2
- package/esm/mutations/member.js +64 -111
- package/esm/mutations/member.js.map +1 -1
- package/esm/mutations/message.d.ts +35 -0
- package/esm/mutations/message.js +66 -45
- package/esm/mutations/message.js.map +1 -1
- package/esm/mutations/pin.d.ts +28 -0
- package/esm/mutations/pin.js +88 -0
- package/esm/mutations/pin.js.map +1 -0
- package/esm/mutations/subscription.d.ts +33 -1
- package/esm/mutations/subscription.js +51 -93
- package/esm/mutations/subscription.js.map +1 -1
- package/esm/queries/channel.d.ts +24 -0
- package/esm/queries/channel.js +37 -79
- package/esm/queries/channel.js.map +1 -1
- package/esm/queries/friend.d.ts +16 -0
- package/esm/queries/friend.js +25 -40
- package/esm/queries/friend.js.map +1 -1
- package/esm/queries/index.d.ts +7 -0
- package/esm/queries/index.js +7 -0
- package/esm/queries/index.js.map +1 -1
- package/esm/queries/member.d.ts +16 -0
- package/esm/queries/member.js +25 -40
- package/esm/queries/member.js.map +1 -1
- package/esm/queries/memberblocks.d.ts +16 -0
- package/esm/queries/memberblocks.js +25 -40
- package/esm/queries/memberblocks.js.map +1 -1
- package/esm/queries/message.d.ts +33 -0
- package/esm/queries/message.js +50 -111
- package/esm/queries/message.js.map +1 -1
- package/esm/queries/pin.d.ts +28 -0
- package/esm/queries/pin.js +92 -0
- package/esm/queries/pin.js.map +1 -0
- package/esm/queries/project.d.ts +13 -0
- package/esm/queries/project.js +20 -32
- package/esm/queries/project.js.map +1 -1
- package/esm/queries/subscription.d.ts +25 -0
- package/esm/queries/subscription.js +39 -76
- package/esm/queries/subscription.js.map +1 -1
- package/lib/CloudChat.js +1211 -363
- package/lib/CoreManager.js +13 -3
- package/lib/Dispatcher.js +25 -9
- package/lib/Network.js +226 -0
- package/lib/Type.js +19 -0
- package/lib/Util.js +15 -1
- package/lib/graphql/channel.js +32 -0
- package/lib/graphql/friend.js +27 -0
- package/lib/graphql/invite.js +18 -0
- package/lib/graphql/member.js +27 -0
- package/lib/graphql/message.js +27 -0
- package/lib/graphql/pin.js +25 -0
- package/lib/graphql/project.js +18 -0
- package/lib/graphql/subscription.js +27 -0
- package/lib/index.js +2 -2
- package/lib/logger.js +6 -0
- package/lib/mutations/channel.js +105 -178
- package/lib/mutations/friend.js +62 -115
- package/lib/mutations/index.js +23 -3
- package/lib/mutations/invite.js +27 -33
- package/lib/mutations/member.js +73 -100
- package/lib/mutations/message.js +86 -48
- package/lib/mutations/pin.js +229 -0
- package/lib/mutations/subscription.js +56 -95
- package/lib/queries/channel.js +40 -84
- package/lib/queries/friend.js +29 -45
- package/lib/queries/index.js +24 -3
- package/lib/queries/member.js +29 -45
- package/lib/queries/memberblocks.js +28 -44
- package/lib/queries/message.js +56 -109
- package/lib/queries/pin.js +243 -0
- package/lib/queries/project.js +24 -41
- package/lib/queries/subscription.js +42 -78
- package/package.json +19 -45
- package/tsconfig.json +1 -0
- package//353/260/260/355/217/254/354/210/234/354/204/234.md +8 -0
- package/package copy.json +0 -74
package/esm/mutations/member.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
8
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
9
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,141 +40,88 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
40
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
|
-
import CoreManager from
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
import CoreManager from "../CoreManager";
|
|
44
|
+
import { fetchData } from "../Network";
|
|
45
|
+
import { loginQuery, createMemberBlockQuery, deleteMemberBlockQuery, } from "../graphql/member";
|
|
46
|
+
/**
|
|
47
|
+
* Login a user
|
|
48
|
+
*
|
|
49
|
+
* @async
|
|
50
|
+
* @function login
|
|
51
|
+
* @param {string} user_id - The id of a user loggin in.
|
|
52
|
+
* @param {string} name
|
|
53
|
+
* @param {string} profile
|
|
54
|
+
* @param {string} token
|
|
55
|
+
* @returns {Promise<any>}
|
|
56
|
+
*/
|
|
57
|
+
export var login = function (user_id, name, profile, token, customField) {
|
|
58
|
+
if (name === void 0) { name = ""; }
|
|
59
|
+
if (profile === void 0) { profile = ""; }
|
|
60
|
+
if (token === void 0) { token = ""; }
|
|
61
|
+
if (customField === void 0) { customField = ""; }
|
|
43
62
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var projectId, endpoint, mutation;
|
|
45
63
|
return __generator(this, function (_a) {
|
|
46
64
|
switch (_a.label) {
|
|
47
65
|
case 0:
|
|
48
66
|
CoreManager.set("TOKEN", token);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'X-PROJECT-ID': projectId,
|
|
57
|
-
'Content-Type': 'application/json',
|
|
58
|
-
'Accept': 'application/json'
|
|
59
|
-
},
|
|
60
|
-
body: JSON.stringify({
|
|
61
|
-
query: mutation,
|
|
62
|
-
variables: {
|
|
63
|
-
projectId: projectId,
|
|
64
|
-
userId: user_id,
|
|
65
|
-
name: name,
|
|
66
|
-
profile: profile,
|
|
67
|
-
token: token
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
.then(function (res) { return res.json(); })
|
|
72
|
-
.then(function (data) {
|
|
73
|
-
if (data.errors)
|
|
74
|
-
throw data.errors[0];
|
|
75
|
-
if (data.code)
|
|
76
|
-
throw data;
|
|
77
|
-
else if (data.data.login.token) {
|
|
78
|
-
return data.data.login.token;
|
|
79
|
-
}
|
|
80
|
-
else
|
|
81
|
-
return false;
|
|
67
|
+
return [4 /*yield*/, fetchData("login", loginQuery, {
|
|
68
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
69
|
+
userId: user_id,
|
|
70
|
+
name: name,
|
|
71
|
+
profile: profile,
|
|
72
|
+
token: token,
|
|
73
|
+
customField: customField
|
|
82
74
|
})];
|
|
83
75
|
case 1: return [2 /*return*/, _a.sent()];
|
|
84
76
|
}
|
|
85
77
|
});
|
|
86
78
|
});
|
|
87
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Create a member block followed by the getMemberBlockSchema.
|
|
82
|
+
* The member block is to used to ban a member.
|
|
83
|
+
*
|
|
84
|
+
* @async
|
|
85
|
+
* @function createMemberBlock
|
|
86
|
+
* @param {string} channelId - The id of a channel.
|
|
87
|
+
* @param {string} memberId - The id of a member.
|
|
88
|
+
* @param {string} options
|
|
89
|
+
* @returns {Promise<any>}
|
|
90
|
+
*/
|
|
88
91
|
export var createMemberBlock = function (channelId, memberId, options) {
|
|
89
92
|
if (options === void 0) { options = ""; }
|
|
90
93
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
-
var token, projectId, endpoint, mutation;
|
|
92
94
|
return __generator(this, function (_a) {
|
|
93
95
|
switch (_a.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
method: 'POST',
|
|
101
|
-
headers: {
|
|
102
|
-
'Authorization': 'Bearer ' + token,
|
|
103
|
-
'X-PROJECT-ID': projectId,
|
|
104
|
-
'Content-Type': 'application/json',
|
|
105
|
-
'Accept': 'application/json'
|
|
106
|
-
},
|
|
107
|
-
body: JSON.stringify({
|
|
108
|
-
query: mutation,
|
|
109
|
-
variables: {
|
|
110
|
-
projectId: projectId,
|
|
111
|
-
channelId: channelId,
|
|
112
|
-
memberId: memberId,
|
|
113
|
-
options: options
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
.then(function (res) { return res.json(); })
|
|
118
|
-
.then(function (data) {
|
|
119
|
-
if (data.errors)
|
|
120
|
-
throw data.errors[0];
|
|
121
|
-
if (data.code)
|
|
122
|
-
throw data;
|
|
123
|
-
else if (data.data.createMemberBlock) {
|
|
124
|
-
return data.data.createMemberBlock;
|
|
125
|
-
}
|
|
126
|
-
else
|
|
127
|
-
return false;
|
|
128
|
-
})];
|
|
96
|
+
case 0: return [4 /*yield*/, fetchData("createMemberBlock", createMemberBlockQuery, {
|
|
97
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
98
|
+
channelId: channelId,
|
|
99
|
+
memberId: memberId,
|
|
100
|
+
options: options
|
|
101
|
+
})];
|
|
129
102
|
case 1: return [2 /*return*/, _a.sent()];
|
|
130
103
|
}
|
|
131
104
|
});
|
|
132
105
|
});
|
|
133
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Delete a member block.
|
|
109
|
+
* This is used to unban a member from a channel.
|
|
110
|
+
*
|
|
111
|
+
* @async
|
|
112
|
+
* @function deleteMemberBlock
|
|
113
|
+
* @param {string} channelId - The id of a channel that the member is in.
|
|
114
|
+
* @param {string} memberId - The id of a member to be deleted.
|
|
115
|
+
* @returns {Promise<any>}
|
|
116
|
+
*/
|
|
134
117
|
export var deleteMemberBlock = function (channelId, memberId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
135
|
-
var token, projectId, endpoint, mutation;
|
|
136
118
|
return __generator(this, function (_a) {
|
|
137
119
|
switch (_a.label) {
|
|
138
|
-
case 0:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return [4 /*yield*/, fetch(endpoint, {
|
|
144
|
-
method: 'POST',
|
|
145
|
-
headers: {
|
|
146
|
-
'Authorization': 'Bearer ' + token,
|
|
147
|
-
'X-PROJECT-ID': projectId,
|
|
148
|
-
'Content-Type': 'application/json',
|
|
149
|
-
'Accept': 'application/json'
|
|
150
|
-
},
|
|
151
|
-
body: JSON.stringify({
|
|
152
|
-
query: mutation,
|
|
153
|
-
variables: {
|
|
154
|
-
projectId: projectId,
|
|
155
|
-
channelId: channelId,
|
|
156
|
-
memberId: memberId
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
.then(function (res) { return res.json(); })
|
|
161
|
-
.then(function (data) {
|
|
162
|
-
if (data.errors)
|
|
163
|
-
throw data.errors[0];
|
|
164
|
-
if (data.code)
|
|
165
|
-
throw data;
|
|
166
|
-
else if (data.data.deleteMemberBlock) {
|
|
167
|
-
return data.data.deleteMemberBlock;
|
|
168
|
-
}
|
|
169
|
-
else
|
|
170
|
-
return false;
|
|
171
|
-
})];
|
|
120
|
+
case 0: return [4 /*yield*/, fetchData("deleteMemberBlock", deleteMemberBlockQuery, {
|
|
121
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
122
|
+
channelId: channelId,
|
|
123
|
+
memberId: memberId
|
|
124
|
+
})];
|
|
172
125
|
case 1: return [2 /*return*/, _a.sent()];
|
|
173
126
|
}
|
|
174
127
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.js","sourceRoot":"","sources":["../../src/mutations/member.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"member.js","sourceRoot":"","sources":["../../src/mutations/member.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACH,UAAU,EACV,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,KAAK,GAAG,UACjB,OAAe,EACf,IAAiB,EACjB,OAAoB,EACpB,KAAkB,EAClB,WAAwB;IAHxB,qBAAA,EAAA,SAAiB;IACjB,wBAAA,EAAA,YAAoB;IACpB,sBAAA,EAAA,UAAkB;IAClB,4BAAA,EAAA,gBAAwB;;;;;oBAExB,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;oBACzB,qBAAM,SAAS,CAAC,OAAO,EAAC,UAAU,EAAE;4BACvC,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;4BACxC,MAAM,EAAE,OAAO;4BACf,IAAI,MAAA;4BACJ,OAAO,SAAA;4BACP,KAAK,OAAA;4BACL,WAAW,aAAA;yBACd,CAAC,EAAA;wBAPF,sBAAO,SAOL,EAAC;;;;CACN,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAC7B,SAAiB,EACjB,QAAgB,EAChB,OAAoB;IAApB,wBAAA,EAAA,YAAoB;;;;wBAEb,qBAAM,SAAS,CAAC,mBAAmB,EAAE,sBAAsB,EAAE;wBAChE,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;wBACxC,SAAS,WAAA;wBACT,QAAQ,UAAA;wBACR,OAAO,SAAA;qBACV,CAAC,EAAA;wBALF,sBAAO,SAKL,EAAC;;;;CACN,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAC7B,SAAiB,EACjB,QAAgB;;;oBAET,qBAAM,SAAS,CAAC,mBAAmB,EAAE,sBAAsB,EAAE;oBAChE,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;oBACxC,SAAS,WAAA;oBACT,QAAQ,UAAA;iBACX,CAAC,EAAA;oBAJF,sBAAO,SAIL,EAAC;;;KACN,CAAC"}
|
|
@@ -1,2 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Trasnslate a text block to the target language from the source language.
|
|
9
|
+
*
|
|
10
|
+
* @async
|
|
11
|
+
* @function translate
|
|
12
|
+
* @param {string} channelId - The id of a channel.
|
|
13
|
+
* @param {string} srcLang - The source language.
|
|
14
|
+
* @param {string} targetLang - The target language.
|
|
15
|
+
* @param {string} text - The text block to be translated.
|
|
16
|
+
* @returns {Promise<any>}
|
|
17
|
+
*/
|
|
1
18
|
export declare const translate: (channelId: string, srcLang: string, targetLang: string, text: string) => Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Upload a file to a channel. Only supports png, jpg, jpeg file types.
|
|
21
|
+
*
|
|
22
|
+
* @async
|
|
23
|
+
* @function upload
|
|
24
|
+
* @param {string} channelId - The id of a channel.
|
|
25
|
+
* @param {any} file - An image file.
|
|
26
|
+
* @returns {Promise<any>}
|
|
27
|
+
*/
|
|
2
28
|
export declare const upload: (channelId: string, file: any) => Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Send a Message
|
|
31
|
+
*
|
|
32
|
+
* @async
|
|
33
|
+
* @function translate
|
|
34
|
+
* @param {string} data - The id of a message.
|
|
35
|
+
* @returns {Promise<any>}
|
|
36
|
+
*/
|
|
37
|
+
export declare const message: (data: any) => Promise<any>;
|
package/esm/mutations/message.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
8
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
9
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,69 +40,64 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
40
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
|
-
import CoreManager from
|
|
43
|
+
import CoreManager from "../CoreManager";
|
|
44
|
+
import { fetchData } from "../Network";
|
|
45
|
+
import { translateQuery, messageQuery } from "../graphql/message";
|
|
46
|
+
/**
|
|
47
|
+
* Trasnslate a text block to the target language from the source language.
|
|
48
|
+
*
|
|
49
|
+
* @async
|
|
50
|
+
* @function translate
|
|
51
|
+
* @param {string} channelId - The id of a channel.
|
|
52
|
+
* @param {string} srcLang - The source language.
|
|
53
|
+
* @param {string} targetLang - The target language.
|
|
54
|
+
* @param {string} text - The text block to be translated.
|
|
55
|
+
* @returns {Promise<any>}
|
|
56
|
+
*/
|
|
38
57
|
export var translate = function (channelId, srcLang, targetLang, text) { return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
-
var token, projectId, endpoint, query;
|
|
40
58
|
return __generator(this, function (_a) {
|
|
41
59
|
switch (_a.label) {
|
|
42
|
-
case 0:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
headers: {
|
|
50
|
-
'Authorization': 'Bearer ' + token,
|
|
51
|
-
'X-PROJECT-ID': projectId,
|
|
52
|
-
'Content-Type': 'application/json',
|
|
53
|
-
'Accept': 'application/json'
|
|
54
|
-
},
|
|
55
|
-
body: JSON.stringify({
|
|
56
|
-
query: query,
|
|
57
|
-
variables: {
|
|
58
|
-
projectId: projectId,
|
|
59
|
-
channelId: channelId,
|
|
60
|
-
srcLang: srcLang,
|
|
61
|
-
targetLang: targetLang,
|
|
62
|
-
text: text
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
.then(function (res) { return res.json(); })
|
|
67
|
-
.then(function (data) {
|
|
68
|
-
if (data.errors)
|
|
69
|
-
throw data.errors[0];
|
|
70
|
-
if (data.code)
|
|
71
|
-
throw data;
|
|
72
|
-
return data;
|
|
73
|
-
})];
|
|
60
|
+
case 0: return [4 /*yield*/, fetchData("", translateQuery, {
|
|
61
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
62
|
+
channelId: channelId,
|
|
63
|
+
srcLang: srcLang,
|
|
64
|
+
targetLang: targetLang,
|
|
65
|
+
text: text
|
|
66
|
+
})];
|
|
74
67
|
case 1: return [2 /*return*/, _a.sent()];
|
|
75
68
|
}
|
|
76
69
|
});
|
|
77
70
|
}); };
|
|
71
|
+
/**
|
|
72
|
+
* Upload a file to a channel. Only supports png, jpg, jpeg file types.
|
|
73
|
+
*
|
|
74
|
+
* @async
|
|
75
|
+
* @function upload
|
|
76
|
+
* @param {string} channelId - The id of a channel.
|
|
77
|
+
* @param {any} file - An image file.
|
|
78
|
+
* @returns {Promise<any>}
|
|
79
|
+
*/
|
|
78
80
|
export var upload = function (channelId, file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var token,
|
|
81
|
+
var token, endpoint, form, result;
|
|
80
82
|
return __generator(this, function (_a) {
|
|
81
83
|
switch (_a.label) {
|
|
82
84
|
case 0:
|
|
83
85
|
token = CoreManager.get("TOKEN");
|
|
84
86
|
if (!token) {
|
|
85
|
-
console.error(
|
|
87
|
+
console.error("Token is not found");
|
|
86
88
|
return [2 /*return*/];
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
endpoint = CoreManager.get('SERVER_URL') + '/upload';
|
|
90
|
+
endpoint = CoreManager.get("SERVER_URL") + "/upload";
|
|
90
91
|
form = new FormData();
|
|
91
|
-
form.append(
|
|
92
|
-
form.append(
|
|
93
|
-
form.append(
|
|
92
|
+
form.append("file", file);
|
|
93
|
+
form.append("channelId", channelId);
|
|
94
|
+
form.append("upload", "1");
|
|
94
95
|
return [4 /*yield*/, fetch(endpoint, {
|
|
95
|
-
method:
|
|
96
|
+
method: "POST",
|
|
96
97
|
headers: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
Authorization: "Bearer " + token,
|
|
99
|
+
"X-PROJECT-ID": CoreManager.get("PROJECT_ID"),
|
|
100
|
+
projectid: CoreManager.get("PROJECT_ID")
|
|
100
101
|
},
|
|
101
102
|
body: form
|
|
102
103
|
}).then(function (res) { return res.json(); })];
|
|
@@ -106,4 +107,24 @@ export var upload = function (channelId, file) { return __awaiter(void 0, void 0
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
}); };
|
|
110
|
+
/**
|
|
111
|
+
* Send a Message
|
|
112
|
+
*
|
|
113
|
+
* @async
|
|
114
|
+
* @function translate
|
|
115
|
+
* @param {string} data - The id of a message.
|
|
116
|
+
* @returns {Promise<any>}
|
|
117
|
+
*/
|
|
118
|
+
export var message = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0: return [4 /*yield*/, fetchData("createChannelMessage", messageQuery, {
|
|
122
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
123
|
+
channelId: data.channelId,
|
|
124
|
+
content: data.message
|
|
125
|
+
})];
|
|
126
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}); };
|
|
109
130
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/mutations/message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/mutations/message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,SAAS,GAAG,UACrB,SAAiB,EACjB,OAAe,EACf,UAAkB,EAClB,IAAY;;;oBAEL,qBAAM,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE;oBACvC,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;oBACxC,SAAS,WAAA;oBACT,OAAO,SAAA;oBACP,UAAU,YAAA;oBACV,IAAI,MAAA;iBACP,CAAC,EAAA;oBANF,sBAAO,SAML,EAAC;;;KACN,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,IAAM,MAAM,GAAG,UAAO,SAAiB,EAAE,IAAS;;;;;gBAC/C,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACvC,IAAI,CAAC,KAAK,EAAE;oBACR,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;oBACpC,sBAAO;iBACV;gBACK,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;gBAEvD,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBACZ,qBAAM,KAAK,CAAC,QAAQ,EAAE;wBACjC,MAAM,EAAE,MAAM;wBACd,OAAO,EAAE;4BACL,aAAa,EAAE,SAAS,GAAG,KAAK;4BAChC,cAAc,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;4BAC7C,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;yBAC3C;wBACD,IAAI,EAAE,IAAI;qBACb,CAAC,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,EAAA;;gBARtB,MAAM,GAAG,SAQa;gBAC5B,sBAAO,MAAM,EAAC;;;KACjB,CAAC;AAGF;;;;;;;GAOG;AACF,MAAM,CAAC,IAAM,OAAO,GAAG,UAAO,IAAS;;;oBAE7B,qBAAM,SAAS,CAAC,sBAAsB,EAAE,YAAY,EAAE;oBACzD,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;oBACxC,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,OAAO,EAAE,IAAI,CAAC,OAAO;iBACxB,CAAC,EAAA;oBAJF,sBAAO,SAIL,EAAC;;;KACN,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { PinInput } from "../Type";
|
|
8
|
+
/**
|
|
9
|
+
* Create a new pin.
|
|
10
|
+
*
|
|
11
|
+
* @async
|
|
12
|
+
* @function createPin
|
|
13
|
+
* @param {string} channelId - An id of the channel.
|
|
14
|
+
* @param {PinInput} pin - Configuration options of the new pin.
|
|
15
|
+
* @returns {Promise<any>} The data of the newly created pin.
|
|
16
|
+
*/
|
|
17
|
+
export declare const createPin: (channelId: string, pin: PinInput) => Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Update pin options.
|
|
20
|
+
*
|
|
21
|
+
* @async
|
|
22
|
+
* @function updatePin
|
|
23
|
+
* @param {string} id - An id of the pin.
|
|
24
|
+
* @param {string} channelId - An id of the channel.
|
|
25
|
+
* @param {PinInput} pin - New options of the pin.
|
|
26
|
+
* @returns {Promise<any>} The data of the updated created pin.
|
|
27
|
+
*/
|
|
28
|
+
export declare const updatePin: (id: string, channelId: string, pin: PinInput) => Promise<any>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
17
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
20
|
+
function step(op) {
|
|
21
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
22
|
+
while (_) try {
|
|
23
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
24
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
25
|
+
switch (op[0]) {
|
|
26
|
+
case 0: case 1: t = op; break;
|
|
27
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
28
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
29
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
30
|
+
default:
|
|
31
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
32
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
33
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
34
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
35
|
+
if (t[2]) _.ops.pop();
|
|
36
|
+
_.trys.pop(); continue;
|
|
37
|
+
}
|
|
38
|
+
op = body.call(thisArg, _);
|
|
39
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
40
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
import CoreManager from "../CoreManager";
|
|
44
|
+
import { fetchData } from "../Network";
|
|
45
|
+
import { createPinQuery, updatePinQuery } from "../graphql/pin";
|
|
46
|
+
/**
|
|
47
|
+
* Create a new pin.
|
|
48
|
+
*
|
|
49
|
+
* @async
|
|
50
|
+
* @function createPin
|
|
51
|
+
* @param {string} channelId - An id of the channel.
|
|
52
|
+
* @param {PinInput} pin - Configuration options of the new pin.
|
|
53
|
+
* @returns {Promise<any>} The data of the newly created pin.
|
|
54
|
+
*/
|
|
55
|
+
export var createPin = function (channelId, pin) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
return [2 /*return*/, fetchData("createPin", createPinQuery, {
|
|
58
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
59
|
+
channelId: channelId,
|
|
60
|
+
pinned: pin.pinned,
|
|
61
|
+
pinnedAt: pin.pinnedAt,
|
|
62
|
+
expiredAt: pin.expiredAt
|
|
63
|
+
})];
|
|
64
|
+
});
|
|
65
|
+
}); };
|
|
66
|
+
/**
|
|
67
|
+
* Update pin options.
|
|
68
|
+
*
|
|
69
|
+
* @async
|
|
70
|
+
* @function updatePin
|
|
71
|
+
* @param {string} id - An id of the pin.
|
|
72
|
+
* @param {string} channelId - An id of the channel.
|
|
73
|
+
* @param {PinInput} pin - New options of the pin.
|
|
74
|
+
* @returns {Promise<any>} The data of the updated created pin.
|
|
75
|
+
*/
|
|
76
|
+
export var updatePin = function (id, channelId, pin) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
return [2 /*return*/, fetchData("updatePin", updatePinQuery, {
|
|
79
|
+
id: id,
|
|
80
|
+
projectId: CoreManager.get("PROJECT_ID"),
|
|
81
|
+
channelId: channelId,
|
|
82
|
+
pinned: pin.pinned,
|
|
83
|
+
pinnedAt: pin.pinnedAt,
|
|
84
|
+
expiredAt: pin.expiredAt
|
|
85
|
+
})];
|
|
86
|
+
});
|
|
87
|
+
}); };
|
|
88
|
+
//# sourceMappingURL=pin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.js","sourceRoot":"","sources":["../../src/mutations/pin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhE;;;;;;;;EAQE;AACH,MAAM,CAAC,IAAM,SAAS,GAAG,UAAO,SAAiB,EAAE,GAAa;;QAC5D,sBAAO,SAAS,CAAC,WAAW,EAAE,cAAc,EAAE;gBAC1C,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;gBACxC,SAAS,EAAE,SAAS;gBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,SAAS,EAAE,GAAG,CAAC,SAAS;aAC3B,CAAC,EAAC;;KACN,CAAC;AAEF;;;;;;;;;GASG;AACF,MAAM,CAAC,IAAM,SAAS,GAAG,UACtB,EAAU,EACV,SAAiB,EACjB,GAAa;;QAEb,sBAAO,SAAS,CAAC,WAAW,EAAE,cAAc,EAAE;gBAC1C,EAAE,EAAE,EAAE;gBACN,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;gBACxC,SAAS,EAAE,SAAS;gBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,SAAS,EAAE,GAAG,CAAC,SAAS;aAC3B,CAAC,EAAC;;KACN,CAAC"}
|
|
@@ -1,5 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
import type { MarkInput } from "../Type";
|
|
2
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Create a subscription.
|
|
10
|
+
*
|
|
11
|
+
* @async
|
|
12
|
+
* @function createSubscription
|
|
13
|
+
* @param {string} channelId - The id of a channel.
|
|
14
|
+
* @param {string} option
|
|
15
|
+
* @returns {Promise<any>}
|
|
16
|
+
*/
|
|
3
17
|
export declare const createSubscription: (channelId: string, option?: string) => Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a subscription.
|
|
20
|
+
*
|
|
21
|
+
* @async
|
|
22
|
+
* @function deleteSubscription
|
|
23
|
+
* @param {string} channelId - The id of a channel.
|
|
24
|
+
* @returns {Promise<any>}
|
|
25
|
+
*/
|
|
4
26
|
export declare const deleteSubscription: (channelId: string) => Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Update a subscription information, such as marking message read.
|
|
29
|
+
*
|
|
30
|
+
* @async
|
|
31
|
+
* @function updateSubscription
|
|
32
|
+
* @param {string} channelId - The id of a channel.
|
|
33
|
+
* @param {MarkInput} mark
|
|
34
|
+
* @param {string} option
|
|
35
|
+
* @returns {Promise<any>}
|
|
36
|
+
*/
|
|
5
37
|
export declare const updateSubscription: (channelId: string, mark: MarkInput, option?: string) => Promise<any>;
|