npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fieldia/core

v0.36.1

Published

Headless form model for Fieldia: the page format, modifiers, validation and record state. No DOM.

Readme

@fieldia/core

The headless half of Fieldia: the page format, modifiers (invisible, readonly, required), validation, and a form's record state. It never touches the DOM, so it runs the same in a browser, in Node, and on a server that generates pages.

npm install @fieldia/core
import { validatePage, createForm, createMemoryDataSource } from '@fieldia/core';

const checked = validatePage(json);            // { ok, page } or { ok: false, issues }
if (!checked.ok) throw new Error(checked.issues.map((i) => `${i.path}: ${i.message}`).join('\n'));

const form = createForm({ page: checked.page, dataSource: createMemoryDataSource() });
form.setValue('email', '[email protected]');
form.subscribe((state) => console.log(state.values, state.errors));

Fieldia knows no backend. Records load and save through a DataSource — load, save, onchange, search, create, submit, and list and groups for a list of records — that your app implements; createMemoryDataSource implements all of it in memory, for tests and demos.

The page format is also a JSON Schema, for editors and other languages: @fieldia/core/page.schema.json, each setting described (from the docs of the format's TypeScript types).

validatePage and the format's schemas carry zod (about 105 KB gzipped with them); checkPage, which every viewer draws a page with, carries none, and an app that only shows forms never bundles zod. checkPage is the check a viewer runs before it draws a page, refusing what 0.35's viewer refused. checkPageWhole gives validatePage's verdict without zod — the format's schema made from the same definitions, the same rules — in a part of its own, which a viewer asks for after the first draw: in 0.36 what only it finds is said, once in the console and to onError, and refused from 0.37 (page.invalid). A guide for AI agents writing pages: docs/agents.md. Where pages are made, they come on their own too — @fieldia/core/schema (validatePage, PageSchema, FieldSchema), one file with zod inside, which a bundler gives a chunk of its own — for an app to fetch when it needs them, as the designer does as it opens:

const { validatePage } = await import('@fieldia/core/schema');

Importing validatePage from @fieldia/core as well carries the schemas twice: once at once, once in that chunk.

A page says which format it is written in ("fieldia": "0.13", FORMAT_VERSION; a page in 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11 or 0.12 is read as it is) — and a page saved says the lowest one its settings need (stampPage(page), lowestFormat(page) from @fieldia/core/schema; the designer publishes so), so an older Fieldia that knows every setting a page uses reads it. One in an older format is brought up to date as it is read — by checkPage, validatePage and createForm, so by the viewer and the designer too — and upgradePage does it for the pages your app keeps. One newer than this Fieldia is refused with words that say so ("this page is in format 0.2, newer than this Fieldia reads (0.1): update Fieldia to show it"):

import { upgradePage } from '@fieldia/core';

const page = upgradePage(stored);   // the same object when it is already current; a copy brought up step by step if not
if (page !== stored) await save(page);

A release that renames or reshapes a setting adds a step to PAGE_UPGRADES, with a page before and after it that the tests run. What each release changed is in the changelog.

A page's look sets its accent, font, spacing, corners, labels and light or dark scheme, and, under parts, a look for each kind of part over it — the settings each kind has are PART_LOOKS:

"look": {
  "accent": "#1f7a4d",
  "parts": {
    "inputs":  { "background": "#fff7e6", "border": "#c4320a", "corners": "round", "textSize": "large", "accent": "#c4320a" },
    "choices": { "accent": "#1f7a4d", "background": "#f0f7ff", "border": "#1677ff", "corners": "soft", "textSize": "small" },
    "groups":  { "background": "#fbfaf7", "border": "#d6cfc2", "corners": "round" },
    "buttons": { "accent": "#6941c6", "corners": "round", "textSize": "large" },
    "tables":  { "background": "#eef2f7", "border": "#9aa3ad", "textSize": "small" }
  }
}

The validation messages (MESSAGES) come in English, Arabic, German and French, and in Turkish (tr), Persian (fa), Urdu (ur) and Spanish (es); English is there at once, and every other language comes in a chunk of its own, fetched by await wordsReady(locale) — which mountViewer does before it draws — so an app never carries a language it does not show (0.35: Arabic, German and French came at once before). Turkish, Persian, Urdu and Spanish are machine-assisted, not yet reviewed by a native speaker: every message English has, with its blanks, not yet read by a native speaker (corrections welcome). Persian and Urdu are written right to left; readNumber reads their digits (۰–۹) and marks (٫ ٬) as it reads Arabic-Indic ones; a day a message names is written by Intl on the Gregorian calendar a value is kept in (dayTag: Intl's own for Persian is the Solar Hijri — Fieldia shows the Gregorian day, in Latin digits, in Persian too, for now). listComma gives the Arabic comma in Arabic, Persian and Urdu.

firstWeekday(language, page?) is the week's first day, 0 Sunday to 6 Saturday — the one every week Fieldia draws starts on: a list's "this week" and its weeks, a calendar's and a timeline's, a date's and a range's month, booking slots' month, a week's hours, a repeat's days, a chatter's history. CLDR's day for a region, which is decided in this order:

  1. the region of the language's own tag: the page's ("language": "en-GB", where the page is shown in its own language) or the one given (en-GB);
  2. else the reader's, where the browser asks for the same language with a region (navigator.languages, the first that does): an en page read in en-EG starts on Saturday, in en-GB on Monday, in en-US on Sunday;
  3. else the region CLDR has the language most spoken in: the United States' for en (Sunday), Egypt's for ar and Iran's for fa (Saturday), Pakistan's for ur (Sunday), Germany's, France's, Turkey's and Spain's (Monday).

The day is the engine's own Intl.Locale week info, else CLDR's table (Firefox has none). A third argument gives the reader's languages instead of the browser's, for a server or a test. In the one-tag script it comes with the parts that draw a week (fieldia.list.js, fieldia.date.js), not with fieldia.js: Fieldia.firstWeekday answers once one has come — await Fieldia.datePart.load() first where your own code calls it on a page that has drawn no week.

Those four come in a chunk each of their own, so an app never carries the words of a language it does not show: each package says how it fetches its words (wordsInChunks(tableInChunks(table, { tr: () => import('./tr') … }))), and wordsReady(tag) fetches every package's for a language, once — the viewer, a map and a chatter wait for it before they draw. Asked for, a package's table for the language is there at once, English's words, and filled in place as its chunk comes; wordsComing(tag) says whether it has yet. Something that reads them without waiting gets English, and the console says once what to await.

import { wordsReady, createForm, MESSAGES } from '@fieldia/core';
await wordsReady('tr');
const form = createForm({ page, messages: MESSAGES.tr });

Words that come after something was worked out or drawn in their place — a chunk that came past its 30 s wait, say — are an input of it: wordsVersion() grows each time a table is filled, and onWordsCame(listener) is told (it gives back a function that stops it). A form says its problems and warnings again in them as they come, and the viewer draws its parts again, however quick the way a change is worked out.

What a page and its values cannot make Fieldia do

A page may be written by an admin, an AI agent or an imported schema, and its values by anyone; neither can make a form run script or take seconds:

  • Addresses. Every address a link, a picture, a player, a frame or a page sent elsewhere is given goes through safeUrl(value, allowed, base?): read with the browser's own URL parser (tabs, line breaks and control characters dropped, the scheme in any case), and kept only when its scheme is one the place allows — LINK_URL (http, https, mailto, tel, a path of this site), PICTURE_URL (and a blob the page made, a picture written as data), MEDIA_URL, DOWNLOAD_URL. An openUrl step that gives any other opens nothing and says so ("This address was not opened: …"); checkPage and validatePage refuse one the page writes ('javascript:…').
  • Patterns. A field's pattern and an answer rule's are refused — checkPage and validatePage name them, an answer is never tried on them — where they could backtrack for seconds: a part that repeats holding a repeat that can take what its next round starts with (([a-z]+\s?)*, (a+)+), one that may match nothing ((a?)*) or whose choices start alike ((a|ab)*), or two repeats without end side by side, only optional parts between them (\d+\d+, \w+\s*\w+). Every pattern whose repeats each start with what the one before cannot take is fine — (-[A-Za-z0-9]{2,8})*, [^@\s]+@[^@\s]+\.[^@\s]+. An answer longer than PATTERN_MOST (1,000) characters is not of its pattern. On your server, check answers with the same checkValue, or run a page's patterns under RE2 or with a time limit.
  • Sizes. Text read as a date is at most DATE_TEXT_MOST (100) characters; a value the page works out (compute, set, setWhen) at most COMPUTED_MOST — 100,000 characters, 10,000 items — or none.
  • Names. A field is never named constructor, __proto__ or prototype, and an expression reads a value's own properties alone.

A starting page from a schema

pageFromSchema(input, options) makes a page from what an app already has: a JSON Schema, an OpenAPI document (a component's schema, or an operation's request body and parameters — schema: 'POST /enquiries', an operationId, or a component's name; schemaChoices(doc) lists them), or a model's fields — Fieldia's own, or a backend's field list such as Flectra's fields_get (string, selection pairs, relation). Each property becomes a field of its kind, with its label (title, else its name in words), help (description), required, read-only, limits (minimum, maximum, maxLength, multipleOf as decimals), pattern (found anywhere, as JSON Schema reads it), choices (enum, a union of consts) and default; format picks the box (date, date-time, email, uri, time, a phone, a password, a colour, a file); a list of choices is several picked, a list of files several files, a list of objects a table of lines; an object's properties are fields of their own in a section of its name. $refs inside the document are followed, allOf merged, null set aside.

import { pageFromSchema, validatePage } from '@fieldia/core';

const { page, notes, unmapped } = pageFromSchema(openApi, { schema: 'POST /enquiries', kind: 'screen' });
validatePage(page).ok; // true: a page Fieldia reads, to edit in the designer

Nothing is dropped quietly: what is kept with a change is in notes (a name a field cannot have, renamed; an object's properties flattened; a value of a kind no field holds — a list of text, a union of kinds — kept as JSON; a limit no setting holds, such as minLength, left to your server), and what is left out in unmapped (a $ref outside the document, a property of no kind). Each has a code and the property's path; schemaNoteWords(note) says it in English. A survey (kind: 'survey') is a step for the page and one for each object, sent as responses; a screen keeps a record of model (its title's words joined by dots unless given). A schema that gives no page throws SchemaRefused, its code saying why. In the designer: Start from a schema… on a blank page.

Values that wait for a line

A value worked out from others waits while one of them holds text that does not read — "abc" in a line's Quantity — as the table's own total does, so it is never shown counting the value that text replaced. Who works it out does not matter: the page (a compute, such as sum(lines, 'subtotal'), and what is worked out from that in turn) or your app (an amount or totals kept whole, read only, which a source with an onchange works out as the lines change — a sales order's Untaxed, Taxes and Total, Flectra's tax_totals). form.waitsFor(field) says what it waits for — { field: 'line_ids', line: 1, column: 'qty' }, the line as people count lines, or { field: 'rate' } for a field of the record's own — and null when it shows its value; the viewer draws it as a dash, said in words ("Fix line 1 of Order lines to see Untaxed amount"). An answer your onchange gives meanwhile is kept, and shown once the line reads.

It waits the same for an answer the form refuses: one shown that holds a value its checks do not take — an area of −50 under its min of 0, a day past its max of today, a pattern not met, an answer rule's error — on the record or in a line's cell, whether the value is the page's own formula, one of Fieldia's functions (years(built_on, today())) or your app's: "Fix Area (m²) to see Price per m²", never −120,000.00. An empty answer is none, required or not, and one no one is shown is never refused. What waits for an answer is told before what is asked of your app's server for it.

Functions, and your app's own

A value worked out (compute), a value set by a condition (setWhen) and every condition call functions by name. Fieldia's own: round, roundMoney, min, max, abs, sum, count, average on numbers; today, days, age, years, months, addDays, addMonths, addYears on dates; contains, startsWith, endsWith, upper, lower, join, len on words; if, empty, firstOf to choose.

"age":        { "type": "integer",  "label": "Age",            "compute": "age(birth_date)" },
"second_due": { "type": "date",     "label": "Second payment", "compute": "addMonths(first_due, 1)" },
"per_meter":  { "type": "monetary", "label": "Price per m²",   "compute": "roundMoney(price / area, currency_id)", "currencyField": "currency_id" },
"code":       { "type": "char",     "label": "Code",           "compute": "upper(join('-', city, firstOf(nickname, name)))" }
  • age(birth, on?) counts whole years to today on the page's clock (its timeZone), or to a day given; years(from, to) and months(from, to) count whole ones, negative when the second day comes first.
  • addMonths(day, n) ends on a shorter month's last day — 31 January and a month is 28 February — and months counts the same way, so the two agree. A date and time keeps its time. addYears moves 29 February to the 28th.
  • contains, startsWith and endsWith read text whatever its case; contains also finds a value in a list (choices ticked, links).
  • join(between, values…) joins the values — lists opened — with the words given first, leaving the empty ones out: join(' ', first_name, last_name).
  • average takes values or a list, or a field of the lines where a condition holds, as sum does: average(lines, 'price', "qty > 0").
  • roundMoney(amount, currency) rounds to the currency's places — three for a Jordanian dinar, none for a yen — the currency a code ('JOD') or a link to one, read by its name.
  • empty(value) holds for nothing, words of only spaces, an empty list; zero and no are values. firstOf(a, b, …) is the first that is not empty.

Each is read as the page is. Refused, by validatePage, checkPage and so as a form is made: a function there is not, or one given too many or too few values. A warning, never a refusal: a value of a kind a function does not take — age(notes): "age takes a date as its first value; "notes" is text". validatePage passes such a page and says it in warnings beside it (pageWarnings(page) gives them alone; kindProblems to your own tools); the designer says it as a fix to make; the viewer runs the page as it always did, the call giving nothing — a function given a value it cannot use gives nothing, never an error. A page that passed before still passes.

Your app's own. Give the form functions — the viewer and the React, Vue and Angular components take the same option — and a page calls them by name, beside Fieldia's. A plain function will do; say what it takes and gives, and the page's checks and the designer read it:

createForm({
  page,
  functions: {
    vatRate: { takes: [1, 1], values: ['text'], gives: 'number', tip: 'The VAT rate of a country: vatRate(country)', call: (country) => RATES[country] ?? 0 },
    // One that asks your server: a promise.
    districtPrice: { asks: true, call: (district) => api.get(`/districts/${district}/price`).then((r) => r.perMeter) },
  },
});

A number one gives is tidied as Fieldia's own arithmetic tidies one — price * 1.1 of 100 is 110, never 110.00000000000001 — and one that is no number (NaN, Infinity) is nothing. A function that asks your server gives a promise. What is worked out from it waits while it is asked — empty meanwhile, form.getState().asked says so by field ({ total: {} }), form.waitsFor('total') gives { field: 'total', asking: true }, and the viewer shows an ellipsis, said in words ("Working out Total…") — then its answer is worked into everything after it. It is asked once for the same values, for the record shown: another record shown, its answer is laid on none. A save waits for every answer; one that failed ({ failed: 'why' }) is asked again as the person saves, and stops the save under its field when it fails again ("Total could not be worked out: …"). A condition calling one does not hold while it is asked. A name a page cannot call — Fieldia's own, a word of the language — is refused as the form is made. validatePage(page, { functions }) and checkPage(page, { functions }) read pages that call them.

Options that follow the answers

An option of a choice may show only while a condition holds, written as a part's invisible; and a choice may offer the options picked in an earlier one (optionsFrom: { "field": … }), its own options after them:

"features": { "type": "selection", "label": "Features", "multiple": true, "options": [
  { "value": "garden", "label": "Garden",  "invisible": "unit_type != 'villa'" },
  { "value": "lift",   "label": "Lift",    "invisible": "unit_type == 'villa'" },
  { "value": "security", "label": "24-hour security" }
] },
"again": { "type": "selection", "label": "Which would you have again?",
  "options": [{ "value": "none", "label": "None of them" }],
  "optionsFrom": { "field": "treatments" } },
"try_next": { "type": "selection", "label": "Which would you like to try?", "multiple": true,
  "options": [], "optionsFrom": { "field": "treatments", "picked": false } }

form.offered(field) gives the options a choice offers now: its own — or those its app's list gave, or those picked where they are carried from (picked: false: those left unpicked; a "None of these" is never carried) — less those whose condition hides them. A chosen option a change no longer offers is taken out of the answer, never silently kept: form.getState().takenOut says so by path ("Garden is no longer offered, so it was taken out"), while it is true: it goes once the value is written again, or once what it names is offered again (Villa picked again, the treatment ticked again above, the list asked again offering it); one of several offered again leaves it naming the rest. The same words for a choice its app's list no longer offers, a page's or a line's. One a record held as it was opened stays chosen, and the choice says it is no longer offered. The page's checks read each option's condition and refuse a choice carried from itself, from a field that is no choice, or round a circle.

A table line's choice takes conditions on its options too, read on the line's own values and the record it is on (parent.): a room's "Garden room" only on the ground floor, a "Pool house" only for a villa. form.offered("rooms.k1.use") gives a line's by its cell's path; an option a change of the line, or of the record, hides is taken out and said by that path (takenOut["rooms.k1.use"]). A line's choice carries no options from a question: its own, or one of the app's lists — the same optionsFrom as a page's own choice ({ list, dependsOn }, its dependsOn naming the line's columns or parent. and a field).

One text in several languages

A line, a paragraph or formatted text may keep its text in several languages, each typed by a person — Fieldia never translates it (translate), and requiredIn says which a required answer is typed in (every one when left out):

"title": { "type": "char", "label": "Title", "translate": ["ar", "en"], "required": true, "size": 80 },
"description": { "type": "text", "label": "Description", "translate": ["ar", "en"], "required": true, "requiredIn": ["en"] }

Its value is an object of each language's text by its tag — { "ar": "شقة…", "en": "Nile-view flat" } — a language not typed yet left out, none typed null; a plain text loaded for it is read as its first language's. The form checks it in each language: "Title is required in Arabic" while it is typed in some (languagesNeeded, or languagesNeededQuestion for a label that asks), "Title is required" in none; each language held to the field's size and pattern, named in the problem ("Title (English) is 4 characters too long: shorten it to 80"). textIn(value, reader, languages) reads it as a reader of a language does — theirs where typed, else the field's first typed, said to be another's — languageName(tag, locale) names a language, checkTranslated and languagesAtFault check it. They come in the languages part (formLanguagesPart), which a form with such a field asks for as it is made and a save waits for; languagesOf(field) and hasLanguages(page) say whether a page has one. A table's line keeps one language. The memory source finds such a text by a search in any of its languages, and reads one text — a link's name, a list's order — in its language option's.

A public form's bot check

A page of responses anyone may send — a sign-up, a contact form — can check that a person sent it (botCheck): a box no person sees or reaches, which a bot filling every box fills (honeypot, on unless false); the fewest seconds a person takes from the page shown to its send (minSeconds, 3 unless said; 0 tells none); and the slot the app draws its own captcha in (captcha: a slot's name — Turnstile, reCAPTCHA, hCaptcha):

"layout": { "type": "sections", "id": "signup", "children": [
  …,
  { "type": "slot", "id": "s-captcha", "name": "captcha" }
] },
"botCheck": { "minSeconds": 3, "captcha": "captcha" }

Nothing is refused for it on the page: each send tells the app what it saw, beside the answers (submit({ pageId, values, bot }), and the send event), and the app decides — keep the response aside, check the token with its service, or refuse it:

async submit({ pageId, values, bot }) {
  // bot: { honeypot: false, tooFast: false, seconds: 41.2, captcha: '0.Zx…' }
  if (bot?.honeypot || bot?.tooFast) return keepAside(pageId, values);
  if (bot && !(await verifyTurnstile(bot.captcha))) throw saveRefused({ kind: 'rule', message: 'Tick “I am human” first' });
  return store(pageId, values);
}

The app's captcha widget hands its token to the form, form.botCheck({ captcha: token }) (null once it expires); a token goes once it is sent, as a captcha's is spent. The viewer draws the hidden box and tells the form when it is filled (form.botCheck({ honeypot: true })). A page without botCheck sends what it always did.

What a page says once it is sent, and answers in its words

A page of responses' endings say what it shows once its answers are sent: the first whose when holds on the answers as they were sent — with what the data source answered, the id it gave the response and the values it added — else the one with no when, shown otherwise, which comes last. {id} in its words is that reference:

"endings": [
  { "when": "overall <= 2", "title": "We are sorry, {name}", "text": "{branch} will call you today.", "again": false },
  { "title": "Thank you, {name}", "text": "Your booking is {id}.", "again": "Book another" }
]
async submit({ pageId, values }) {
  const kept = await store(pageId, values);
  return { id: kept.reference, values: { confirmed_at: kept.confirmedAt } };   // what the ending reads
}
form.getState().sent;          // { id: 'B-1043', values: { …the answers sent, confirmed_at } } until reset()
form.ending();                 // the ending for them, or null
form.endingWords('Your booking is {id}.');   // "Your booking is B-1043."

{field} shows an answer in the page's own words too — a field's label and help, each choice's words, a step's title and words, a wizard's and a button's words — as in a text's and an alert's: form.words('How was your visit to {branch}?') is "How was your visit to Zamalek?", and the form's messages name the field so ("Please answer “How was your visit to Zamalek?”": a label that is a question — ending with a question mark, or an ellipsis the answer completes — is quoted in the language's marks wherever a sentence names it, isQuestion and quotedLabel, and its required message is requiredQuestion). How a value reads there is the viewer's (valueWords in createForm's options: a choice by its label, money with its currency, a day in the page's order); without one, a choice's label, a link's name, Yes or No, anything else as held. After a bar, the words said while the answer is empty — {branch|this branch} reads "this branch" until one is chosen, translated with the page's other words; without them an empty answer says nothing. A {name} that is no field of the page is refused by the page check. createMemoryDataSource answers each response as a server would with submitted: (request, count) => ({ id: `B-${1042 + count}` }).

A brace the words quote, never a value, has a backslash right before it: \{list} shows "{list}" (in JSON, "\\{list}"), \{method:value} shows "{method:value}", \{\{customer}} shows "{{customer}}", and the page check refuses none of them. A run of backslashes before a brace shows half of them, and an odd run leaves the brace as written: \\{name} is one backslash, then the value. A backslash anywhere else is as written — C:\files\report.pdf reads as it is — and words with no backslash before a brace read as they always did. This is so wherever a page's words are shown, value or none: a label, a help, a box's placeholder, a choice, a title, a section, a tab, a counter, a badge, an alert, a button and its question, a toast, an ending, a quiz's feedback, the page on paper, a list, the designer's preview — and in the page's translations, which find their words as written.

An app that puts words it did not write into a page — a step's help, a choice from its own list — writes them at one place with literalWords(text): each brace escaped, each run of backslashes before one doubled, so every reader shows text exactly, with no value and nothing for the page check to refuse. literalPage(page) does so for every word a person reads in a page — the words translatePage translates, and its translations — and leaves names, ids, choice values, conditions, addresses and data as they are. plainWords(words) reads words as Fieldia draws those that show no values (a title, a tab): each escaped brace a brace, a {field} as written; plainPart(part) reads every word of a field, a part or a page so, for an app that draws them itself.

A quiz's results

A page of responses with quiz shows the person their results once the answers are sent: their score, each question marked right or wrong, the right answer to one missed and the question's own feedback. A choice's right answers are its options marked correct; a question typed — a word, a number — names the answers it takes (quiz.answers: words whatever their case and spaces, a number by its value). A right answer earns its question's quiz.points, else the page's, else 1; a choice whose options carry points (score) earns those, as before, marked neither right nor wrong. With several answers, right is exactly the right ones.

"quiz": { "results": "now", "points": 1, "rightAnswers": true },
"fields": {
  "reversible": { "type": "selection", "label": "Which filler can be dissolved?",
    "options": [{ "value": "ha", "label": "Hyaluronic acid", "correct": true }, { "value": "caha", "label": "Calcium hydroxylapatite" }],
    "quiz": { "feedback": { "right": "Yes: hyaluronidase dissolves it.", "wrong": "Only hyaluronic acid can be dissolved." } } },
  "enzyme": { "type": "char", "label": "Which enzyme dissolves it?", "quiz": { "answers": ["Hyaluronidase"] } }
}

The form marks the answers as they go — form.getState().sent.quiz is { score, max, questions: [{ field, points, max, right, answered, rightAnswer?, feedback? }] }, in the order they were asked — with the survey flow's part (formSurveyPart, asked for as the form opens). results: "later" says the results come once you have reviewed them, and shows none; rightAnswers: false keeps the right answers back. The right answers travel in the page, where anyone who reads its JSON finds them: a test where that matters keeps them out of the page, marks the answers on your server and answers the send with them — submit returns { quiz: { score, max, questions } }, shown in place of the page's. quizResults(page, values, asked?) marks answers the page's way for your own code. A quiz has no pass mark of its own yet: your server may answer the send with a value of its own (values: { passed: true }), which an ending's when reads.

A review before sending

review on a page of responses shows every answer before it is sent — by step on a wizard, by titled group on a page of sections — each with Edit back to its question, then Send: true in Fieldia's words ("Check your answers"), or { "title": "Before you send", "text": "Press Edit to change one." } in the page's. The viewer draws it (the survey flow's part); the answers are checked as a step's are before they show. form.validate(within) checks the answers inside one part alone — a step, a question — as the review and one question at a time do.

One question at a time

"flow": "one" on a page of responses asks one question at a time (the viewer's survey part draws it): each question on a screen of its own, Enter or OK going on once its answer is checked (form.validate(within), the question's part alone), a choice picked going on by itself. A wizard's steps are entered, checked and kept as ever. A record's sheet, and a list, are refused it.

Questions in an order drawn, and N of M

On a page of responses, a wizard's "order": "random" shows its steps in an order drawn for each respondent — a step "fixed": true keeps its place (a welcome first, a page about you last) — and a step's or a group's shows its questions so: words and pictures, and a question fixed, keep their places. "draw": 5 asks 5 of its questions, drawn, the rest never asked (nor required, nor sent). The draw is seeded — createForm's seed (an invitation's code, a candidate's id), else the person's user.id, else one of the browser's for each response — so the same seed draws the same in every engine. The form keeps it as state.order (by part, its parts' ids in the order shown), in its drafts — a page opened again shows the same questions — and sends it with the answers (SubmitRequest.order). A quiz's results follow the order shown. The draw comes in the survey flow's part (formSurveyPart, asked for as the form opens; a form made before it came draws once it has).

A time limit

"timeLimit": { "minutes": 20, "warn": 2, "then": "send" } on a page of responses, or on one of its steps. A page's clock starts with form.startTimer() (the viewer's Start), a step's as it is first entered; each runs on the form's clock (now, scheduler) and runs out on time (state.timeUp, by scope: #form, or the step's id). Its answers are then locked, and their checks refuse nothing: they go as they stood — a required answer not given goes empty. then: "send" (a page's default) leaves the send to the viewer, at once; a headless app calls form.save() as timeUp changes. lock (a step's default) keeps them for the person to send; a step's that locks gives way to the next step. form.countdown() is the countdown showing now ({ scope, left, ends, stage: 'running' | 'warning' | 'up', … }). Their starts are kept in drafts (StoredDraft.timers) with the answers, so a page opened again goes on counting: a reload is never a way round a limit. A clock's start is kept the moment it starts, and a draft whose clock started is laid at once — never offered to be let go, even with drafts.restore: "ask". Where the app keeps no drafts (no drafts, no saveDraft), a timed page keeps them in the tab's own store (sessionStorage): a reload goes on with the time left, or — past its end — says the time is up and sends or locks as the page says. Sent, or started again (form.reset()), the draft is let go: the next response is a new one, with its own clock. The send tells started and timeUp. The clock is the browser's, and another tab or device starts afresh: a server that must be sure keeps its own (it has started), and takes one response per person (limits.onePerPerson).

Files stored as they are picked

Give the data source upload(file, request) and a file or picture field sends each file to your store as soon as it is picked; the record keeps only the link it returns — { url, name, size, type, fileId }. form.upload(field, files) does it for a widget of your own: state.uploads shows each on its way (its status and the bytes sent of total), three at a time, in the order picked, and form.uploading(field) gives one field's own; form.cancelUpload(id) and form.retryUpload(id) stop one and send a failed one again. A file picked in a table's cell goes as its line's (request.line). form.save() waits for those still going, stops under the field for one that failed, and stores bytes still in the record (a signature drawn) first. A saved form placed in a record keeps to the same: its files are stored for the record (model and recordId are the record's, field is where it sits: consent.deed), and the record's save waits for them. A file picked while a save is on its way stays a change, to save next. A draft never keeps a file's bytes where the source has upload; without it, a draft keeps them, as before. The sending itself — each file made ready and sent, its link put in its field — is a part of its own (formUploadsPart), which comes with @fieldia/widgets' files part, or the first time a form sends a file: form.upload gives its ids at once, each file waiting its turn until the part is in.

import { uploadTo } from '@fieldia/core';

// A POST of a form with the file under `file`; its link from the answer's JSON `url`.
const dataSource = { ...yourDataSource, upload: uploadTo({ url: '/api/files', headers: { 'X-CSRF-Token': token } }) };
// Or a PUT to an address your server signs (Azure Blob's SAS): the link kept without the signature.
const toAzure = uploadTo({ method: 'PUT', url: (file) => signedAddress(file.name), headers: { 'x-ms-blob-type': 'BlockBlob' } });

To refuse a file, throw saveRefused({ kind: 'rule', message }): the field shows your words and offers no Retry; any other error offers Retry. Stop with an AbortError when request.signal aborts. createMemoryDataSource({ storage: { bytesPerSecond, fails } }) is a store as slow, or as unreliable, as a real one. Without upload, files travel inside the record as base64, as before. See files stored as they are picked. uploadTo's work comes in the files part (0.31), asked for as its first file goes — a page with a file field has it already; one with none never downloads it.

A photo set ("widget": "photos", @fieldia/widgets' README) keeps everything in the field's value, so any source that keeps a file value keeps it: the photos in the order a person put them (the first the cover), a photo's caption, and for a photo cropped or turned the photo as it was (original, a file value of its own) and what was done to it (edit: { turn: 90, crop: { x, y, width, height } }, fractions of the turned original). A photo cropped is stored at once — form.upload(field, [file], { replaces }): its link takes the place of the bytes the field holds for it, with whatever stands beside them by then (a caption typed meanwhile).

Lists that add up, and filter by time

A list asks its source's optional totals({ model, filter, totals, groupBy?, interval?, currencies? }) for a column's sum, average, lowest, highest or count — over the search, under each group, or the rows ticked (id in their ids) — and its groups for a date by the span it falls in (interval: day, week, month, quarter or year, with weekStart and timeZone), each group's value its span's first day. An amount named in currencies (by the field holding each record's currency) is totalled within one currency only: over several, its sum is null, and currencies in the answer names the one it is in. A period a list's filter names ("This month", "Overdue") arrives as plain conditions. spanStart(value, interval, { weekStart, timeZone }) finds the span a value falls in as the list counts it, and dayIn and dayStarts a day in a time zone; createMemoryDataSource does it all. See lists that add up.

A map's records counted where they crowd

A list's map (@fieldia/map) asks its source's optional clusters({ model, filter, field, longitude?, bbox, zoom, radius, fields, weight?, signal }) for the view's bubbles — { clusters: [{ lat, lng, count, bbox?, weight? }], points?: [{ id, values }], unplaced? } — instead of loading at most 500 records and gathering them itself: every record a search finds, however many, a record standing alone with its values for its pin and its card. Answer false to let the map load the search's records, as it does without the member. The memory source has it where its clusters option says how it answers: createMemoryDataSource({ records, clusters: gridClusters({ models: ['home'] }) }) gathers its records by a grid of squares fixed to the world, as a server does. See lists on a map.

Time zones and booking slots

A page may name the time zone its dates and times are in, by its IANA name — a branch's, a clinic's — and a date and time field may name its own:

{ "timeZone": "Europe/Berlin", "fields": { "flight": { "type": "datetime", "label": "Departs", "timeZone": "Africa/Cairo" } } }

A date and time is still kept as an instant, as before (2026-10-15T12:30:00.000Z; one written with its offset is read the same). It is shown and typed on the zone's clock wherever the person is, with the zone's short name beside it where the browser's zone is another ("14:30 CEST"). Today is the zone's day: a date's default "today", its earliest and latest counted from today, today(), a rule's past and future, and form.today(). A time the clocks skip, or repeat, on a change day is said, never moved. zonedPage(page) writes the page's zone into each date and time field that names none, as the form and the viewer read it; wallTime, instantsAt, dayIn and clocksSkip are the clock arithmetic they use. checkPage and validatePage refuse a zone the browser does not know. Without timeZone, the browser's own zone, as before.

A selection's choices may come from the app's own lists (optionsFrom: { list, dependsOn }), through the data source's options({ list, values }), asked again when a field in dependsOn changes — by the person, a step or the app: a choice the new answer does not offer is then taken out and said (state.takenOut, as a condition's is, until its value changes again); a record that comes in with one keeps it, and its save says why. On a table's line they are that line's: asked with the line's values and the record it is on as parent (dependsOn naming the line's columns, or parent. and a field), shared by the lines whose columns hold the same values, and kept by the cell's path in state.choices (form.loadChoices("tool_ids.k1.tool")), taken out and said the same way, by the cell's path, as a column they change with changes on that line. form.lineChoices(field, key, column, values) asks a line's for a row about to be pasted on it. The memory source's lists functions take the request after the values. Such a choice may leave its options out: it has none to start with, and the list fills them — upgradePage, which checkPage, validatePage, createForm and the designer read a page through, reads them as [].

A date and time drawn as booking slots ("widget": "slots") asks the data source's slots(request) for its free times: the days asked (from, to, in timeZone), the schedule its node names (options.schedule), the booking's length and the minutes between two as the page says, the record and its values. It answers each day's state — open, full, closed, holiday with a note — and the times free, as instants, and may say the booking's length. form.findSlots(field, { from, to }) asks it for a widget of your own; form.canFindSlots() says whether the source can. Without slots, the field is the plain date and time box. For demos and tests, scheduleSlots(schedules) answers from booking schedules — hours by the day of the week on a zone's clock, a booking's length, the minutes kept free after one, holidays, and the records the bookings are:

import { createMemoryDataSource, scheduleSlots } from '@fieldia/core';

const weekday: [string, string][] = [['09:00', '13:00'], ['14:00', '18:00']];
const dataSource = createMemoryDataSource({
  records,
  slots: scheduleSlots({
    showroom: {
      timeZone: 'Europe/Berlin',
      hours: { 1: weekday, 2: weekday, 3: weekday, 4: weekday, 5: weekday, 6: [['10:00', '14:00']] },
      length: 45,
      between: 15,
      holidays: { '2026-12-25': 'Christmas Day' },
      bookings: { model: 'drive.booking', field: 'start', endField: 'stop', same: ['car'] },
    },
  }),
});

Possible duplicates and Merge

A record's page may name the fields records like the one typed are found by — the same phone, email or tax id, a name close enough:

{ "duplicates": { "fields": ["name", "phone", "email", "vat"], "on": "type" } }

The data source's duplicates({ model, recordId, values, fields }) is asked with the fields named that hold a value (none: nothing is asked), every value of the form and the record typed (null while new), and answers with the records like it — { matches: [{ id, name, why: ['phone'], score? }] }, why naming the fields each matched on. on: "type" (the default) asks as those fields are typed in, as a saved record opens and as it is saved; "save" only as it is saved. Nothing is in the way of a save. merge({ model, keepId, mergeIds, values, fields }) keeps keepId with the value picked for each field and takes mergeIds away; moving what was theirs (messages, activities, links) is the source's work, and saveRefused({ kind: 'rule', message }) refuses it. form.findDuplicates(), form.readRecord(id) and form.merge(…) ask the source for a screen of your own, form.canFindDuplicates() and form.canMerge() say whether it can; the viewer says each match under the field it matched on, with Open it, "It's someone new" and Merge (@fieldia/viewer). "It's someone new" is kept on the app's server where the source has both notDuplicates({ model, recordId }) → ids (asked as a saved record is shown, before its matches are said) and markNotDuplicate({ model, recordId, matchId }) (as it is pressed on a saved record, or a new one is saved after it): a pair, answered from either side, so another device lets that record be too; without both, the person's browser keeps it (the viewer's preferences), as before. form.keepsNotDuplicates(), form.notDuplicates() and form.markNotDuplicate(matchId) reach them. checkPage and validatePage refuse a field the page has not, one named twice, and one of a kind records are not compared by (DUPLICATE_KINDS). Without duplicates in the source, nothing is asked. For demos and tests, alikeRecords() answers from the memory source's records — the same value as people write them apart (a phone's spaces, an email's case, a link's record) or, in the name field, a name close enough (nameLikeness) — its merge merges as a backend would, and its notDuplicates and markNotDuplicate keep what was let be as pairs (notDuplicatePairs, an option to start from):

import { alikeRecords, createMemoryDataSource } from '@fieldia/core';

const dataSource = createMemoryDataSource({ records, duplicates: alikeRecords() });

A signature that signs the answers

A signature ("widget": "signature" on a binary field) may sign answers: signs names them — "form", every answer shown on the page, or the fields by name — and signerField the field holding the signer's name (a text, or a link's record; left out, the name typed on the pad, else the form's user):

{ "type": "field", "id": "f-signature", "field": "signature", "widget": "signature",
  "options": { "signs": ["patient", "treatment", "areas", "risks_read"], "signerField": "patient" } }

Signed, it keeps beside its picture who, when and a fingerprint of the answers (FileValue.signed, a SignatureEvidence), once what is typed in them is read — an answer still to give, or text that does not read, is said, and nothing is signed:

{ "name": "signature.png", "type": "image/png", "size": 5120, "data": "iVBOR…",
  "signed": { "format": "fieldia-signature/1", "by": "Mona Adel", "at": "2026-10-19T08:42:00.000Z",
              "fields": ["patient", "treatment", "areas", "risks_read"],
              "sha256": "2e3b5fa2ca4b2012eeb1fe7895af5c05dda2c3f5a76246b78fff3b530dbae16d" } }

While a signature with evidence is kept, the form locks the answers it names — whatever the page's conditions say (form.node(id).readonly, form.fieldReadonly(name)) — until the person takes it away with Change answers, asked first, and signs again. signedBy(fields, values) says which signature locks which answer; evidenceOf(value) reads one. The evidence travels in the value: a store that keeps a signature as bytes keeps signed beside them (a save storing the picture keeps it, as it keeps a typed name's text). form.now(), form.user() and form.shownFields() are what a signature reads — the clock, the person, the answers shown.

The canonical form, fieldia-signature/1. The fingerprint is the SHA-256, in small hexadecimal letters, of the UTF-8 bytes of this JSON, written as RFC 8785 (JCS) writes JSON — no spaces, each object's keys in the order of their UTF-16 code units, numbers as JavaScript writes them:

{"answers":{"areas":["forehead"],"patient":"Mona Adel","risks_read":true,"treatment":"botox"},"at":"2026-10-19T08:42:00.000Z","by":"Mona Adel","field":"signature","format":"fieldia-signature/1","page":"clinic-consent"}

— the text of the evidence above, whose SHA-256 is its sha256.

answers holds each field the evidence names, as the person saw it as they signed: nothing (null, an empty text, no choice) is null; yes and no true and false; a number itself; a text, a choice's value, a date and a time their text as kept; a date and time kept with its zone, its instant in UTC with milliseconds; a link its record's id (several, their ids in order); a reference { "id", "model" }; a file { "name", "size", "type" }; a table's lines an array of each line's own fields; anything else its JSON by these rules. by is left out when no one is named; page is the page's id and field the signature's. So an app checks a record it keeps in any language — or with the evidence part's own functions (@fieldia/widgets' evidencePart, the part a page whose signature signs answers loads), in a browser or on a server:

import { evidencePart } from '@fieldia/widgets';

const { answersMatch, signatureText, sha256Hex } = await evidencePart.load();
const same = await answersMatch(record.signature.signed, page, 'signature', record);   // true while no signed answer changed

Only a signature the page has sign answers locks them (signsAnswers(node)): a page whose signature no longer says signs treats it as a picture, whatever its value carries.

checkPage and validatePage refuse signs that is neither "form" nor a list of the page's fields, a signature signing itself, and a signerField that holds no name. Two people signing in turn is the app's (a flow's) to order: each signature signs its answers.

Opening, closing and limiting a form

A page of responses may say when it takes answers, and how many; any choice's options may say how many may pick each:

{
  "limits": { "opens": "2026-11-01T09:00", "closes": "2026-11-20", "maxResponses": 200, "onePerPerson": true, "message": "See you in December." },
  "fields": { "session": { "type": "selection", "label": "Session", "options": [{ "value": "am", "label": "Morning", "seats": 30 }] } }
}

opens and closes are read on the page's clock (timeZone): a day and a time, or a day alone — opening at its first minute, closing at its end. The data source's limits({ pageId, model, recordId, fields, user }) answers { responses, mine, perChoice }: the responses sent so far, this person's, and for each choice field asked how many hold each option (the record edited not counted). The form asks it as it opens — state.limits.state is asking meanwhile where the page counts responses — after a record loads, after every send, as it starts again, and just before its answers go. state.limits tells whether it takes answers now (open, soon, closed, full, sent), when it opens and closes, the responses it takes still, and each choice's places (seats[field][value]: { seats, taken, left }); takingWords(page, limits, messages) says why it takes none ("This form closed on 20 Nov 2026."). Every message that names a day writes it as the page's date boxes do — its look.dateOrder (the form puts it on its messages, messages.dateOrder), its language, a time on its clock: "can’t be after 20 Oct 2026", "Oct 20, 2026" month first; dayWords(day, messages, order?) is that rule (a time after it: whenWords). A full option the person picks is refused, said under its field ("Afternoon workshop is full"); one that filled up while held, or a page closed since it was opened, stops the send. The app's own setValues is never refused: the check says it. Without limits in the source, the page keeps to its dates alone. The memory source counts its own responses over its limits option's starting counts, and answeredElsewhere(pageId, values) takes one as someone else would.

Save and resume on another device

A page with continueLater keeps its answers on the app's server as they are typed — and as a wizard's step is entered — through the data source's saveDraft({ pageId, model, recordId, key, draft, later }), which answers with the draft's key (and, on Continue later, the link to carry on from and words of its own); loadDraft({ pageId, key }) gives the draft back. A draft keeps the answers, the wizard's step and the steps passed over, text typed that does not read (unread, as typed, with why) and the fields answered. The form's resume (the key from the link) opens it — at its step, or the nearest before it that still applies, its unread text said again — and a key that names none leaves state.resume.missing. form.continueLater() reads what is typed and keeps the draft (later: true); form.canContinueLater() says whether the page and its source can; the draft event tells each draft kept. A send carries the draft's key (SubmitRequest.draft, SaveRequest.draft). Without the two members, drafts stay in the browser's store (drafts.store), as before — with their wizard step now; with them, that store keeps only the key.

const form = createForm({ page, dataSource, resume: new URLSearchParams(location.search).get('resume') ?? undefined });
form.on('draft', ({ key, later, saved }) => later && console.log('Continue from', saved.link));

Approvals on a record

A record's page may say its records wait for approval:

{ "approval": { "open": ["notes"] } }

The data source tells where a record stands, approvals({ model, recordId, user }) answering { levels, history, mine, together, why } — each level its id, name, approvers (each { id, name, decision, at } in the round asked now), needs (any, the default, or all) and state (waiting, later, approved, rejected, skipped); history oldest first ({ decision: 'requested' | 'approved' | 'rejected', level, by, at, reason }); mine the levels this person may decide now — and takes the decisions, decide({ model, recordId, level, decision, reason, user }), a rejection always with why. Who is asked, and in what order, is the app's, or its approval engine's: Fieldia never works it out. The form asks as a saved record is shown, after each save and each decision, keeping what it told in state.approval (status: none, needed, waiting, approved, rejected); an answer for a record no longer shown is laid on none. While it waits, every field is read-only but those open names (form.node(id).readonly, form.fieldReadonly), form.approvalLock(name) saying why; "lock": false locks none. form.decide(level, decision, reason?) reads and saves what is typed first, then decides, then loads the record again; it refuses a level not this person's and a rejection with no reason, in words. The memory source's approvals option routes records as an engine would (in turn or together, any or all, a rejection ending the round), keeping each decision; approvalHistory is what it starts from.

await form.decide('finance', 'rejected', 'Over the quarter’s budget');
form.getState().approval?.status; // 'rejected'

AI help: values proposed, words written, a search read

Three optional members answer with the app's own model — Fieldia ships no model and no keys. suggest({ page, values, fields, from: { text?, files? } }) gives values for a form (a page's suggest: fields, label, from, fromField), a table's lines to add among them; rewrite({ field, how, text, values }) a text field's words (its node's options.rewrite: "draft", "polish", or { "how", "label" }); searchToFilter({ text, fields }) a list's conditions (its searchToFilter). The viewer shows each value on its field to accept or reject first, and Undo after; checkPage and validatePage check the settings. The memory source has each member only where its assist option answers it; assistStandIn({ drafts }) is a stand-in for demos and tests — no model, words read by their patterns, every answer saying so ("Stand-in AI, no model: …"):

import { assistStandIn, createMemoryDataSource } from '@fieldia/core';

const dataSource = createMemoryDataSource({ records, assist: assistStandIn({ drafts: { 'enquiry.reply': (values) => `Dear ${values.partner_name},` } }) });

Fields filled from the link

A page may fill fields from the link it is opened with — a campaign's, a broker's, a unit's — with no code of the app's:

{
  "prefill": { "fromUrl": ["utm_source", "utm_campaign", { "param": "agent", "field": "agent_code" }, "unit"] },
  "fields": { "utm_source": { "type": "char", "label": "Source" }, "agent_code": { "type": "char", "label": "Agent" }, "unit": { "type": "char", "label": "Unit" } }
}

https://homes.example/enquiry?utm_source=whatsapp&agent=mona&unit=B-12 starts the form with those values: each parameter named fills the field of its name, or the field it names, as a new record or response starts — and again after Submit another. A field the page fills so and places nowhere is a hidden field: sent with the answers (a page of responses otherwise sends only what its questions show), seen by no one. One placed on the page shows the value, for the person to keep or change. Words are read as the field reads them — a number as a number, yes/no/1/0 for a yes or no, a choice by one of its options' values, a day as 2026-10-20, a day and time with its offset — and one that does not read so, or that the field's own checks would refuse (its most characters, its pattern, its least and most), is left out: a hidden field no one can put right never stops a send. The link never writes over an answer: a draft opened over it, and what the person types, are theirs; a stored record opened is never filled. The form reads url (the address, its ?… part, or the parameters by name), else the page's own address (location.href) — an app rendered on a server, or embedded, gives the one it knows (the React, Vue and Angular wrappers' url) — and linkValues(page, url) is the reading, exported. The page's checks refuse a field it has not, a link's field, one worked out, a choice of the app's own list, and a field filled twice.

Proof of an email or a phone

A field drawn as an email or a phone may ask the person to prove it is theirs before the answers go — "options": { "verify": true }, or { "by": ["whatsapp", "sms"] } for the ways a code may be sent — where the data source has sendCode({ pageId, model, recordId, field, value, kind, by, language }) (answering { id, expiresAt, retryAfter, length, message }) and checkCode({ …, value, code, id }) (answering { ok, proof }, or { ok: false, triesLeft, expired }). Fieldia sends nothing and holds no keys: the app sends the code its own way. form.joined('verify')?.mark(field, { value, proof }) keeps a proof while the field holds that value (state.verified); a send is refused while a shown field asking for a code holds a value not proved ("Mobile is not confirmed: send a code and type it in"), and every send carries verified — by field, the value and the proof. Anyone can call mark() in their own browser: the server trusts a value only by a proof it signed itself (checkSubmission checks each is there, for the value sent). form.joined('verify')?.asks(field) says whether a field asks for one: never where the source lacks either member. The memory source sends and checks codes as a service would (its codes option), each kept in codes.

A payment the answers wait for

A page may take a payment before its answers go — a reservation fee, a deposit — through the app's own provider: "payment": { "label": "Reservation fee", "amount": 10000, "currency": "EGP", "when": "visit == 'reserve'" } (the amount a number or a number or money field's name, the currency a code or a field's, else a money field's own). Where the data source has pay(request) (answering { status: 'paid' | 'failed' | 'cancelled', reference, message }), a send checks the answers, then waits for the payment — through the host's payment step (the viewer's, else ActionHost.pay), else the source's pay itself — and sends nothing unpaid; paid, the send carries payment ({ amount, currency, key, reference }). request.key is the same for every try of one response's payment: the provider's idempotency key. A send that failed after paying is sent again without paying twice. form.joined('pay')?.due() says what is due now, state.paid what was taken. A new payment in the designer asks 100 USD until its amount and currency are set. Fieldia holds no keys and no provider's code. The memory source answers paid unless its pay option says otherwise.

What the browser works out as due is the person's to change — in their own devtools, or in the address where a link fills the amount (the page's checks warn of that). The app's server works out what is due itself, from the page it keeps and the answers it was sent — (await checkSubmission(page, values)).due — and its checkout charges that, never an amount the browser hands it; once the answers arrive, checkSubmission(page, values, { payment }) refuses a payment short or in another currency. Check its reference with your provider.

Sends kept without signal

A page with "outbox": true keeps a send that finds no network — a site visit's report in a compound, a delivery's proof — on the device and sends it when the signal comes back. The form goes on as though it went: a response ends "Kept on this device" (state.outbox.kept), and state.outbox says how many wait ({ waiting, sending, offline, kept, refused }). The items are kept in the browser's IndexedDB (indexedOutbox(): never lost on a reload, shared by a site's tabs), or the store given as outbox (memoryOutbox() for tests). A photo the network could not take stays in its field as its bytes and is stored through upload just before its send goes. form.joined('outbox') sends what waits in order — each item claimed by one sender (the claim renewed while its send goes, so a long upload is never taken by a second tab), sent with the key of its first try (key, and queued: { key, at }) so a server keeps it once — and keeps a refusal to retry or discard. Kept sends go in the order they were kept; a save of a record with kept saves sends them first and goes after them (still without signal, it is kept behind them), each at the version the one before left. A new record saved twice without signal is saved once, and the form takes its id when it went. Where the browser keeps nothing past the page (no IndexedDB), sends wait in memory and state.outbox.lasting is false: the viewer says to keep the page open, never "Kept on this device". The memory source's offline option fails as a network does.

Every save and send carries one idempotency key from its first try (key): a Retry after an answer lost on the way, and an outbox's copy, carry the same, until it went — a new record's until it has its id, a response's until the form starts another. A server that kept a send with that key keeps no second: it stores the values over that one's and answers as it did (the memory source does). form.save() asked again while a save is on its way, nothing changed since, is that save once it went (stopped or refused, it is asked anew); a response's answers once sent are never sent again as they were (form.reset() starts another); a new record whose source answers with no id is not taken as saved.

Parts that join a form

The four above are parts of their own, asked for as a page needs them (formJoins(page)): the form knows only that its page asks for one, and each joins it by one hook into its send (FormJoin) — before the send, once the form's own checks ran (a field not proved added to what they found; a payment not taken, nothing sent), around the send itself (what it carries added, or kept on the device), and reset as another response or record starts. Their state, their words and their checks come with them. form.joined(name) is a part's side of the form once it came — null before, and on a page that asks for none; a send made before it came waits for it.

A part that guards a send fails closed: a payment, a code check, a time limit's clock, a link's hidden fields, a record's approvals — and the form's own options by condition, texts in several languages and limits. Where one cannot come (offline, a deploy that removed its file, a cached fieldia.js beside a part of another version), the send waits for it, asks for it once more, and then sends nothing: its save problem says which ({ kind: 'other', message: "The payment step could not load, so nothing was sent. Try again." } — "Reload the page and try again." where the part comes by import(), which a page keeps failed), the viewer shows it with Retry, and what was typed stays. An outbox and a record made live guard nothing: without them a send goes as it would have.

Nothing waits for ever

Each request a person waits on — a record's load, a list's rows, a save, a send, an onchange, a search, a list's options — answers within the form's (or the viewer's) timeout (milliseconds, 30 000 unless said; 0 for none) or ends as the network's problem ("The server did not answer in time"), said where it was asked, with Retry; its signal (an AbortSignal, on the request) aborts then, and a late answe