@sjcrh/proteinpaint-rust 2.178.0 → 2.180.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -83,6 +83,11 @@ export function run_rust(binfile, input_data, args = [], { signal } = {}) {
83
83
  })
84
84
  }
85
85
 
86
+ // May need to add an abort signal as argument like in run_rust above.
87
+ // Or it's likely not needed since a closed stream connection from a web browser
88
+ // will already trigger an error. `stream_rust()` was heavily tested manually
89
+ // while troubleshooting and fixing the idle rust processes the led to memory leacks
90
+ // as part of `/gdc/mafBuild` handler code, leave this code as-is for now.
86
91
  export function stream_rust(binfile, input_data, emitJson) {
87
92
  const binpath = path.join(__dirname, '/target/release/', binfile)
88
93
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.178.0",
2
+ "version": "2.180.0",
3
3
  "name": "@sjcrh/proteinpaint-rust",
4
4
  "type": "module",
5
5
  "description": "Rust-based utilities for proteinpaint",
package/src/gdcmaf.rs CHANGED
@@ -4,10 +4,12 @@
4
4
  Input JSON:
5
5
  host: GDC host
6
6
  fileIdLst: An array of uuid
7
+ headers: required headers for GDC API
7
8
  Output gzip compressed maf file to stdout.
8
9
 
9
10
  Example of usage:
10
- echo '{"host": "https://api.gdc.cancer.gov/data/","columns": ["Hugo_Symbol", "Entrez_Gene_Id", "Center", "NCBI_Build", "Chromosome", "Start_Position"], "fileIdLst": ["8b31d6d1-56f7-4aa8-b026-c64bafd531e7", "b429fcc1-2b59-4b4c-a472-fb27758f6249"]}'|./target/release/gdcmaf
11
+ headers='{"X-Forwarded-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.…ML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0", "X-Forwarded-For": "127.0.0.1"}'
12
+ echo '{"host": "https://api.gdc.cancer.gov/data/","columns": ["Hugo_Symbol", "Entrez_Gene_Id", "Center", "NCBI_Build", "Chromosome", "Start_Position"], "fileIdLst": ["8b31d6d1-56f7-4aa8-b026-c64bafd531e7", "b429fcc1-2b59-4b4c-a472-fb27758f6249"], "headers": '$headers'}'|./target/release/gdcmaf
11
13
  */
12
14
 
13
15
  use flate2::Compression;
@@ -139,6 +141,31 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
139
141
  //url.push(Path::new(&host).join(&v.as_str().unwrap()).display().to_string());
140
142
  url.push(format!("{}/{}", host.trim_end_matches('/'), v.as_str().unwrap()));
141
143
  }
144
+ let mut req_headers = reqwest::header::HeaderMap::new();
145
+ if let Some(headers_val) = file_id_lst_js.get("headers") {
146
+ let headers_obj = match headers_val.as_object() {
147
+ Some(obj) => obj,
148
+ None => {
149
+ let header_error = ErrorEntry {
150
+ url: String::new(),
151
+ error: "headers is not an object".to_string(),
152
+ };
153
+ let header_error_js = serde_json::to_string(&header_error).unwrap();
154
+ writeln!(io::stderr(), "{}", header_error_js).expect("Failed to output stderr!");
155
+ return Err(Box::new(std::io::Error::new(
156
+ std::io::ErrorKind::InvalidInput,
157
+ "headers is not an object",
158
+ )) as Box<dyn std::error::Error>);
159
+ }
160
+ };
161
+ for (key, value) in headers_obj {
162
+ req_headers.insert(
163
+ reqwest::header::HeaderName::from_bytes(key.as_bytes()).expect("Invalid header key"),
164
+ reqwest::header::HeaderValue::from_str(value.as_str().expect("Invalid string value"))
165
+ .expect("Invalid header value"),
166
+ );
167
+ }
168
+ }
142
169
 
143
170
  // read columns as array from input json and convert data type from Vec<Value> to Vec<String>
144
171
  let maf_col: Vec<String>;
@@ -176,10 +203,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
176
203
 
177
204
  //downloading maf files parallelly and merge them into single maf file
178
205
  let download_futures = futures::stream::iter(url.into_iter().map(|url| {
206
+ let req_headers_clone = req_headers.clone();
179
207
  async move {
180
208
  let client = reqwest::Client::builder()
181
209
  .timeout(Duration::from_secs(60)) // 60-second timeout per request
182
210
  .connect_timeout(Duration::from_secs(15))
211
+ .default_headers(req_headers_clone.clone())
183
212
  .build()
184
213
  .map_err(|_e| {
185
214
  let client_error = ErrorEntry {