trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
50 lines (47 loc) • 1.52 kB
JavaScript
import {
FIELD_CONTROLS
} from "./chunk-VKZC4ZIY.js";
import {
defineType,
rel
} from "./chunk-E4T2QHKA.js";
// src/forms/ontology.ts
import { z } from "zod";
var CONTROL_ENUM = [...FIELD_CONTROLS];
var FormFieldType = defineType("FormField", {
/** Attribute name in the entity record — must match a schema field. */
fieldName: z.string(),
label: z.string().optional(),
control: z.enum(CONTROL_ENUM).optional(),
required: z.boolean().optional(),
readonly: z.boolean().optional(),
hidden: z.boolean().optional(),
/** Render order within the section (relative). */
order: z.number().optional(),
/** Move the field to a section (created on demand). */
section: z.string().optional(),
options: z.array(z.union([z.string(), z.number(), z.boolean()])).optional(),
defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
placeholder: z.string().optional(),
description: z.string().optional()
}, { title: "fieldName" });
var FormType = defineType("Form", {
/** Bare entity type name (e.g. `Task`). */
entityType: z.string(),
/** Undefined = applies to all modes. */
mode: z.enum(["create", "edit", "view"]).optional(),
/** Overrides the schema label / form title. */
title: z.string().optional(),
description: z.string().optional()
}, {
title: "entityType",
relations: {
fields: rel(() => FormFieldType, "many")
}
});
var FORMS_ONTOLOGY = [FormType.definition, FormFieldType.definition];
export {
FormFieldType,
FormType,
FORMS_ONTOLOGY
};