mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 21:08:33 +03:00
Add blueprinterWithSchema exporter
This commit is contained in:
@@ -2,7 +2,7 @@ import path from 'path'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import R from 'ramda'
|
import R from 'ramda'
|
||||||
|
|
||||||
export const defaultBlueprint = {
|
const defaultBlueprint = {
|
||||||
name: null,
|
name: null,
|
||||||
sheet: {
|
sheet: {
|
||||||
name: null,
|
name: null,
|
||||||
@@ -11,11 +11,11 @@ export const defaultBlueprint = {
|
|||||||
resources: {}
|
resources: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultResource = {
|
const defaultResource = {
|
||||||
data: []
|
data: []
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildDesaturated (sheetId, sheetName, tab, resources) {
|
function buildDesaturated (sheetId, sheetName, tab, resources) {
|
||||||
const bp = R.clone(defaultBlueprint)
|
const bp = R.clone(defaultBlueprint)
|
||||||
bp.sheet.name = sheetName
|
bp.sheet.name = sheetName
|
||||||
bp.sheet.id = sheetId
|
bp.sheet.id = sheetId
|
||||||
@@ -50,10 +50,22 @@ fs.readdirSync(normalizedPath).forEach(file => {
|
|||||||
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function transformerFromSchema (datafierName, schema) {
|
||||||
|
// TODO: enact schema
|
||||||
|
const datafier = data => data
|
||||||
|
|
||||||
|
return buildBlueprinter(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
|
||||||
// each file in blueprinters folder available for granular import from here.
|
// each file in blueprinters folder available for granular import from here.
|
||||||
module.exports = Object.assign({
|
module.exports = Object.assign({
|
||||||
defaultBlueprint,
|
defaultBlueprint,
|
||||||
defaultResource,
|
defaultResource,
|
||||||
buildDesaturated
|
buildDesaturated,
|
||||||
|
blueprinterWithSchema
|
||||||
}, allBps)
|
}, allBps)
|
||||||
|
|||||||
Reference in New Issue
Block a user