Documentation
¶
Overview ¶
Package scriptlist is what the scripts listing is narrowed and ordered by.
It holds the query string half of GET /portal/scripts: the scope that decides which scripts a caller is asking about, the axes that narrow whatever that scope selected, and the ordering the store applies ahead of the page cap (#1795). It takes the caller as an address and a flag rather than as the HTTP layer's identity type, so it can be read and tested without the handler and cannot import it back.
Index ¶
Constants ¶
const ( KindScript = "script" KindLibrary = "library" )
The kinds the listing narrows to with kind=, in the words of the listing's Kind column (#1970): a script is the kind that runs, a library the kind other scripts load.
const ( EndpointBound = "bound" EndpointUnbound = "unbound" )
The values endpoint= narrows to (#2259): the scripts bound to an endpoint, and the ones that are not.
const ScopeMine = "mine"
ScopeMine is the scope value that narrows a listing to the caller's own scripts.
Variables ¶
This section is empty.
Functions ¶
func Endpoints ¶ added in v1.152.0
func Endpoints( ctx context.Context, list func(context.Context, epbinding.Filter) ([]epbinding.Binding, int, error), ids []string, ) map[string]*Endpoint
Endpoints is the endpoint each script ids names is bound to, by script id, read with list in one call whose limit is the number of scripts, so no bound one is cut off. A script bound to none is absent, and so is every script when the read fails: a listing that cannot report an endpoint is still a listing.
func Filter ¶
Filter turns the query string into the listing's predicate and its ordering.
Two different things meet here and are kept apart. The SCOPE decides which scripts the caller is asking about -- every script by default, their own with scope=mine (#1994), and every script unconditionally for an administrator. The NARROWING axes (category and tag, #1369; free text, #1405; author, status and enabled, #1795) narrow whatever that scope selected, and apply to an administrator exactly as they do to everybody else, because they narrow what a reader asked for rather than what they are entitled to. Every one of them runs in the store, so each covers every script the scope admits rather than the page of them a listing happens to hold.
The ORDERING is carried through for the same reason: the store applies the page cap, so a column sorted anywhere else would sort the page.
A nil query names no axis, which is how a caller asks for the scope alone.
func ParseEndpoint ¶ added in v1.152.0
ParseEndpoint reads endpoint=: whether it names the bound scripts, and whether it names either (an absent value lists both), or an error for a value that names neither.
Types ¶
type Endpoint ¶ added in v1.152.0
type Endpoint struct {
Name string `json:"name" example:"order-lookup"`
// Path is the address it answers at, with the template's parameters in
// braces.
Path string `json:"path" example:"/endpoints/order-lookup/{id}"`
AuthMode string `json:"auth_mode" example:"authenticated"`
Enabled bool `json:"enabled" example:"true"`
}
Endpoint is a listed script's endpoint (#2314): where it answers, who it admits and whether it is on. The binding's limits and callers are read on the script's own page.