[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationShared types

Shared types

The `types` subpath holds the vocabulary every other part of the `base` domain is built from: the base props interface every component's props extend, the colour and size scales, the action targets a button or a row…

Overview

The types subpath holds the vocabulary every other part of the base domain is built from: the base props interface every component's props extend, the colour and size scales, the action targets a button or a row action can point at, the rule algebra that decides whether a row action applies to a row, the guard signatures a table view runs before a mutation, and a handful of small enums and value unions.

Most of it is exported from one subpath:

typescript
import {
  Color,
  FormMode,
  HttpMethod,
  Size,
} from "@antelopejs/interface-dms/base/types";

Four modules are not re-exported by that barrel and are imported from their own file: types/action-target, types/row-action, types/row-action-operators and types/guards. The guard types and RowActionRule are also re-exported by the table view, so they can equally be imported from @antelopejs/interface-dms/base.

SymbolsImport from
BaseComponentProps, ButtonVariant, Color, ColorValue, ComponentOrNoInput, CustomButton, CustomButtonSerialized, CustomButtonAvailability, CustomButtonUnavailability, CustomButtonHidden, ButtonColor, ErrorWithMessage, isErrorWithMessage, getErrorMessage, ExportStatus, ListableConfig, FieldMetadata, FormMode, DefaultValue, FormFieldValue, HttpMethod, JsonPrimitive, JsonValue, AxeOrientation, ReadonlyBehavior, ReadonlyBehaviorType, ReadonlyBehaviorConfig, Size, SizeValue, TONES, Tone, ICON_TONES, IconTone, ModalSize, ComponentId, WatchAction, WatchActionCondition, WatchFunctionParamMap, WatchFunctionId, WatchFunctionParams@antelopejs/interface-dms/base/types
ActionTarget, ActionTargetSerialized@antelopejs/interface-dms/base/types/action-target
RowActionRule, RowActionConfig, CustomRowAction, CustomRowActionSerialized, FieldEqualsRule, FieldNotEqualsRule, FieldInRule, FieldNotInRule, AndRule, OrRule, NotRule, LogicalRule@antelopejs/interface-dms/base/types/row-action
FIELD_OPERATORS, FIELD_KEY, FieldOperatorKey, FieldRule, AnyFieldRule, LOGICAL_OPERATOR_KEYS, LogicalOperatorKey@antelopejs/interface-dms/base/types/row-action-operators
EditGuardArgs, DeleteGuardArgs, BulkGuardArgs, NewGuardArgs, GuardFn, AfterWrite, TableViewGuards@antelopejs/interface-dms/base/types/guards

Base component props

BaseComponentProps is the one field every component props interface inherits.

typescript
import type { BaseComponentProps } from "@antelopejs/interface-dms/base/types";

Its declaration is shown below for reference; import the existing type rather than redeclaring it in your module:

typescript
import type { WatchAction } from "@antelopejs/interface-dms/base/types";

interface BaseComponentProps {
  watchActions?: WatchAction[];
}

FormProps, TabProps, KpiCardProps, ChartCardProps, TopListCardProps, PeriodSelectorProps and the chart props all extend it. The ComponentBuilder from @antelopejs/interface-dms/component strips a caller-supplied watchActions from the options it receives and fills the field itself from .watch() / .watchOn() calls, so the property is the transport rather than something you set by hand.

Watch actions

A WatchAction binds an event emitted by a component to a function exposed by a component.

typescript
import type {
  WatchAction,
  WatchActionCondition,
} from "@antelopejs/interface-dms/base/types";
FieldTypeDescription
componentstringIdentifier of the component that emits the event. ComponentId.SELF ("$component:self") refers to the declaring component.
eventstringEvent name, e.g. FormEvents.SUBMIT_SUCCESS.
functionIdstringIdentifier of the function to invoke, e.g. FormFunctions.SET_FIELD_HIDDEN.
paramsobjectArguments passed to the function. Read a member after checking it ("targetField" in params), or read the shape the function registers through WatchFunctionParams.
onParamWatchActionCondition | WatchActionCondition[]Only run when the event payload matches these { key, value } pairs.
requirePermissionstringPermission id the viewer must hold for the action to be kept.

WatchFunctionParamMap is an interface extended by declaration merging: each module that exposes a watch function adds its functionId and the exact parameter shape to the map. WatchFunctionId is keyof WatchFunctionParamMap & string, and WatchFunctionParams<F> resolves to the registered parameter shape for F, falling back to Record<string, unknown> | undefined for ids that are not in the map. Form and TableView both register their functions in this map, as Forms and Tables describe.

Colors and sizes

typescript
import {
  Color,
  type ColorValue,
  type ModalSize,
  Size,
  type SizeValue,
} from "@antelopejs/interface-dms/base/types";

Color is an enum of the semantic palette names: primary, secondary, success, info, warning, error, neutral. ColorValue is Color | (string & {}), so a component that accepts a ColorValue takes either an enum member or an arbitrary string while keeping the enum members in editor completion.

TONES (Tone, from types/tone) is neutral, primary, secondary, success, warning, error, info; ICON_TONES (IconTone) adds muted. color is for what is clicked (buttons, row actions, header actions, tabs), tone for what shows a state (pills, icon wells, banners, meters, notifications, blocks); see Display blocks.

Size maps readable names onto the scale tokens: tiny → "xs", small → "sm", medium → "md", large → "lg", huge → "xl". SizeValue widens it the same way ColorValue widens Color.

ModalSize is a separate, wider union for modal and drawer action targets: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full": a modal's width, and the width of a side drawer given that size, full the whole window.

Buttons

ButtonVariant is an enum with solid, outline, soft, ghost and link. ButtonColor is a plain string union, "primary" | "secondary" | "success" | "error" | "warning" | "info" | "neutral", used by CustomButton in place of the Color enum.

CustomButton describes a toolbar button; it is what TableViewOptions.customButtons takes.

typescript
import { ButtonVariant } from "@antelopejs/interface-dms/base/types";
import type { CustomButton } from "@antelopejs/interface-dms/base/types";

const inviteButton: CustomButton = {
  label: "$page.settings.members.invite.button",
  icon: "i-ph-user-plus",
  variant: ButtonVariant.solid,
  color: "primary",
  target: { type: "page", url: "/settings/users/invite" },
};
OptionTypeDescription
idstringNames the button so a quick action can press it. Unique within its table.
labelstringButton label. Required.
iconstringIcon identifier.
variantButtonVariantVisual variant.
colorButtonColorColour name.
targetActionTargetWhat pressing the button does. Required.
permissionstring | ActionGate the button behind a permission.
permissionIdstringAbsolute permission id the button requires; wins over permission.
availabilityCustomButtonAvailabilityDisable the button, with a reason, for a request it refuses.

permission takes either form: a string names one of the owner's actions, relative to its permission id: the table's for a toolbar button ("add" → <table permission id>.add), the page's for a header button (DefaultLayout({ headerActions })). An Action references any component's action, such as another table's add. permissionId takes an absolute permission id ("settings.workspace.invites") and wins when both are set. A button the caller lacks the permission for is stripped from the serialized options rather than disabled, so it never reaches the browser. A declared permission that cannot be resolved to an id, such as an action on a page that never registered, fails closed and strips the button too.

A button with an id can be exposed as a quick action with a "button" target. The quick action opens what the button opens and inherits the button's permission: it is listed for exactly the callers the button is shown to.

availability is called per request with { tenantId, user } once the permission passed. Returning { reason } (a string or a $ i18n key) serves the button disabled, with the reason in its tooltip; undefined leaves it enabled, and so does a resolver that throws. It only shapes the UI: the operation behind the button must still refuse on its own.

CustomButtonSerialized is CustomButton with target replaced by ActionTargetSerialized and permission, permissionId and availability removed, since both are applied server-side; disabled and disabledReason carry what availability answered. The table view produces it when it serializes its options.

PermissionGate

PermissionGate, imported from @antelopejs/interface-dms/permission-gate, names the shared optional permission?: ButtonPermission and permissionId?: string fields described above. ButtonPermission is string | Action; permissionId takes precedence. The shape is shared by permission-filtered buttons, row actions, table tabs and views. It does not authorize the route that a control calls: protect that route with a guard too.

Action targets

ActionTarget is a discriminated union on type. It is what a custom button or a custom row action points at.

typescript
import type { ActionTarget } from "@antelopejs/interface-dms/base/types/action-target";
typeFields
"drawer"component: Component, title?, description?, direction?: DrawerDirection, plus DrawerTargetOptions: size?: ModalSize, rowHeader?, rowTitle?, positionLabel?, deepLink?, notFound?
"modal"component: Component, size?: ModalSize, title?, description?
"sidePanel"component: Component, plus SidePanelTargetOptions: title?, rowTitle?, positionLabel?, deepLink?, notFound?. For global, page-independent panels. A detail panel is a drawer.
"page"url: string: the page URL's {{params.X}} / {{query.X}} (a query pair without a value left out), then on a row action the row's {{row.field}}; see Template tokens
"external"url: string, newTab?: boolean; the same tokens as page
"download"url: string, filename?: string (DownloadActionTarget); the same tokens as page, the file name taking them as written. Fetched with the user's session and saved under filename, else the server's Content-Disposition name, else the URL's last segment; a failure is toasted
"quickAction"id: string (category:id, or the bare id)
"api"url: string, method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body?, copy?, redirect?: string, successMessage: string; the same tokens as page. redirect is a dashboard path (starting with /, an absolute URL throws when the target is serialized) opened on success; it takes the tokens of url plus {{response.<field>}} (dotted paths allowed), and a field the response lacks leaves the user on the page
"exportJob"url: string, method?: "GET" | "POST", statusUrl?, downloadUrl?, labels?; the same tokens as page, plus {{job.id}} in statusUrl and downloadUrl

SidePanelTargetOptions sets the header the DMS draws above a sidePanel target's component: title (the action's label by default; $: an i18n key), rowTitle, the title while a row is open, an i18n key or a literal receiving the row's fields ("{method} {path}"), positionLabel, an i18n key receiving { index } (from 1) and { total } for the row's position among all the rows the table lists, its count rather than the page loaded (the DMS's "{index} of {total}" by default), and deepLink, which keeps the open row in the URL like the action's own deepLink. It is on by default for a side panel, false opting out (the action's own deepLink wins when set), and notFound (SidePanelNotFoundTexts: title?, description?), the state the panel draws with a close button when the row a link names answers 404. The panel is non-modal and docked on the right, one at a time with a module's side panels. It is meant for global, page-independent panels (an assistant dock): a detail or record panel opens in a drawer.

DrawerTargetOptions gives a drawer target opened on a row the same options, so a detail panel moves from sidePanel to drawer without losing any: rowTitle, positionLabel and notFound as above; rowHeader, the DMS drawing the row header (the title naming the row, its position, previous and next buttons next to the close button), on when rowTitle or positionLabel is set, false leaving the drawer's own title, true drawing it with the defaults; deepLink, off by default for a drawer (the action's own deepLink wins when set); and size (ModalSize), the width a left / right drawer opens at from lg, a modal's width at that size. J and K step through the rows in place whatever the header. A drawer shows its not-found state only once its target sets notFound; otherwise a deep link to a missing row is a toast, as before.

DrawerDirection is "top" | "right" | "bottom" | "left", the edge the drawer slides in from: bottom by default, while left and right open a side sheet spanning the window's height, 600px wide from lg without a size (capped to the window) and 440px below it. From lg the user resizes every drawer by its inner edge (width or height), and the drawer opens again at the size it was left at.

A target carries no confirmation: the action does (CustomButton.confirm, CustomRowAction.confirm, RowActionConfig.confirm), with one type, ActionConfirm = ConfirmDialog | ConfirmDialogFrom (see below). The labels object on exportJob accepts title, exporting, downloading, successTitle, successMessage, errorTitle and retry, all optional strings.

typescript
import { ActionTarget } from "@antelopejs/interface-dms/base/types/action-target";

const validateEmail: ActionTarget = {
  type: "api",
  url: "/settings/workspace/members/{{row._id}}/validate-email",
  method: "POST",
  successMessage: "$page.settings.members.action.validate_email_success",
};

Confirmations

typescript
import type {
  ActionConfirm,
  ConfirmDialog,
} from "@antelopejs/interface-dms/base/types/confirm-dialog";

ConfirmDialog is the one confirmation every action asks in: title, description?, params? (interpolated into the texts, besides a row action's row fields; a numeric count pluralizes them), icon?, color? (ButtonColor), confirmLabel?, cancelLabel?, impact?: ConfirmDialogImpact[] ({ icon, label, count? }), secondaryAction?: ConfirmDialogSecondaryAction ({ label, icon?, target }, a button next to cancel and confirm that leaves the dialog open; its target is an external link or { type: "download", url, filename? }, fetched with the user's session), blocked? (the dialog only explains why the action cannot run), confirmText? (type-to-confirm), confirmTextCaseInsensitive? (the typed text compared ignoring case), fields?: FormField[] and component?: Component. The values of fields are sent with the action's request, merged into an api target's body with the input winning. A field error the server answers shows under its field. ConfirmDialogFrom is { from: string }: a URL (on a row action, built-in or custom, the row's fields filled in, such as {{row._id}}, plus {{row.id}}, the row's id) answering a ConfirmDialogSerialized, which serializeConfirmDialog(dialog) builds. The dashboard draws such an answer without its component, and fails it when a field is drawn by any input but a built-in one that reads no URL (see Confirmations). ActionConfirm is either.

ActionTargetSerialized mirrors the union exactly, with component on the drawer, modal and sidePanel variants replaced by ComponentInfoSerialized.

Row action rules

A row action rule decides, per row, whether an action applies. The same rule value is sent to the frontend so the row's menu matches what the backend will accept, and evaluated on the backend before an edit, delete, archive or restore runs.

Field operators

FIELD_OPERATORS is the catalogue of leaf comparisons. Each entry declares whether the rule value is an array and carries the comparison itself.

typescript
import {
  FIELD_KEY,
  FIELD_OPERATORS,
  LOGICAL_OPERATOR_KEYS,
} from "@antelopejs/interface-dms/base/types/row-action-operators";
KeyisArrayComparison
equalsfalsefieldValue === ruleValue
notEqualsfalsefieldValue !== ruleValue
intrueruleValue.includes(fieldValue)
notIntrue!ruleValue.includes(fieldValue)

FieldOperatorKey is keyof typeof FIELD_OPERATORS. FIELD_KEY is the literal "field", the property name that carries the field name inside a leaf rule. LOGICAL_OPERATOR_KEYS is the tuple ["and", "or", "not"] and LogicalOperatorKey is its element type.

Rule shapes

A leaf rule is { field: K } plus the operator key. FieldRule<T, Op> builds that shape for one operator over the keys of T, choosing Awaited<T[K]>[] for the array operators and Awaited<T[K]> for the others: a getter answering a promise is compared by the value it resolves to, as the served row holds it. AnyFieldRule<T> is the union over all four operators.

typescript
import type {
  AndRule,
  FieldEqualsRule,
  RowActionRule,
} from "@antelopejs/interface-dms/base/types/row-action";

interface Invoice extends Record<string, unknown> {
  status: string;
  archived: boolean;
}

const isDraft: FieldEqualsRule<Invoice> = { field: "status", equals: "draft" };

const editable: AndRule<Invoice> = {
  and: [isDraft, { field: "archived", notEquals: true }],
};

The four named leaf aliases are FieldEqualsRule<T>, FieldNotEqualsRule<T>, FieldInRule<T> and FieldNotInRule<T>, each an alias of FieldRule<T, Op> for the matching operator. The three combinators are AndRule<T> ({ and: RowActionRule<T>[] }), OrRule<T> ({ or: RowActionRule<T>[] }) and NotRule<T> ({ not: RowActionRule<T> }); LogicalRule<T> is their union. RowActionRule<T> is AnyFieldRule<T> | LogicalRule<T>, so rules nest to any depth.

Attach a rule

RowActionConfig<T> is the object form of a built-in row action.

OptionTypeDescription
isEnabledbooleanWhether the action can be triggered.
isVisiblebooleanWhether the action is shown.
ruleRowActionRule<T>Per-row condition.

CustomRowAction<T> is an extra action in the row menu:

OptionTypeDescription
labelstringMenu label. Required.
iconstringIcon identifier.
targetActionTargetWhat the action does. Required.
ruleRowActionRule<T>Per-row condition.
isVisiblebooleanWhether the action is shown.
isDefaultbooleanMake this action the row click target, ahead of edit / details.

CustomRowActionSerialized is the same shape with target: ActionTargetSerialized and an untyped RowActionRule.

Tables covers where these are consumed: TableViewOptions.rowActions and the archive-mode defaults.

Guards

A guard is a function the table view calls before a mutating route runs. Throwing from it aborts the operation.

typescript
import type {
  GuardFn,
  EditGuardArgs,
  TableViewGuards,
} from "@antelopejs/interface-dms/base/types/guards";

The imported GuardFn has this signature:

typescript
import type { RequestContext } from "@antelopejs/interface-api";

type AfterWrite<TWritten extends unknown[] = []> = (
  ...written: TWritten
) => void | Promise<void>;

type GuardFn<
  TArgs,
  TController = unknown,
  TWritten extends unknown[] = [],
> = (
  this: TController,
  ctx: RequestContext,
  args: TArgs,
) => void | AfterWrite<TWritten> | Promise<void | AfterWrite<TWritten>>;

A mutating guard may return an AfterWrite: the table view runs it once the write succeeded, in the same request. It is where work comparing the row before the write (what the guard saw) with the row after belongs, such as a notification or an audit entry; a failure there is logged and does not fail the request, since the write is done. What a get guard returns is ignored.

After a new or an edit, the AfterWrite receives written: the row as stored once the write is done, read back the way the edit guard's current is, so a created row comes with its new _id. TableViewGuards<T> types it as T & { _id: string }, through AfterWrite<[written]>; a bare AfterWrite takes no argument, and fits every guard. After a delete, archive or restore it receives nothing, since the guard already holds the ids.

ctx is the RequestContext from @antelopejs/interface-api. this is the data controller instance, typed as such in TableViewGuards<T> (TController is T there), so a guard written as a function reaches the properties declared with @Model without a cast.

InterfaceFields
EditGuardArgs<T>id: string, body: Partial<T>, current: T
NewGuardArgs<T>body: Partial<T>
DeleteGuardArgsids: string[], values?: Record<string, unknown> (the answer of the confirmation's fields; unset when the request carried no body)
BulkGuardArgsids: string[], values?: Record<string, unknown> (as on DeleteGuardArgs)

TableViewGuards<T> collects one guard per action:

KeyGuard argument
editEditGuardArgs<T>
deleteDeleteGuardArgs
archiveBulkGuardArgs
restoreBulkGuardArgs
newNewGuardArgs<T>

T is the data controller instance TableView() infers from its controller; it defaults to Record<string, unknown> on every one of them. How guards are attached and when each one fires is documented in Tables.

Form and field types

FormMode

FormMode is the enum new, edit, view. It selects which variant of a form the table view generates and which readonly behaviour applies.

ReadonlyBehavior

ReadonlyBehaviorType is an enum with disabled, hidden and default. ReadonlyBehaviorConfig gives one value per mode:

typescript
import { ReadonlyBehaviorType } from "@antelopejs/interface-dms/base/types";

const createdAtBehavior = {
  new: ReadonlyBehaviorType.hidden,
  edit: ReadonlyBehaviorType.disabled,
  view: ReadonlyBehaviorType.disabled,
};

ReadonlyBehavior is ReadonlyBehaviorType | ReadonlyBehaviorConfig, so a column may pass a single value that applies to every mode or a per-mode object. It is read by ColumnOptions.readonlyBehavior.

ListableConfig and FieldMetadata

FieldMetadata is the slice of a field's data-api metadata the table view reads when it builds a column or a form field.

FieldTypeDescription
mandatorySet<FormMode>Modes in which the field is required.
modeAccessModeAccess mode from @antelopejs/interface-data-api/metadata.
listableListableConfigWhich pluck modes include the field.
sortablebooleanWhether the field can be sorted on.

ListableConfig is { list?: boolean; select?: boolean; export?: boolean }, one flag per pluck mode.

Field values

DefaultValue is the recursive union string | number | boolean | Date | null, arrays of itself, and objects of itself (a row of an ArrayType field). FormFieldValue holds the same scalars, Record<string, string> and arrays of itself. DefaultValue types FormField.defaultValue and ColumnOptions.defaultValue; FormFieldValue types a value held by a form field.

ComponentOrNoInput

typescript
import { Component } from "vue";

type ComponentOrNoInput<T = undefined> = Component<T> | "noInput";

The literal "noInput" stands for a compare mode that takes no value. is_empty and is_not_empty are registered that way, and serializeType substitutes the literal for their filter component. The serialized counterpart used by data types is FilterComponent, documented in Data types.

Transport and other types

HttpMethod

HttpMethod is an enum of GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, keyed by the lowercase name (HttpMethod.get, HttpMethod.post, …). Every component with a fetchUrl also accepts a fetchUrlMethod of this type.

AxeOrientation

AxeOrientation is the enum horizontal / vertical. TabProps.orientation, BarChartProps.orientation and FormComponents.RadioGroupOptions.orientation take it.

ExportStatus

ExportStatus is the enum pending, completed, failed. It is the status stored on an export job and returned by the export-status route, as Helpers describes.

JSON values

typescript
type JsonPrimitive = string | number | boolean | null;
type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };

JsonValue describes anything that survives a JSON round trip.

Error helpers

typescript
import {
  getErrorMessage,
  isErrorWithMessage,
} from "@antelopejs/interface-dms/base/types";

try {
  await save();
} catch (error: unknown) {
  if (isErrorWithMessage(error)) {
    // error is narrowed to ErrorWithMessage
  }
  const message = getErrorMessage(error); // "Unknown error" when there is none
}

ErrorWithMessage is { message: string }. isErrorWithMessage is a type guard that accepts any object carrying a message property. getErrorMessage returns that message, or the string "Unknown error" for anything else, including an object whose message is not a string.

Next steps

  • Forms: Build a form, its fields, and its validation schema.