Skip to content

Commit 576126d

Browse files
authored
fix: data post-processing; feat: controlsData meta accepted (#17)
* fix: export settings pre-saved in file metadata * feat: controlsData in metadata * fixes starting export from upload * adds ability to supply controlsData meta * chore: update deps
1 parent 73a8e81 commit 576126d

7 files changed

Lines changed: 44 additions & 6 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"lodash": "^4.13.1",
3131
"md5": "^2.1.0",
3232
"ms-amqp-transport": "^3.0.0",
33-
"ms-conf": "^2.0.0",
33+
"ms-conf": "^2.1.0",
3434
"ms-files-gce": "^1.0.1",
3535
"ms-files-providers": "^1.0.2",
3636
"ms-validation": "^2.0.0",
37-
"mservice": "^2.4.0",
37+
"mservice": "^2.5.1",
3838
"redis-filtered-sort": "^1.2.0"
3939
},
4040
"optionalDependencies": {
@@ -51,7 +51,7 @@
5151
"cz-conventional-changelog": "^1.1.6",
5252
"eslint": "^2.13.1",
5353
"eslint-config-airbnb-base": "^3.0.1",
54-
"eslint-plugin-import": "^1.9.2",
54+
"eslint-plugin-import": "^1.10.0",
5555
"eslint-plugin-mocha": "^3.0.0",
5656
"faker": "^3.1.0",
5757
"isparta": "^4.0.0",

schemas/common.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
"type": "string",
1515
"pattern": "^[0-9A-Fa-f]{32}\/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}"
1616
},
17+
"controlsData": {
18+
"type": "array",
19+
"minItems": 29,
20+
"maxItems": 29,
21+
"items": {
22+
"type": "number"
23+
}
24+
},
1725
"export": {
1826
"type": "object",
1927
"required": ["format", "compression"],
@@ -141,6 +149,9 @@
141149
},
142150
"export": {
143151
"$ref": "common#/definitions/export"
152+
},
153+
"controlsData": {
154+
"$ref": "common#/definitions/controlsData"
144155
}
145156
}
146157
},

schemas/update.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
"$ref": "common#/definitions/owner"
1111
},
1212
"meta": {
13-
"$ref": "common#/definitions/meta"
13+
"allOf": [
14+
{
15+
"not": { "required": ["export"] }
16+
},
17+
{
18+
"$ref": "common#/definitions/meta"
19+
}
20+
]
1421
}
1522
}
1623
}

src/actions/download.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module.exports = function getDownloadURL(opts) {
5757
urls = Promise.map(files, file => provider.createSignedURL({ ...settings, resource: file.filename }));
5858
}
5959

60-
return Promise.props({ uploadId, name, files, urls, username: alias });
60+
return Promise
61+
.props({ uploadId, name, files, urls, username: alias })
62+
.tap(output => this.hook.call(this, 'files:download:post', data, output));
6163
});
6264
};

src/actions/process.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const hasAccess = require('../utils/hasAccess.js');
1212
* @return {Promise}
1313
*/
1414
module.exports = function postProcessFile(opts) {
15-
const { uploadId, username, export: exportSettings } = opts;
15+
const { uploadId, username } = opts;
1616
const key = `${FILES_DATA}:${uploadId}`;
1717

1818
return Promise
@@ -21,6 +21,7 @@ module.exports = function postProcessFile(opts) {
2121
.then(hasAccess(username))
2222
.then(data => {
2323
const status = data.status;
24+
const exportSettings = opts.export || data.export;
2425

2526
if (exportSettings) {
2627
if (data[exportSettings.format]) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const findIndex = require('lodash/findIndex');
2+
const PROPS_TO_ADD = ['model', 'obj', 'wrl', 'stl'];
3+
4+
/**
5+
* Decorates output with extra data to ease fetching of links
6+
*/
7+
module.exports = function decorateOutput(originalData, output) {
8+
const files = originalData.files;
9+
PROPS_TO_ADD.forEach(prop => {
10+
const nonResolvedLink = originalData[prop];
11+
if (nonResolvedLink) {
12+
const idx = findIndex(files, { filename: nonResolvedLink });
13+
output[prop] = output.urls[idx];
14+
}
15+
});
16+
};

test/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ services:
6161
working_dir: /src
6262
volumes:
6363
- ${PWD}:/src
64+
- /etc/localtime:/etc/localtime:ro
6465
container_name: tester
6566
environment:
6667
NODE_ENV: "test"

0 commit comments

Comments
 (0)