@askrjs/askr/actions
Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.
Exports
This entrypoint publishes 6 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.
actiontype
action: <TInput extends Record<string, unknown>, TResult = unknown>(descriptor: ActionDescriptor<TInput>, options?: { readonly csrfToken: (signal: AbortSignal) => Promise<string | undefined>; }) => { state: StateTuple<ActionStatus<TResult>>; submit(input: TInput): Promise<TResult>; }Bind an action descriptor to the calling component and return its
{ state, submit } handle. action() allocates its status with state(),
so it follows the same rule: call it during component render, at the top
level and in the same order on every render. submit() itself may be
called from event handlers or other async work. An explicit csrfToken
resolver runs fresh for every submission under the component/data lifetime.
Its undefined result omits the token instead of falling back to SSR data.
ActionDescriptortype
ActionDescriptor: anyA declared server action, built by {@link defineAction}, bound to a form via {@link ActionForm}.
id- readonly id: string;
input- readonly input: ObjectSchema<TInput>;
invalidates- readonly invalidates: readonly string[];
ActionFormtype
ActionForm: <TInput extends Record<string, unknown>>({ action, children, ...props }: { readonly action: ActionDescriptor<TInput>; readonly children?: RenderableChild; readonly [key: string]: unknown; }) => JSXElementA native form bound to a declared action; it is not a synthetic event API.
ActionStatustype
ActionStatus: anyPending/result/error status for an action, as reported by the action() hook.
pending- readonly pending: boolean;
result- readonly result?: TResult;
error- readonly error?: unknown;
ActionValidationErrortype
ActionValidationError: anyServer-replayed validation failure for an {@link ActionForm} submission.
kind- readonly kind: 'invalid';
action- readonly action: string;
values- readonly values: Readonly<Record<string, unknown>>;
issues- readonly issues: readonly unknown[];
fieldErrors- readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
defineActiontype
defineAction: <TInput extends Record<string, unknown>>(options: { readonly id: string; readonly input: ObjectSchema<TInput>; readonly invalidates?: readonly string[]; }) => ActionDescriptor<TInput>Declare a server action with a stable id, input schema, and query prefixes to invalidate on success.