Skip to content

defineActions

function defineActions<A>(definition): ActionsDefinitionResult<A>;

Defined in: src/authorization/contract.ts:79

Build a product’s action constants from its lists. The const type parameter keeps the literal union, so a product can derive its action type from the list instead of writing it twice.

Throws if mutating or portal names an action that is not in all.

Type Parameter
A extends string
Parameter Type
definition ActionsDefinition<A>

ActionsDefinitionResult<A>

import { defineActions } from "@xtandard/kit/authorization";
export const { ALL_ACTIONS, MUTATING_ACTIONS, isMutatingAction } = defineActions({
all: ["endpoint:read", "endpoint:write", "message:read", "message:send"],
mutating: ["endpoint:write", "message:send"],
});
export type WebhooksAction = (typeof ALL_ACTIONS)[number];