diff --git a/examples/app-crm/src/hooks/opportunity.hook.ts b/examples/app-crm/src/hooks/opportunity.hook.ts index 852fd8bef33..40131dacf5e 100644 --- a/examples/app-crm/src/hooks/opportunity.hook.ts +++ b/examples/app-crm/src/hooks/opportunity.hook.ts @@ -1,12 +1,12 @@ // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. -import type { Hook, HookContext } from '@objectstack/spec/data'; +import { defineHook, type HookContext } from '@objectstack/spec/data'; /** * Pin the probability to 100% when an opportunity is marked Closed Won, * and 0% when Closed Lost. Demonstrates a basic before-update hook. */ -export const OpportunityStageHook: Hook = { +export const OpportunityStageHook = defineHook({ name: 'opportunity_stage_probability', object: 'crm_opportunity', events: ['beforeInsert', 'beforeUpdate'], @@ -16,4 +16,4 @@ export const OpportunityStageHook: Hook = { if (input.stage === 'closed_won') input.probability = 100; if (input.stage === 'closed_lost') input.probability = 0; }, -}; +}); diff --git a/examples/app-todo/src/objects/task.hook.ts b/examples/app-todo/src/objects/task.hook.ts index 0e20efbf5f6..34ffb8c48b1 100644 --- a/examples/app-todo/src/objects/task.hook.ts +++ b/examples/app-todo/src/objects/task.hook.ts @@ -1,6 +1,6 @@ // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. -import { HookContext, Hook } from '@objectstack/spec/data'; +import { defineHook, type HookContext } from '@objectstack/spec/data'; /** * Lifecycle logic for `todo_task` — insert defaults and the completion stamp. @@ -47,7 +47,7 @@ import { HookContext, Hook } from '@objectstack/spec/data'; * timestamp that every report and list view reads as fact. The same * `readonly`/strip reasoning applies — only a hook can write the clear. */ -const taskHook: Hook = { +const taskHook = defineHook({ name: 'task_logic', object: 'todo_task', events: ['beforeInsert', 'beforeUpdate', 'afterUpdate'], @@ -120,6 +120,6 @@ const taskHook: Hook = { // runs daily and selects on `due_date` directly. } } -}; +}); export default taskHook;