defineActions
function defineActions<T>(actions): T;Defined in: src/standard-schema.ts:108
Declare the typed action catalog. Identity at runtime; preserves the literal
types so core.record() can infer action names and metadata shapes.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends ActionMap |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
actions |
T |
Returns
Section titled “Returns”T
Example
Section titled “Example”import * as v from "valibot";import { createAuditCore, defineActions } from "@xtandard/audit";
const actions = defineActions({ "invoice.paid": { metadata: v.object({ invoiceId: v.string(), amount: v.number() }), targets: ["invoice"], description: "An invoice was paid", }, "member.removed": { targets: ["user"] },});
const audit = createAuditCore({ storage, actions });await audit.record({ tenant: "acme", action: "invoice.paid", // ← autocompletes; typos are compile errors actor: { id: "user_1" }, metadata: { invoiceId: "inv_1", amount: 4200 }, // ← typed});