screens

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0, MIT Imports: 17 Imported by: ? modules, 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.

README

A2UI screens (screens)

Package screens fills the A2UI 1.0 screens of a ringi server's requests, and reads what their buttons send. ritsu writes a template of each screen (ritsu gen --target requests), and this package fills it with the values of a request, for the person who sees it. When a button is pressed, it turns the message a renderer sends into an operation of the API. The package depends on the standard library alone and keeps nothing. Every request type runs through the same code. Japanese: README.ja.md.

To Read
show A2UI screens in an application of your own Use the A2UI screens. A server serves them over HTTP with package web, and you call nothing of this package
serve the screens from a server of your own, without web Use, below
show the same screens as plain HTML package page: a browser needs no A2UI renderer and no JavaScript for them
know how it works, and why the design

Use

Read what ritsu wrote
//go:embed requests
var generated embed.FS

sub, _ := fs.Sub(generated, "requests")
set, err := screens.Load(sub) // openapi.json, types/, a2ui/
Show a request

The card of a request has what was asked for, its route, and the buttons of what the viewer may do now. Find which of the card's actions those are, and fill the card:

actions, _ := set.Actions("expense", "card") // edit, approve, reject, send_back, …, comment
can := allowed(viewer, ticket, actions)       // the server checks with the gate and the kind (Server.Can)
serving := screens.Serving{Find: "/a2ui/find", Upload: "/files"}
card, err := set.Card(screens.Card{Language: "en", Ticket: ticketJSON, Can: can, Names: directory, Serving: serving})
// card.Messages: createSurface, updateDataModel, updateComponents, to send the renderer in order
  • directory is a screens.Lookup of the server. It is called once for each table, with the IDs the screen shows, and answers the names of people and of the rows of masters, and the addresses of files.
  • serving has the addresses the server chooses: Find, where a screen finds people, teams and the rows of masters, and Upload, where it uploads an attachment.

The card that the tests keep in testdata/golden/expense.card.en.json begins with

{"version":"1.0","createSurface":{"catalogId":"https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json","surfaceId":"expense.card.T-1"}}

and its data has, among other things,

"ticket": {"id": "T-1", "made_by": null, "requester": "e1201", "revision": {"edits": 0, "round": 1, "stage": 0}, "stage": "first", "status": "in_progress"},
"can": {"add_approver": false, "approve": true, "comment": true, "discard": false, "edit": false, "hand_over": false, "reject": true, "send_back": true, "withdraw": false},
"add_approver": {"approver": null, "parts": [{"part": "manager"}]},
"files": {"receipt.pdf": "https://files.example.test/receipt.pdf"},
"find": "/a2ui/find",
"refused": {"field": null, "text": null}
Show the form of a new request

It needs a Surface of its own each time it is shown (a random ID), as the key that keeps it from being submitted twice is made from it.

form, err := set.Form(screens.Form{Kind: "leave", Language: "en", Surface: newID(), Can: []string{"submit"}, Serving: serving})
Show the lists

set.List is filled with the requests that wait for the viewer, and set.Mine with the viewer's own: those they are the requester of, and those they made for someone else.

waiting, err := set.List(screens.List{Kind: "expense", Language: "en", Tickets: waitingTickets, Names: directory})
mine, err := set.Mine(screens.List{Kind: "expense", Language: "en", Tickets: ownTickets, Names: directory})
Do what a button asks

When a button is pressed, the renderer sends a message of its action. Turn it into an operation, and do that for the person who sent it, as the same operation sent over HTTP is done.

a, err := screens.ParseAction(message)
op, err := set.Operation(a)
// op.ID, op.Method, op.Path, op.Ticket, op.Body, op.Key

For example, in testdata/golden/operations.json, this message

{"version":"1.0","action":{"name":"approve","surfaceId":"expense.card.T-1","sourceComponentId":"button.approve","timestamp":"2026-11-16T09:05:00.000Z","context":{"ticket":"T-1","revision":{"round":1,"stage":0,"edits":0},"comment":"Fine."}}}

becomes this operation:

{"id":"approve","method":"POST","path":"/tickets/T-1/approve","ticket":"T-1","body":{"revision":{"round":1,"stage":0,"edits":0},"comment":"Fine."},"key":"screen-8d0467a0aadff7e480af24d481d53aa2e36df49c83ecfc2172995b9eeded1a9b"}

The server checks the body as it checks any body. The key is the operation's Idempotency-Key. A new request has one for each form and body, and an operation on a request has one for each press (the design, 3.1).

Show why something was refused

When the server refuses the operation, put what the API answered into a screens.Refusal: the kind, the text in English and in Japanese, and the place in the form (at, such as items[1].price, with the rows counted from 0) when the form is what was refused. set.Refused makes the message that shows it on the screen, and what the person typed stays as it is.

The refusal Where its text is shown
names a place in the form Beside that field
is of the kind comment Under the comment
any other At the head of the screen

This is a refusal at items[0].price on a Japanese form (testdata/golden/expense.form.refused.ja.json):

{"version":"1.0","updateDataModel":{"surfaceId":"expense.form.f1","path":"/refused","value":{"comment":false,"field":"items","text":"`1_000_001JPY` は、`items[0].price` の範囲(`>=1JPY <=1_000_000JPY`)の外です"}}}

The sentences shown with a refusal are in this package, for the pages and the tools of agents to use too.

Function The sentence it answers
RefusalWords(lang, kind) Of a refusal, by its kind alone (the design, 3.2)
LimitedWords When the server does not take a comment now
OfferedWords When a request type has no version in effect yet, and may be used from a day

Someone who may make the request from that day (Server.Offered) is shown the screen offered, filled with the day and the way back: set.Offered(screens.Offered{Kind: "leave", Language: "en", From: "2027-04-01", Home: "/pages/", Surface: newID()}). A package that ritsu generated before that screen was in the contract has none, and its form is answered 404 with the sentence of OfferedWords.

Serve the catalog and the functions

A renderer reads ritsu's catalog and its functions, too. set.Asset("catalog.json") and set.Asset("functions.js") answer each with its content type and ETag, and set.Assets() answers both as a file system.

The tests

go test .            # about 6 seconds; ./... adds the pages (page/), about 9 seconds in all
go test -race .      # about 65 seconds; ./... about 95

They use ritsu's examples, which are generated into testdata/: 120 templates of ten kinds, their vectors, and the Go package ritsu makes from them. They read the screens in Node 24 as a renderer does, through testdata/driver.mjs. Without Node those tests print SKIP: and pass.

  • They fill 5,542 screens from the vectors, and press each of the 336 buttons.
  • They make the vectors' events on the screens in 2,230 presses, and give what the screens send to the generated code. Each of the 2,052 sent has the result its vector says.
  • The kinds also refuse what the screens keep from being sent: each of the 176 that the screens' checks stop, each of the 2 that give a field the screen hides, and each of the 138 lines that ask for what no screen sends.

The design, 7, lists the tests. To take in a newer ritsu's examples, with a ritsu checkout, and ritsu on PATH:

testdata/regen.sh <ritsu checkout>/crates/ringi/examples
testdata/bless.sh   # the golden files; read their diff before you commit them

Documentation

Overview

Package screens serves the screens ritsu writes for the kinds of request of a project (A2UI 1.0): it fills a screen's template with a ticket's values for one viewer, and makes the action a renderer sends when a button is pressed into the operation of the API it is.

It keeps nothing and asks no one: the server reads the tickets, asks the gate, names the people and the files, and runs the operations. Every kind of request runs through the same code, by what its templates, its description (types/<kind>.json) and the API (openapi.json) say.

Package web uses it. README.md shows how to call it, and DESIGN.md says how it works; ringi's DESIGN 12.4 and 13 are the contract it keeps.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContract is a generated set of a contract this module does not read.
	ErrContract = errors.New("screens: a contract this module does not read")
	// ErrSet is a generated set whose files do not agree with each other or with this module.
	ErrSet = errors.New("screens: the generated files do not agree")
	// ErrKind is a kind or a language the set does not have, or a ticket of another kind.
	ErrKind = errors.New("screens: no such kind or language")
	// ErrVersion is a ticket of another version of its kind than the set has.
	ErrVersion = errors.New("screens: a ticket of another version of its kind")
	// ErrInput is an input of a fill that does not fit the screen.
	ErrInput = errors.New("screens: the input does not fit the screen")
	// ErrMessage is a message that is not an action message of A2UI 1.0.
	ErrMessage = errors.New("screens: not an action message of A2UI 1.0")
	// ErrSurface is an action from a surface of no screen of the set.
	ErrSurface = errors.New("screens: no screen has the surface")
	// ErrButton is an action no button of its screen sends.
	ErrButton = errors.New("screens: no button of the screen sends the action")
	// ErrContext is an action whose context does not fit its button, or misses a value its
	// operation requires.
	ErrContext = errors.New("screens: the context does not fit the button")
)
View Source
var Contracts = []int{3}

Contracts lists the versions of ritsu's contract this module reads (openapi.json's x-ritsu-contract, a description's contract).

Functions

func EndOfDay

func EndOfDay(at time.Time) (string, bool)

EndOfDay answers the day a time is the end of, as ringi says a deadline at the end of a day: for 2026-11-20 00:00 in its zone, 2026-11-19. A screen says it "2026-11-19 at the end of the day", not the next day's 00:00, which reads as if it could be answered that day. False for a time that is not midnight.

func LimitedWords

func LimitedWords(lang string, wait int) string

LimitedWords answers what a screen says to a person when the server does not take their comment now (the API's 429, the core's DESIGN 7.4): wait seconds to send it again, or, when wait is 0, the request takes no more comments from them, which holds both when the ticket has as many as the server takes and when they made as many as it takes of one person. In the screen's language, as RefusalWords.

func OfferedWords

func OfferedWords(lang, from string) string

OfferedWords answers what a screen says to a person who opens the form of a new request of a kind no version of which is in effect now, and who may make the request from a day (Server.Offered; from is YYYY-MM-DD): the sentence the MCP tools say of it too, in the screen's language, as RefusalWords.

func RefusalKinds

func RefusalKinds() []string

RefusalKinds are the kinds of refusal RefusalWords has sentences of, sorted.

func RefusalWords

func RefusalWords(lang, kind string) string

RefusalWords answers what a screen says to a person when the server refuses what they did, by the kind of the refusal (`{"refused": kind}`), in the screen's language: Japanese for "ja", English for any other. The sentence is made from the kind alone, not from the refusal's text, which names the events, the fields and the lines of the kind as the kind writes them (`self approval not allowed`). The text is shown too, in the screen's language (Refusal.In): a form or a card holds it at /refused/text, which the A2UI screens show by the field the refusal names (at their head when it names none); package web's answer of a refusal (409) carries it as `text` beside this sentence; a page shows it folded at its head.

func UnavailableWords

func UnavailableWords(lang string, wait int) string

UnavailableWords answers what a screen says to a person when the request's type failed to answer what they did a moment ago (the API's 503 with the seconds of the minute left, the core's DESIGN 8.1): wait seconds and do it again. In the screen's language, as LimitedWords.

Types

type Action

type Action struct {
	Name      string                     // the event's name: an operationId
	SurfaceID string                     // the surface of the screen it was pressed on
	Component string                     // sourceComponentId: the button's ID
	Timestamp time.Time                  // when it was pressed
	Context   map[string]json.RawMessage // what the button sends, as the renderer resolved it
}

Action is a button's action, as a renderer sends it (A2UI 1.0's message from the renderer to the agent).

func ParseAction

func ParseAction(message []byte) (Action, error)

ParseAction reads the message a renderer sends when a button is pressed: {"version": "1.0", "action": {"name", "surfaceId", "sourceComponentId", "timestamp", "context", …}}. Any other message (a renderer's error, a function's answer) is ErrMessage.

type Asset

type Asset struct {
	Name        string // "catalog.json", "functions.js"
	ContentType string // "application/json", "text/javascript; charset=utf-8"
	Body        []byte // the file as ritsu wrote it; the caller does not change it
	ETag        string // a strong ETag: the body's SHA-256, quoted
}

Asset is a file a renderer reads from the server: ritsu's catalog (catalog.json) and its functions (functions.js, an ES module a browser loads as it is). Its name does not change with what it holds; its ETag does.

type Button

type Button struct {
	ID    string   // the part's ID: "button.approve", "line.open"
	Event string   // the event it sends, an operationId: "approve", "submit_expense"
	Keys  []string // the keys it sends, in their order: "ticket", "revision", "comment"
}

Button is a button of a screen that sends an event.

type Card

type Card struct {
	Kind     string // may be left out
	Language string
	Ticket   json.RawMessage // required
	Can      []string        // what the viewer may do now (Set.Actions)
	Names    Lookup
	Surface  string         // by default the ticket's ID
	Zone     *time.Location // the zone the deadlines (/due) are written in: the kind's; nil is UTC
	// Records is the ticket's history, in its order, of which the card shows what an agent answered
	// in the round the ticket is in (/agent); nil shows none.
	Records []Record
	// Works is the work the ticket launched once it ended, in its order (/works); nil shows none.
	Works []Work
	Serving
}

Card is what an approval card is filled with.

type Deadline

type Deadline struct {
	Of string
	At time.Time
}

Deadline is the deadline a ticket runs to now (ringi's DESIGN 13.8): Of is which, "stage" (the due of the stage it waits at, while it is in progress), "resubmit" (by when the requester is to submit it again, while it is with them) or "pause_ends" (when its hold ends, while it is on hold), and At when. A ticket runs to one of them at a time, by its status; one that has ended, to none.

func DeadlineOf

func DeadlineOf(ticket json.RawMessage) (Deadline, bool, error)

DeadlineOf answers the deadline a ticket of the API runs to now, as a card's /due and a list's row's due say it; false for none.

type Form

type Form struct {
	Kind      string          // the kind's ASCII name; may be left out with a Ticket
	Language  string          // a language the kind's screens are written in: "en", "ja"
	Ticket    json.RawMessage // the ticket sent back, to make the request again; nil for a new request
	SubmitFor []string        // a new request: the people the viewer may make it for (ringi's DESIGN 5.8, 5.13)
	MaySubmit bool            // a kind with `submitted by`: whether the viewer may make it themselves
	Can       []string        // what the viewer may do now: submit; or resubmit, discard
	Names     Lookup          // nil shows IDs as they are
	// Surface follows "<kind>.form." in the surface's ID. A new request's form needs one of its own
	// each time it is shown (a random ID will do): the key of its submit is made from it. A request
	// made again has the ticket's ID by default.
	Surface string
	Serving
}

Form is what a request form is filled with: a new request (no Ticket), or one made again after it was sent back (the Ticket).

type History

type History struct {
	Kind     string // may be left out
	Language string
	Ticket   json.RawMessage // required
	Records  []Record        // the ticket's history, in its order
	Names    Lookup
	Surface  string // by default the ticket's ID
}

History is what a ticket's history is filled with.

type Kind

type Kind struct {
	Name      string   // its ASCII name: "expense", "expense_ja"
	Version   int      // the version the set has
	Languages []string // the languages its screens are written in, sorted: "en", "ja"
	Screens   []string // the screens it has, in their order: the five of screenNames, then "offered" when the package writes it
}

Kind is a kind of request of a set.

type List

type List struct {
	Kind     string // required: every ticket is of this kind
	Language string
	Tickets  []json.RawMessage // in the order to show them; of any version of the kind
	// More is whether the list holds tickets after the last of Tickets (the API's `more`): the
	// screen shows its button of the next page (/more), whose action (Set.Operation) is the list's
	// operation with that ticket as `before`.
	More    bool
	Names   Lookup
	Surface string         // by default nothing
	Zone    *time.Location // the zone the rows' deadlines (due) are written in: the kind's; nil is UTC
}

List is what a list of tickets is filled with: the tickets that wait for the viewer (List), or the viewer's own requests (Mine).

type Lookup

type Lookup interface {
	// PeopleNames answers the names, in lang, of the people and teams with these IDs.
	PeopleNames(lang string, ids []string) (map[string]string, error)
	// MasterNames answers the names, in lang, of the rows with these keys of a master, named by
	// its path: the master file's name and the master's ("company_masters/vendors").
	MasterNames(lang, master string, keys []string) (map[string]string, error)
	// FileURLs answers the addresses a browser opens the files with these IDs at.
	FileURLs(ids []string) (map[string]string, error)
	// FileNames answers the names the files with these IDs were given when they were uploaded, of
	// those the person may open (as FileURLs answers their addresses).
	FileNames(ids []string) (map[string]string, error)
}

Lookup names what a screen shows by ID or key. A fill calls each method at most once for each table, with every ID or key of it the screen shows, sorted, each once, none empty; it does not call a method when there is nothing to ask. An ID left out of the answer is shown as it is (the screens' lookup shows a code it does not find). An error stops the fill.

type Offered

type Offered struct {
	Kind     string // required
	Language string
	// From is the day the request may first be made (YYYY-MM-DD, as Server.Offered answers it): the
	// sentence that says it (/from). "" leaves it null, and no sentence is shown.
	From string
	// Home is the address the button that goes back opens (/home); "" leaves it null, and the
	// button is not shown.
	Home    string
	Surface string // by default nothing
}

Offered is what the "offered" screen of a kind is filled with: the screen a kind with no version in effect shows to one the gate lets make a request of it when a version is to start (Server.Offered), in place of the form a request would be made with.

type Operation

type Operation struct {
	ID     string          // the operationId: "approve", "submit_expense", "get_ticket"
	Method string          // "GET" or "POST"
	Path   string          // the path, with the ticket put in: "/tickets/T-1/approve"
	Ticket string          // the ticket of the path ({id}); "" when it has none
	Body   json.RawMessage // the body, for an operation that takes one; nil otherwise
	// Query is the query of an operation that takes one, as the button sends it (a list's next
	// page: `before`, the last ticket of the page shown, and list_mine's `kind`); nil when the
	// button sends none of it. A null is left out.
	Query url.Values
	Key   string // the operation's idempotency key, for a POST; "" for a GET (see Set.Operation)
}

Operation is an operation of the API (openapi.json).

type Output

type Output struct {
	Name  string
	Value json.RawMessage
}

Output is a value a work ended with: its name and its value of the contract ({"str": {"v": …}}, {"num": …}, {"truth": …}, "nothing" or {"rows": …}).

type Record

type Record struct {
	At      time.Time
	History json.RawMessage
}

Record is a line of a ticket's history: the `history` of a thing to do `next` answered (ringi's DESIGN 12.4), and when the server kept it.

type Refusal

type Refusal struct {
	Refused string // its kind: "form", "comment", "stale", "person"…
	Text    string // the text in English
	TextJa  string // the text in Japanese
	// At is the place of the form a refusal of form names (ReadPlace): a field ("purpose"), a
	// field of a row ("items[1].price", the row counted from 0), a cell the form works out in a row
	// (the first row it is outside its range in: "lines[0].subtotal"), the rows ("lines", for their
	// count). "" names none: a refusal of the comment (its kind "comment") names none.
	At string
}

Refusal is an operation's refusal (the API's 409, ringi's DESIGN 12.4): its kind, its text in English and in Japanese, and the place of the form a refusal of form names.

func (Refusal) Field

func (r Refusal) Field() string

Field is the field At names: its first name ("items" of "items[1].price"); "" for none.

func (Refusal) In

func (r Refusal) In(lang string) string

In is the refusal's text in a language a kind's screens are written in: in Japanese for "ja", else in English. A text missing in Japanese is said in English.

func (Refusal) Place

func (r Refusal) Place() (field string, row int, column string, ok bool)

Place reads At: the field it names; and for a field of a row, the row (from 0) and the field of the row ("" and -1 for none). ok is false when At names no place, or a place a refusal of form does not name.

type Screen

type Screen struct {
	SurfaceID string
	Messages  []json.RawMessage
}

Screen is a filled screen: the messages of A2UI 1.0 to send a renderer, in their order (createSurface, updateDataModel, updateComponents).

func (Screen) WithOldNames

func (sc Screen) WithOldNames() (Screen, error)

WithOldNames is the screen for a renderer that reads the names A2UI 1.0 gives four properties of a part (@checks, @accessibility, @metadata, @catalogId) by their names before 1.0, without the `@` (ringi's DESIGN 13.5). The templates stay as ritsu writes them.

type Serving

type Serving struct {
	// Find is the address the pickers find people, teams and the rows of masters under (/find):
	// <Find>/people, <Find>/teams, <Find>/masters/<the master's path>. "" leaves it null, and a
	// picker finds nothing.
	Find string
	// Upload is the address a file attachment uploads a file to (/upload), on a screen of a kind
	// with attachments. "" leaves it null, and no file can be attached.
	Upload string
	// Refused is the refusal said on the screen (/refused); nil for none.
	Refused *Refusal
}

Serving is what the server puts in a form or a card of its own (ringi's DESIGN 13.2, 13.8): where the screen's parts find values and upload files, and the refusal of what a button of the screen sent, when the screen is shown again after it.

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is the screens of one generated package: the templates of every kind of request in every language, ritsu's catalog and its functions, and the operations of the API. It does not change after Load, and is safe to use from many goroutines.

func Load

func Load(fsys fs.FS) (*Set, error)

Load reads the directory `ritsu gen --target requests` writes (openapi.json, types/ and a2ui/), as fsys: with embed, fs.Sub(files, "requests"). It reads no vector. It refuses a set of a contract it does not read (ErrContract), and one whose files do not agree (ErrSet).

func (*Set) Actions

func (s *Set) Actions(kindName, screenName string) ([]string, error)

Actions lists what a screen of a kind asks the server of the viewer, whether they may do it: the keys of its /can in their order (submit, resubmit and discard on a form; the operations of the kind, and comment, on a card). The two lists and the history ask nothing.

func (*Set) Asset

func (s *Set) Asset(name string) (Asset, error)

Asset is the file of a name: "catalog.json" or "functions.js" (fs.ErrNotExist for another).

func (*Set) Assets

func (s *Set) Assets() fs.FS

Assets is the two files as a file system, at their names. A server that serves it sets each file's Content-Type from Set.Asset rather than from its system's table of types.

func (*Set) Buttons

func (s *Set) Buttons(kindName, screenName string) ([]Button, error)

Buttons lists the buttons of a kind's screen that send an event, sorted by ID: what an action's context must hold for Operation. A button that acts on the renderer alone (one that opens a file) is not among them. The screen is the same in every language.

func (*Set) Card

func (s *Set) Card(in Card) (Screen, error)

Card fills the approval card of a ticket.

func (*Set) CatalogID

func (s *Set) CatalogID() string

CatalogID is the ID of ritsu's catalog the screens name (`ritsu gen --catalog`).

func (*Set) Description

func (s *Set) Description(kindName string) (json.RawMessage, error)

Description is a kind's description as ritsu wrote it (types/<kind>.json): for a module that shows the fields itself, as the plain HTML screens do (ringi's DESIGN 13.6). The caller does not change it.

func (*Set) Form

func (s *Set) Form(in Form) (Screen, error)

Form fills the request form of a kind.

func (*Set) History

func (s *Set) History(in History) (Screen, error)

History fills the history of a ticket.

func (*Set) Kinds

func (s *Set) Kinds() []Kind

Kinds lists the set's kinds of request, sorted by name.

func (*Set) List

func (s *Set) List(in List) (Screen, error)

List fills the list of the tickets of a kind that wait for the viewer.

func (*Set) Mine

func (s *Set) Mine(in List) (Screen, error)

Mine fills the list of the viewer's own requests of a kind: those they are the requester of, or made for someone else.

func (*Set) Offered

func (s *Set) Offered(in Offered) (Screen, error)

Offered fills the "offered" screen of a kind: the day's sentence and the button that goes back, each null and hidden without its value. A package written before the screen was part of the contract has no such screen (ErrKind).

func (*Set) Operation

func (s *Set) Operation(a Action) (Operation, error)

Operation makes a button's action into the operation of the API it is (ringi's DESIGN 13.1): the event's name is the operationId, `ticket` the ticket of its path, and the rest of what the button sends its body, or the parameters of its query (a string, or a number as it is written) for an operation that takes them there.

The surface names the screen (its first two parts are the kind and the screen; ErrSurface for another), the component its button (ErrButton for a part that is not a button sending this event, or a button that acts on the renderer alone). The context must hold exactly what the button sends, and a value the body requires that the API does not take null for (ErrContext).

The key is made from the action, and is the same for the same message sent again. A new request (an operation that makes a ticket) has one key for each body on a surface: its button pressed twice with the same values is one request, which is why a server shows each new request's form under a Surface of its own. An operation on a ticket has a key for each press (the message's timestamp too): pressed twice, an operation that takes the revision is refused as stale the second time, and a comment is written twice. The person is not in the key; the server keeps keys for each person.

func (*Set) Refused

func (s *Set) Refused(surfaceID, lang string, r *Refusal) (json.RawMessage, error)

Refused is the message that says a refusal on a form or a card shown (ringi's DESIGN 13.8): it puts the refusal at /refused of the surface, in the screen's language, and leaves what the viewer typed as it is. nil says that nothing is refused. ErrSurface is a surface of no form or card of the set, or of one with no /refused.

type Step

type Step struct {
	Name string
	Row  int
}

Step is a name of a place, and the row of it the place names (from 0; -1 for none).

func ReadPlace

func ReadPlace(at string) (steps []Step, ok bool)

ReadPlace reads a place as ringi writes the places its answers name (DESIGN 12.4: a refusal's `at`; the elements its rules' refusals and its entries' errors name): ASCII names (a letter or "_", then letters, digits and "_") joined by ".", a row of a list in brackets after the list's name, counted from 0 with no leading zero ("items[1].price", "submit.form.items[1].price"). ok is false for a place not written so, or empty.

type Tables

type Tables struct {
	People  map[string]string            // a person's or a team's ID → its name
	Masters map[string]map[string]string // a master's path → a row's key → its name
	Files   map[string]string            // a file's ID → its address
	Names   map[string]string            // a file's ID → its name
}

Tables is a Lookup over maps, the same in every language: for tests, and for a server that reads the names beforehand.

func (Tables) FileNames

func (t Tables) FileNames(ids []string) (map[string]string, error)

FileNames answers the names of t.Names among ids.

func (Tables) FileURLs

func (t Tables) FileURLs(ids []string) (map[string]string, error)

FileURLs answers the addresses of t.Files among ids.

func (Tables) MasterNames

func (t Tables) MasterNames(_, master string, keys []string) (map[string]string, error)

MasterNames answers the names of t.Masters[master] among keys.

func (Tables) PeopleNames

func (t Tables) PeopleNames(_ string, ids []string) (map[string]string, error)

PeopleNames answers the names of t.People among ids.

type Work

type Work struct {
	// Flow is the name the kind gives its flow.
	Flow string
	// State is waiting, retrying, started, done or failed.
	State string
	// At is when it was started (started), or when it said what became of it (done, failed); zero
	// for none.
	At time.Time
	// Reason is why it failed, as it said.
	Reason string
	// Outputs are what it ended with, as named values of the contract.
	Outputs []Output
}

Work is a piece of work a ticket launched (an `on … launch` line of its kind), as the server knows it (the framework's server.Work).

Directories

Path Synopsis
Package page shows the screens of a kind of request as plain HTML (ringi's DESIGN 13.6): the request form, the approval card, the list and the history, for any browser, with JavaScript or without.
Package page shows the screens of a kind of request as plain HTML (ringi's DESIGN 13.6): the request form, the approval card, the list and the history, for any browser, with JavaScript or without.

Jump to

Keyboard shortcuts

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