import { SmrtObject } from '@happyvertical/smrt-core'; import { ReferralLinkOptions, ReferralLinkStatus } from '../types.js'; /** * Assert that a target URL is an absolute http/https URL. Exported for the * collection's create path; the model also enforces it at save time so no * write path can persist a malformed target. */ export declare function assertHttpTargetUrl(targetUrl: string): void; /** * A ReferralLink is the shareable artifact a Referrer distributes: a * globally unique `code` (natural key `['code']` — codes resolve without * knowing the tenant/program) plus an optional destination `targetUrl`. * * Codes are minted by `ReferralLinkCollection.createWithUniqueCode()` — * crypto-random, 10 lowercase-alphanumeric characters, collision-checked * with a capped retry loop. Click traffic lands through * `ReferralLinkCollection.recordClick()`, which atomically increments * {@link clickCount} and writes one immutable, replay-keyed `ReferralTouch` * evidence row after enforcing the final UTF-8 evidence bound; disabled links * refuse clicks. */ export declare class ReferralLink extends SmrtObject { /** Tenant ID for multi-tenant isolation (nullable → global links). */ tenantId: string | null; /** The Referrer this link credits. Required. */ referrerId: string; /** The ReferralProgram this link belongs to. Required. */ programId: string; /** * Globally unique share code (10 lowercase-alphanumeric characters when * minted by `createWithUniqueCode`). Natural key. */ code: string; /** * Optional destination URL the shared link forwards to. Must be an * absolute http/https URL when non-empty (validated at save time). */ targetUrl: string; /** Human-readable label for the referrer's own bookkeeping. */ label: string; /** `active` (default) accepts clicks; `disabled` refuses them. */ status: ReferralLinkStatus; /** Number of recorded clicks (incremented by `recordClick`). */ clickCount: number; /** * Free-form JSON object stored as a string. Use * {@link getMetadata}/{@link setMetadata} instead of parsing manually. */ metadata: string; constructor(options?: ReferralLinkOptions); /** Whether the link currently accepts clicks. */ isActive(): boolean; /** Parse the metadata JSON string; returns `{}` on malformed content. */ getMetadata(): Record; /** Serialize and store the metadata object. */ setMetadata(metadata: Record): void; /** * Save with two guards: * * - a non-empty {@link targetUrl} must be an absolute http/https URL * regardless of which write path set it; * - the {@link code} must not belong to a DIFFERENT persisted link. Codes * are the upsert natural key and they are public — without this check a * generated-surface `create` carrying an existing code would silently * UPSERT over that link (rewriting its referrer/program/target: a * referral-code hijack). Mint codes through * `ReferralLinkCollection.createWithUniqueCode()`. */ save(): Promise; } export default ReferralLink; //# sourceMappingURL=ReferralLink.d.ts.map