diff --git a/README.md b/README.md index f05a15b3..bad2d96f 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,11 @@ npx cdk deploy 3. Command-Click "Quilt Catalog" to open the package in a new window 4. Drag in an attachment to the Benchling entry 1. Click "Update package" to create a new version + 2. The package will include: + - entry.json: Entry metadata + - assay-results.json: Associated assay results + - input.json: Original webhook payload + - README.md: Package documentation ## Testing diff --git a/lib/constants.ts b/lib/constants.ts index 2633f8b0..1f4a7df3 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -9,6 +9,7 @@ export const FILES = { INPUT_JSON: "input.json", README_MD: "README.md", ENTRY_MD: "entry.md", + ASSAY_RESULTS_JSON: "assay-results.json", } as const; export const MIME_TYPES = { diff --git a/lib/packaging-state-machine.ts b/lib/packaging-state-machine.ts index 55828ec0..5aaf95ce 100644 --- a/lib/packaging-state-machine.ts +++ b/lib/packaging-state-machine.ts @@ -137,10 +137,14 @@ export class PackagingStateMachine extends Construct { private createDefinition(): stepfunctions.IChainable { const fetchEntryTask = this.createFetchEntryTask(); + const fetchAssayResults = this.createFetchAssayResultsTask(); const templates = this.writeTemplates(); const exportWorkflow = this.createExportWorkflow(); - return fetchEntryTask.next(templates).next(exportWorkflow); + return fetchEntryTask + .next(fetchAssayResults) + .next(templates) + .next(exportWorkflow); } @@ -230,6 +234,11 @@ export class PackagingStateMachine extends Construct { FILES.ENTRY_JSON, "$.entry.entryData", ); + const writeAssayResultsToS3Task = this.createS3WriteTask( + this.props.bucket, + FILES.ASSAY_RESULTS_JSON, + "$.assayResults.assayResults", + ); const writeMetadataTask = this.createS3WriteTask( this.props.bucket, FILES.INPUT_JSON, @@ -240,10 +249,32 @@ export class PackagingStateMachine extends Construct { return extractDownloadURL .next(processExportTask) .next(writeEntryToS3Task) + .next(writeAssayResultsToS3Task) .next(writeMetadataTask) .next(sendToSQSTask); } + private createFetchAssayResultsTask(): stepfunctions.CustomState { + return new stepfunctions.CustomState(this, "FetchAssayResults", { + stateJson: { + Type: "Task", + Resource: "arn:aws:states:::http:invoke", + Parameters: { + "ApiEndpoint.$": + "States.Format('{}/api/v2/assay-results?entryId={}', $.baseURL, $.entity)", + Method: "GET", + Authentication: { + ConnectionArn: this.props.benchlingConnection.attrArn, + }, + }, + ResultSelector: { + "assayResults.$": "$.ResponseBody.assayResults", + }, + ResultPath: "$.assayResults", + }, + }); + } + private createFetchEntryTask(): stepfunctions.CustomState { return new stepfunctions.CustomState(this, "FetchEntry", { stateJson: {