verteilen-core 1.4.4 → 1.4.7
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 +14 -16
- package/dist/server/io.js +42 -362
- package/dist/server/io2.d.ts +3 -4
- package/dist/server/io2.js +412 -17
- 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 +13 -13
- package/dist/server/server2.d.ts +3 -0
- package/dist/server/server2.js +7 -0
- package/package.json +1 -1
- package/src/computed.ts +1 -0
- package/src/server/io.ts +45 -389
- package/src/server/io2.ts +451 -7
- package/src/server/module/account.ts +1 -1
- package/src/server/module/project.ts +4 -4
- package/src/server/server.ts +13 -17
- package/src/server/server2.ts +14 -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Project,
|
|
1
|
+
import { Project, Database, UserProfile, Library, ExecutionLog, Node, Task, Job } from "../interface";
|
|
2
2
|
export interface MemoryData {
|
|
3
3
|
projects: Array<Project>;
|
|
4
4
|
tasks: Array<Task>;
|
|
@@ -10,23 +10,14 @@ export interface MemoryData {
|
|
|
10
10
|
user: Array<UserProfile>;
|
|
11
11
|
}
|
|
12
12
|
export interface RecordIOLoader {
|
|
13
|
-
|
|
13
|
+
fetch_all: () => Promise<Array<string>>;
|
|
14
|
+
load_all: (token?: string) => Promise<Array<string>>;
|
|
14
15
|
delete_all: (token?: string) => Promise<Array<string>>;
|
|
15
16
|
list_all: (token?: string) => Promise<Array<string>>;
|
|
16
17
|
save: (uuid: string, data: string, token?: string) => Promise<boolean>;
|
|
17
18
|
load: (uuid: string, token?: string) => Promise<string>;
|
|
18
19
|
delete: (uuid: string, token?: string) => Promise<boolean>;
|
|
19
20
|
}
|
|
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;
|
|
29
|
-
}
|
|
30
21
|
export interface RecordIOBase {
|
|
31
22
|
root: string;
|
|
32
23
|
join: (...paths: Array<string>) => string;
|
|
@@ -40,7 +31,14 @@ export interface RecordIOBase {
|
|
|
40
31
|
rm: (path: string) => Promise<void>;
|
|
41
32
|
cp: (path: string, newpath: string) => Promise<void>;
|
|
42
33
|
}
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
export interface RecordLoader {
|
|
35
|
+
project: RecordIOLoader;
|
|
36
|
+
task: RecordIOLoader;
|
|
37
|
+
job: RecordIOLoader;
|
|
38
|
+
database: RecordIOLoader;
|
|
39
|
+
node: RecordIOLoader;
|
|
40
|
+
log: RecordIOLoader;
|
|
41
|
+
lib: RecordIOLoader;
|
|
42
|
+
user: RecordIOLoader;
|
|
43
|
+
}
|
|
44
|
+
export declare const CreateRecordMemoryLoader_Browser: (loader: 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_Browser = 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,298 +17,58 @@ const _CreateRecordMemoryLoader = (loader, type) => {
|
|
|
97
17
|
}
|
|
98
18
|
};
|
|
99
19
|
return {
|
|
100
|
-
|
|
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
|
-
});
|
|
123
|
-
},
|
|
124
|
-
delete_all: async (token) => {
|
|
125
|
-
return new Promise((resolve, reject) => {
|
|
126
|
-
const arr = get_array(type);
|
|
127
|
-
const pub = permissionGetPublic(arr);
|
|
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
|
-
});
|
|
154
|
-
},
|
|
155
|
-
list_all: async (token) => {
|
|
156
|
-
return new Promise((resolve, reject) => {
|
|
157
|
-
const arr = get_array(type);
|
|
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
|
-
});
|
|
180
|
-
},
|
|
181
|
-
save: async (uuid, data, token) => {
|
|
182
|
-
return new Promise((resolve, reject) => {
|
|
183
|
-
const arr = get_array(type);
|
|
184
|
-
const index = arr.findIndex(x => x.uuid == uuid);
|
|
185
|
-
const exist = index == -1 ? undefined : arr[index];
|
|
186
|
-
if (!exist) {
|
|
187
|
-
arr.push(JSON.parse(data));
|
|
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
|
-
});
|
|
20
|
+
fetch_all: async () => {
|
|
21
|
+
const arr = get_array(type);
|
|
22
|
+
return arr.map(x => JSON.stringify(x));
|
|
219
23
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
});
|
|
24
|
+
load_all: async () => {
|
|
25
|
+
const arr = get_array(type);
|
|
26
|
+
return arr.map(x => JSON.stringify(x));
|
|
256
27
|
},
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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);
|
|
28
|
+
delete_all: async () => {
|
|
29
|
+
const arr = get_array(type);
|
|
30
|
+
const p = arr.splice(0, arr.length);
|
|
31
|
+
return p.map(x => x.uuid);
|
|
320
32
|
},
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
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;
|
|
33
|
+
list_all: async () => {
|
|
34
|
+
const arr = get_array(type);
|
|
35
|
+
return arr.map(x => x.uuid);
|
|
329
36
|
},
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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);
|
|
37
|
+
save: async (uuid, data) => {
|
|
38
|
+
const arr = get_array(type);
|
|
39
|
+
const index = arr.findIndex(x => x.uuid == uuid);
|
|
40
|
+
if (index != -1)
|
|
41
|
+
arr[index] = JSON.parse(data);
|
|
42
|
+
else
|
|
43
|
+
arr.push(JSON.parse(data));
|
|
345
44
|
return true;
|
|
346
45
|
},
|
|
347
|
-
load: async (uuid
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
46
|
+
load: async (uuid) => {
|
|
47
|
+
const arr = get_array(type);
|
|
48
|
+
const p = arr.find(x => x.uuid == uuid);
|
|
49
|
+
if (p == undefined)
|
|
50
|
+
throw new Error("Item do not exists");
|
|
51
|
+
return JSON.stringify(p);
|
|
352
52
|
},
|
|
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
|
-
}
|
|
53
|
+
delete: async (uuid) => {
|
|
54
|
+
const arr = get_array(type);
|
|
55
|
+
const index = arr.findIndex(x => x.uuid == uuid);
|
|
56
|
+
if (index != -1)
|
|
57
|
+
arr.splice(index, 1);
|
|
364
58
|
return true;
|
|
365
59
|
}
|
|
366
60
|
};
|
|
367
61
|
};
|
|
368
|
-
|
|
369
|
-
const CreateRecordMemoryLoader = (loader) => {
|
|
370
|
-
return {
|
|
371
|
-
project: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.PROJECT),
|
|
372
|
-
task: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.TASK),
|
|
373
|
-
job: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.JOB),
|
|
374
|
-
database: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.DATABASE),
|
|
375
|
-
node: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.NODE),
|
|
376
|
-
log: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.LOG),
|
|
377
|
-
lib: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.LIB),
|
|
378
|
-
user: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.USER),
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
exports.CreateRecordMemoryLoader = CreateRecordMemoryLoader;
|
|
382
|
-
const CreateRecordIOLoader = (loader, memory) => {
|
|
62
|
+
const CreateRecordMemoryLoader_Browser = (loader) => {
|
|
383
63
|
return {
|
|
384
|
-
project: (
|
|
385
|
-
task: (
|
|
386
|
-
job: (
|
|
387
|
-
database: (
|
|
388
|
-
node: (
|
|
389
|
-
log: (
|
|
390
|
-
lib: (
|
|
391
|
-
user: (
|
|
64
|
+
project: _CreateRecordMemoryLoader(loader, interface_1.RecordType.PROJECT),
|
|
65
|
+
task: _CreateRecordMemoryLoader(loader, interface_1.RecordType.TASK),
|
|
66
|
+
job: _CreateRecordMemoryLoader(loader, interface_1.RecordType.JOB),
|
|
67
|
+
database: _CreateRecordMemoryLoader(loader, interface_1.RecordType.DATABASE),
|
|
68
|
+
node: _CreateRecordMemoryLoader(loader, interface_1.RecordType.NODE),
|
|
69
|
+
log: _CreateRecordMemoryLoader(loader, interface_1.RecordType.LOG),
|
|
70
|
+
lib: _CreateRecordMemoryLoader(loader, interface_1.RecordType.LIB),
|
|
71
|
+
user: _CreateRecordMemoryLoader(loader, interface_1.RecordType.USER),
|
|
392
72
|
};
|
|
393
73
|
};
|
|
394
|
-
exports.
|
|
74
|
+
exports.CreateRecordMemoryLoader_Browser = CreateRecordMemoryLoader_Browser;
|
package/dist/server/io2.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const _CreateRecordMongoLoader: (loader: MongoClient, memory: MemoryData, type: RecordType, db: string, collection: string) => RecordIOLoader;
|
|
1
|
+
import { MemoryData, RecordIOBase, RecordLoader } from "./io";
|
|
2
|
+
export declare const CreateRecordMemoryLoader: (loader: MemoryData) => RecordLoader;
|
|
3
|
+
export declare const CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData) => RecordLoader;
|
|
5
4
|
export declare const CreateRecordMongoLoader: (url: string, memory: MemoryData) => RecordLoader;
|