UNPKG

@viewdo/dxp-story-cli

Version:
50 lines (38 loc) 898 B
const JSONFile = require('./json-file') module.exports = class OrganizationConfig { constructor(organization_key, output = '.', file_service) { let root = [output, 'organizations', organization_key].join('/') Object.assign(this, { output, root, key: organization_key, file: new JSONFile(`${root}/organization-config.json`, file_service) } ) let config = this.file.read() if(config) Object.assign(this, config) } save(organization) { // mapping from the domain-model let { key, name, dataPoints, entities } = organization let config = { kind: 'Organization', apiVersion: 'api.view.do/v1', key, name, dataPoints, entities, updated: new Date() } Object.assign(this, config) this.file.write(config) return this } }