Resources
A resource is a serializable file. It describes the table, form, filters, navigation, and actions for a Prisma model. There are no pages to generate and no files to keep in sync.
import { defineResource } from "@dashild/core";
export const customerResource = defineResource({ model: "Customer", navigation: { label: "Customers", slug: "customers", group: "Sales", icon: "users", }, table: { searchable: ["name", "email"], columns: [ { field: "name", sortable: true }, { field: "email" }, { field: "status", format: "badge", tone: { ACTIVE: "green", LEAD: "danger" }, }, ], filters: [{ field: "status", type: "enum" }], }, form: { fields: [ { field: "name", type: "text", rules: { required: true } }, { field: "email", type: "email", rules: { required: true } }, { field: "status", type: "select" }, ], }, policy: { scope: "organization" },});dashild make:resource Customer generates this file from the Prisma metadata
and registers it in panel.ts and policies.ts. The file is write-once: the
command never overwrites your edits.
Navigation
Section titled “Navigation”label is the sidebar label, slug is the URL segment under the panel route,
and group groups resources in the sidebar. icon is resolved by the shell
(users, user, building, organization, file-text, settings,
database, folder, chart, layout-dashboard, package, shopping-cart,
tag, calendar, mail, briefcase, credit-card, truck, layers), and
the app can add its own in src/dashild/icons.tsx.
columns: field, optional label,sortable,format,cell,display, andtone.searchable: fields used by the search box. Pagination, sorting, and filters run on the server.filters:boolean,enum,relation,text,number, ordate.pageSize: optional page size.actions: header or row actions (see below).
tone accepts accent, green, muted, or danger; any other value renders
the default outline badge.
format accepts badge, number, currency, date, datetime, json, or
text. Booleans and enums use badge by default. number and currency
format with the panel locale; for Decimal money use
format: "currency", currency: "EUR". Scalar lists (String[], Int[]…)
render and edit as a JSON array. cell points to a component registered with
registerCell (see Customization).
For relations, set field to the relation name and display to the related
field:
{ field: "organization", display: "name" }Filters
Section titled “Filters”Declared filters render as a bar above the table: selects for enum,
relation, and boolean, inputs for text, number, and date. Applying
them submits a GET form, so the values stay in the URL and you can link to a
filtered table (?status=ACTIVE). The server applies them; relation filters
support many-to-one relations only, and enum/text compare exact values.
Enum options come from the values in Prisma metadata; they are the same for all
users. Relation options are loaded on the server for the current user and
respect the active scope where that relation is scoped.
Fields use the Prisma type by default. rules adds required, min, max, or
a pattern string; component points to a field registered with
registerField; default sets an initial value.
form: { fields: [ { field: "name", type: "text", rules: { required: true, max: 120 } }, { field: "email", type: "email", component: "email" }, { field: "notes", type: "textarea" }, { field: "tags", type: "relation", relation: "tags", multiple: true, display: "name" }, ],}Bytes fields render a file picker and are sent as base64. createdAt and
deletedAt are shown in the table; updatedAt, id, and relation-owned
foreign keys are omitted from the table and the form. make:resource also
leaves audit fields (createdAt, updatedAt, deletedAt) out of the form.
Relations
Section titled “Relations”- o2m (one-to-many): the parent detail page shows a
RelationManagerfor the children. Create and edit are available; delete only when the child resource allows it, and detach only when the foreign key is optional. - m2m (many-to-many): the detail page allows attach and detach when the
child resource permits it, and the form can use
type: "relation"withmultiple: true.
The child model needs its own resource in panel.resources, and the manager
needs relationAction wired in the route (the scaffold does it). Without rows
or without that action, the manager is not rendered.
Relation ids are re-checked on the server. A form or CSV import cannot connect a record to a row outside the related resource’s policy scope, even if the id is guessed; the save returns a field error. Attach/detach requires update permission on the child, and o2m detach also verifies that the child belongs to that parent.
Actions
Section titled “Actions”Actions are declared in the resource and handled on the server:
table: { actions: [{ name: "export", label: "Export", placement: "header" }],}import type { ActionHandler, CurrentUser } from "@dashild/core";import { prisma } from "../../lib/prisma";
export const resourceActions: Record< string, Record<string, ActionHandler<CurrentUser>>> = { Customer: { export: async ({ db, organizationId }) => { // `db` is the scoped Prisma client, typed as `unknown` in core. const client = db as typeof prisma; // Use `client.customer` here for the server-side export/query. return { ok: true, message: "Export started" }; }, },};Declaring table.actions replaces the built-in create, view, edit, and
delete actions; include them yourself if you still want them. Form actions
behave the same way.
An action can declare requires (checked against policies), confirm,
variant, placement (header or row), and href for link actions.
variant styles the button and the confirmation, not the row dropdown item.
Doctor
Section titled “Doctor”pnpm dashild doctorIt parses resources with Babel (without importing Next) and checks models,
columns, filters, form fields, relations, policy, the policies.ts entry,
action handlers, requires predicates, and duplicate slugs. It always reports
the file; the line is included when the issue comes from a resource node. Some
findings are warnings and do not affect the exit code. It exits with code 1 on
errors, and also when no resource is found. It does not validate presentation
details such as navigation.label, format, tone, or placement.