repoformat

package
v0.13.4 Latest Latest
Warning

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

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

Documentation

Overview

Package repoformat is what an anfra repo is, as anything handling one outside the engine needs it: which files make up a repo (Publishable), which of them are Data Apps and what they are called (DataApp, AppLabel), and how a file's content is named (BlobID). anfra core owns it, as it owns the repo format; anfra-cloud imports it, so a server, the CLI and every host agree on them.

Index

Constants

View Source
const AppsDir = "apps"

AppsDir is where a repo's Data Apps are: published whole.

TODO: configurable, in the repo's config, rather than fixed.

Variables

This section is empty.

Functions

func AppLabel added in v0.12.0

func AppLabel(p string, content []byte) string

AppLabel is what a host calls a Data App: its definition's <title>, with whitespace collapsed and entities decoded, or else its file name. p is the definition's slash-separated path, content its HTML.

func BlobID

func BlobID(content []byte) string

BlobID is content's git blob id: SHA-1 over "blob <size>\0" and the content, as git names it with no filters applied. It is what a publish names a file's content by, and what a server, storing it in git, answers for it.

func CheckOrigin added in v0.12.0

func CheckOrigin(s string) error

CheckOrigin reports whether s may be added to a Data App's content policy: https://<host>[:<port>] and nothing after it, written as a browser writes an origin (lowercase, no default port), so it cannot widen a directive (a scheme, a wildcard) or end one (a space, a ";"). The SDK's checkOrigin is the same rule, in the browser.

func DataApp added in v0.12.0

func DataApp(path string) bool

DataApp reports whether a file is a Data App definition: an .html file under AppsDir that a publish carries. The other files there are what definitions refer to (an image, a script). path is as Publishable takes it.

func Publishable

func Publishable(path string) bool

Publishable reports whether a file is part of an anfra repo, so a publish carries it: its AML (*.aml), and its Data Apps (everything under AppsDir). path is slash-separated and relative to the repo root.

A publish carries the repo, not the folder it is in: what the server uses, chosen by the repo's format, the same on every machine, with or without git. So a .env, build output, notes or scripts beside the repo are never sent, and nothing depends on .gitignore, which says what belongs in version control, a different question (PUBLISH.md §What gets published). Within the repo, never:

  • a path with a part starting with ".": git's own files, the repo's config (.anfra/, whose data_sources.yml holds credentials), editors' and tools' state;
  • a path through node_modules: a Data App's installed dependencies.

The CLI selects with it, and a server refuses what it does not allow, so neither a modified client nor a mistake in one can publish anything else.

Types

type AppIssue added in v0.12.0

type AppIssue struct {
	Line    int
	Message string
}

AppIssue is something in a Data App definition that will not work in a host: where it is, and what to do about it.

func CheckApp added in v0.12.0

func CheckApp(content []byte) []AppIssue

CheckApp is what in a Data App definition will not work in a host, in document order:

  • A reference to a local file (a relative or root-relative src, href, srcset, poster or CSS url()): a Data App is one HTML file, and a host serves nothing beside it.
  • A script or stylesheet from another server without an integrity hash: the library runs beside the reader's query results, so a change to it at its CDN should stop it, not run it.

It never fails: a definition it cannot read has no issues it can name.

func (AppIssue) String added in v0.12.0

func (i AppIssue) String() string

Jump to

Keyboard shortcuts

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