verteilen-core 1.4.4 → 1.4.6
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/dist/computed.d.ts +1 -0
- package/dist/computed.js +2 -1
- package/dist/server/io.d.ts +16 -18
- package/dist/server/io.js +30 -353
- package/dist/server/io2.d.ts +34 -2
- package/dist/server/io2.js +392 -3
- package/dist/server/module/account.js +1 -1
- package/dist/server/module/project.d.ts +3 -3
- package/dist/server/module/project.js +1 -1
- package/dist/server/server.d.ts +2 -2
- package/dist/server/server.js +12 -12
- package/dist/server/server2.d.ts +7 -0
- package/dist/server/server2.js +26 -0
- package/package.json +1 -1
- package/src/computed.ts +1 -0
- package/src/server/io.ts +44 -393
- package/src/server/io2.ts +484 -2
- package/src/server/module/account.ts +1 -1
- package/src/server/module/project.ts +4 -4
- package/src/server/server.ts +11 -15
- package/src/server/server2.ts +38 -0
- package/test/client/execute.test.ts +3 -1
- package/test/client/task.test.ts +3 -1
- package/test/server/plugin.test.ts +1 -4
package/dist/computed.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export * as ClientParameter from './client/database';
|
|
|
11
11
|
export * as ClientResource from './client/resource';
|
|
12
12
|
export * as ClientShell from './client/shell';
|
|
13
13
|
export * as Execute_WebhookServerManager from './script/webhook_server_manager';
|
|
14
|
+
export * as ServerWorker from './server/server2';
|
|
14
15
|
export * as ServerIO from './server/io2';
|
package/dist/computed.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ServerIO = exports.Execute_WebhookServerManager = exports.ClientShell = exports.ClientResource = exports.ClientParameter = exports.ClientOS = exports.ClientJavascript = exports.ClientHttp = exports.ClientJobParameter = exports.ClientJobExecute = exports.ClientExecute = exports.ClientCluster = exports.Client = exports.ClientAnalysis = void 0;
|
|
36
|
+
exports.ServerIO = exports.ServerWorker = exports.Execute_WebhookServerManager = exports.ClientShell = exports.ClientResource = exports.ClientParameter = exports.ClientOS = exports.ClientJavascript = exports.ClientHttp = exports.ClientJobParameter = exports.ClientJobExecute = exports.ClientExecute = exports.ClientCluster = exports.Client = exports.ClientAnalysis = void 0;
|
|
37
37
|
exports.ClientAnalysis = __importStar(require("./client/analysis"));
|
|
38
38
|
exports.Client = __importStar(require("./client/client"));
|
|
39
39
|
exports.ClientCluster = __importStar(require("./client/cluster"));
|
|
@@ -47,4 +47,5 @@ exports.ClientParameter = __importStar(require("./client/database"));
|
|
|
47
47
|
exports.ClientResource = __importStar(require("./client/resource"));
|
|
48
48
|
exports.ClientShell = __importStar(require("./client/shell"));
|
|
49
49
|
exports.Execute_WebhookServerManager = __importStar(require("./script/webhook_server_manager"));
|
|
50
|
+
exports.ServerWorker = __importStar(require("./server/server2"));
|
|
50
51
|
exports.ServerIO = __importStar(require("./server/io2"));
|
package/dist/server/io.d.ts
CHANGED
|
@@ -10,22 +10,12 @@ export interface MemoryData {
|
|
|
10
10
|
user: Array<UserProfile>;
|
|
11
11
|
}
|
|
12
12
|
export interface RecordIOLoader {
|
|
13
|
-
load_all: (
|
|
14
|
-
delete_all: (
|
|
15
|
-
list_all: (
|
|
16
|
-
save: (uuid: string, data: string
|
|
17
|
-
load: (uuid: string
|
|
18
|
-
delete: (uuid: string
|
|
19
|
-
}
|
|
20
|
-
export interface RecordLoader {
|
|
21
|
-
project: RecordIOLoader;
|
|
22
|
-
task: RecordIOLoader;
|
|
23
|
-
job: RecordIOLoader;
|
|
24
|
-
database: RecordIOLoader;
|
|
25
|
-
node: RecordIOLoader;
|
|
26
|
-
log: RecordIOLoader;
|
|
27
|
-
lib: RecordIOLoader;
|
|
28
|
-
user: RecordIOLoader;
|
|
13
|
+
load_all: () => Promise<Array<string>>;
|
|
14
|
+
delete_all: () => Promise<Array<string>>;
|
|
15
|
+
list_all: () => Promise<Array<string>>;
|
|
16
|
+
save: (uuid: string, data: string) => Promise<boolean>;
|
|
17
|
+
load: (uuid: string) => Promise<string>;
|
|
18
|
+
delete: (uuid: string) => Promise<boolean>;
|
|
29
19
|
}
|
|
30
20
|
export interface RecordIOBase {
|
|
31
21
|
root: string;
|
|
@@ -40,7 +30,15 @@ export interface RecordIOBase {
|
|
|
40
30
|
rm: (path: string) => Promise<void>;
|
|
41
31
|
cp: (path: string, newpath: string) => Promise<void>;
|
|
42
32
|
}
|
|
33
|
+
export interface RecordLoader {
|
|
34
|
+
project: RecordIOLoader;
|
|
35
|
+
task: RecordIOLoader;
|
|
36
|
+
job: RecordIOLoader;
|
|
37
|
+
database: RecordIOLoader;
|
|
38
|
+
node: RecordIOLoader;
|
|
39
|
+
log: RecordIOLoader;
|
|
40
|
+
lib: RecordIOLoader;
|
|
41
|
+
user: RecordIOLoader;
|
|
42
|
+
}
|
|
43
43
|
export declare const _CreateRecordMemoryLoader: (loader: MemoryData, type: RecordType) => RecordIOLoader;
|
|
44
|
-
export declare const _CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData, type: RecordType, folder: string, ext?: string) => RecordIOLoader;
|
|
45
44
|
export declare const CreateRecordMemoryLoader: (loader: MemoryData) => RecordLoader;
|
|
46
|
-
export declare const CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData) => RecordLoader;
|
package/dist/server/io.js
CHANGED
|
@@ -1,87 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
3
|
+
exports.CreateRecordMemoryLoader = exports._CreateRecordMemoryLoader = void 0;
|
|
7
4
|
const interface_1 = require("../interface");
|
|
8
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
9
|
-
const permissionHelper = (x, uuid) => {
|
|
10
|
-
const ispublic = x.owner == undefined || x.acl == interface_1.ACLType.PUBLIC;
|
|
11
|
-
if (ispublic)
|
|
12
|
-
return true;
|
|
13
|
-
const isowner = x.owner == uuid;
|
|
14
|
-
if (isowner)
|
|
15
|
-
return true;
|
|
16
|
-
const canbeshared = x.acl != interface_1.ACLType.PRIVATE;
|
|
17
|
-
if (!canbeshared)
|
|
18
|
-
return false;
|
|
19
|
-
if (!x.shared)
|
|
20
|
-
return false;
|
|
21
|
-
const target = x.shared.find(x => x.user == uuid);
|
|
22
|
-
if (target == undefined)
|
|
23
|
-
return false;
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
const permissionGetPublic = (v) => {
|
|
27
|
-
return v.filter(x => x.owner == undefined || x.acl == interface_1.ACLType.PUBLIC);
|
|
28
|
-
};
|
|
29
|
-
const obsoleteSupport = async (loader, type, folder) => {
|
|
30
|
-
if (type == interface_1.RecordType.PROJECT) {
|
|
31
|
-
const path = loader.join(loader.root, "record");
|
|
32
|
-
if (!loader.exists(path))
|
|
33
|
-
return;
|
|
34
|
-
const p = await loader.read_dir_file(path);
|
|
35
|
-
const ps = p.filter(x => x.endsWith(".json")).map(x => {
|
|
36
|
-
const path_r = loader.join(path, x);
|
|
37
|
-
return loader.read_string(path_r);
|
|
38
|
-
});
|
|
39
|
-
const allRecordText = await Promise.all(ps);
|
|
40
|
-
const allRecord = allRecordText.map(x => JSON.parse(x));
|
|
41
|
-
const execute_project = [];
|
|
42
|
-
const execute_task = [];
|
|
43
|
-
const execute_job = [];
|
|
44
|
-
for (let x of allRecord) {
|
|
45
|
-
const tasks = x.task;
|
|
46
|
-
x.tasks = [];
|
|
47
|
-
x.database_uuid = x.parameter_uuid;
|
|
48
|
-
x.tasks_uuid = tasks.map(y => y.uuid);
|
|
49
|
-
delete x.parameter_uuid;
|
|
50
|
-
delete x.task;
|
|
51
|
-
for (let y of tasks) {
|
|
52
|
-
const jobs = y.jobs;
|
|
53
|
-
y.jobs = [];
|
|
54
|
-
y.jobs_uuid = jobs.map(z => z.uuid);
|
|
55
|
-
for (let z of jobs) {
|
|
56
|
-
z.id_args = [];
|
|
57
|
-
const d3 = loader.join(loader.root, "job", `${z.uuid}.json`);
|
|
58
|
-
execute_job.push(loader.write_string(d3, JSON.stringify(z, null, 4)));
|
|
59
|
-
}
|
|
60
|
-
const d2 = loader.join(loader.root, "task", `${y.uuid}.json`);
|
|
61
|
-
execute_task.push(loader.write_string(d2, JSON.stringify(y, null, 4)));
|
|
62
|
-
}
|
|
63
|
-
const d1 = loader.join(loader.root, "project", `${x.uuid}.json`);
|
|
64
|
-
execute_project.push(loader.write_string(d1, JSON.stringify(x, null, 4)));
|
|
65
|
-
}
|
|
66
|
-
await Promise.all(execute_project);
|
|
67
|
-
await Promise.all(execute_task);
|
|
68
|
-
await Promise.all(execute_job);
|
|
69
|
-
await loader.rm(path);
|
|
70
|
-
}
|
|
71
|
-
else if (type == interface_1.RecordType.DATABASE) {
|
|
72
|
-
const path = loader.join(loader.root, "parameter");
|
|
73
|
-
if (!loader.exists(path))
|
|
74
|
-
return;
|
|
75
|
-
const p = await loader.read_dir_file(path);
|
|
76
|
-
const ps = p.filter(x => x.endsWith(".json")).map(x => {
|
|
77
|
-
const path2 = loader.join(path, x);
|
|
78
|
-
const path3 = loader.join(loader.root, folder, x);
|
|
79
|
-
return loader.cp(path2, path3);
|
|
80
|
-
});
|
|
81
|
-
await Promise.all(ps);
|
|
82
|
-
loader.rm(path);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
5
|
const _CreateRecordMemoryLoader = (loader, type) => {
|
|
86
6
|
const get_array = (type) => {
|
|
87
7
|
switch (type) {
|
|
@@ -97,275 +17,45 @@ const _CreateRecordMemoryLoader = (loader, type) => {
|
|
|
97
17
|
}
|
|
98
18
|
};
|
|
99
19
|
return {
|
|
100
|
-
load_all: async (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const pub = permissionGetPublic(arr).map(x => JSON.stringify(x));
|
|
104
|
-
const default_behaviour = (v) => resolve(v);
|
|
105
|
-
if (token == undefined) {
|
|
106
|
-
default_behaviour(pub);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
110
|
-
if (err) {
|
|
111
|
-
reject(err.name);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (decode == undefined) {
|
|
115
|
-
default_behaviour(pub);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const payload = JSON.parse(decode.payload);
|
|
119
|
-
return arr.filter(x => permissionHelper(x, payload.user))
|
|
120
|
-
.map(x => JSON.stringify(x));
|
|
121
|
-
});
|
|
122
|
-
});
|
|
20
|
+
load_all: async () => {
|
|
21
|
+
const arr = get_array(type);
|
|
22
|
+
return arr.map(x => JSON.stringify(x));
|
|
123
23
|
},
|
|
124
|
-
delete_all: async (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const default_behaviour = (kill) => {
|
|
129
|
-
const r = kill.map(x => x.uuid);
|
|
130
|
-
kill.forEach(x => {
|
|
131
|
-
const index = arr.findIndex(y => y.uuid == x.uuid);
|
|
132
|
-
arr.slice(index, 1);
|
|
133
|
-
});
|
|
134
|
-
resolve(r);
|
|
135
|
-
};
|
|
136
|
-
if (token == undefined) {
|
|
137
|
-
default_behaviour(pub);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
141
|
-
if (err) {
|
|
142
|
-
reject(err.name);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (decode == undefined) {
|
|
146
|
-
default_behaviour(pub);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const payload = JSON.parse(decode.payload);
|
|
150
|
-
const targets = arr.filter(x => permissionHelper(x, payload.user));
|
|
151
|
-
default_behaviour(targets);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
24
|
+
delete_all: async () => {
|
|
25
|
+
const arr = get_array(type);
|
|
26
|
+
const p = arr.splice(0, arr.length);
|
|
27
|
+
return p.map(x => x.uuid);
|
|
154
28
|
},
|
|
155
|
-
list_all: async (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const pub = permissionGetPublic(arr);
|
|
159
|
-
const default_behaviour = () => {
|
|
160
|
-
resolve(pub.map(x => x.uuid));
|
|
161
|
-
};
|
|
162
|
-
if (token == undefined) {
|
|
163
|
-
default_behaviour();
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
167
|
-
if (err) {
|
|
168
|
-
reject(err.name);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (decode == undefined) {
|
|
172
|
-
default_behaviour();
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const payload = JSON.parse(decode.payload);
|
|
176
|
-
const targets = arr.filter(x => permissionHelper(x, payload.user));
|
|
177
|
-
resolve(targets.map(x => x.uuid));
|
|
178
|
-
});
|
|
179
|
-
});
|
|
29
|
+
list_all: async () => {
|
|
30
|
+
const arr = get_array(type);
|
|
31
|
+
return arr.map(x => x.uuid);
|
|
180
32
|
},
|
|
181
|
-
save: async (uuid, data
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
resolve(true);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const ispublic = exist.owner == undefined || exist.acl == interface_1.ACLType.PUBLIC;
|
|
192
|
-
if (ispublic) {
|
|
193
|
-
arr[index] = Object.assign(exist, JSON.parse(data));
|
|
194
|
-
resolve(true);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (token == undefined) {
|
|
198
|
-
reject("Require Token");
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
202
|
-
if (err) {
|
|
203
|
-
reject(err.name);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (decode == undefined) {
|
|
207
|
-
reject("Require Token");
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
const payload = JSON.parse(decode.payload);
|
|
211
|
-
if (permissionHelper(exist, payload.user)) {
|
|
212
|
-
arr[index] = Object.assign(exist, JSON.parse(data));
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
reject("Permission Denied");
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
load: async (uuid, token) => {
|
|
221
|
-
return new Promise((resolve, reject) => {
|
|
222
|
-
const arr = get_array(type);
|
|
223
|
-
const index = arr.findIndex(x => uuid == x.uuid);
|
|
224
|
-
const exist = index == -1 ? undefined : arr[index];
|
|
225
|
-
if (exist == undefined) {
|
|
226
|
-
reject("Item do not exists");
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const ispublic = exist.owner == undefined || exist.acl == interface_1.ACLType.PUBLIC;
|
|
230
|
-
if (ispublic) {
|
|
231
|
-
resolve(JSON.stringify(exist));
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (token == undefined) {
|
|
235
|
-
reject("Require Token");
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
239
|
-
if (err) {
|
|
240
|
-
reject(err.name);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (decode == undefined) {
|
|
244
|
-
reject("Require Token");
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const payload = JSON.parse(decode.payload);
|
|
248
|
-
if (permissionHelper(exist, payload.user)) {
|
|
249
|
-
resolve(JSON.stringify(exist));
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
reject("Permission Denied");
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
delete: async (uuid, token) => {
|
|
258
|
-
return new Promise((resolve, reject) => {
|
|
259
|
-
const arr = get_array(type);
|
|
260
|
-
const index = arr.findIndex(x => uuid == x.uuid);
|
|
261
|
-
const exist = index == -1 ? undefined : arr[index];
|
|
262
|
-
const default_behaviour = () => {
|
|
263
|
-
arr.splice(index, 1);
|
|
264
|
-
resolve(true);
|
|
265
|
-
};
|
|
266
|
-
if (exist == undefined) {
|
|
267
|
-
resolve(false);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const ispublic = exist.owner == undefined || exist.acl == interface_1.ACLType.PUBLIC;
|
|
271
|
-
if (ispublic) {
|
|
272
|
-
default_behaviour();
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (token == undefined) {
|
|
276
|
-
reject("Require Token");
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
jsonwebtoken_1.default.verify(token, interface_1.SERECT, { complete: true }, (err, decode) => {
|
|
280
|
-
if (err) {
|
|
281
|
-
reject(err.name);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (decode == undefined) {
|
|
285
|
-
reject("Require Token");
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const payload = JSON.parse(decode.payload);
|
|
289
|
-
if (permissionHelper(exist, payload.user)) {
|
|
290
|
-
default_behaviour();
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
reject("Permission Denied");
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
exports._CreateRecordMemoryLoader = _CreateRecordMemoryLoader;
|
|
301
|
-
const _CreateRecordIOLoader = (loader, memory, type, folder, ext = ".json") => {
|
|
302
|
-
const mem = (0, exports._CreateRecordMemoryLoader)(memory, type);
|
|
303
|
-
return {
|
|
304
|
-
load_all: async (cache, token) => {
|
|
305
|
-
const root = loader.join(loader.root, folder);
|
|
306
|
-
if (!loader.exists(root))
|
|
307
|
-
await loader.mkdir(root);
|
|
308
|
-
if (cache)
|
|
309
|
-
return mem.load_all(cache, token);
|
|
310
|
-
await obsoleteSupport(loader, type, folder);
|
|
311
|
-
const files = await loader.read_dir_file(root);
|
|
312
|
-
const r = files.map(x => loader.read_string(loader.join(root, x), { encoding: 'utf8', flag: 'r' }));
|
|
313
|
-
const p = await Promise.all(r);
|
|
314
|
-
const saver = p.map(x => {
|
|
315
|
-
const data = JSON.parse(x);
|
|
316
|
-
return mem.save(data.uuid, x, token);
|
|
317
|
-
});
|
|
318
|
-
await Promise.all(saver);
|
|
319
|
-
return mem.load_all(cache, token);
|
|
320
|
-
},
|
|
321
|
-
delete_all: async (token) => {
|
|
322
|
-
const root = loader.join(loader.root, folder);
|
|
323
|
-
const c = await mem.delete_all(token);
|
|
324
|
-
const kill_all = c.map(x => {
|
|
325
|
-
return loader.rm(loader.join(root, x + ext));
|
|
326
|
-
});
|
|
327
|
-
await Promise.all(kill_all);
|
|
328
|
-
return c;
|
|
329
|
-
},
|
|
330
|
-
list_all: async (token) => {
|
|
331
|
-
const root = loader.join(loader.root, folder);
|
|
332
|
-
if (!loader.exists(root))
|
|
333
|
-
await loader.mkdir(root);
|
|
334
|
-
return mem.list_all(token);
|
|
335
|
-
},
|
|
336
|
-
save: async (uuid, data, token) => {
|
|
337
|
-
const root = loader.join(loader.root, folder);
|
|
338
|
-
if (!loader.exists(root))
|
|
339
|
-
await loader.mkdir(root);
|
|
340
|
-
const r = await mem.save(uuid, data, token);
|
|
341
|
-
if (!r)
|
|
342
|
-
return false;
|
|
343
|
-
const file = loader.join(root, uuid + ext);
|
|
344
|
-
await loader.write_string(file, data);
|
|
33
|
+
save: async (uuid, data) => {
|
|
34
|
+
const arr = get_array(type);
|
|
35
|
+
const index = arr.findIndex(x => x.uuid == uuid);
|
|
36
|
+
if (index != -1)
|
|
37
|
+
arr[index] = JSON.parse(data);
|
|
38
|
+
else
|
|
39
|
+
arr.push(JSON.parse(data));
|
|
345
40
|
return true;
|
|
346
41
|
},
|
|
347
|
-
load: async (uuid
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
42
|
+
load: async (uuid) => {
|
|
43
|
+
const arr = get_array(type);
|
|
44
|
+
const p = arr.find(x => x.uuid == uuid);
|
|
45
|
+
if (p == undefined)
|
|
46
|
+
throw new Error("Item do not exists");
|
|
47
|
+
return JSON.stringify(p);
|
|
352
48
|
},
|
|
353
|
-
delete: async (uuid
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if (!r)
|
|
359
|
-
return false;
|
|
360
|
-
const file = loader.join(root, uuid + ext);
|
|
361
|
-
if (loader.exists(file)) {
|
|
362
|
-
await loader.rm(file);
|
|
363
|
-
}
|
|
49
|
+
delete: async (uuid) => {
|
|
50
|
+
const arr = get_array(type);
|
|
51
|
+
const index = arr.findIndex(x => x.uuid == uuid);
|
|
52
|
+
if (index != -1)
|
|
53
|
+
arr.splice(index, 1);
|
|
364
54
|
return true;
|
|
365
55
|
}
|
|
366
56
|
};
|
|
367
57
|
};
|
|
368
|
-
exports.
|
|
58
|
+
exports._CreateRecordMemoryLoader = _CreateRecordMemoryLoader;
|
|
369
59
|
const CreateRecordMemoryLoader = (loader) => {
|
|
370
60
|
return {
|
|
371
61
|
project: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.PROJECT),
|
|
@@ -379,16 +69,3 @@ const CreateRecordMemoryLoader = (loader) => {
|
|
|
379
69
|
};
|
|
380
70
|
};
|
|
381
71
|
exports.CreateRecordMemoryLoader = CreateRecordMemoryLoader;
|
|
382
|
-
const CreateRecordIOLoader = (loader, memory) => {
|
|
383
|
-
return {
|
|
384
|
-
project: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.PROJECT, "project"),
|
|
385
|
-
task: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.TASK, "task"),
|
|
386
|
-
job: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.JOB, "job"),
|
|
387
|
-
database: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.DATABASE, "database"),
|
|
388
|
-
node: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.NODE, "node"),
|
|
389
|
-
log: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.LOG, "log"),
|
|
390
|
-
lib: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.LIB, "lib"),
|
|
391
|
-
user: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.USER, "user"),
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
exports.CreateRecordIOLoader = CreateRecordIOLoader;
|
package/dist/server/io2.d.ts
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import { MongoClient } from "mongodb";
|
|
2
|
-
import { RecordType } from "../interface";
|
|
3
|
-
import {
|
|
2
|
+
import { Project, RecordType, Database, UserProfile, Library, ExecutionLog, Node, Task, Job } from "../interface";
|
|
3
|
+
import { RecordIOBase } from "./io";
|
|
4
|
+
export interface MemoryData {
|
|
5
|
+
projects: Array<Project>;
|
|
6
|
+
tasks: Array<Task>;
|
|
7
|
+
jobs: Array<Job>;
|
|
8
|
+
database: Array<Database>;
|
|
9
|
+
nodes: Array<Node>;
|
|
10
|
+
logs: Array<ExecutionLog>;
|
|
11
|
+
libs: Array<Library>;
|
|
12
|
+
user: Array<UserProfile>;
|
|
13
|
+
}
|
|
14
|
+
export interface RecordIOLoader {
|
|
15
|
+
load_all: (cache: boolean, token?: string) => Promise<Array<string>>;
|
|
16
|
+
delete_all: (token?: string) => Promise<Array<string>>;
|
|
17
|
+
list_all: (token?: string) => Promise<Array<string>>;
|
|
18
|
+
save: (uuid: string, data: string, token?: string) => Promise<boolean>;
|
|
19
|
+
load: (uuid: string, token?: string) => Promise<string>;
|
|
20
|
+
delete: (uuid: string, token?: string) => Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
export interface RecordLoader {
|
|
23
|
+
project: RecordIOLoader;
|
|
24
|
+
task: RecordIOLoader;
|
|
25
|
+
job: RecordIOLoader;
|
|
26
|
+
database: RecordIOLoader;
|
|
27
|
+
node: RecordIOLoader;
|
|
28
|
+
log: RecordIOLoader;
|
|
29
|
+
lib: RecordIOLoader;
|
|
30
|
+
user: RecordIOLoader;
|
|
31
|
+
}
|
|
32
|
+
export declare const _CreateRecordMemoryLoader: (loader: MemoryData, type: RecordType) => RecordIOLoader;
|
|
33
|
+
export declare const _CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData, type: RecordType, folder: string, ext?: string) => RecordIOLoader;
|
|
4
34
|
export declare const _CreateRecordMongoLoader: (loader: MongoClient, memory: MemoryData, type: RecordType, db: string, collection: string) => RecordIOLoader;
|
|
35
|
+
export declare const CreateRecordMemoryLoader: (loader: MemoryData) => RecordLoader;
|
|
36
|
+
export declare const CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData) => RecordLoader;
|
|
5
37
|
export declare const CreateRecordMongoLoader: (url: string, memory: MemoryData) => RecordLoader;
|