Executes the STAC rows of the receipt mapping (STAC item in
inst/extdata/receipt/mapping/v1.1.0/mapping.csv, published at
https://newgraphenvironment.github.io/crate/receipt/mapping/v1.1.0/mapping.csv)
for one receipt: the item properties and asset fields that let a STAC client or a
pgstac queryable read a build's identity without fetching its receipt (crate#59).
The receipt stays the full record. Every implementation of the mapping runs the
vectors in mapping/v1.1.0/stac.json, so two of them agree on every item.
Arguments
- receipt
A receipt, as a list from
crt_receipt_read(), or a path to one.- assets
A named character vector: each asset's key, and as its value the asset's href relative to the item, which is the path a part is keyed by.
NULLfor none.- receipt_asset
The key of the asset that links the receipt, or
NULL.- receipt_sha256
With
receipt_asset: the SHA-256 of the published receipt's bytes, ascrt_receipt_write()returns it.
Value
A list of stac_extensions (a character vector marked I(), so a JSON
writer keeps it an array), properties and assets (named lists).
What it mirrors
properties:receipt:recipe_idfromrecipe.recipe_id, left out for a migrated receipt (output.migrated_from), which claims no recipe identity, and refused when missing on any other: the item never publishes a null one;processing:datetimefromcontext.time, which is required;processing:software, one entry per repository inrecipe.codethat has aversion, and left out when none has.A block or entry present but not an object,
nullincluded, is refused, never read as absent.
Refusals
A receipt or an argument the mapping cannot place is refused with an error of class
crate_stac_refused, whose code field names what was refused: the same codes the
error field of stac.json carries, so an implementation's refusals can be compared
by code rather than by message. The receipt must be of the form this mapping reads
(output.receipt_version 1.0.0), as crt_receipt_read() requires of a file; a
character receipt is read as a path.
assets: for each asset inassets, the part its href names, asfile:checksum(multihash:1220and the part'ssha256) andfile:size(itsbytes). A part no asset names is not mirrored, since an item may publish fewer files than the build made; two assets may name one part. An asset whose href names no part is an error: the item would otherwise carry a guessed checksum or none.The receipt asset, named by
receipt_asset:file:checksumonly, the multihash ofreceipt_sha256, the digestcrt_receipt_write()returned for the bytes it wrote. Never from a part, since a receipt is not one of its own parts, and with nofile:size, deliberately: the digest identifies the bytes (crate#60).stac_extensions: the file, processing and receipt extension URLs, in that order, each only when one of its fields is present.
Merge the result into the item being built. Nothing else of the item (its id, geometry, other assets' hrefs, types and roles) comes from the receipt.
Examples
wc <- system.file("extdata", "receipt", "examples", "worked_case", "build_1",
package = "crate")
digest <- digest::digest(file.path(wc, "receipt.json"), algo = "sha256", file = TRUE)
s <- crt_receipt_stac(wc, assets = c(access = "access_check.csv"),
receipt_asset = "receipt", receipt_sha256 = digest)
s$properties
#> $`receipt:recipe_id`
#> [1] "b06f982dd07b5e44edf586519e5d6ab60b29715a051c3827fba647230636f977"
#>
#> $`processing:datetime`
#> [1] "2026-11-04T18:22:05Z"
#>
#> $`processing:software`
#> $`processing:software`$knowledge
#> [1] "0.14.0"
#>
#> $`processing:software`$link
#> [1] "0.31.2"
#>
#>
str(s$assets)
#> List of 2
#> $ access :List of 2
#> ..$ file:checksum: chr "122004994ff01cdee55d69fc410add51ad261ec4b33a751135fc224e97305823c3e2"
#> ..$ file:size : int 124
#> $ receipt:List of 1
#> ..$ file:checksum: chr "12200a51e33a6fbea388844c577746bad6ce10293291fc2185fa84e34a1f9d94a44c"
