import { SerializedSchema } from "@valbuild/core"; import { JSONValue } from "@valbuild/core/patch"; /** * What `emptyOf` cannot read off a serialized schema. * * The project's languages, and which one is being worked in. Neither is in the * schema: a locale-keyed record has one entry per language and the languages * are declared in the settings module, and "which language am I writing" is a * fact about the editor, not about the content. Optional throughout: a caller * that has no context gets an empty record and an unset locale, which * validation then reports, rather than wrong ones. */ export type EmptyOfContext = { /** `locales.available` from the settings module. */ locales?: string[]; /** * The one language being worked in, where the editor has narrowed to one. * * A new `s.locale()` field is created already set to it. Someone filtered to * Norwegian is writing Norwegian, and a new item that defaulted to unset * would fail validation and vanish from the list they are looking at, in * that order. */ selectedLocale?: string; }; /** * The empty value for a schema — the thing a "create this" affordance writes. * * Returns `JSONValue`, the MUTABLE shape, rather than `Json`. Every value here * is built fresh on the way out — `Object.fromEntries`, a new array, a * primitive — and none of it aliases anything a caller could then mutate out * from under someone. Saying `Json` instead made the type readonly, which is * a claim about sharing that is not true of anything this returns, and left * every caller asserting `as JSONValue` at the point of writing a patch. A * `JSONValue` is still assignable to `Json`, so a reader of the value loses * nothing. */ export declare function emptyOf(schema: SerializedSchema, context?: EmptyOfContext): JSONValue;