@gudhub/core 1.0.41 → 1.0.45
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/GUDHUB/Auth/Auth.js +2 -0
- package/GUDHUB/Auth/Auth.test.js +49 -2
- package/GUDHUB/Managers/DocumentManager/DocumentManager.js +4 -4
- package/GUDHUB/Managers/FileManager/FileManager.js +58 -44
- package/GUDHUB/Managers/FileManager/file_manager.test.js +17 -0
- package/GUDHUB/config.js +2 -2
- package/GUDHUB/gudhub-https-service.js +10 -6
- package/GUDHUB/gudhub.js +9 -5
- package/fake_server/fake_java_server.js +8 -0
- package/package.json +1 -1
- package/umd/library.min.js +6 -6
- package/umd/library.min.js.map +1 -1
package/GUDHUB/Auth/Auth.js
CHANGED
|
@@ -128,10 +128,12 @@ export class Auth {
|
|
|
128
128
|
async updateUser(userData) {
|
|
129
129
|
const user = await this.updateUserApi(userData);
|
|
130
130
|
this.storage.updateUser(user);
|
|
131
|
+
return user;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
async updateAvatar(imageData) {
|
|
134
135
|
const user = await this.avatarUploadApi(imageData);
|
|
135
136
|
this.storage.updateUser(user);
|
|
137
|
+
return user;
|
|
136
138
|
}
|
|
137
139
|
}
|
package/GUDHUB/Auth/Auth.test.js
CHANGED
|
@@ -3,13 +3,60 @@ import {GudHub} from './../gudhub.js';
|
|
|
3
3
|
|
|
4
4
|
describe("AUTHORIZATION", async function() {
|
|
5
5
|
const auth_key = 'Z/lxMHLenEaQTvPjW5U6c3jBDwWFYZrh2F9Kxa3fbt8drvabS2u2lXQ2zI+SRmic';
|
|
6
|
-
const gudhub = new GudHub(auth_key);
|
|
7
6
|
|
|
8
7
|
it("GET USER BY ID / It Should return user with 'Vasya Pupkin' fullname", async function () {
|
|
9
|
-
|
|
8
|
+
const gudhub = new GudHub(auth_key);
|
|
10
9
|
var user = await gudhub.auth.getUserById("58");
|
|
11
10
|
|
|
12
11
|
user.fullname.should.equal('Vasya Pupkin');
|
|
13
12
|
})
|
|
14
13
|
|
|
14
|
+
it("Authentication with login and password", async function () {
|
|
15
|
+
const gudhub = new GudHub();
|
|
16
|
+
let credentials = {
|
|
17
|
+
username: 'test@gudhub.com',
|
|
18
|
+
password: 'gudhub'
|
|
19
|
+
}
|
|
20
|
+
var user = await gudhub.login(credentials);
|
|
21
|
+
|
|
22
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it("Signing up user", async function () {
|
|
26
|
+
const gudhub = new GudHub();
|
|
27
|
+
let credentials = {
|
|
28
|
+
fullname: "Vasya Pupkin",
|
|
29
|
+
password: "gudhub",
|
|
30
|
+
username: "test@gudhub.com"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var user = await gudhub.signup(credentials);
|
|
34
|
+
|
|
35
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("Update user", async function() {
|
|
39
|
+
const gudhub = new GudHub(auth_key);
|
|
40
|
+
|
|
41
|
+
const dataToUpdate = {
|
|
42
|
+
fullname: 'Vasya Pupkin'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const user = await gudhub.updateUser(dataToUpdate);
|
|
46
|
+
|
|
47
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("Update user avatar", async function() {
|
|
51
|
+
const gudhub = new GudHub(auth_key);
|
|
52
|
+
|
|
53
|
+
const dataToUpdate = {
|
|
54
|
+
avatar: '/9j/4AAQSkZJRgABAQAAAQA'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const user = await gudhub.updateUser(dataToUpdate);
|
|
58
|
+
|
|
59
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
60
|
+
})
|
|
61
|
+
|
|
15
62
|
});
|
|
@@ -14,7 +14,7 @@ export class DocumentManager {
|
|
|
14
14
|
this.req = req;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
createDocument(documentObject) {
|
|
18
18
|
return this.req.post({
|
|
19
19
|
url: "/api/new/document/insert-one",
|
|
20
20
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -22,7 +22,7 @@ export class DocumentManager {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
getDocument(documentAddress) {
|
|
26
26
|
return this.req.post({
|
|
27
27
|
url: "/api/new/document/find-one",
|
|
28
28
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -30,7 +30,7 @@ export class DocumentManager {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
getDocuments(documentsAddresses) {
|
|
34
34
|
return this.req.post({
|
|
35
35
|
url: "/api/new/document/find",
|
|
36
36
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -38,7 +38,7 @@ export class DocumentManager {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
deleteDocument(documentAddress) {
|
|
42
42
|
return this.req.post({
|
|
43
43
|
url: "/api/new/document/remove-one",
|
|
44
44
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -26,29 +26,11 @@ export class FileManager {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
async uploadFileFromStringApi(
|
|
30
|
-
source,
|
|
31
|
-
file_name,
|
|
32
|
-
app_id,
|
|
33
|
-
item_id,
|
|
34
|
-
extension,
|
|
35
|
-
format,
|
|
36
|
-
element_id
|
|
37
|
-
) {
|
|
29
|
+
async uploadFileFromStringApi(fileObject) {
|
|
38
30
|
try {
|
|
39
|
-
const fileObj = {
|
|
40
|
-
app_id,
|
|
41
|
-
item_id,
|
|
42
|
-
extension,
|
|
43
|
-
file_name,
|
|
44
|
-
format,
|
|
45
|
-
element_id,
|
|
46
|
-
source,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
31
|
const file = await this.req.post({
|
|
50
32
|
url: "/file/upload",
|
|
51
|
-
form: { file: JSON.stringify(
|
|
33
|
+
form: { file: JSON.stringify(fileObject) },
|
|
52
34
|
});
|
|
53
35
|
return file;
|
|
54
36
|
} catch (err) {
|
|
@@ -78,7 +60,7 @@ export class FileManager {
|
|
|
78
60
|
}
|
|
79
61
|
}
|
|
80
62
|
|
|
81
|
-
async
|
|
63
|
+
async duplicateFileApi(files) {
|
|
82
64
|
return this.req.post({
|
|
83
65
|
url: "/api/new/file/duplicate",
|
|
84
66
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -88,6 +70,31 @@ export class FileManager {
|
|
|
88
70
|
});
|
|
89
71
|
}
|
|
90
72
|
|
|
73
|
+
async downloadFileFromString(app_id, file_id) {
|
|
74
|
+
if(await this.isFileExists(app_id, file_id)) {
|
|
75
|
+
let file = await this.getFile(app_id, file_id);
|
|
76
|
+
let data = await this.req.get({
|
|
77
|
+
url: file.url,
|
|
78
|
+
externalResource: true
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
file,
|
|
82
|
+
data,
|
|
83
|
+
type: 'file'
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async duplicateFile(files) {
|
|
91
|
+
let duplicatedFiles = await this.duplicateFileApi(files);
|
|
92
|
+
duplicatedFiles.forEach(file => {
|
|
93
|
+
this.addFileToStorage(file.app_id, file);
|
|
94
|
+
});
|
|
95
|
+
return duplicatedFiles;
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
async deleteFileApi(id) {
|
|
92
99
|
try {
|
|
93
100
|
const file = await this.req.get({
|
|
@@ -119,9 +126,17 @@ export class FileManager {
|
|
|
119
126
|
deleteFileFromStorage(fileId, app_id) {
|
|
120
127
|
const app = this.storage.getApp(app_id);
|
|
121
128
|
if (app) {
|
|
122
|
-
|
|
129
|
+
let deletedFile;
|
|
130
|
+
app.file_list = app.file_list.filter((file) => {
|
|
131
|
+
if(file.file_id != fileId) {
|
|
132
|
+
return true;
|
|
133
|
+
} else {
|
|
134
|
+
deletedFile = file;
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
123
138
|
this.storage.updateApp(app);
|
|
124
|
-
this.pipeService.emit("gh_file_delete", { file_id: fileId },
|
|
139
|
+
this.pipeService.emit("gh_file_delete", { file_id: fileId }, deletedFile);
|
|
125
140
|
}
|
|
126
141
|
}
|
|
127
142
|
|
|
@@ -167,25 +182,9 @@ export class FileManager {
|
|
|
167
182
|
return file;
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
async uploadFileFromString(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
app_id,
|
|
174
|
-
item_id,
|
|
175
|
-
extension,
|
|
176
|
-
format,
|
|
177
|
-
element_id
|
|
178
|
-
) {
|
|
179
|
-
const file = await this.uploadFileFromStringApi(
|
|
180
|
-
source,
|
|
181
|
-
file_name,
|
|
182
|
-
app_id,
|
|
183
|
-
item_id,
|
|
184
|
-
extension,
|
|
185
|
-
format,
|
|
186
|
-
element_id
|
|
187
|
-
);
|
|
188
|
-
this.addFileToStorage(app_id, file);
|
|
185
|
+
async uploadFileFromString(fileObject) {
|
|
186
|
+
const file = await this.uploadFileFromStringApi(fileObject);
|
|
187
|
+
this.addFileToStorage(file.app_id, file);
|
|
189
188
|
return file;
|
|
190
189
|
}
|
|
191
190
|
|
|
@@ -201,8 +200,23 @@ export class FileManager {
|
|
|
201
200
|
return file;
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
deleteFile(
|
|
205
|
-
this.deleteFileApi(id);
|
|
203
|
+
async deleteFile(id, app_id) {
|
|
204
|
+
await this.deleteFileApi(id);
|
|
206
205
|
this.deleteFileFromStorage(id, app_id);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async isFileExists(app_id, file_id) {
|
|
210
|
+
let urlPattern = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
|
|
211
|
+
if(Boolean(file_id)) {
|
|
212
|
+
let file = await this.getFile(app_id, file_id);
|
|
213
|
+
if(Boolean(file)) {
|
|
214
|
+
return urlPattern.test(file.url);
|
|
215
|
+
} else {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
207
221
|
}
|
|
208
222
|
}
|
|
@@ -8,10 +8,27 @@ describe("FILE MANAGER", function () {
|
|
|
8
8
|
let file = await gudhub.getFile(16259,809199);
|
|
9
9
|
file.should.have.property("url","https://gudhub.com/userdata/16259/809199.jpg");
|
|
10
10
|
});
|
|
11
|
+
|
|
11
12
|
it("GET FILES URL's", async function () {
|
|
12
13
|
//-- checking if file exist
|
|
13
14
|
let files = await gudhub.getFiles(16259,[809199,811768]);
|
|
14
15
|
files[0].should.have.property("url","https://gudhub.com/userdata/16259/809199.jpg");
|
|
15
16
|
files[1].should.have.property("url", "https://gudhub.com/userdata/16259/811768.png");
|
|
16
17
|
});
|
|
18
|
+
|
|
19
|
+
it("CHECK IF FILE EXISTS", async function() {
|
|
20
|
+
let existingFile = await gudhub.fileManager.isFileExists(16259,809199);
|
|
21
|
+
let notExistingFile = await gudhub.fileManager.isFileExists(16259,300);
|
|
22
|
+
|
|
23
|
+
existingFile.should.equals(true);
|
|
24
|
+
notExistingFile.should.equals(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("DOWNLOAD FILE", async function() {
|
|
28
|
+
let file = await gudhub.downloadFileFromString(16259,811769);
|
|
29
|
+
|
|
30
|
+
file.file.url.should.equals('https://gudhub.com/userdata/16259/811769.html');
|
|
31
|
+
file.data.should.not.be.empty();
|
|
32
|
+
});
|
|
33
|
+
|
|
17
34
|
});
|
package/GUDHUB/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const server_url = "https://gudhub.com/GudHub";
|
|
1
|
+
//export const server_url = "https://gudhub.com/GudHub";
|
|
2
2
|
//export const server_url = "https://gudhub.com/GudHub_Temp";
|
|
3
3
|
//export const server_url = "https://integration.gudhub.com/GudHub_Test";
|
|
4
|
-
|
|
4
|
+
export const server_url = "http://localhost:9000";
|
|
5
5
|
export const wss_url = "wss://gudhub.com/GudHub/ws/app/";
|
|
6
6
|
|
|
7
7
|
// FOR TESTS
|
|
@@ -31,13 +31,17 @@ export class GudHubHttpsService {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const promise = new Promise((resolve, reject) => {
|
|
34
|
-
|
|
34
|
+
let url;
|
|
35
|
+
if(request.externalResource) {
|
|
36
|
+
url = request.url;
|
|
37
|
+
} else {
|
|
38
|
+
url = this.root + request.url;
|
|
39
|
+
url = `${url}${
|
|
40
|
+
/\?/.test(url) ? "&" : "?"
|
|
41
|
+
}token=${accessToken}${convertObjToUrlParams(request.params)}`;
|
|
42
|
+
}
|
|
35
43
|
|
|
36
|
-
axios.get(
|
|
37
|
-
`${url}${
|
|
38
|
-
/\?/.test(url) ? "&" : "?"
|
|
39
|
-
}token=${accessToken}${convertObjToUrlParams(request.params)}`
|
|
40
|
-
).then(function (response) {
|
|
44
|
+
axios.get(url).then(function (response) {
|
|
41
45
|
// handle success
|
|
42
46
|
resolve(response.data);
|
|
43
47
|
})
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -65,7 +65,7 @@ export class GudHub {
|
|
|
65
65
|
this.appProcessor,
|
|
66
66
|
this.itemProcessor
|
|
67
67
|
);
|
|
68
|
-
this.fileManager = new FileManager(this.storage, this.
|
|
68
|
+
this.fileManager = new FileManager(this.storage, this.pipeService, this.req, this.appProcessor);
|
|
69
69
|
this.documentManager = new DocumentManager(this.req);
|
|
70
70
|
|
|
71
71
|
if (options.initWebsocket) {
|
|
@@ -359,20 +359,24 @@ export class GudHub {
|
|
|
359
359
|
return this.fileManager.duplicateFile(files);
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
downloadFileFromString(app_id, file_id) {
|
|
363
|
+
return this.fileManager.downloadFileFromString(app_id, file_id);
|
|
364
|
+
}
|
|
365
|
+
|
|
362
366
|
createDocument(documentObject) {
|
|
363
|
-
return this.documentManager.
|
|
367
|
+
return this.documentManager.createDocument(documentObject);
|
|
364
368
|
}
|
|
365
369
|
|
|
366
370
|
getDocument(documentAddress) {
|
|
367
|
-
return this.documentManager.
|
|
371
|
+
return this.documentManager.getDocument(documentAddress);
|
|
368
372
|
}
|
|
369
373
|
|
|
370
374
|
getDocuments(documentAddress) {
|
|
371
|
-
return this.documentManager.
|
|
375
|
+
return this.documentManager.getDocuments(documentAddress);
|
|
372
376
|
}
|
|
373
377
|
|
|
374
378
|
deleteDocument(documentAddress) {
|
|
375
|
-
return this.documentManager.
|
|
379
|
+
return this.documentManager.deleteDocument(documentAddress);
|
|
376
380
|
}
|
|
377
381
|
|
|
378
382
|
login(data) {
|
|
@@ -38,10 +38,18 @@ export default function(app) {
|
|
|
38
38
|
res.status(200).send(data.token);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
app.post('/auth/singup', (req, res) => {
|
|
42
|
+
res.status(200).send(data.token);
|
|
43
|
+
});
|
|
44
|
+
|
|
41
45
|
app.get('/auth/getuserbyid', (req, res) => {
|
|
42
46
|
res.status(200).send(data.token);
|
|
43
47
|
});
|
|
44
48
|
|
|
49
|
+
app.post('/auth/updateuser', (req, res) => {
|
|
50
|
+
res.status(200).send(data.token);
|
|
51
|
+
});
|
|
52
|
+
|
|
45
53
|
|
|
46
54
|
app.post('/api/items/update', (req, res) => {
|
|
47
55
|
let result = null;
|
package/package.json
CHANGED
package/umd/library.min.js
CHANGED
|
@@ -70,7 +70,7 @@ module.exports=require("./lib/axios");
|
|
|
70
70
|
},{"./utils":"Qri1"}],"hIRQ":[function(require,module,exports) {
|
|
71
71
|
"use strict";var r=require("./stringify"),e=require("./parse"),s=require("./formats");module.exports={formats:s,parse:e,stringify:r};
|
|
72
72
|
},{"./stringify":"mwZo","./parse":"snX5","./formats":"XaX2"}],"hDvy":[function(require,module,exports) {
|
|
73
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHubHttpsService=void 0;var e=n(require("axios")),t=require("./utils.js"),r=n(require("qs"));function n(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r,n,s,o,i){try{var u=e[o](i),a=u.value}catch(c){return void r(c)}u.done?t(a):Promise.resolve(a).then(n,s)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){s(i,n,o,u,a,"next",e)}function a(e){s(i,n,o,u,a,"throw",e)}u(void 0)})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),e}var c=function(){function n(e){i(this,n),this.root=e,this.requestPromises=[]}return a(n,[{key:"init",value:function(e){this.getToken=e,this.promiseCollector(5e3)}},{key:"get",value:function(){var r=o(regeneratorRuntime.mark(function r(n){var s,o,i,u=this;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getToken();case 2:if(s=r.sent,o=this.getHashCode(n),!this.requestPromises[o]){r.next=6;break}return r.abrupt("return",this.requestPromises[o].promise);case 6:return i=new Promise(function(r,o){var i=u.root+n.url
|
|
73
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHubHttpsService=void 0;var e=n(require("axios")),t=require("./utils.js"),r=n(require("qs"));function n(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r,n,s,o,i){try{var u=e[o](i),a=u.value}catch(c){return void r(c)}u.done?t(a):Promise.resolve(a).then(n,s)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){s(i,n,o,u,a,"next",e)}function a(e){s(i,n,o,u,a,"throw",e)}u(void 0)})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),e}var c=function(){function n(e){i(this,n),this.root=e,this.requestPromises=[]}return a(n,[{key:"init",value:function(e){this.getToken=e,this.promiseCollector(5e3)}},{key:"get",value:function(){var r=o(regeneratorRuntime.mark(function r(n){var s,o,i,u=this;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getToken();case 2:if(s=r.sent,o=this.getHashCode(n),!this.requestPromises[o]){r.next=6;break}return r.abrupt("return",this.requestPromises[o].promise);case 6:return i=new Promise(function(r,o){var i;n.externalResource?i=n.url:(i=u.root+n.url,i="".concat(i).concat(/\?/.test(i)?"&":"?","token=").concat(s).concat((0,t.convertObjToUrlParams)(n.params))),e.default.get(i).then(function(e){r(e.data)}).catch(function(e){console.log("ERROR -> GUDHUB HTTP SERVICE -> GET :",e.message),console.log("Request message: ",n),o(e)})}),this.requestPromises[o]={promise:i,time:Date.now()},r.abrupt("return",i);case 9:case"end":return r.stop()}},r,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"simpleGet",value:function(){var t=o(regeneratorRuntime.mark(function t(r){var n,s,o=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.getHashCode(r),!this.requestPromises[n]){t.next=3;break}return t.abrupt("return",this.requestPromises[n].promise);case 3:return s=new Promise(function(t,n){var s=o.root+r.url;e.default.get(s).then(function(e){t(e.data)}).catch(function(e){console.log("ERROR -> GUDHUB HTTP SERVICE -> GET :",e.message),console.log("Request message: ",r),n(e)})}),this.requestPromises[n]={promise:s,time:Date.now()},t.abrupt("return",s);case 6:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"post",value:function(){var t=o(regeneratorRuntime.mark(function t(n){var s,o,i=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=this.getHashCode(n),t.next=3,this.getToken();case 3:if(n.form.token=t.sent,!this.requestPromises[s]){t.next=6;break}return t.abrupt("return",this.requestPromises[s].promise);case 6:return o=new Promise(function(t,s){e.default.post(i.root+n.url,r.default.stringify(n.form),{headers:n.headers||{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){t(e.data)}).catch(function(e){console.log("ERROR -> GUDHUB HTTP SERVICE -> POST :",e.message),console.log("Request message: ",n),s(e)})}),this.requestPromises[s]={promise:o,time:Date.now()},t.abrupt("return",o);case 9:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"simplePost",value:function(){var t=o(regeneratorRuntime.mark(function t(n){var s,o,i=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.getHashCode(n),!this.requestPromises[s]){t.next=3;break}return t.abrupt("return",this.requestPromises[s].promise);case 3:return o=new Promise(function(t,s){e.default.post(i.root+n.url,r.default.stringify(n.form),{headers:n.headers||{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){t(e.data)}).catch(function(e){console.log("ERROR -> GUDHUB HTTP SERVICE -> SIMPLE POST :",e.message),console.log("Request message: ",n),s(e)})}),this.requestPromises[s]={promise:o,time:Date.now()},t.abrupt("return",o);case 6:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"getHashCode",value:function(e){var t=0,n=r.default.stringify(e);if(0==n.length)return t;for(var s=0;s<n.length;s++){t=(t<<5)-t+n.charCodeAt(s),t&=t}return"h"+t}},{key:"promiseCollector",value:function(e){var t=this;setInterval(function(){Object.keys(t.requestPromises).forEach(function(r){Date.now()-t.requestPromises[r].time>e&&delete t.requestPromises[r]})},e)}}]),n}();exports.GudHubHttpsService=c;
|
|
74
74
|
},{"axios":"O4Aa","./utils.js":"EgeI","qs":"hIRQ"}],"Lc8J":[function(require,module,exports) {
|
|
75
75
|
"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(e)}function e(o){var e="";for(var t in o)o.hasOwnProperty(t)&&o[t]&&(e+="."+o[t]);return e?e.substring(1):"any"}function t(e,t,n){return null==e||"string"!=typeof e?(console.log("Listener type is \"undefined\" or not have actual 'type' for subscribe"),!1):null==t||"object"!==o(t)?(console.log("Listener destination is \"undefined\" or not have actual 'type' for subscribe"),!1):"function"==typeof n||(console.log("Listener is not a function for subscribe!"),!1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createId=e,exports.checkParams=t;
|
|
76
76
|
},{}],"E3xI":[function(require,module,exports) {
|
|
@@ -82,7 +82,7 @@ module.exports=require("./lib/axios");
|
|
|
82
82
|
},{}],"pHMV":[function(require,module,exports) {
|
|
83
83
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WebSocketApi=void 0;var e=t(require("ws"));function t(e){return e&&e.__esModule?e:{default:e}}function n(e,t,n,o,r,s,i){try{var a=e[s](i),c=a.value}catch(u){return void n(u)}a.done?t(c):Promise.resolve(c).then(o,r)}function o(e){return function(){var t=this,o=arguments;return new Promise(function(r,s){var i=e.apply(t,o);function a(e){n(i,r,s,a,c,"next",e)}function c(e){n(i,r,s,a,c,"throw",e)}a(void 0)})}}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var c=function(){function t(e,n){s(this,t),this.websocket=null,this.connected=!1,this.queue=[],this.url=e,this.auth=n,this.heartBeatTimeStemp=1e13,this.ALLOWED_HEART_BEAT_DELEY=12e3,this.firstHeartBeat=!0,this.reload=!0,this.isBrowser=!["undefined"==typeof window?"undefined":r(window),"undefined"==typeof document?"undefined":r(document)].includes("undefined")}return a(t,[{key:"addSubscription",value:function(){var e=o(regeneratorRuntime.mark(function e(t){var n,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auth.getToken();case 2:n=e.sent,o="token=".concat(n,"/~/app_id=").concat(t),this.connected&&this.websocket.send(o),this.queue.push(t);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"onOpen",value:function(){var e=o(regeneratorRuntime.mark(function e(){var t,n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.reload=!0,console.log("websocket opened"),this.connected=!0,e.next=5,this.auth.getToken();case 5:t=e.sent,this.queue.forEach(function(e){var o="token=".concat(t,"/~/app_id=").concat(e);n.websocket.send(o)});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"onError",value:function(e){console.log("websocket error: ",e),this.websocket.close()}},{key:"onClose",value:function(){console.log("websocket close"),this.connected=!1,this.initWebSocket()}},{key:"onMessage",value:function(){var e=o(regeneratorRuntime.mark(function e(t){var n,o,r,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.isBrowser?t.data:t).match(/HeartBeat/)){e.next=10;break}if(o=(new Date).getTime()-this.heartBeatTimeStemp,!(this.ALLOWED_HEART_BEAT_DELEY<o)){e.next=8;break}return e.next=6,this.onConnectionLost();case 6:e.next=10;break;case 8:this.websocket.send("HeartBeat"),this.heartBeatTimeStemp=(new Date).getTime();case 10:if(this.firstHeartBeat&&(this.connectionChecker(),this.firstHeartBeat=!1),!n.match(/[{}]/)){e.next=17;break}return r=JSON.parse(n),e.next=15,this.auth.getToken();case 15:s=e.sent,r.token!=s&&this.onMassageHandler(r);case 17:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"initWebSocket",value:function(t,n){this.onMassageHandler=t,this.refreshAppsHandler=n,this.isBrowser?(this.websocket=new WebSocket(this.url),this.websocket.onopen=this.onOpen.bind(this),this.websocket.onerror=this.onError.bind(this),this.websocket.onclose=this.onClose.bind(this),this.websocket.onmessage=this.onMessage.bind(this)):(this.websocket=new e.default(this.url),this.websocket.on("open",this.onOpen),this.websocket.on("error",this.onError),this.websocket.on("close",this.onClose),this.websocket.on("message",this.onMessage)),console.log("websocket initialized")}},{key:"connectionChecker",value:function(){var e=this;setInterval(o(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=(new Date).getTime()-e.heartBeatTimeStemp,!(e.ALLOWED_HEART_BEAT_DELEY<n)){t.next=4;break}return t.next=4,e.onConnectionLost();case 4:case"end":return t.stop()}},t)})),1e3)}},{key:"onConnectionLost",value:function(){var e=o(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.auth.getVersion();case 3:this.reload&&(this.reload=!1,console.log("Connected"),this.heartBeatTimeStemp=1e13,this.websocket.close(),this.refreshAppsHandler(this.queue)),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.log(e.t0);case 9:case"end":return e.stop()}},e,this,[[0,6]])}));return function(){return e.apply(this,arguments)}}()}]),t}();exports.WebSocketApi=c;
|
|
84
84
|
},{"ws":"p58b"}],"TPH7":[function(require,module,exports) {
|
|
85
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.port=exports.wss_url=exports.server_url=void 0;var r="
|
|
85
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.port=exports.wss_url=exports.server_url=void 0;var r="http://localhost:9000";exports.server_url=r;var e="wss://gudhub.com/GudHub/ws/app/";exports.wss_url=e;var s=9e3;exports.port=s;
|
|
86
86
|
},{}],"DvAj":[function(require,module,exports) {
|
|
87
87
|
"use strict";function e(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=t(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var a=0,u=function(){};return{s:u,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(c)throw o}}}}function t(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t,r,n,a,u,o){try{var i=e[u](o),c=i.value}catch(l){return void r(l)}i.done?t(c):Promise.resolve(c).then(n,a)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(a,u){var o=e.apply(t,r);function i(e){n(o,a,u,i,c,"next",e)}function c(e){n(o,a,u,i,c,"throw",e)}i(void 0)})}}function u(e,t,r,n,a,u){return o.apply(this,arguments)}function o(){return(o=a(regeneratorRuntime.mark(function t(r,n,a,u,o,i){var c,l,f,s,p,v,h,b,d,y,g=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(y=function(e){return new Promise(function(t){i.on("gh_value_get",e,function r(n,a){i.destroy("gh_value_get",e,r),t(a)}).emit("gh_value_get",{},e)})},c=g.length>6&&void 0!==g[6]?g[6]:[],l=[],f={variableMethodcurrent_app:function(){return[a]},variableMethodelement_app:function(){return[n]},variableMethodcurrent_item:function(){return["".concat(a,".").concat(u)]},variableMethoduser_id:function(){return[o.getUser().user_id]},variableMethoduser_email:function(e){return[o.getUser().username]},variableMethodtoday:function(e){var t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1);return[r.valueOf().toString()+":"+n.valueOf().toString()]},variableMethodvariable:function(){return c}},!r){t.next=40;break}s=e(r),t.prev=6,s.s();case 8:if((p=s.n()).done){t.next=32;break}if(!(v=p.value)){t.next=29;break}t.t0=v.input_type,t.next="variable"===t.t0?14:"field"===t.t0?19:25;break;case 14:return h=v.input_type+"Method"+v.input_value,b=f[h],v.valuesArray="function"==typeof b?b():f.variableMethodvariable(),l.push(v),t.abrupt("break",27);case 19:return t.next=21,y({app_id:a,item_id:u,field_id:v.input_value});case 21:return null!=(d=t.sent)&&v.valuesArray.push(d),l.push(v),t.abrupt("break",27);case 25:return l.push(v),t.abrupt("break",27);case 27:t.next=30;break;case 29:l.push(v);case 30:t.next=8;break;case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(6),s.e(t.t1);case 37:return t.prev=37,s.f(),t.finish(37);case 40:return t.abrupt("return",l);case 41:case"end":return t.stop()}},t,null,[[6,34,37,40]])}))).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.filterPreparation=u;
|
|
88
88
|
},{}],"jqRt":[function(require,module,exports) {
|
|
@@ -135,7 +135,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
|
|
|
135
135
|
},{}],"mWlG":[function(require,module,exports) {
|
|
136
136
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=v(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),i=require("./filter/group.js"),u=require("./filter/utils.js"),o=v(require("./populate_items/populate_items.js")),s=require("./get_date/get_date.js"),a=require("./merge_objects/merge_objects.js"),l=require("./merge_chunks/merge_chunks.js"),c=require("./interpretation/interpretation.js"),f=require("./nested_list/nested_list.js"),p=require("./compare_items_lists_worker/compare_items_lists.worker.js"),m=require("./json_constructor/json_constructor.js");function v(e){return e&&e.__esModule?e:{default:e}}function h(e){return _(e)||y(e)||d(e)||g()}function g(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(e,t):void 0}}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _(e){if(Array.isArray(e))return j(e)}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function k(e,t,r,n,i,u,o){try{var s=e[u](o),a=s.value}catch(l){return void r(l)}s.done?t(a):Promise.resolve(a).then(n,i)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var u=e.apply(t,r);function o(e){k(u,n,i,o,s,"next",e)}function s(e){k(u,n,i,o,s,"throw",e)}o(void 0)})}}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function q(e,t,r){return t&&I(e.prototype,t),r&&I(e,r),e}var A=function(){function v(e){w(this,v),this.gudhub=e}return q(v,[{key:"prefilter",value:function(t,r,n,i){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,i,this.gudhub.storage,this.gudhub.pipeService,u)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,i.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=b(regeneratorRuntime.mark(function e(){var t,r,n,i,o,s,a,l,c,f,p,m=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=m.length>0&&void 0!==m[0]?m[0]:[],r=m.length>1&&void 0!==m[1]?m[1]:[],n=m.length>2?m[2]:void 0,i=m.length>3?m[3]:void 0,o=m.length>4?m[4]:void 0,s=m.length>5&&void 0!==m[5]?m[5]:"",a=m.length>6?m[6]:void 0,l=m.length>7?m[7]:void 0,e.next=10,this.prefilter(r,n,i,o);case 10:return c=e.sent,f=this.filter(t,[].concat(h(r),h(c))),p=this.group(s,f),e.abrupt("return",p.filter(function(e){return!a||1===(0,u.searchValue)([e],a).length}).filter(function(e){return!l||1===(0,u.searchValue)([e],l).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,s.getDate)(e)}},{key:"populateItems",value:function(e,t,r){return(0,o.default)(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return(0,c.getInterpretedValue)(this.gudhub,e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,s.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,i,u,o){return(0,n.populateWithItemRef)(e,t,r,i,u,o)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,a.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,i){return(0,f.makeNestedList)(e,t,r,n,i)}},{key:"mergeChunks",value:function(e){return(0,l.mergeChunks)(e)}},{key:"jsonConstructor",value:function(e,t,r){return(0,m.compiler)(e,t,this,r)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,p.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}}]),v}();exports.Utils=A;
|
|
137
137
|
},{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./interpretation/interpretation.js":"pMyP","./nested_list/nested_list.js":"S7Iy","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW"}],"rK64":[function(require,module,exports) {
|
|
138
|
-
"use strict";function e(e,t,
|
|
138
|
+
"use strict";function e(e,r,t,n,u,a,s){try{var i=e[a](s),o=i.value}catch(c){return void t(c)}i.done?r(o):Promise.resolve(o).then(n,u)}function r(r){return function(){var t=this,n=arguments;return new Promise(function(u,a){var s=r.apply(t,n);function i(r){e(s,u,a,i,o,"next",r)}function o(r){e(s,u,a,i,o,"throw",r)}i(void 0)})}}function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var a=function(){function e(r,n){t(this,e),this.req=r,this.storage=n}return u(e,[{key:"login",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.username,t=e.password;return this.req.simplePost({url:"/auth/login",form:{username:r,password:t}})}},{key:"logout",value:function(e){return this.req.post({url:"/auth/logout",form:{token:e}})}},{key:"signup",value:function(e){return this.req.simplePost({url:"/auth/singup",form:{user:JSON.stringify(e)}})}},{key:"getUsersList",value:function(e){return this.req.get({url:"/auth/userlist",params:{keyword:e}})}},{key:"updateUserApi",value:function(e){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(e)}})}},{key:"updateToken",value:function(e){return this.req.simplePost({url:"/auth/login",form:{auth_key:e}})}},{key:"avatarUploadApi",value:function(e){return this.req.post({url:"/auth/avatar-upload",form:{image:e}})}},{key:"getUserByIdApi",value:function(e){return this.req.get({url:"/auth/getuserbyid",params:{id:e}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(e){return this.storage.getUsersList().find(function(r){return r.user_id==e})}},{key:"saveUserToStorage",value:function(e){var r=this.storage.getUsersList(),t=r.find(function(r){return r.user_id==e.user_id});return t||(r.push(e),e)}},{key:"getUserById",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getUserFromStorage(r)){e.next=9;break}return e.next=4,this.getUserByIdApi(r);case 4:if(n=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:(t=this.getUserFromStorage(r))||(this.saveUserToStorage(n),t=n);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"getToken",value:function(){var e=r(regeneratorRuntime.mark(function e(){var r,t,n,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=new Date(this.storage.getUser().expirydate),t=new Date,n=this.storage.getUser().accesstoken,!(r<t)&&n){e.next=9;break}return e.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:u=e.sent,this.storage.updateUser(u),n=u.accesstoken;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateUser",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateUserApi(r);case 2:return t=e.sent,this.storage.updateUser(t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.avatarUploadApi(r);case 2:return t=e.sent,this.storage.updateUser(t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()}]),e}();exports.Auth=a;
|
|
139
139
|
},{}],"UV2u":[function(require,module,exports) {
|
|
140
140
|
"use strict";function e(o){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_WEB=void 0;var o=!["undefined"==typeof window?"undefined":e(window),"undefined"==typeof document?"undefined":e(document)].includes("undefined");exports.IS_WEB=o;
|
|
141
141
|
},{}],"I3sf":[function(require,module,exports) {
|
|
@@ -147,15 +147,15 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
|
|
|
147
147
|
},{}],"WIY5":[function(require,module,exports) {
|
|
148
148
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"AppProcessor",{enumerable:!0,get:function(){return e.AppProcessor}}),Object.defineProperty(exports,"ItemProcessor",{enumerable:!0,get:function(){return r.ItemProcessor}}),Object.defineProperty(exports,"FieldProcessor",{enumerable:!0,get:function(){return o.FieldProcessor}});var e=require("./AppProcessor/AppProcessor.js"),r=require("./ItemProcessor/ItemProcessor.js"),o=require("./FieldProcessor/FieldProcessor.js");
|
|
149
149
|
},{"./AppProcessor/AppProcessor.js":"I3sf","./ItemProcessor/ItemProcessor.js":"EQyW","./FieldProcessor/FieldProcessor.js":"eGYU"}],"gVik":[function(require,module,exports) {
|
|
150
|
-
"use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentManager=void 0;var o=function(){function n(t){e(this,n),this.req=t}return t(n,[{key:"
|
|
150
|
+
"use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentManager=void 0;var o=function(){function n(t){e(this,n),this.req=t}return t(n,[{key:"createDocument",value:function(e){return this.req.post({url:"/api/new/document/insert-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocument",value:function(e){return this.req.post({url:"/api/new/document/find-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocuments",value:function(e){return this.req.post({url:"/api/new/document/find",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"deleteDocument",value:function(e){return this.req.post({url:"/api/new/document/remove-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}}]),n}();exports.DocumentManager=o;
|
|
151
151
|
},{}],"ndt3":[function(require,module,exports) {
|
|
152
|
-
"use strict";function e(e){return i(e)||n(e)||t(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return u(e)}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r,t,n,i,u,a){try{var o=e[u](a),s=o.value}catch(
|
|
152
|
+
"use strict";function e(e){return i(e)||n(e)||t(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return u(e)}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r,t,n,i,u,a){try{var o=e[u](a),s=o.value}catch(c){return void t(c)}o.done?r(s):Promise.resolve(s).then(n,i)}function o(e){return function(){var r=this,t=arguments;return new Promise(function(n,i){var u=e.apply(r,t);function o(e){a(u,n,i,o,s,"next",e)}function s(e){a(u,n,i,o,s,"throw",e)}o(void 0)})}}function s(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function c(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,r,t){return r&&c(e.prototype,r),t&&c(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileManager=void 0;var l=function(){function r(e,t,n,i){s(this,r),this.storage=e,this.pipeService=t,this.req=n,this.appProcessor=i}return p(r,[{key:"uploadFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,i={"file-0":r,app_id:t,item_id:n},e.next=4,this.req.post({url:"/file/formupload",form:i});case 4:return u=e.sent,e.abrupt("return",u);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/file/upload",form:{file:JSON.stringify(r)}});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,u){var a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a={file_name:n,extension:i,file_id:t,format:u,source:r},e.next=4,this.req.post({url:"/file/update",form:{file:JSON.stringify(a)}});case 4:return o=e.sent,e.abrupt("return",o);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n,i,u){return e.apply(this,arguments)}}()},{key:"duplicateFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.req.post({url:"/api/new/file/duplicate",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{files:JSON.stringify(r)}}));case 1:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"downloadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.isFileExists(r,t);case 2:if(!e.sent){e.next=12;break}return e.next=5,this.getFile(r,t);case 5:return n=e.sent,e.next=8,this.req.get({url:n.url,externalResource:!0});case 8:return i=e.sent,e.abrupt("return",{file:n,data:i,type:"file"});case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"duplicateFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.duplicateFileApi(r);case 2:return(t=e.sent).forEach(function(e){n.addFileToStorage(e.app_id,e)}),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"deleteFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/file/delete?file_id=".concat(r)});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"addFileToStorage",value:function(e,r){var t=this.storage.getApp(e);t&&(t.file_list.push(r),this.storage.updateApp(t))}},{key:"addFilesToStorage",value:function(r,t){var n,i=this.storage.getApp(r);i&&((n=i.file_list).push.apply(n,e(t)),this.storage.updateApp(i))}},{key:"deleteFileFromStorage",value:function(e,r){var t,n=this.storage.getApp(r);n&&(n.file_list=n.file_list.filter(function(r){return r.file_id!=e||(t=r,!1)}),this.storage.updateApp(n),this.pipeService.emit("gh_file_delete",{file_id:e},t))}},{key:"updateFileInStorage",value:function(e,r,t){var n=this.storage.getApp(r);n&&(n.file_list=n.file_list.map(function(r){return r.file_id==e?t:r}),this.storage.updateApp(n),this.pipeService.emit("gh_file_update",{file_id:e}))}},{key:"getFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.appProcessor.getApp(r);case 3:return n=e.sent,e.abrupt("return",n.file_list.find(function(e){return e.file_id==t}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r,t){return e.apply(this,arguments)}}()},{key:"getFiles",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n,i=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>1&&void 0!==i[1]?i[1]:[],e.prev=1,e.next=4,this.appProcessor.getApp(r);case 4:return n=e.sent,e.abrupt("return",n.file_list.filter(function(e){return t.some(function(r){return r==e.file_id})}));case 8:return e.prev=8,e.t0=e.catch(1),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[1,8]])}));return function(r){return e.apply(this,arguments)}}()},{key:"uploadFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileApi(r,t,n);case 2:return i=e.sent,this.addFileToStorage(t,i),e.abrupt("return",i);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileFromStringApi(r);case 2:return t=e.sent,this.addFileToStorage(t.app_id,t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,u){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateFileFromStringApi(r,t,n,i,u);case 2:return a=e.sent,this.updateFileInStorage(t,a.app_id,a),e.abrupt("return",a);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n,i,u){return e.apply(this,arguments)}}()},{key:"deleteFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteFileApi(r);case 2:return this.deleteFileFromStorage(r,t),e.abrupt("return",!0);case 4:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"isFileExists",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/,!Boolean(t)){e.next=12;break}return e.next=4,this.getFile(r,t);case 4:if(i=e.sent,!Boolean(i)){e.next=9;break}return e.abrupt("return",n.test(i.url));case 9:return e.abrupt("return",!1);case 10:e.next=13;break;case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()}]),r}();exports.FileManager=l;
|
|
153
153
|
},{}],"yYLL":[function(require,module,exports) {
|
|
154
154
|
"use strict";function e(e,t,r,n,u,a,i){try{var s=e[a](i),o=s.value}catch(c){return void r(c)}s.done?t(o):Promise.resolve(o).then(n,u)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(u,a){var i=t.apply(r,n);function s(t){e(i,u,a,s,o,"next",t)}function o(t){e(i,u,a,s,o,"throw",t)}s(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChunksManager=void 0;var a=function(){function e(t,n,u,a){r(this,e),this.storage=t,this.pipeService=n,this.req=u,this.util=a,this.itemListeners()}return u(e,[{key:"getChunkApi",value:function(){var e=t(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.simpleGet({url:"/api/get-items-chunk/".concat(t,"/").concat(r)});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getLastChunkApi",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.simpleGet({url:"/api/get-last-items-chunk/".concat(t)});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getChunk",value:function(e,t){return this.getChunkApi(e,t)}},{key:"getChunks",value:function(){var e=t(regeneratorRuntime.mark(function e(t,r){var n,u=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=[],!r){e.next=5;break}return e.next=4,Promise.all(r.map(function(e){return u.getChunkApi(t,e)}));case 4:n=e.sent;case 5:return e.abrupt("return",n);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getLastChunk",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getLastChunkApi(t);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){}},{key:"getApp",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",null);case 2:if(r=this.getAppFromStorage(t)){e.next=16;break}if(!this.getAppPromises[t]){e.next=6;break}return e.abrupt("return",this.getAppPromises[t]);case 6:return this.getAppPromises[t]=this.getAppApi(t),e.next=9,this.getAppPromises[t];case 9:if(!(r=e.sent)){e.next=15;break}this.saveAppInStorage(r),this.ws.addSubscription(t),e.next=16;break;case 15:return e.abrupt("return",null);case 16:return e.abrupt("return",r);case 17:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();exports.ChunksManager=a;
|
|
155
155
|
},{}],"WyOa":[function(require,module,exports) {
|
|
156
156
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"DocumentManager",{enumerable:!0,get:function(){return e.DocumentManager}}),Object.defineProperty(exports,"FileManager",{enumerable:!0,get:function(){return r.FileManager}}),Object.defineProperty(exports,"ChunksManager",{enumerable:!0,get:function(){return n.ChunksManager}});var e=require("./DocumentManager/DocumentManager.js"),r=require("./FileManager/FileManager.js"),n=require("./ChunksManager/ChunksManager.js");
|
|
157
157
|
},{"./DocumentManager/DocumentManager.js":"gVik","./FileManager/FileManager.js":"ndt3","./ChunksManager/ChunksManager.js":"yYLL"}],"U9gy":[function(require,module,exports) {
|
|
158
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHub=void 0;var e=require("./gudhub-https-service.js"),t=require("./PipeService/PipeService.js"),r=require("./Storage/Storage.js"),i=require("./WebSocket/WebSocket.js"),n=require("./config.js"),s=require("./Utils/Utils.js"),o=require("./Auth/Auth.js"),u=require("./Processors/processors.js"),a=require("./Managers/managers.js"),l=require("./consts.js");function c(e,t,r,i,n,s,o){try{var u=e[s](o),a=u.value}catch(l){return void r(l)}u.done?t(a):Promise.resolve(a).then(i,n)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function o(e){c(s,i,n,o,u,"next",e)}function u(e){c(s,i,n,o,u,"throw",e)}o(void 0)})}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),e}var g=function(){function c(l){var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{server_url:n.server_url,wss_url:n.wss_url,initWebsocket:!1,activateSW:!1,swLink:""};d(this,c),this.pipeService=new t.PipeService,this.storage=new r.Storage(this.pipeService),this.util=new s.Utils(this),this.req=new e.GudHubHttpsService(p.server_url),this.auth=new o.Auth(this.req,this.storage),l&&this.storage.setUser({auth_key:l}),this.req.init(this.auth.getToken.bind(this.auth)),this.ws=new i.WebSocketApi(p.wss_url,this.auth),this.chunksManager=new a.ChunksManager(this.storage,this.pipeService,this.req,this.util),this.appProcessor=new u.AppProcessor(this.storage,this.pipeService,this.req,this.ws,this.chunksManager,this.util,p.activateSW),this.itemProcessor=new u.ItemProcessor(this.storage,this.pipeService,this.req,this.appProcessor,this.util),this.fieldProcessor=new u.FieldProcessor(this.storage,this.req,this.appProcessor,this.itemProcessor),this.fileManager=new a.FileManager(this.storage,this.req,this.pipeService,this.appProcessor),this.documentManager=new a.DocumentManager(this.req),p.initWebsocket&&this.ws.initWebSocket(this.websocketHandler.bind(this),this.appProcessor.refreshApps.bind(this.appProcessor)),p.activateSW&&this.activateSW(p.swLink)}return f(c,[{key:"activateSW",value:function(){var e=p(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(l.IS_WEB&&"serviceWorker"in window.navigator)){e.next=14;break}return e.prev=1,e.next=4,window.navigator.serviceWorker.register(t);case 4:(r=e.sent).update().then(function(){return console.log("%cSW ->>> Service worker successful updated","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;")}).catch(function(){return console.warn("SW ->>> Service worker is not updated")}),console.log("%cSW ->>> Service worker is registered","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.warn("%cSW ->>> Service worker is not registered","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",e.t0);case 12:e.next=15;break;case 14:console.log("%cSW ->>> ServiceWorkers not supported","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;");case 15:case"end":return e.stop()}},e,null,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"on",value:function(e,t,r){return this.pipeService.on(e,t,r),this}},{key:"emit",value:function(e,t,r,i){return this.pipeService.emit(e,t,r,i),this}},{key:"destroy",value:function(e,t,r){return this.pipeService.destroy(e,t,r),this}},{key:"prefilter",value:function(e,t,r,i,n){return this.util.prefilter(e,t,r,i,n)}},{key:"filter",value:function(e,t){return this.util.filter(e,t)}},{key:"group",value:function(e,t){return this.util.group(e,t)}},{key:"getFilteredItems",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.util.getFilteredItems(e,t,r.element_app_id,r.app_id,r.item_id,r.field_group,r.search,r.search_params)}},{key:"jsonToItems",value:function(e,t){return this.util.jsonToItems(e,t)}},{key:"getDate",value:function(e){return this.util.getDate(e)}},{key:"populateWithDate",value:function(e,t){return this.util.populateWithDate(e,t)}},{key:"populateItems",value:function(e,t,r){return this.util.populateItems(e,t,r)}},{key:"populateWithItemRef",value:function(e,t,r,i,n,s){return this.util.populateWithItemRef(e,t,r,i,n,s)}},{key:"compareItems",value:function(e,t,r){return this.util.compareItems(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return this.util.mergeItems(e,t,r)}},{key:"mergeObjects",value:function(e,t){return this.util.mergeObjects(e,t)}},{key:"makeNestedList",value:function(e,t,r,i,n){return this.util.makeNestedList(e,t,r,i,n)}},{key:"jsonConstructor",value:function(e,t,r){return this.util.jsonConstructor(e,t,r)}},{key:"getAppsList",value:function(){return this.appProcessor.getAppsList()}},{key:"getAppInfo",value:function(e){return this.appProcessor.getAppInfo(e)}},{key:"deleteApp",value:function(e){return this.appProcessor.deleteApp(e)}},{key:"getApp",value:function(e){return this.appProcessor.getApp(e)}},{key:"updateApp",value:function(e){return this.appProcessor.updateApp(e)}},{key:"updateAppInfo",value:function(e){return this.appProcessor.updateAppInfo(e)}},{key:"createNewApp",value:function(e){return this.appProcessor.createNewApp(e)}},{key:"getItems",value:function(e){return this.itemProcessor.getItems(e)}},{key:"getItem",value:function(){var e=p(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getItems(t);case 2:if(!(i=e.sent)){e.next=5;break}return e.abrupt("return",i.find(function(e){return e.item_id==r}));case 5:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(e,t){return this.itemProcessor.addNewItems(e,t)}},{key:"updateItems",value:function(e,t){return this.itemProcessor.updateItems(e,t)}},{key:"deleteItems",value:function(e,t){return this.itemProcessor.deleteItems(e,t)}},{key:"getField",value:function(e,t){return this.fieldProcessor.getField(e,t)}},{key:"getFieldModels",value:function(e){return this.fieldProcessor.getFieldModels(e)}},{key:"updateField",value:function(e,t){return this.fieldProcessor.updateField(e,t)}},{key:"deleteField",value:function(e,t){return this.fieldProcessor.deleteField(e,t)}},{key:"getFieldValue",value:function(e,t,r){return this.fieldProcessor.getFieldValue(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return this.util.getInterpretedValue(e,t,r)}},{key:"setFieldValue",value:function(e,t,r,i){return this.fieldProcessor.setFieldValue(e,t,r,i)}},{key:"getFile",value:function(e,t){return this.fileManager.getFile(e,t)}},{key:"getFiles",value:function(e,t){return this.fileManager.getFiles(e,t)}},{key:"uploadFile",value:function(e,t,r){return this.fileManager.uploadFile(e,t,r)}},{key:"uploadFileFromString",value:function(e,t,r,i,n,s,o){return this.fileManager.uploadFileFromString(e,t,r,i,n,s,o)}},{key:"updateFileFromString",value:function(e,t,r,i,n){return this.fileManager.updateFileFromString(e,t,r,i,n)}},{key:"deleteFile",value:function(e,t){return this.fileManager.deleteFile(e,t)}},{key:"duplicateFile",value:function(e){return this.fileManager.duplicateFile(e)}},{key:"createDocument",value:function(e){return this.documentManager.createDocumentApi(e)}},{key:"getDocument",value:function(e){return this.documentManager.getDocumentApi(e)}},{key:"getDocuments",value:function(e){return this.documentManager.getDocumentsApi(e)}},{key:"deleteDocument",value:function(e){return this.documentManager.deleteDocumentApi(e)}},{key:"login",value:function(e){return this.auth.login(e)}},{key:"logout",value:function(e){return this.appProcessor.clearAppProcessor(),this.auth.logout(e)}},{key:"signup",value:function(e){return this.auth.signup(e)}},{key:"getUsersList",value:function(e){return this.auth.getUsersList(e)}},{key:"updateToken",value:function(e){return this.auth.updateToken(e)}},{key:"avatarUploadApi",value:function(e){return this.auth.avatarUploadApi(e)}},{key:"getVersion",value:function(){return this.auth.getVersion()}},{key:"getUserById",value:function(e){return this.auth.getUserById(e)}},{key:"getToken",value:function(){return this.auth.getToken()}},{key:"updateUser",value:function(e){return this.auth.updateUser(e)}},{key:"updateAvatar",value:function(e){return this.auth.updateAvatar(e)}},{key:"websocketHandler",value:function(e){switch(e.api){case"/items/update":console.log("/items/update - ",e),this.itemProcessor.updateItemsInStorage(e.app_id,e.response);break;case"/items/add":console.log("/items/add - ",e),this.itemProcessor.addItemsToStorage(e.app_id,e.response);break;case"/items/delete":console.log("/items/delete - ",e),this.itemProcessor.deleteItemsFromStorage(e.app_id,e.response);break;case"/app/update":console.log("/app/update - ",e),this.appProcessor.updatingAppInStorage(e.response);break;case"/file/delete":console.log("file/delete - ",e),this.fileManager.deleteFileFromStorage(e.response.file_id,e.app_id);break;case"/file/upload":console.log("file/upload - ",e),this.fileManager.addFileToStorage(e.app_id,e.response);break;case"/file/formupload":console.log("file/formupload - ",e);break;case"/file/update":this.fileManager.updateFileInStorage(e.response.file_id,e.response.app_id,e.response),console.log("file/update - ",e);break;case"/new/file/duplicate":this.fileManager.addFilesToStorage(e.app_id,e.response),console.log("new/file/duplicate - ",e);break;default:console.warn("WEBSOCKETS is not process this API:",e.api)}}}]),c}();exports.GudHub=g;
|
|
158
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHub=void 0;var e=require("./gudhub-https-service.js"),t=require("./PipeService/PipeService.js"),r=require("./Storage/Storage.js"),i=require("./WebSocket/WebSocket.js"),n=require("./config.js"),s=require("./Utils/Utils.js"),o=require("./Auth/Auth.js"),u=require("./Processors/processors.js"),a=require("./Managers/managers.js"),l=require("./consts.js");function c(e,t,r,i,n,s,o){try{var u=e[s](o),a=u.value}catch(l){return void r(l)}u.done?t(a):Promise.resolve(a).then(i,n)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function o(e){c(s,i,n,o,u,"next",e)}function u(e){c(s,i,n,o,u,"throw",e)}o(void 0)})}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}var g=function(){function c(l){var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{server_url:n.server_url,wss_url:n.wss_url,initWebsocket:!1,activateSW:!1,swLink:""};d(this,c),this.pipeService=new t.PipeService,this.storage=new r.Storage(this.pipeService),this.util=new s.Utils(this),this.req=new e.GudHubHttpsService(p.server_url),this.auth=new o.Auth(this.req,this.storage),l&&this.storage.setUser({auth_key:l}),this.req.init(this.auth.getToken.bind(this.auth)),this.ws=new i.WebSocketApi(p.wss_url,this.auth),this.chunksManager=new a.ChunksManager(this.storage,this.pipeService,this.req,this.util),this.appProcessor=new u.AppProcessor(this.storage,this.pipeService,this.req,this.ws,this.chunksManager,this.util,p.activateSW),this.itemProcessor=new u.ItemProcessor(this.storage,this.pipeService,this.req,this.appProcessor,this.util),this.fieldProcessor=new u.FieldProcessor(this.storage,this.req,this.appProcessor,this.itemProcessor),this.fileManager=new a.FileManager(this.storage,this.pipeService,this.req,this.appProcessor),this.documentManager=new a.DocumentManager(this.req),p.initWebsocket&&this.ws.initWebSocket(this.websocketHandler.bind(this),this.appProcessor.refreshApps.bind(this.appProcessor)),p.activateSW&&this.activateSW(p.swLink)}return h(c,[{key:"activateSW",value:function(){var e=p(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(l.IS_WEB&&"serviceWorker"in window.navigator)){e.next=14;break}return e.prev=1,e.next=4,window.navigator.serviceWorker.register(t);case 4:(r=e.sent).update().then(function(){return console.log("%cSW ->>> Service worker successful updated","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;")}).catch(function(){return console.warn("SW ->>> Service worker is not updated")}),console.log("%cSW ->>> Service worker is registered","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.warn("%cSW ->>> Service worker is not registered","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",e.t0);case 12:e.next=15;break;case 14:console.log("%cSW ->>> ServiceWorkers not supported","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;");case 15:case"end":return e.stop()}},e,null,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"on",value:function(e,t,r){return this.pipeService.on(e,t,r),this}},{key:"emit",value:function(e,t,r,i){return this.pipeService.emit(e,t,r,i),this}},{key:"destroy",value:function(e,t,r){return this.pipeService.destroy(e,t,r),this}},{key:"prefilter",value:function(e,t,r,i,n){return this.util.prefilter(e,t,r,i,n)}},{key:"filter",value:function(e,t){return this.util.filter(e,t)}},{key:"group",value:function(e,t){return this.util.group(e,t)}},{key:"getFilteredItems",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.util.getFilteredItems(e,t,r.element_app_id,r.app_id,r.item_id,r.field_group,r.search,r.search_params)}},{key:"jsonToItems",value:function(e,t){return this.util.jsonToItems(e,t)}},{key:"getDate",value:function(e){return this.util.getDate(e)}},{key:"populateWithDate",value:function(e,t){return this.util.populateWithDate(e,t)}},{key:"populateItems",value:function(e,t,r){return this.util.populateItems(e,t,r)}},{key:"populateWithItemRef",value:function(e,t,r,i,n,s){return this.util.populateWithItemRef(e,t,r,i,n,s)}},{key:"compareItems",value:function(e,t,r){return this.util.compareItems(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return this.util.mergeItems(e,t,r)}},{key:"mergeObjects",value:function(e,t){return this.util.mergeObjects(e,t)}},{key:"makeNestedList",value:function(e,t,r,i,n){return this.util.makeNestedList(e,t,r,i,n)}},{key:"jsonConstructor",value:function(e,t,r){return this.util.jsonConstructor(e,t,r)}},{key:"getAppsList",value:function(){return this.appProcessor.getAppsList()}},{key:"getAppInfo",value:function(e){return this.appProcessor.getAppInfo(e)}},{key:"deleteApp",value:function(e){return this.appProcessor.deleteApp(e)}},{key:"getApp",value:function(e){return this.appProcessor.getApp(e)}},{key:"updateApp",value:function(e){return this.appProcessor.updateApp(e)}},{key:"updateAppInfo",value:function(e){return this.appProcessor.updateAppInfo(e)}},{key:"createNewApp",value:function(e){return this.appProcessor.createNewApp(e)}},{key:"getItems",value:function(e){return this.itemProcessor.getItems(e)}},{key:"getItem",value:function(){var e=p(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getItems(t);case 2:if(!(i=e.sent)){e.next=5;break}return e.abrupt("return",i.find(function(e){return e.item_id==r}));case 5:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(e,t){return this.itemProcessor.addNewItems(e,t)}},{key:"updateItems",value:function(e,t){return this.itemProcessor.updateItems(e,t)}},{key:"deleteItems",value:function(e,t){return this.itemProcessor.deleteItems(e,t)}},{key:"getField",value:function(e,t){return this.fieldProcessor.getField(e,t)}},{key:"getFieldModels",value:function(e){return this.fieldProcessor.getFieldModels(e)}},{key:"updateField",value:function(e,t){return this.fieldProcessor.updateField(e,t)}},{key:"deleteField",value:function(e,t){return this.fieldProcessor.deleteField(e,t)}},{key:"getFieldValue",value:function(e,t,r){return this.fieldProcessor.getFieldValue(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return this.util.getInterpretedValue(e,t,r)}},{key:"setFieldValue",value:function(e,t,r,i){return this.fieldProcessor.setFieldValue(e,t,r,i)}},{key:"getFile",value:function(e,t){return this.fileManager.getFile(e,t)}},{key:"getFiles",value:function(e,t){return this.fileManager.getFiles(e,t)}},{key:"uploadFile",value:function(e,t,r){return this.fileManager.uploadFile(e,t,r)}},{key:"uploadFileFromString",value:function(e,t,r,i,n,s,o){return this.fileManager.uploadFileFromString(e,t,r,i,n,s,o)}},{key:"updateFileFromString",value:function(e,t,r,i,n){return this.fileManager.updateFileFromString(e,t,r,i,n)}},{key:"deleteFile",value:function(e,t){return this.fileManager.deleteFile(e,t)}},{key:"duplicateFile",value:function(e){return this.fileManager.duplicateFile(e)}},{key:"downloadFileFromString",value:function(e,t){return this.fileManager.downloadFileFromString(e,t)}},{key:"createDocument",value:function(e){return this.documentManager.createDocument(e)}},{key:"getDocument",value:function(e){return this.documentManager.getDocument(e)}},{key:"getDocuments",value:function(e){return this.documentManager.getDocuments(e)}},{key:"deleteDocument",value:function(e){return this.documentManager.deleteDocument(e)}},{key:"login",value:function(e){return this.auth.login(e)}},{key:"logout",value:function(e){return this.appProcessor.clearAppProcessor(),this.auth.logout(e)}},{key:"signup",value:function(e){return this.auth.signup(e)}},{key:"getUsersList",value:function(e){return this.auth.getUsersList(e)}},{key:"updateToken",value:function(e){return this.auth.updateToken(e)}},{key:"avatarUploadApi",value:function(e){return this.auth.avatarUploadApi(e)}},{key:"getVersion",value:function(){return this.auth.getVersion()}},{key:"getUserById",value:function(e){return this.auth.getUserById(e)}},{key:"getToken",value:function(){return this.auth.getToken()}},{key:"updateUser",value:function(e){return this.auth.updateUser(e)}},{key:"updateAvatar",value:function(e){return this.auth.updateAvatar(e)}},{key:"websocketHandler",value:function(e){switch(e.api){case"/items/update":console.log("/items/update - ",e),this.itemProcessor.updateItemsInStorage(e.app_id,e.response);break;case"/items/add":console.log("/items/add - ",e),this.itemProcessor.addItemsToStorage(e.app_id,e.response);break;case"/items/delete":console.log("/items/delete - ",e),this.itemProcessor.deleteItemsFromStorage(e.app_id,e.response);break;case"/app/update":console.log("/app/update - ",e),this.appProcessor.updatingAppInStorage(e.response);break;case"/file/delete":console.log("file/delete - ",e),this.fileManager.deleteFileFromStorage(e.response.file_id,e.app_id);break;case"/file/upload":console.log("file/upload - ",e),this.fileManager.addFileToStorage(e.app_id,e.response);break;case"/file/formupload":console.log("file/formupload - ",e);break;case"/file/update":this.fileManager.updateFileInStorage(e.response.file_id,e.response.app_id,e.response),console.log("file/update - ",e);break;case"/new/file/duplicate":this.fileManager.addFilesToStorage(e.app_id,e.response),console.log("new/file/duplicate - ",e);break;default:console.warn("WEBSOCKETS is not process this API:",e.api)}}}]),c}();exports.GudHub=g;
|
|
159
159
|
},{"./gudhub-https-service.js":"hDvy","./PipeService/PipeService.js":"E3xI","./Storage/Storage.js":"CSHe","./WebSocket/WebSocket.js":"pHMV","./config.js":"TPH7","./Utils/Utils.js":"mWlG","./Auth/Auth.js":"rK64","./Processors/processors.js":"WIY5","./Managers/managers.js":"WyOa","./consts.js":"UV2u"}],"iRRN":[function(require,module,exports) {
|
|
160
160
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"GudHub",{enumerable:!0,get:function(){return e.GudHub}}),exports.default=void 0,require("regenerator-runtime/runtime.js");var e=require("./GUDHUB/gudhub.js"),r=e.GudHub;exports.default=r;
|
|
161
161
|
},{"regenerator-runtime/runtime.js":"KA2S","./GUDHUB/gudhub.js":"U9gy"}]},{},["iRRN"], "GudHubLibrary")
|