verteilen-core 1.3.11 → 1.3.13

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/server/io.js CHANGED
@@ -96,56 +96,56 @@ const _CreateRecordIOLoader = (loader, memory, type, folder, ext = ".json") => {
96
96
  await loader.mkdir(root);
97
97
  return loader.read_dir_file(root);
98
98
  },
99
- save: async (name, data) => {
99
+ save: async (uuid, data) => {
100
100
  const root = loader.join(loader.root, folder);
101
101
  if (!loader.exists(root))
102
102
  await loader.mkdir(root);
103
- const file = loader.join(root, name + ext);
103
+ const file = loader.join(root, uuid + ext);
104
104
  await loader.write_string(file, data);
105
105
  const arr = get_array(type);
106
- const b = arr.findIndex(x => x.uuid == name);
106
+ const b = arr.findIndex(x => x.uuid == uuid);
107
107
  if (b != -1)
108
108
  arr.push(JSON.parse(data));
109
109
  else
110
110
  arr[b] = JSON.parse(data);
111
111
  },
112
- load: async (name, cache) => {
112
+ load: async (uuid, cache) => {
113
113
  const arr = get_array(type);
114
114
  if (cache) {
115
- const b = arr.findIndex(x => x.uuid == name);
115
+ const b = arr.findIndex(x => x.uuid == uuid);
116
116
  if (b != -1)
117
117
  return JSON.stringify(arr[b]);
118
118
  }
119
119
  const root = loader.join(loader.root, folder);
120
120
  if (!loader.exists(root))
121
121
  await loader.mkdir(root);
122
- const file = loader.join(root, name + ext);
122
+ const file = loader.join(root, uuid + ext);
123
123
  const a = await loader.read_string(file);
124
124
  if (cache)
125
125
  arr.push(JSON.parse(a));
126
126
  return a;
127
127
  },
128
- rename: async (name, newname) => {
128
+ rename: async (uuid, newuuid) => {
129
129
  const root = loader.join(loader.root, folder);
130
130
  if (!loader.exists(root))
131
131
  await loader.mkdir(root);
132
- const oldfile = loader.join(root, name + ext);
133
- const newfile = loader.join(root, newname + ext);
132
+ const oldfile = loader.join(root, uuid + ext);
133
+ const newfile = loader.join(root, newuuid + ext);
134
134
  await loader.cp(oldfile, newfile);
135
135
  await loader.rm(oldfile);
136
136
  const arr = get_array(type);
137
- const b = arr.findIndex(x => x.uuid == name);
137
+ const b = arr.findIndex(x => x.uuid == uuid);
138
138
  if (b != -1)
139
- arr[b].uuid = newname;
139
+ arr[b].uuid = newuuid;
140
140
  },
141
- delete: async (name) => {
141
+ delete: async (uuid) => {
142
142
  const root = loader.join(loader.root, folder);
143
143
  if (!loader.exists(root))
144
144
  await loader.mkdir(root);
145
- const file = loader.join(root, name + ext);
145
+ const file = loader.join(root, uuid + ext);
146
146
  await loader.rm(file);
147
147
  const arr = get_array(type);
148
- const b = arr.findIndex(x => x.uuid == name);
148
+ const b = arr.findIndex(x => x.uuid == uuid);
149
149
  if (b != -1)
150
150
  arr.splice(b, 1);
151
151
  }
@@ -52,7 +52,7 @@ class Project_Module {
52
52
  return this.loader.task.load(x, true);
53
53
  });
54
54
  await Promise.all(r);
55
- const tasks = this.memory.tasks.filter(x => p.tasks_uuid.includes(x.uuid));
55
+ const tasks = p.tasks_uuid.map(x => this.memory.tasks.find(y => y.uuid == x)).filter(x => x != undefined);
56
56
  return tasks;
57
57
  }
58
58
  async GetTaskRelatedJob(uuid) {
@@ -64,14 +64,14 @@ class Project_Module {
64
64
  return this.loader.job.load(x, true);
65
65
  });
66
66
  await Promise.all(r);
67
- const jobs = this.memory.jobs.filter(x => p.jobs_uuid.includes(x.uuid));
67
+ const jobs = p.jobs_uuid.map(x => this.memory.jobs.find(y => y.uuid == x)).filter(x => x != undefined);
68
68
  return jobs;
69
69
  }
70
70
  async CloneProjects(uuids) {
71
71
  const p = uuids.map(x => this.loader.project.load(x, true));
72
72
  const ps = await Promise.all(p);
73
73
  const projects = ps.map(x => JSON.parse(x));
74
- projects.forEach(x => x.uuid = (0, uuid_1.v6)());
74
+ projects.forEach((x, i) => x.uuid = (0, uuid_1.v6)({}, undefined, i));
75
75
  const jus = projects.map(x => this.CloneTasks(x.tasks_uuid));
76
76
  const ju = await Promise.all(jus);
77
77
  projects.forEach((t, index) => {
@@ -85,7 +85,7 @@ class Project_Module {
85
85
  const p = uuids.map(x => this.loader.task.load(x, true));
86
86
  const ps = await Promise.all(p);
87
87
  const tasks = ps.map(x => JSON.parse(x));
88
- tasks.forEach(x => x.uuid = (0, uuid_1.v6)());
88
+ tasks.forEach((x, i) => x.uuid = (0, uuid_1.v6)({}, undefined, 2500 + i));
89
89
  const jus = tasks.map(x => this.CloneJobs(x.jobs_uuid));
90
90
  const ju = await Promise.all(jus);
91
91
  tasks.forEach((t, index) => {
@@ -99,7 +99,7 @@ class Project_Module {
99
99
  const p = uuids.map(x => this.loader.job.load(x, true));
100
100
  const ps = await Promise.all(p);
101
101
  const jobs = ps.map(x => JSON.parse(x));
102
- jobs.forEach(x => x.uuid = (0, uuid_1.v6)());
102
+ jobs.forEach((x, i) => x.uuid = (0, uuid_1.v6)({}, undefined, 5000 + i));
103
103
  const js = jobs.map(x => this.loader.job.save(x.uuid, JSON.stringify(x)));
104
104
  await Promise.all(js);
105
105
  return jobs.map(x => x.uuid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verteilen-core",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "license": "MIT",
5
5
  "homepage": "https://verteilen.github.io/wiki/",
6
6
  "author": "Elly",
package/src/server/io.ts CHANGED
@@ -181,47 +181,47 @@ export const _CreateRecordIOLoader = (loader:RecordIOBase, memory:MemoryData, ty
181
181
  if(!loader.exists(root)) await loader.mkdir(root)
182
182
  return loader.read_dir_file(root)
183
183
  },
184
- save: async (name:string, data:string):Promise<void> => {
184
+ save: async (uuid:string, data:string):Promise<void> => {
185
185
  const root = loader.join(loader.root, folder)
186
186
  if(!loader.exists(root)) await loader.mkdir(root)
187
- const file = loader.join(root, name + ext)
187
+ const file = loader.join(root, uuid + ext)
188
188
  await loader.write_string(file, data)
189
189
  const arr = get_array(type)
190
- const b = arr.findIndex(x => x.uuid == name)
190
+ const b = arr.findIndex(x => x.uuid == uuid)
191
191
  if(b != -1) arr.push(JSON.parse(data))
192
192
  else arr[b] = JSON.parse(data)
193
193
  },
194
- load: async (name:string, cache: boolean):Promise<string> => {
195
- const arr = get_array(type)
194
+ load: async (uuid:string, cache: boolean):Promise<string> => {
195
+ const arr:Array<any> = get_array(type)
196
196
  if(cache){
197
- const b = arr.findIndex(x => x.uuid == name)
197
+ const b = arr.findIndex(x => x.uuid == uuid)
198
198
  if(b != -1) return JSON.stringify(arr[b])
199
199
  }
200
200
  const root = loader.join(loader.root, folder)
201
201
  if(!loader.exists(root)) await loader.mkdir(root)
202
- const file = loader.join(root, name + ext)
202
+ const file = loader.join(root, uuid + ext)
203
203
  const a = await loader.read_string(file)
204
204
  if(cache) arr.push(JSON.parse(a))
205
205
  return a
206
206
  },
207
- rename: async (name:string, newname:string):Promise<void> => {
207
+ rename: async (uuid:string, newuuid:string):Promise<void> => {
208
208
  const root = loader.join(loader.root, folder)
209
209
  if(!loader.exists(root)) await loader.mkdir(root)
210
- const oldfile = loader.join(root, name + ext)
211
- const newfile = loader.join(root, newname + ext)
210
+ const oldfile = loader.join(root, uuid + ext)
211
+ const newfile = loader.join(root, newuuid + ext)
212
212
  await loader.cp(oldfile, newfile)
213
213
  await loader.rm(oldfile)
214
214
  const arr = get_array(type)
215
- const b = arr.findIndex(x => x.uuid == name)
216
- if(b != -1) arr[b].uuid = newname
215
+ const b = arr.findIndex(x => x.uuid == uuid)
216
+ if(b != -1) arr[b].uuid = newuuid
217
217
  },
218
- delete: async (name:string):Promise<void> => {
218
+ delete: async (uuid:string):Promise<void> => {
219
219
  const root = loader.join(loader.root, folder)
220
220
  if(!loader.exists(root)) await loader.mkdir(root)
221
- const file = loader.join(root, name + ext)
221
+ const file = loader.join(root, uuid + ext)
222
222
  await loader.rm(file)
223
223
  const arr = get_array(type)
224
- const b = arr.findIndex(x => x.uuid == name)
224
+ const b = arr.findIndex(x => x.uuid == uuid)
225
225
  if(b != -1) arr.splice(b, 1)
226
226
  }
227
227
  }
@@ -69,7 +69,7 @@ export class Project_Module {
69
69
  return this.loader.task.load(x, true)
70
70
  })
71
71
  await Promise.all(r)
72
- const tasks = this.memory.tasks.filter(x => p.tasks_uuid.includes(x.uuid))
72
+ const tasks = p.tasks_uuid.map(x => this.memory.tasks.find(y => y.uuid == x)).filter(x => x != undefined)
73
73
  return tasks
74
74
  }
75
75
  /**
@@ -85,7 +85,7 @@ export class Project_Module {
85
85
  return this.loader.job.load(x, true)
86
86
  })
87
87
  await Promise.all(r)
88
- const jobs = this.memory.jobs.filter(x => p.jobs_uuid.includes(x.uuid))
88
+ const jobs = p.jobs_uuid.map(x => this.memory.jobs.find(y => y.uuid == x)).filter(x => x != undefined)
89
89
  return jobs
90
90
  }
91
91
  /**
@@ -97,7 +97,7 @@ export class Project_Module {
97
97
  const p = uuids.map(x => this.loader.project.load(x, true))
98
98
  const ps = await Promise.all(p)
99
99
  const projects:Array<Project> = ps.map(x => JSON.parse(x))
100
- projects.forEach(x => x.uuid = uuidv6())
100
+ projects.forEach((x, i) => x.uuid = uuidv6({}, undefined, i))
101
101
  const jus = projects.map(x => this.CloneTasks(x.tasks_uuid))
102
102
  const ju = await Promise.all(jus)
103
103
  projects.forEach((t, index) => {
@@ -116,7 +116,7 @@ export class Project_Module {
116
116
  const p = uuids.map(x => this.loader.task.load(x, true))
117
117
  const ps = await Promise.all(p)
118
118
  const tasks:Array<Task> = ps.map(x => JSON.parse(x))
119
- tasks.forEach(x => x.uuid = uuidv6())
119
+ tasks.forEach((x, i) => x.uuid = uuidv6({}, undefined, 2500 + i))
120
120
  const jus = tasks.map(x => this.CloneJobs(x.jobs_uuid))
121
121
  const ju = await Promise.all(jus)
122
122
  tasks.forEach((t, index) => {
@@ -135,7 +135,7 @@ export class Project_Module {
135
135
  const p = uuids.map(x => this.loader.job.load(x, true))
136
136
  const ps = await Promise.all(p)
137
137
  const jobs:Array<Job> = ps.map(x => JSON.parse(x))
138
- jobs.forEach(x => x.uuid = uuidv6())
138
+ jobs.forEach((x, i) => x.uuid = uuidv6({}, undefined, 5000 + i))
139
139
  const js = jobs.map(x => this.loader.job.save(x.uuid, JSON.stringify(x)))
140
140
  await Promise.all(js)
141
141
  return jobs.map(x => x.uuid)