report

package
v0.1.103 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package report renders tabular results to HTML or PDF through facet.

Index

Constants

View Source
const (
	// PropertyURL names the facet server used when a report does not name one.
	PropertyURL = "facet.url"
	// PropertyConnection names the facet connection used when neither the
	// report nor facet.url names a server.
	PropertyConnection = "facet.connection"
)
View Source
const EntryFile = "QueryReport.tsx"

EntryFile is the TSX component the embedded template renders with.

Variables

View Source
var SourceDir = os.Getenv("QUERY_REPORT_SOURCE_DIR")

SourceDir overrides the extracted template with a directory on disk, for developing the TSX without rebuilding the binary.

Functions

func Render

func Render(
	ctx context.Context,
	server facet.Server,
	data any,
	format, srcDir, entryFile string,
) ([]byte, error)

Render sends the render to the configured server, falling back to the local facet binary only when none is configured.

func ResolveServer

func ResolveServer(ctx dbcontext.Context, options Options) (facet.Server, error)

ResolveServer picks the facet render service, preferring what the report asks for and falling back to the facet.url and facet.connection properties. A zero Server means none is configured and the local binary is used.

func TemplateDir

func TemplateDir() (string, error)

TemplateDir returns a directory holding the report template, extracting the embedded copy on first use.

The location is content-addressed by the template's own hash, so the pnpm install and Vite build cached under .facet/ survive across renders and across restarts — a cold render costs roughly ten times a warm one — while a change to the template lands in a different directory and is never served stale.

Types

type Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Unit string `json:"unit,omitempty"`
}

Column is one facet DynamicTable column. Type drives the cell renderer, and must be one of facet's own names.

type Options

type Options struct {
	Connection   string
	URL          string
	Timeout      time.Duration
	TimestampURL string
}

Options select the facet server for one render.

type Payload

type Payload struct {
	// Name is what facet writes the file as when the output path is a
	// directory, so it doubles as the report's slug.
	Name        string      `json:"name"`
	Title       string      `json:"title"`
	Subtitle    string      `json:"subtitle,omitempty"`
	GeneratedAt string      `json:"generatedAt"`
	RowCount    int         `json:"rowCount"`
	Truncated   bool        `json:"truncated,omitempty"`
	Columns     []Column    `json:"columns"`
	Rows        []query.Row `json:"rows"`
}

Payload is what the TSX template is called with. It mirrors ReportData in QueryReport.tsx.

func NewPayload

func NewPayload(title string, result *query.Result, columns []query.ColumnDef) Payload

NewPayload projects a result and its columns onto the template's props.

Jump to

Keyboard shortcuts

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