|
- import arvadosTypeName from 'arvados-type-name';
- import makeArvadosRequest from 'make-arvados-request';
-
- function wbFetchObjects(arvHost, arvToken, uuids) {
- const unique = {};
- uuids.map(u => (unique[u] = true));
- uuids = {};
- Object.keys(unique).map(u => {
- let typeName = arvadosTypeName(u);
- if (!typeName) {
- console.log('Unknown type name for UUID: ' + u);
- return;
- }
- if (!(typeName in uuids))
- uuids[typeName] = [];
- uuids[typeName].push(u);
- });
-
- const lookup = {};
- let prom = new Promise(accept => accept());
- for (let typeName in uuids) {
- let filters = [
- ['uuid', 'in', uuids[typeName]]
- ];
- prom = prom.then(() => makeArvadosRequest(arvHost, arvToken,
- '/arvados/v1/' + typeName + 's?filters=' +
- encodeURIComponent(JSON.stringify(filters))));
- prom = prom.then(xhr => xhr.response.items.map(it => (
- lookup[it.uuid] = it)));
- prom = prom.catch(xhr => console.log(xhr.responseURL + ': ' + xhr.statusText));
- }
-
- prom = prom.then(() => lookup);
-
- return prom;
- }
-
- export default wbFetchObjects;
|