Documentation
¶
Overview ¶
Package scriptout is the one serializer for a managed script's outputs: the bytes platform.export and platform.publish_data write, the ceiling they are held to, and the media type and file extension they are stored under.
It is one package because both runs of a script go through it. A platform run persists exactly these bytes and a draft run measures them, so an output too large or malformed to write is refused while the author is still iterating rather than at the first scheduled fire. It was extracted from internal/platform/scriptrun, which composes these arms by the shape of the export request, when the xlsx arm (#1849) arrived.
Index ¶
Constants ¶
const FormatXLSX = "xlsx"
FormatXLSX is the export format that writes an Excel workbook (#1849). Its body is neither rows nor a string: it is a dict describing the sheets.
const MaxBytes = 100 << 20
MaxBytes caps one serialized output. It matches the ceiling the portal export path applies, so a script cannot write an asset a human could not have exported by hand.
Variables ¶
This section is empty.
Functions ¶
func DataPayload ¶
DataPayload serializes one publish_data payload as the JSON the data region will hold, checked against the same ceiling every export is.
It is the single serializer for the payload -- a draft measures exactly the bytes a platform run splices -- and it keeps encoding/json's default escaping, which writes <, > and & as \u escapes, so no string in the payload can ever terminate the <script> element it lands inside. Go serializes map keys in sorted order, so the bytes are deterministic for a given payload. The indentation is for the reader of a version diff: a refreshed dashboard's history should read field by field, not as one replaced line.
func SheetsValue ¶
func SheetsValue(shapes []tablexlsx.SheetShape) *starlark.List
SheetsValue renders a workbook's shape as the list an export record hands the script: one {"name": ..., "rows": ...} dict per sheet, in order.
func WorkbookArg ¶
WorkbookArg reads platform.export's body for the xlsx format, a dict {"sheets": [...]}, into a checked workbook.
A sheet that names no "columns" takes them from its rows' keys, in the order the script wrote them: the Starlark dicts still hold that order, and the Go maps they convert to do not, so it is read here, before conversion.
Types ¶
type Identity ¶
Identity is how one output is stored: the media type it carries and the file extension its object keys take. It is a value rather than the formatter that produced the bytes, because the bytes are already serialized when a serializer here returns -- nothing downstream may re-serialize, and a document has no serializer to hand back.
func Document ¶
Document passes a string body through as the output's bytes, checked against the same ceiling a tabular output is. Verbatim is the contract: what the script composed is what the portal stores or the bucket receives, byte for byte, so a draft's measurement and a real run's write cannot differ.
The format is checked here as well as at the argument edge: this is the serializer both runs share, and a request some other constructor built with a body under csv or json must be refused rather than written verbatim as a "well-formed by construction" feed.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package exportmeta reads platform.export's tags= and metadata= arguments (#1848): what identifies a portal output beyond its name, so an application finds the reports it generated again.
|
Package exportmeta reads platform.export's tags= and metadata= arguments (#1848): what identifies a portal output beyond its name, so an application finds the reports it generated again. |