-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
call out to Octopus Imaging API from
database-bridge-lambda
in `cre…
…ateItem` mutation if the `type` is `imaging-request`
- Loading branch information
1 parent
edbb5ff
commit 3af427f
Showing
9 changed files
with
108 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import fetch from "node-fetch"; | ||
import { getEnvironmentVariableOrThrow } from "shared/environmentVariables"; | ||
import { ItemWithParsedPayload } from "shared/types/ItemWithParsedPayload"; | ||
|
||
export const performImagingRequest = async ({ | ||
item, | ||
}: { | ||
item: ItemWithParsedPayload; | ||
}) => { | ||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // self-signed cert on imaging server, which fails SSL check, so ignore | ||
const response = await fetch( | ||
`https://${getEnvironmentVariableOrThrow( | ||
"octopusImagingApiVpcEndpoint" | ||
)}/v1/rgbimageorder`, | ||
{ | ||
// note this travels via vpc endpoint, via VPN to specific machine(s) on office network, no need to auth at this point | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
workflowId: item.pinboardId, | ||
pinboardItemId: item.id, | ||
lastUser: item.userEmail, | ||
notes: item.message, //TODO check for 256 max (probably limit in UI too) | ||
requestType: item.payload?.requestType, // TODO tighten this up | ||
// gridId: TODO extract from url in payload probably | ||
// composerId: TODO lookup somehow | ||
// pubDate TODO scheduled launch vs some date field in workflow - what's worse wrong date or no date? | ||
// section TODO lookup somehow | ||
// story group name TODO (synced from InCopy most likely, if available) | ||
}), | ||
} | ||
); | ||
return (await response.json()).octopusImagingOrderId; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Item } from "../graphql/graphql"; | ||
|
||
export type ItemWithParsedPayload = Omit<Item, "payload"> & { | ||
payload: Record<string, unknown> | null | undefined; | ||
}; |