/** * Manifest-as-definition-registry helpers. * * Field policy is validated and seeded from the LIVE `ObjectRegistry` (never * from checked-in `manifest.json` artifacts): the registry is the runtime * source of truth for which objects/fields exist, their types, their security * flags, and their `_meta.ui` presentation hints (#2046). */ import type { FieldUIHints } from '@happyvertical/smrt-core'; import { ObjectRegistry } from '@happyvertical/smrt-core'; import type { FieldPolicyDelta, FieldPolicyVisibility } from './types.js'; /** * Field map for one object, keyed by field name (includes inherited fields). * Derived structurally from the PUBLIC `ObjectRegistry.getAllFields` return * type — core does not export its internal `RegisteredField` name. */ export type FieldDefinitionMap = Awaited>; /** One field's registered metadata, as returned by `getAllFields`. */ export type RegisteredFieldInfo = FieldDefinitionMap extends Map ? F : never; /** * Resolve `objectRef` (qualified `@package/name:ClassName`) against the live * registry, throwing a descriptive error when the class is unknown. */ export declare function requireRegisteredObject(objectRef: string): void; /** Load the full (inherited) field map for a registered objectRef. */ export declare function getObjectFieldMap(objectRef: string): Promise; /** * Narrow a manifest `_meta.ui` bag to the known {@link FieldUIHints} keys with * their expected primitive types, dropping junk (mirrors the sanitization the * web emission applies in core's `web-collections.ts`). */ export declare function sanitizeFieldUIHints(value: unknown): FieldUIHints | undefined; /** Security rail: `sensitive` may live top-level or under `_meta` (STI merges). */ export declare function isSensitiveField(field: RegisteredFieldInfo): boolean; /** Security rail: `readPermission` may live top-level or under `_meta`. */ export declare function getFieldReadPermission(field: RegisteredFieldInfo): string | undefined; export declare function isTransientField(field: RegisteredFieldInfo): boolean; /** * True when a registered field can receive a policy row. Keep this shared by * the resolver and the catalog audit: otherwise a row that never resolves can * accidentally be presented as an editable setting. */ export declare function isPolicyAddressableField(field: RegisteredFieldInfo): boolean; /** * A field is required when flagged required and not explicitly nullable. * * `nullable` is read from BOTH the top level and `_meta` for the same reason * `sensitive`/`readPermission`/`transient` are: registrations reach the * registry through several paths (decorator, manifest, STI merge) and land the * flag in either place. Checking only one side made the pair asymmetric — * `required` was read from both while `nullable` was read from one. */ export declare function isRequiredField(field: RegisteredFieldInfo): boolean; /** The manifest/code default for a field, boxed; `undefined` when none. */ export declare function getCodeDefault(field: RegisteredFieldInfo): { value: unknown; } | undefined; /** * A resolved default satisfies the required-field invariant only when it is a * value a form could actually submit: explicit `null` and the empty string do * not count (a required text field "defaulting" to `''` is still unfilled). */ export declare function isUsableRequiredDefault(defaultBox: { value: unknown; } | undefined): boolean; /** * Compute the code-seed visibility for every field of an object using the * cold-start rule (#2046): with no `ui.basic` markers anywhere on the object, * every field is `basic`; once any field is marked `basic: true`, unmarked * fields default to `advanced` (and an explicit `basic: false` is always * `advanced`). */ export declare function buildCodeSeedVisibility(fields: FieldDefinitionMap): Map; /** Code-seed delta for one field (visibility supplied by the cold-start pass). */ export declare function buildCodeSeedDelta(field: RegisteredFieldInfo, visibility: FieldPolicyVisibility): FieldPolicyDelta; /** Code-seed grouping key (`ui.group`) — not overridable by stored rows. */ export declare function getCodeSeedGroup(field: RegisteredFieldInfo): string | null; /** * True when a reference identifier can be stored in the field's backing * column. Native UUID columns accept UUIDs only; `idType: 'text'` opts into * arbitrary non-empty string identifiers. Shared by policy defaults and the * usage histogram so a poisoned sample can never become an unwriteable * suggestion. */ export declare function isStorableReferenceId(field: RegisteredFieldInfo, value: unknown): value is string; /** * Type-check a parsed default value against the manifest field type. * * Explicit `null` is allowed only for optional fields (a required field with a * null default has no usable default). Unsupported field types reject defaults * outright (fail closed). */ export declare function assertDefaultValueMatchesFieldType(objectRef: string, fieldName: string, field: RegisteredFieldInfo, value: unknown): void; //# sourceMappingURL=field-definitions.d.ts.map