@gudhub/core 1.1.124 → 1.1.126
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/Storage/ModulesList.js +7 -0
- package/GUDHUB/Utils/AppsTemplateService/AppsTemplateService.js +351 -406
- package/GUDHUB/Utils/FIleHelper/FileHelper.js +107 -57
- package/GUDHUB/Utils/Utils.js +5 -5
- package/GUDHUB/Utils/sharing/GroupInvitation.js +2 -2
- package/package.json +1 -1
- package/umd/library.min.js +6 -6
- package/umd/library.min.js.map +1 -1
|
@@ -3,67 +3,117 @@ export class FileHelper {
|
|
|
3
3
|
this.gudhub = gudhub;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
fileInstallerHelper(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
destination: {
|
|
24
|
-
app_id: appId,
|
|
25
|
-
item_id: itemId,
|
|
26
|
-
element_id: elementId
|
|
27
|
-
}
|
|
28
|
-
}
|
|
6
|
+
async fileInstallerHelper(
|
|
7
|
+
mapAppIds,
|
|
8
|
+
appId,
|
|
9
|
+
items,
|
|
10
|
+
elementId,
|
|
11
|
+
isInstallFromRemoteServer,
|
|
12
|
+
remoteServerGudHubInstance
|
|
13
|
+
) {
|
|
14
|
+
const files = [[]];
|
|
15
|
+
let results = [];
|
|
16
|
+
|
|
17
|
+
items.forEach(item => {
|
|
18
|
+
const itemId = item.item_id;
|
|
19
|
+
const field = item.fields.find(field => field.element_id === elementId);
|
|
20
|
+
|
|
21
|
+
if (field?.field_value) {
|
|
22
|
+
const fileIds = field.field_value.split('.');
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
fileIds.forEach(fileId => {
|
|
25
|
+
const newFile = {
|
|
26
|
+
source: fileId,
|
|
27
|
+
destination: {
|
|
28
|
+
app_id: appId,
|
|
29
|
+
item_id: itemId,
|
|
30
|
+
element_id: elementId
|
|
34
31
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return self.gudhub.duplicateFile(filePack);
|
|
42
|
-
}).then(result => {
|
|
43
|
-
results = [
|
|
44
|
-
...results,
|
|
45
|
-
...result
|
|
46
|
-
]
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
chainPromises.then(() => {
|
|
51
|
-
items.forEach(item => {
|
|
52
|
-
const itemId = item.item_id;
|
|
53
|
-
const field = item.fields.find(field => field.element_id === elementId);
|
|
54
|
-
|
|
55
|
-
if(field && field.field_value) {
|
|
56
|
-
field.field_value = '';
|
|
57
|
-
results.forEach(file => {
|
|
58
|
-
if(file.item_id === itemId) {
|
|
59
|
-
field.field_value = field.field_value.split(',').filter(fileId => fileId).concat(file.file_id).join(',');
|
|
60
|
-
}
|
|
61
|
-
})
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (files[files.length - 1].length !== 10) { // 10 - max duplicate files
|
|
35
|
+
files[files.length - 1].push(newFile);
|
|
36
|
+
} else {
|
|
37
|
+
files.push([newFile]);
|
|
62
38
|
}
|
|
63
|
-
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
for (const filePack of files) {
|
|
44
|
+
if (!filePack.length) continue;
|
|
45
|
+
|
|
46
|
+
let result;
|
|
47
|
+
|
|
48
|
+
if (isInstallFromRemoteServer) {
|
|
49
|
+
result = await this._copyFilesFromRemoteServer(mapAppIds, filePack, remoteServerGudHubInstance);
|
|
50
|
+
} else {
|
|
51
|
+
result = await this.gudhub.duplicateFile(filePack);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
results = [
|
|
55
|
+
...results,
|
|
56
|
+
...result
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
items.forEach(item => {
|
|
61
|
+
const itemId = item.item_id;
|
|
62
|
+
const field = item.fields.find(field => field.element_id === elementId);
|
|
63
|
+
|
|
64
|
+
if (field?.field_value) {
|
|
65
|
+
field.field_value = '';
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
results.forEach(file => {
|
|
68
|
+
if (file.item_id === itemId) {
|
|
69
|
+
field.field_value = field.field_value
|
|
70
|
+
.split(',')
|
|
71
|
+
.filter(fileId => fileId)
|
|
72
|
+
.concat(file.file_id)
|
|
73
|
+
.join(',');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
67
77
|
});
|
|
68
78
|
}
|
|
79
|
+
|
|
80
|
+
async _copyFilesFromRemoteServer(apps, filePack, remoteServerGudHubInstance) {
|
|
81
|
+
const createdFiles = [];
|
|
82
|
+
|
|
83
|
+
for (const file of filePack) {
|
|
84
|
+
const sourceFileIds = String(file.source)
|
|
85
|
+
.split(',')
|
|
86
|
+
.map(fileId => fileId.trim())
|
|
87
|
+
.filter(Boolean);
|
|
88
|
+
|
|
89
|
+
const appMap = apps.find(
|
|
90
|
+
app => app.new_app_id === file.destination.app_id
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (!appMap) {
|
|
94
|
+
console.warn('App mapping not found for:', file.destination.app_id);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const sourceAppId = appMap.old_app_id;
|
|
99
|
+
|
|
100
|
+
for (const sourceFileId of sourceFileIds) {
|
|
101
|
+
const sourceFile = await remoteServerGudHubInstance.getFile(
|
|
102
|
+
sourceAppId,
|
|
103
|
+
sourceFileId
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const createdFile = await this.gudhub.uploadFileFromString({
|
|
107
|
+
...sourceFile,
|
|
108
|
+
app_id: file.destination.app_id,
|
|
109
|
+
item_id: file.destination.item_id,
|
|
110
|
+
element_id: file.destination.element_id
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
createdFiles.push(createdFile);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return createdFiles;
|
|
118
|
+
}
|
|
69
119
|
}
|
package/GUDHUB/Utils/Utils.js
CHANGED
|
@@ -178,12 +178,12 @@ export class Utils {
|
|
|
178
178
|
return compiler(scheme, item, this, variables, appId)
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
fileInstallerHelper(appId, items, elementId) {
|
|
182
|
-
return this.FileHelper.fileInstallerHelper(appId, items, elementId);
|
|
181
|
+
fileInstallerHelper(mapAppIds, appId, items, elementId, isInstallFromRemoteServer, remoteServerGudHubInstance) {
|
|
182
|
+
return this.FileHelper.fileInstallerHelper(mapAppIds, appId, items, elementId, isInstallFromRemoteServer, remoteServerGudHubInstance);
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
createAppsFromTemplate(pack,
|
|
186
|
-
return this.AppsTemplateService.createAppsFromTemplate(pack,
|
|
184
|
+
|
|
185
|
+
createAppsFromTemplate(pack, remoteServerUrl, remoteServerAuthKey, isInstallFromRemoteServer, maxNumberOfInstalledItems, progressCallback) {
|
|
186
|
+
return this.AppsTemplateService.createAppsFromTemplate(pack, remoteServerUrl, remoteServerAuthKey, isInstallFromRemoteServer, maxNumberOfInstalledItems, progressCallback);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
createApps(pack) {
|
|
@@ -35,9 +35,9 @@ export class GroupInvitation {
|
|
|
35
35
|
|
|
36
36
|
async groupInvitationAccept(invitationId) {
|
|
37
37
|
try {
|
|
38
|
-
return await this.req.
|
|
38
|
+
return await this.req.post({
|
|
39
39
|
url: "/api/invitation/accept",
|
|
40
|
-
|
|
40
|
+
form: {
|
|
41
41
|
invitation_id: invitationId
|
|
42
42
|
}
|
|
43
43
|
});
|