Commit 07d27835 authored by A. Koch's avatar A. Koch

update generic api, update import script

parent cc91d4cf
const
Acl = require('acl'),
Backend = Acl.mongodbBackend,
MongoClient = require('mongodb').MongoClient,
path = require('path'),
fs = require('mz/fs'),
{ MongoDB } = require('mbjs-persistence'),
......@@ -29,6 +32,7 @@ const proc = async function (folder) {
await mapsClient.connect()
const maps = await fs.readdir(path.join(folder, 'maps'))
for (let m of maps) {
if (m[0] === '.') continue
const file = await fs.readFile(path.join(folder, 'maps', m))
const entry = JSON.parse(file)
await mapsClient.create(updateAuthor(entry))
......@@ -42,11 +46,38 @@ const proc = async function (folder) {
await annoClient.connect()
const annos = await fs.readdir(path.join(folder, 'annotations'))
for (let a of annos) {
if (a[0] === '.') continue
const file = await fs.readFile(path.join(folder, 'annotations', a))
const entry = JSON.parse(file)
await annoClient.create(updateAuthor(entry))
}
const cfg = config.get('acl.mongodb')
cfg.logger = console
const db = await new Promise((resolve, reject) => {
MongoClient.connect(cfg.url, function (err, client) {
if (err) return reject(err)
cfg.logger.info(`ACL connected at ${cfg.url}/${cfg.dbName}`)
const db = client.db(cfg.dbName)
resolve(db)
})
})
const acl = new Acl(new Backend(db))
const acls = await fs.readdir(path.join(folder, 'acl'))
for (let a of acls) {
if (a[0] === '.') continue
const file = await fs.readFile(path.join(folder, 'acl', a))
const entry = JSON.parse(file)
await new Promise((resolve, reject) => {
const resource = a.replace('.json', '')
acl.allow(entry.role, resource, entry.permissions, err => {
if (err) reject(err)
else resolve()
})
})
}
}
proc(folder)
.then(() => process.exit(0))
proc(folder).then(() => process.exit(0))
......@@ -182,9 +182,9 @@
"integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA=="
},
"@types/node": {
"version": "10.9.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.3.tgz",
"integrity": "sha512-DOzWZKUnmFYG0KUOs+9HEBju2QhBU6oM2zeluunQNt0vnJvnkHvtDNlQPZDkTrkC5pZrNx1TPqeL137zciXZMQ=="
"version": "10.11.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.6.tgz",
"integrity": "sha512-fnA7yvqg3oKQDb3skBif9w5RRKVKAaeKeNuLzZL37XcSiWL4IoSXQnnbchR3UnBu2EMLHBip7ZVEkqoIVBP8QQ=="
},
"@types/range-parser": {
"version": "1.2.2",
......@@ -208,16 +208,6 @@
"millisecond": "~0.1.2",
"setheader": "~1.0.0",
"vary": "~1.1.0"
},
"dependencies": {
"setheader": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/setheader/-/setheader-1.0.1.tgz",
"integrity": "sha512-iNDik8ipRBZHfpbpdWlhfZxc0JM9Cg4NYo8jqBkjSRLPxvcgnrE9oiF3AhpFvypg2erVyWNS+QhykhQt0G9tpA==",
"requires": {
"diagnostics": "1.x.x"
}
}
}
},
"acl": {
......@@ -524,18 +514,11 @@
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"basic-auth": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz",
"integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
"requires": {
"safe-buffer": "5.1.1"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
}
"safe-buffer": "5.1.2"
}
},
"bcrypt-pbkdf": {
......@@ -1067,9 +1050,9 @@
}
},
"env-variable": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.4.tgz",
"integrity": "sha512-+jpGxSWG4vr6gVxUHOc4p+ilPnql7NzZxOZBxNldsKGjCF+97df3CbuX7XMaDa5oAVkKQj4rKp38rYdC4VcpDg=="
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz",
"integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA=="
},
"error-ex": {
"version": "1.3.2",
......@@ -1082,7 +1065,7 @@
},
"es6-promise": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
},
"escape-string-regexp": {
......@@ -1341,7 +1324,7 @@
"dependencies": {
"async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
}
}
......@@ -1633,7 +1616,7 @@
},
"http-errors": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
"requires": {
"depd": "~1.1.2",
......@@ -2015,9 +1998,9 @@
}
},
"kuler": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.0.tgz",
"integrity": "sha512-oyy6pu/yWRjiVfCoJebNUKFL061sNtrs9ejKTbirIwY3oiHmENVCSkHhxDV85Dkm7JYR/czMCBeoM87WilTdSg==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz",
"integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==",
"requires": {
"colornames": "^1.1.1"
}
......@@ -2134,9 +2117,9 @@
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM="
},
"logform": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/logform/-/logform-1.9.1.tgz",
"integrity": "sha512-ZHrZE8VSf7K3xKxJiQ1aoTBp2yK+cEbFcgarsjzI3nt3nE/3O0heNSppoOQMUJVMZo/xiVwCxiXIabaZApsKNQ==",
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/logform/-/logform-1.10.0.tgz",
"integrity": "sha512-em5ojIhU18fIMOw/333mD+ZLE2fis0EzXl1ZwHx4iQzmpQi6odNiY/t+ITNr33JZhT9/KEaH+UPIipr6a9EjWg==",
"requires": {
"colors": "^1.2.1",
"fast-safe-stringify": "^2.0.4",
......@@ -2222,9 +2205,9 @@
}
},
"mbjs-generic-api": {
"version": "0.0.15",
"resolved": "https://registry.npmjs.org/mbjs-generic-api/-/mbjs-generic-api-0.0.15.tgz",
"integrity": "sha512-TrVIXVPxAtK8cb6ysDTnpiY5sR05bfJGAQtDxBxl4YfIDchK3z7dQWEyd/KTPU+jXvv+/WDAejAROCuyL94o2w==",
"version": "0.0.16",
"resolved": "https://registry.npmjs.org/mbjs-generic-api/-/mbjs-generic-api-0.0.16.tgz",
"integrity": "sha512-dwA1tRE8eDN+HhY+BNZuC72lZYF1gEHL5VEhTK/NXnpymbVqUxBlKJ020gb+OLm6d3AReWiqFn62VC5Z7XxnoQ==",
"requires": {
"@polka/send-type": "^0.4.0",
"acl": "^0.4.11",
......@@ -2440,13 +2423,13 @@
}
},
"morgan": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz",
"integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
"integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==",
"requires": {
"basic-auth": "~2.0.0",
"debug": "2.6.9",
"depd": "~1.1.1",
"depd": "~1.1.2",
"on-finished": "~2.3.0",
"on-headers": "~1.0.1"
},
......@@ -2510,9 +2493,9 @@
"integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw=="
},
"nanoid": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.0.7.tgz",
"integrity": "sha512-DCTnU68QAckm8vgPbFhM1XcK3/zX8LWL4/kEXzPH5w2qy2ibBWHig+685aF8ff8rd5lUXkhVB3W60pb4mbRcDA=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.2.6.tgz",
"integrity": "sha512-um9vXiM407BaRbBNa0aKPzFBSD2fDbVmmA9TzCWWlxZvEBzTbixM7ss6GDS4G/cNMYeZSNFx5SzAgWoG1uHU9g=="
},
"natural-compare": {
"version": "1.4.0",
......@@ -2764,9 +2747,9 @@
"dev": true
},
"primus": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/primus/-/primus-7.2.2.tgz",
"integrity": "sha512-OrF2NgVpTB6ioWbJaBjA93NCrhPJM3rKFGB45LmKEYOFFc4/iG/xATmwMMKhQJuOi7JYv62tJ4l+VsJsb9nZ4g==",
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/primus/-/primus-7.2.3.tgz",
"integrity": "sha512-GDfNu0hkRzoy9auyYnIGxfX81Q1c91IQ9jdu0lqPOLNiC9OvtrPYcgx9YndkcE7eKG7N7tHq69vh0BlE+y6mxQ==",
"requires": {
"access-control": "~1.0.0",
"asyncemit": "~3.0.1",
......@@ -2775,8 +2758,8 @@
"eventemitter3": "~3.1.0",
"forwarded-for": "~1.0.1",
"fusing": "~1.0.0",
"nanoid": "~1.0.2",
"setheader": "~0.0.4",
"nanoid": "~1.2.0",
"setheader": "~1.0.0",
"ultron": "~1.1.0"
}
},
......@@ -2792,9 +2775,9 @@
"dev": true
},
"prom-client": {
"version": "11.1.1",
"resolved": "https://registry.npmjs.org/prom-client/-/prom-client-11.1.1.tgz",
"integrity": "sha512-itUicyrq3Rko56v3ovQAMYwxEouK7lIylp26bjnlt1b/3fzn783riZnZn432I4udYmPsRgNx1F/u9RFvLyH7zA==",
"version": "11.1.3",
"resolved": "https://registry.npmjs.org/prom-client/-/prom-client-11.1.3.tgz",
"integrity": "sha512-vpEQ8NltXq+lrtOYvPEoX+kvN4FG3LrIfa0/eVE8sfePDIprhV/RY7EX8u14EN4KWNjO9O70b9mNLHglSt1rzQ==",
"requires": {
"tdigest": "^0.1.1"
}
......@@ -2815,21 +2798,21 @@
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"raven": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/raven/-/raven-2.6.3.tgz",
"integrity": "sha512-bKre7qlDW+y1+G2bUtCuntdDYc8o5v1T233t0vmJfbj8ttGOgLrGRlYB8saelVMW9KUAJNLrhFkAKOwFWFJonw==",
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/raven/-/raven-2.6.4.tgz",
"integrity": "sha512-6PQdfC4+DQSFncowthLf+B6Hr0JpPsFBgTVYTAOq7tCmx/kR4SXbeawtPch20+3QfUcQDoJBLjWW1ybvZ4kXTw==",
"requires": {
"cookie": "0.3.1",
"md5": "^2.2.1",
"stack-trace": "0.0.10",
"timed-out": "4.0.1",
"uuid": "3.0.0"
"uuid": "3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.0.tgz",
"integrity": "sha1-Zyj8BFnEUNeWqZwxg3VpvfZy1yg="
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
}
}
},
......@@ -2912,9 +2895,9 @@
}
},
"redis-commands": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.5.tgz",
"integrity": "sha512-foGF8u6MXGFF++1TZVC6icGXuMYPftKXt1FBT2vrfU9ZATNtZJ8duRC5d1lEfE8hyVe3jhelHGB91oB7I6qLsA=="
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz",
"integrity": "sha512-cu8EF+MtkwI4DLIT0x9P8qNTLFhQD4jLfxLR0cCNkeGzs87FN6879JOJwNQR/1zD7aSYNbU0hgsV9zGY71Itvw=="
},
"redis-parser": {
"version": "2.6.0",
......@@ -3116,18 +3099,11 @@
}
},
"setheader": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/setheader/-/setheader-0.0.4.tgz",
"integrity": "sha1-km7SjPdiFJYgkx566j8blYFuxpQ=",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/setheader/-/setheader-1.0.1.tgz",
"integrity": "sha512-iNDik8ipRBZHfpbpdWlhfZxc0JM9Cg4NYo8jqBkjSRLPxvcgnrE9oiF3AhpFvypg2erVyWNS+QhykhQt0G9tpA==",
"requires": {
"debug": "0.7.x"
},
"dependencies": {
"debug": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz",
"integrity": "sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk="
}
"diagnostics": "1.x.x"
}
},
"setprototypeof": {
......@@ -3610,14 +3586,14 @@
}
},
"winston": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/winston/-/winston-3.0.0.tgz",
"integrity": "sha512-7QyfOo1PM5zGL6qma6NIeQQMh71FBg/8fhkSAePqtf5YEi6t+UrPDcUuHhuuUasgso49ccvMEsmqr0GBG2qaMQ==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/winston/-/winston-3.1.0.tgz",
"integrity": "sha512-FsQfEE+8YIEeuZEYhHDk5cILo1HOcWkGwvoidLrDgPog0r4bser1lEIOco2dN9zpDJ1M88hfDgZvxe5z4xNcwg==",
"requires": {
"async": "^2.6.0",
"diagnostics": "^1.0.1",
"diagnostics": "^1.1.1",
"is-stream": "^1.1.0",
"logform": "^1.9.0",
"logform": "^1.9.1",
"one-time": "0.0.4",
"readable-stream": "^2.3.6",
"stack-trace": "0.0.x",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment