Skip to content

Commit 3cb84ba

Browse files
committed
Merge latest develop changes
2 parents 0a584b5 + 385383d commit 3cb84ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1363
-293
lines changed

src/nodejs/controllers/proxy.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,25 +738,19 @@ module.exports.submissionOperationInitialize = function submissionOperationIniti
738738
};
739739

740740
module.exports.submissionOperationActive = function submissionOperationActive(req, res, next) {
741-
const { params } = req.swagger;
742-
const { payload } = params;
743741
const lambdaEvent = {
744742
operation: 'active',
745-
context: { user_id: req.user_id },
746-
...payload.value
743+
context: { user_id: req.user_id }
747744
};
748745
handlers.submission(lambdaEvent).then((body) => {
749746
setTimeout(() => res.send(body), latency);
750747
});
751748
};
752749

753750
module.exports.submissionOperationInactive = function submissionOperationInactive(req, res, next) {
754-
const { params } = req.swagger;
755-
const { payload } = params;
756751
const lambdaEvent = {
757752
operation: 'inactive',
758-
context: { user_id: req.user_id },
759-
...payload.value
753+
context: { user_id: req.user_id }
760754
};
761755
handlers.submission(lambdaEvent).then((body) => {
762756
setTimeout(() => res.send(body), latency);

src/nodejs/lambda-handlers/file-upload.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,36 @@ async function listStepFilesMethod(event, user) {
264264
return ({ error: 'Not Authorized' });
265265
}
266266

267+
async function getAttachmentDownloadUrlMethod(event, user, s3Client) {
268+
// TODO - Write a proper query to check if user has permissions to view note instead of relying
269+
// on larger find query
270+
const noteId = event.key.split('/')[1];
271+
const { id } = await db.note.findById({ id: noteId, user_id: user });
272+
if (id) {
273+
const payload = {
274+
Bucket: ingestBucket,
275+
Key: event.key
276+
};
277+
278+
try {
279+
const command = new GetObjectCommand(payload);
280+
return getSignedUrl(s3Client, command, { expiresIn: 60 });
281+
} catch (err) {
282+
console.error(err);
283+
return ({ error: 'Failed to download' });
284+
}
285+
}
286+
return ({ error: 'Not Authorized' });
287+
}
288+
267289
async function getDownloadUrlMethod(event, user) {
268290
const { key } = event;
269291
const s3Client = new S3Client({
270292
region
271293
});
272294

295+
if (key.split('/')[0] === 'attachments') return getAttachmentDownloadUrlMethod(event, user, s3Client);
296+
273297
const submissionId = key.split('/')[0];
274298
const userInfo = await db.user.findById({ id: user });
275299
const groupIds = userInfo.user_groups.map((group) => group.id);

src/nodejs/lambda-layers/database-util/src/query/parsers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module.exports.removeContributor = one;
7676
module.exports.getConversationId = one;
7777
module.exports.createForm = one;
7878
module.exports.getFormData = one;
79+
module.exports.updateForm = one;
7980
module.exports.getUsers = many;
8081
module.exports.setDetail = one;
8182
module.exports.getStepMessage = one;

src/nodejs/lambda-layers/schema-util/src/models/action.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ module.exports.model = (path) => ({
33
type: 'object',
44
properties: {
55
id: { $ref: `#${path}UUID` },
6-
action_name: { type: 'string' },
6+
short_name: { type: 'string' },
77
version: { type: 'number' },
8+
long_name: { type: 'string' },
89
description: { type: 'string' },
9-
file_key: { type: 'string' },
10-
input_schema: { type: 'object' }
10+
source: { type: 'object' },
11+
created_at: { type: 'string' }
1112
}
1213
});
1314

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports.model = () => ({
2+
description: 'General response object',
3+
type: 'object',
4+
properties: {
5+
message: {
6+
description: 'Message indicating status',
7+
type: 'string'
8+
},
9+
error: {
10+
description: 'Message describing the error encountered',
11+
type: 'string'
12+
}
13+
}
14+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports.model = (path) => ({
2+
description: 'Code Validation results',
3+
type: 'object',
4+
properties: {
5+
is_valid: { type: 'boolean' },
6+
submission_id: { $ref: `#${path}UUID` },
7+
daac_id: { $ref: `#${path}UUID` },
8+
}
9+
});
10+
11+
module.exports.refs = ['UUID'];

src/nodejs/lambda-layers/schema-util/src/models/daac.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ module.exports.model = (path) => ({
66
short_name: { type: 'string' },
77
long_name: { type: 'string' },
88
url: { type: 'string' },
9-
description: { type: 'string' }
9+
description: { type: 'string' },
10+
discipline: { type: 'string' },
11+
workflow_id: { $ref: `#${path}UUID` },
12+
edpgroup_id: { $ref: `#${path}UUID` },
13+
hidden: { type: 'boolean' }
1014
}
1115
});
1216

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports.model = (path) => ({
2+
description: 'A template for creating a form.',
3+
type: 'object',
4+
properties: {
5+
short_name: { type: 'string' },
6+
version: { type: 'number' },
7+
long_name: { type: 'string' },
8+
description: { type: 'string' },
9+
daac_only: { type: 'boolean' },
10+
}
11+
});
12+
13+
module.exports.refs = ['UUID'];
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module.exports.model = (path) => ({
2+
description: 'Fields for a form with a collection of sections containing questions.',
3+
type: 'object',
4+
allOf: [{ $ref: `#${path}Form` }],
5+
properties: {
6+
form_id: { $ref: `#${path}UUID` },
7+
sections: {
8+
type: 'array',
9+
items: {
10+
type: 'object',
11+
description: 'A group of related questions.',
12+
properties: {
13+
daac_id: { $ref: `#${path}UUID` },
14+
heading: { type: 'string' },
15+
show_if: {
16+
type: 'array',
17+
items: { type: 'object' }
18+
},
19+
questions: {
20+
type: 'array',
21+
items: {
22+
description: 'A grouping of related inputs to be displayed on a form',
23+
type: 'object',
24+
properties: {
25+
help: { type: 'string' },
26+
text: { type: 'string' },
27+
inputs: {
28+
type: 'array',
29+
items: {
30+
type: 'object',
31+
properties: {
32+
type: { type: 'string' },
33+
enums: {
34+
type: 'array',
35+
items: {
36+
oneOf: [
37+
{ type: 'string' },
38+
{ type: 'object' },
39+
]
40+
}
41+
},
42+
label: { type: 'string' },
43+
show_if: {
44+
type: 'array',
45+
items: { type: 'object' }
46+
},
47+
required: { type: 'boolean' },
48+
attributes: { type: 'object' },
49+
control_id: { type: 'string' },
50+
list_order: { type: 'number' },
51+
required_if: {
52+
type: 'array',
53+
items: {
54+
type: 'object',
55+
properties: {
56+
field: { type: 'string' },
57+
value: { type: 'string' },
58+
message: { type: 'string' }
59+
}
60+
}
61+
},
62+
}
63+
}
64+
},
65+
show_if: {
66+
type: 'array',
67+
items: { type: 'object' }
68+
},
69+
version: { type: 'number' },
70+
daac_ids: {
71+
type: 'array',
72+
items: {
73+
$ref: `#${path}UUID`
74+
}
75+
},
76+
required: { type: 'boolean' },
77+
long_name: { type: 'string'},
78+
short_name: { type: 'string' },
79+
required_if: {
80+
type: 'array',
81+
items: { type: 'object' }
82+
}
83+
}
84+
}
85+
},
86+
required_if: {
87+
type: 'array',
88+
items: { type: 'object' }
89+
}
90+
}
91+
}
92+
}
93+
}
94+
95+
});
96+
97+
module.exports.refs = ['UUID', 'Form'];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports.model = (path) => ({
2+
description: 'A template for updating a form',
3+
type: 'object',
4+
properties: {
5+
short_name: { type: 'string' },
6+
version: { type: 'number' },
7+
long_name: { type: 'string' },
8+
description: { type: 'string' },
9+
daac_only: { type: 'boolean' },
10+
original_shortname: { type: 'string' },
11+
original_version: { type: 'number' }
12+
}
13+
});
14+
15+
module.exports.refs = ['UUID'];

0 commit comments

Comments
 (0)