|
|
|
@ -5,7 +5,7 @@ const dlayer = require("..");
|
|
|
|
|
const syncpipe = require("syncpipe");
|
|
|
|
|
|
|
|
|
|
let fakeDriveTree = {
|
|
|
|
|
one: [ "/dev/1a", "/dev/1b" ],
|
|
|
|
|
one: [ "/dev/1a", "/dev/1b", "INVALID" ],
|
|
|
|
|
two: [ "/dev/2a" ]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -53,7 +53,8 @@ let moduleDrives = {
|
|
|
|
|
_ => (names != null)
|
|
|
|
|
? _.filter(([ name, _devices ]) => names.includes(name))
|
|
|
|
|
: _,
|
|
|
|
|
_ => _.map(([ name, _devices ]) => $make("sysquery.core.Drive", { name }))
|
|
|
|
|
_ => _.map(([ name, _devices ]) => $make("sysquery.core.Drive", { name })),
|
|
|
|
|
_ => Promise.all(_)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -68,14 +69,19 @@ let moduleDrives = {
|
|
|
|
|
let moduleBlockDevices = {
|
|
|
|
|
name: "Block Devices",
|
|
|
|
|
types: {
|
|
|
|
|
"sysquery.core.BlockDevice": function ({ path }) {
|
|
|
|
|
return {
|
|
|
|
|
path: path,
|
|
|
|
|
testContext: function (_, { counter }) {
|
|
|
|
|
console.log(`[context ${counter}] BlockDevice::testContext`);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
"sysquery.core.BlockDevice": async function ({ path }) {
|
|
|
|
|
if (path === "INVALID") {
|
|
|
|
|
// Simulating an async type creation function that 'detects validity' of a specified path
|
|
|
|
|
return dlayer.InvalidObject;
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
path: path,
|
|
|
|
|
testContext: function (_, { counter }) {
|
|
|
|
|
console.log(`[context ${counter}] BlockDevice::testContext`);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
extensions: {
|
|
|
|
@ -83,7 +89,9 @@ let moduleBlockDevices = {
|
|
|
|
|
blockDevices: async function (_, { counter, $getProperty, $make }) {
|
|
|
|
|
console.log(`[context ${counter}] Drive::blockDevices`);
|
|
|
|
|
|
|
|
|
|
return fakeDriveTree[await $getProperty(this, "name")].map((path) => {
|
|
|
|
|
let root = fakeDriveTree[await $getProperty(this, "name")];
|
|
|
|
|
|
|
|
|
|
return Promise.map(root, (path) => {
|
|
|
|
|
return $make("sysquery.core.BlockDevice", { path });
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -100,7 +108,8 @@ let moduleBlockDevices = {
|
|
|
|
|
_ => (paths != null)
|
|
|
|
|
? _.filter((path) => paths.includes(path))
|
|
|
|
|
: _,
|
|
|
|
|
_ => _.map((path) => $make("sysquery.core.BlockDevice", { path }))
|
|
|
|
|
_ => _.map((path) => $make("sysquery.core.BlockDevice", { path })),
|
|
|
|
|
_ => Promise.all(_)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|