Help us shape the future of Go! Take the 2026 Go Developer Survey

epsubmit

package
v1.152.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package epsubmit reads a form's stored submissions for its owner (#2180): the newest rows of webhook_form_<endpoint>, through the Trino connection the form's source is on, with each sensitive field decrypted and the read audited with the fields it opened (#2179), and the same rows as CSV or an Excel workbook.

Index

Constants

View Source
const (
	// DefaultLimit is how many submissions the page shows.
	DefaultLimit = 50
	// MaxLimit is the most one read or export returns.
	MaxLimit = 10000
)

Bounds of a read.

View Source
const (
	FormatCSV  = "csv"
	FormatXLSX = "xlsx"
)

The export formats.

Variables

View Source
var ErrNoForm = errors.New("this script stores no form submissions: bind it as a form with manage_script endpoint_set")

ErrNoForm is a script with no form source: it was never bound as a form.

Functions

This section is empty.

Types

type File

type File struct {
	Data        []byte
	ContentType string
	Name        string
}

File is an export: its bytes, content type and file name.

func Export

func Export(page Page, format string) (File, error)

Export is the page's submissions as a file.

type Page

type Page struct {
	Form       string `json:"form"`
	Source     string `json:"source"`
	Table      string `json:"table"`
	Connection string `json:"connection"`
	// Fields are the columns, in the order the newest submission's form
	// declared them, then any an older one held.
	Fields []string `json:"fields"`
	// Sensitive are the fields that were decrypted for this read.
	Sensitive   []string     `json:"sensitive"`
	Submissions []Submission `json:"submissions"`
	Limit       int          `json:"limit"`
}

Page is a form's newest submissions and what reads them.

type Querier

type Querier func(ctx context.Context, connection, sql string) ([]map[string]any, error)

Querier runs one read statement on a Trino connection and returns its rows.

type Reader

type Reader struct {
	Sources epcollect.SourceLister
	Tables  Targets
	Query   Querier
	Sealer  epcollect.Sealer
	Audit   middleware.AuditLogger
}

Reader reads a form's submissions.

func (*Reader) Available

func (r *Reader) Available() bool

Available reports whether the reader has what a read needs.

func (*Reader) Recent

func (r *Reader) Recent(ctx context.Context, scriptID string, limit int, who Viewer) (Page, error)

Recent is the newest limit submissions of the form scriptID is, with each sensitive field decrypted for who, and the read audited when it decrypted any.

type Submission

type Submission struct {
	ID         string               `json:"id"`
	ReceivedAt time.Time            `json:"received_at"`
	Submitter  *epcollect.Submitter `json:"submitter,omitempty"`
	Values     map[string]any       `json:"values"`
}

Submission is one stored submission.

type Targets

type Targets interface {
	TargetFor(connection string) (whtable.Target, error)
}

Targets is where a source's tables live on a connection (whtable.Tables).

type Viewer

type Viewer struct {
	UserID  string
	Email   string
	Persona string
}

Viewer is who reads the submissions.

Jump to

Keyboard shortcuts

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