Skip to content

Commit

Permalink
feat(scripts): Update get-flattened-publication to consume stream cells
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Aug 12, 2022
1 parent 60e0d6f commit 81a68a0
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions scripts/get-flattened-publication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
'

0 comments on commit 81a68a0

Please sign in to comment.