| title | Hook |
|---|---|
| description | Hook protocol schemas |
{/*
Hook Lifecycle Events
Defines the interception points in the ObjectQL execution pipeline.
**Source:** `packages/spec/src/data/hook.zod.ts`import { HookContext, HookEvent } from '@objectstack/spec/data';
import type { HookContext, HookEvent } from '@objectstack/spec/data';
// Validate data
const result = HookContext.parse(data);| 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 |
beforeFindafterFindbeforeInsertafterInsertbeforeUpdateafterUpdatebeforeDeleteafterDelete