mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-12 21:38:32 +03:00
export as deeprowsWithSchema
This commit is contained in:
@@ -50,15 +50,18 @@ fs.readdirSync(normalizedPath).forEach(file => {
|
|||||||
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
||||||
})
|
})
|
||||||
|
|
||||||
function transformerFromSchema (datafierName, schema) {
|
function deeprowsWithSchema (datafierName, schema) {
|
||||||
// TODO: enact schema
|
const datafier = data => {
|
||||||
const datafier = data => data
|
const transformedData = allBps.deeprows('', '', '', data).resources.deeprows.data
|
||||||
|
return transformedData.map(row => {
|
||||||
|
Object.keys(schema).forEach(key => {
|
||||||
|
row[key] = schema[key](row[key])
|
||||||
|
})
|
||||||
|
return row
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return buildBlueprinter(datafierName, datafier)
|
return buildBlueprinter(`deeprows_${datafierName}`, datafier)
|
||||||
}
|
|
||||||
|
|
||||||
function blueprinterWithSchema (name, blueprinter, schema) {
|
|
||||||
return transformerFromSchema(name, schema)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: revert to ES5 'module.exports' required to make blueprinters from
|
// NB: revert to ES5 'module.exports' required to make blueprinters from
|
||||||
@@ -67,5 +70,5 @@ module.exports = Object.assign({
|
|||||||
defaultBlueprint,
|
defaultBlueprint,
|
||||||
defaultResource,
|
defaultResource,
|
||||||
buildDesaturated,
|
buildDesaturated,
|
||||||
blueprinterWithSchema
|
deeprowsWithSchema
|
||||||
}, allBps)
|
}, allBps)
|
||||||
|
|||||||
Reference in New Issue
Block a user