This commit is contained in:
Seth Trowbridge 2025-07-03 10:05:26 -04:00
parent 9ca41cb629
commit 297cc5e07d
5 changed files with 8 additions and 11 deletions

8
app.js
View File

@ -35,6 +35,7 @@ const Work = DB({
return ["", workObj]; return ["", workObj];
} }
}); });
/**@type {(work:WorkData)=>void} */ /**@type {(work:WorkData)=>void} */
const WorkMake =(work)=> const WorkMake =(work)=>
{ {
@ -46,10 +47,10 @@ const WorkMake =(work)=>
part.make.forEach(itr); part.make.forEach(itr);
}; };
/** @typedef {"all"|"one"} DeskMode*/ /** @typedef {"all"|"one"} DeskMode*/
/** @typedef {[need:Record<string, number>, make:string[], ...role:string[]]} DeskJSON */ /** @typedef {[need:Record<string, number>, make:string[], ...role:string[]]} DeskJSON */
/** @typedef {{name:string, mode:DeskMode, need:Record<string, number>, make:string[], role:string[]}} DeskData */ /** @typedef {{name:string, mode:DeskMode, need:Record<string, number>, make:string[], role:string[]}} DeskData */
/** @type {(desk:DeskData)=>[dirtyNeed:string[], dirtyMake:string[]]} */ /** @type {(desk:DeskData)=>[dirtyNeed:string[], dirtyMake:string[]]} */
const Scan =(desk)=> const Scan =(desk)=>
{ {
@ -93,14 +94,15 @@ const Scan =(desk)=>
console.log("scan", dirtyNeed, dirtyMake); console.log("scan", dirtyNeed, dirtyMake);
return [dirtyNeed, dirtyMake]; return [dirtyNeed, dirtyMake];
}; };
const Desk = DB({ const Desk = DB({
path:"./db_desk.csv", path:"./db_desk.csv",
cols:4, cols:4,
load(_i, id, name, /** @type {DeskMode}*/mode, data) load(_i, id, name, mode, data)
{ {
/**@type {DeskJSON} */ /**@type {DeskJSON} */
const [need, make, ...role] = JSON.parse(data); const [need, make, ...role] = JSON.parse(data);
const deskObj = { name, mode, need, make, role }; const deskObj = { name, mode:/**@type{DeskMode}*/(mode), need, make, role };
make.forEach(partId=>Part.find(partId).make.push(id)); make.forEach(partId=>Part.find(partId).make.push(id));
Object.keys(need).forEach(partId=>Part.find(partId).need.push(id)); Object.keys(need).forEach(partId=>Part.find(partId).need.push(id));

View File

@ -1 +1 @@
d1,Desk One,all,[{"p1":1, "p2":1},["p3"],"r1"] d1,Desk One,all,[{"p1":1, "p2":1, "p4":0},["p3"],"r1"]

Can't render this file because it contains an unexpected character in line 1 and column 19.

View File

@ -1,3 +1,4 @@
p1,Part 1 p1,Part 1
p2,Part 2 p2,Part 2
p3,Part 3 p3,Part 3
p4,Part Empty

1 p1 Part 1
2 p2 Part 2
3 p3 Part 3
4 p4 Part Empty

1
db_pass.csv Normal file
View File

@ -0,0 +1 @@
August 2025,./db_part.csv,./db_work.csv,./db_desk.csv
1 August 2025 ./db_part.csv ./db_work.csv ./db_desk.csv

View File

@ -1,7 +0,0 @@
{
"p1":{
"u1":{
"1":{"key1": "value1", "key2": "value2"}
}
}
}