import { SmrtObject } from '@happyvertical/smrt-core'; import { OpportunityConversionOptions } from '../types.js'; /** * OpportunityConversion records that a WON opportunity materialized into a * downstream record — a client, project, contract, subscription, or any * caller-defined kind. The target is a generic `(targetKind, targetId)` * string pair: CRM never creates (or mutates) the downstream records * themselves and never touches referral or commission state. * * The natural key `(opportunity_id, target_kind, target_id)` * (`conflictColumns`) makes recording idempotent — use * `OpportunityConversionCollection.recordConversion()`, which enforces the * won-status precondition and reports whether the link already existed. * Links are append-only: the generated surfaces expose `list`/`get`/`create` * only (no update/delete). * * @example * ```typescript * const conversions = await OpportunityConversionCollection.create({ db }); * const { conversion, created } = await conversions.recordConversion({ * opportunityId: opportunity.id ?? '', * targetKind: 'contract', * targetId: contractId, * }); * ``` */ export declare class OpportunityConversion extends SmrtObject { /** * Tenant ID for multi-tenant isolation. * Nullable to support both tenant-scoped and global conversions. */ tenantId: string | null; /** The won opportunity that converted. Required. */ opportunityId: string; /** * Downstream record kind — OPEN string: `'client'`, `'project'`, * `'contract'`, `'subscription'`, … Required. */ targetKind: string; /** Identifier of the downstream record within `targetKind`. Required. */ targetId: string; /** Optional human-readable note about the conversion. */ note: string; /** * Free-form JSON object stored as a string. Use * {@link getMetadata}/{@link setMetadata} instead of parsing manually. */ metadata: string; constructor(options?: OpportunityConversionOptions); /** Parse the metadata JSON string; returns `{}` on malformed content. */ getMetadata(): Record; /** Serialize and store the metadata object. */ setMetadata(metadata: Record): void; /** * Save with the append-only guard: a fresh instance whose * `(opportunityId, targetKind, targetId)` natural key already belongs to * a DIFFERENT row is refused — the conflict-column upsert would replace * the existing conversion link (note and id) without the won-opportunity * validation. Idempotent linking goes through * `OpportunityConversionCollection.recordConversion()`, which finds * first and reports `{ created: false }`. */ save(): Promise; } export default OpportunityConversion; //# sourceMappingURL=OpportunityConversion.d.ts.map