scriptout

package
v1.135.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
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.

View Source
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

func DataPayload(name string, data any) ([]byte, error)

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

func WorkbookArg(v starlark.Value) (*tablexlsx.Workbook, error)

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

type Identity struct {
	ContentType string
	Extension   string
}

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

func Document(name, format, body string) ([]byte, Identity, error)

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.

func Rows

func Rows(name, format string, columns []string, rows []any) ([]byte, Identity, error)

Rows serializes row dicts in a tabular format, projected onto columns, and checks the result against the ceiling.

func Workbook

func Workbook(name string, book *tablexlsx.Workbook) ([]byte, Identity, error)

Workbook writes an xlsx workbook, checked against the ceiling (#1849).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL