From 81a68a03e74313b91b0d266a8147f9ea84685615 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 12 Aug 2022 05:39:23 -0400 Subject: [PATCH] feat(scripts): Update get-flattened-publication to consume stream cells --- scripts/get-flattened-publication.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scripts/get-flattened-publication.sh b/scripts/get-flattened-publication.sh index a357db7f5644..6f6060b3168d 100755 --- a/scripts/get-flattened-publication.sh +++ b/scripts/get-flattened-publication.sh @@ -60,17 +60,26 @@ curl -sS "$URL_PREFIX" --request POST --header 'Content-Type: application/json' )" | \ # Decode, simplify, flatten, and compact the output. jq -c ' - # Capture block height. - .result.response.height? as $height | + # Capture response block height. + .result.response.height? as $responseHeight | # Decode `value` as base64, then decode that as JSON. .result.response.value | @base64d | fromjson | - # Decode `value` as JSON, capture `slots`, then decode `body` as JSON. - .value | fromjson | .slots as $slots | .body | fromjson | + # Decode `value` as JSON. + .value | fromjson | - # Add block height. - (.blockHeight |= $height) | + # Upgrade a naked value to a stream cell if necessary. + if has("height") and has("values") then . else { values: [ . | tojson ] } end | + + # Capture data block height. + .height as $dataHeight | + + # Flatten each value independently. + .values[] | fromjson | + + # Capture `slots`, then decode `body` as JSON. + .slots as $slots | .body | fromjson | # Replace select capdata. walk( @@ -92,5 +101,9 @@ jq -c ' ) | # Flatten the resulting structure, joining deep member names with "-". - [ paths(scalars) as $path | { key: $path | join("-"), value: getpath($path) } ] | from_entries + [ paths(scalars) as $path | { key: $path | join("-"), value: getpath($path) } ] | from_entries | + + # Add block height information. + (.dataBlockHeight |= $dataHeight) | + (.blockHeight |= $responseHeight) '