Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.82 KB

File metadata and controls

64 lines (45 loc) · 1.82 KB
title Hook
description Hook protocol schemas

{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}

Hook Lifecycle Events

Defines the interception points in the ObjectQL execution pipeline.

**Source:** `packages/spec/src/data/hook.zod.ts`

TypeScript Usage

import { HookContext, HookEvent } from '@objectstack/spec/data';
import type { HookContext, HookEvent } from '@objectstack/spec/data';

// Validate data
const result = HookContext.parse(data);

HookContext

Properties

Property Type Required Description
id string optional Unique execution ID for tracing
object string
event Enum<'beforeFind' | 'afterFind' | 'beforeInsert' | 'afterInsert' | 'beforeUpdate' | 'afterUpdate' | 'beforeDelete' | 'afterDelete'>
input Record<string, any> Mutable input parameters
result any optional Operation result (After hooks only)
previous Record<string, any> optional Record state before operation
session { userId?: string; organizationId?: string; roles?: string[]; accessToken?: string; … } optional Current session context
transaction any optional Database transaction handle
ql any ObjectQL Engine Reference
api any optional Cross-object data access (ScopedContext)
user { id?: string; name?: string; email?: string; organizationId?: string } optional Current user info shortcut

HookEvent

Allowed Values

  • beforeFind
  • afterFind
  • beforeInsert
  • afterInsert
  • beforeUpdate
  • afterUpdate
  • beforeDelete
  • afterDelete