verteilen-core 1.3.7 → 1.3.8
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.
|
@@ -11,6 +11,9 @@ export declare class Project_Module {
|
|
|
11
11
|
PopulateTask(uuid: string): Task | undefined;
|
|
12
12
|
GetProjectRelatedTask(uuid: string): Array<Task>;
|
|
13
13
|
GetTaskRelatedJob(uuid: string): Array<Job>;
|
|
14
|
+
CloneProjects(uuids: Array<string>): Promise<Array<string>>;
|
|
15
|
+
CloneTasks(uuids: Array<string>): Promise<Array<string>>;
|
|
16
|
+
CloneJobs(uuids: Array<string>): Promise<Array<string>>;
|
|
14
17
|
CascadeDeleteProject(uuid: string, bind: boolean): void;
|
|
15
18
|
CascadeDeleteTask(uuid: string): void;
|
|
16
19
|
Delete_Database_Idle(uuid: string): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Project_Module = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
4
5
|
class Project_Module {
|
|
5
6
|
server;
|
|
6
7
|
constructor(memory) {
|
|
@@ -60,6 +61,43 @@ class Project_Module {
|
|
|
60
61
|
}).filter(x => x != undefined);
|
|
61
62
|
return r;
|
|
62
63
|
}
|
|
64
|
+
async CloneProjects(uuids) {
|
|
65
|
+
const p = uuids.map(x => this.loader.project.load(x, true));
|
|
66
|
+
const ps = await Promise.all(p);
|
|
67
|
+
const projects = ps.map(x => JSON.parse(x));
|
|
68
|
+
projects.forEach(x => x.uuid = (0, uuid_1.v6)());
|
|
69
|
+
const jus = projects.map(x => this.CloneTasks(x.tasks_uuid));
|
|
70
|
+
const ju = await Promise.all(jus);
|
|
71
|
+
projects.forEach((t, index) => {
|
|
72
|
+
t.tasks_uuid = ju[index];
|
|
73
|
+
});
|
|
74
|
+
const js = projects.map(x => this.loader.project.save(x.uuid, JSON.stringify(x)));
|
|
75
|
+
await Promise.all(js);
|
|
76
|
+
return projects.map(x => x.uuid);
|
|
77
|
+
}
|
|
78
|
+
async CloneTasks(uuids) {
|
|
79
|
+
const p = uuids.map(x => this.loader.task.load(x, true));
|
|
80
|
+
const ps = await Promise.all(p);
|
|
81
|
+
const tasks = ps.map(x => JSON.parse(x));
|
|
82
|
+
tasks.forEach(x => x.uuid = (0, uuid_1.v6)());
|
|
83
|
+
const jus = tasks.map(x => this.CloneJobs(x.jobs_uuid));
|
|
84
|
+
const ju = await Promise.all(jus);
|
|
85
|
+
tasks.forEach((t, index) => {
|
|
86
|
+
t.jobs_uuid = ju[index];
|
|
87
|
+
});
|
|
88
|
+
const js = tasks.map(x => this.loader.task.save(x.uuid, JSON.stringify(x)));
|
|
89
|
+
await Promise.all(js);
|
|
90
|
+
return tasks.map(x => x.uuid);
|
|
91
|
+
}
|
|
92
|
+
async CloneJobs(uuids) {
|
|
93
|
+
const p = uuids.map(x => this.loader.job.load(x, true));
|
|
94
|
+
const ps = await Promise.all(p);
|
|
95
|
+
const jobs = ps.map(x => JSON.parse(x));
|
|
96
|
+
jobs.forEach(x => x.uuid = (0, uuid_1.v6)());
|
|
97
|
+
const js = jobs.map(x => this.loader.job.save(x.uuid, JSON.stringify(x)));
|
|
98
|
+
await Promise.all(js);
|
|
99
|
+
return jobs.map(x => x.uuid);
|
|
100
|
+
}
|
|
63
101
|
CascadeDeleteProject(uuid, bind) {
|
|
64
102
|
const p = this.memory.projects.find(p => p.uuid == uuid);
|
|
65
103
|
if (!p)
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { Job, Project, Task } from "../../interface"
|
|
7
7
|
import { MemoryData, RecordLoader } from "../io"
|
|
8
8
|
import { Server } from "../server"
|
|
9
|
+
import { v6 as uuidv6 } from 'uuid'
|
|
9
10
|
|
|
10
11
|
export class Project_Module {
|
|
11
12
|
server:Server
|
|
@@ -81,6 +82,58 @@ export class Project_Module {
|
|
|
81
82
|
}).filter(x => x != undefined)
|
|
82
83
|
return r
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Clone Project Container
|
|
87
|
+
* @param uuids project uuids
|
|
88
|
+
* @returns The new uuids list
|
|
89
|
+
*/
|
|
90
|
+
async CloneProjects(uuids:Array<string>):Promise<Array<string>>{
|
|
91
|
+
const p = uuids.map(x => this.loader.project.load(x, true))
|
|
92
|
+
const ps = await Promise.all(p)
|
|
93
|
+
const projects:Array<Project> = ps.map(x => JSON.parse(x))
|
|
94
|
+
projects.forEach(x => x.uuid = uuidv6())
|
|
95
|
+
const jus = projects.map(x => this.CloneTasks(x.tasks_uuid))
|
|
96
|
+
const ju = await Promise.all(jus)
|
|
97
|
+
projects.forEach((t, index) => {
|
|
98
|
+
t.tasks_uuid = ju[index]
|
|
99
|
+
})
|
|
100
|
+
const js = projects.map(x => this.loader.project.save(x.uuid, JSON.stringify(x)))
|
|
101
|
+
await Promise.all(js)
|
|
102
|
+
return projects.map(x => x.uuid)
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Clone Task Container
|
|
106
|
+
* @param uuids task uuids
|
|
107
|
+
* @returns The new uuids list
|
|
108
|
+
*/
|
|
109
|
+
async CloneTasks(uuids:Array<string>):Promise<Array<string>>{
|
|
110
|
+
const p = uuids.map(x => this.loader.task.load(x, true))
|
|
111
|
+
const ps = await Promise.all(p)
|
|
112
|
+
const tasks:Array<Task> = ps.map(x => JSON.parse(x))
|
|
113
|
+
tasks.forEach(x => x.uuid = uuidv6())
|
|
114
|
+
const jus = tasks.map(x => this.CloneJobs(x.jobs_uuid))
|
|
115
|
+
const ju = await Promise.all(jus)
|
|
116
|
+
tasks.forEach((t, index) => {
|
|
117
|
+
t.jobs_uuid = ju[index]
|
|
118
|
+
})
|
|
119
|
+
const js = tasks.map(x => this.loader.task.save(x.uuid, JSON.stringify(x)))
|
|
120
|
+
await Promise.all(js)
|
|
121
|
+
return tasks.map(x => x.uuid)
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clone Job Container
|
|
125
|
+
* @param uuids job uuids
|
|
126
|
+
* @returns The new uuids list
|
|
127
|
+
*/
|
|
128
|
+
async CloneJobs(uuids:Array<string>):Promise<Array<string>>{
|
|
129
|
+
const p = uuids.map(x => this.loader.job.load(x, true))
|
|
130
|
+
const ps = await Promise.all(p)
|
|
131
|
+
const jobs:Array<Job> = ps.map(x => JSON.parse(x))
|
|
132
|
+
jobs.forEach(x => x.uuid = uuidv6())
|
|
133
|
+
const js = jobs.map(x => this.loader.job.save(x.uuid, JSON.stringify(x)))
|
|
134
|
+
await Promise.all(js)
|
|
135
|
+
return jobs.map(x => x.uuid)
|
|
136
|
+
}
|
|
84
137
|
/**
|
|
85
138
|
* Delete project related data and project itself
|
|
86
139
|
* @param uuid Project UUID
|