import { SmrtObject } from '@happyvertical/smrt-core'; import { SalesActivityOptions, SalesActivitySubjectKind } from '../types.js'; /** * Permit one monotonic `completedAt` stamp on a hydrated task. * * This intentionally stays out of the CRM barrel: generated CRUD exposes no * activity update route, and the public `LeadWorkflowService` is the only * supported completion surface that may acquire this internal capability. */ export declare function permitSalesActivityWorkflowCompletion(activity: SalesActivity): void; /** * SalesActivity is the shared trail for Leads and Opportunities: human * touchpoints (`note`, `call`, `email`, `meeting`), next actions (`task` * with `dueAt`/`completedAt`), and framework-written audit rows * (`assignment`, `qualification`, `stage_change`, `merge`, `status_change`). * * The subject is polymorphic by string pair — `subjectKind` * (`'lead' | 'opportunity'`) plus `subjectId` — deliberately NOT a typed FK * so one table serves both subjects. `activityKind` is an OPEN string; * `SALES_ACTIVITY_KINDS` exports the recommended vocabulary. * * Activities are an immutable trail: the generated surfaces expose only * `create`/`list`/`get` (no update/delete). Merges intentionally leave the * losing lead's activities attached to the loser — * `LeadCollection.activitiesIncludingMerged()` re-assembles the full history * across merge chains. * * @example * ```typescript * const activities = await SalesActivityCollection.create({ db }); * await activities.create({ * subjectKind: 'lead', * subjectId: lead.id, * activityKind: 'task', * summary: 'Send follow-up deck', * dueAt: new Date('2026-08-01'), * }); * const open = await activities.findOpenTasks('lead', lead.id ?? ''); * ``` */ export declare class SalesActivity extends SmrtObject { /** * Tenant ID for multi-tenant isolation. * Nullable to support both tenant-scoped and global activities. */ tenantId: string | null; /** Which model the activity attaches to: `'lead'` or `'opportunity'`. */ subjectKind: SalesActivitySubjectKind; /** Id of the subject row. Required. */ subjectId: string; /** * Kind of activity — OPEN string so consumers can extend the vocabulary * without schema changes. See `SALES_ACTIVITY_KINDS` for the recommended * kinds (framework-written rows use `qualification`, `stage_change`, * `merge`). */ activityKind: string; /** One-line human-readable description. */ summary: string; /** Next-action due date — set for `task`-like activities. */ dueAt: Date | null; /** When the next action was completed; `null` while open. */ completedAt: Date | null; /** * Profile of the human/agent who performed or recorded the activity — * cross-package string reference to smrt-profiles. */ actorProfileId: string; /** * Free-form JSON object stored as a string (framework audit rows carry * structured detail here, e.g. `stage_change` from/to ids or the full * loser snapshot on `merge`). Use {@link getMetadata}/{@link setMetadata}. */ metadata: string; constructor(options?: SalesActivityOptions); /** Whether this is an open next action (due date set, not completed). */ isOpenTask(): boolean; /** Parse the metadata JSON string; returns `{}` on malformed content. */ getMetadata(): Record; /** Serialize and store the metadata object. */ setMetadata(metadata: Record): void; /** * Keep Lead-task completion monotonic and service-owned even for direct * model callers. The shared activity model continues to support existing * opportunity and imported-history completion flows; only the Lead * follow-up workflow owns its task completion transition. */ save(): Promise; /** `undefined` means this id has not been persisted yet. */ private resolvePersistedState; } export default SalesActivity; //# sourceMappingURL=SalesActivity.d.ts.map