import { JunctionAttachOptions, SmrtCollectionOptions, SmrtJunction } from '@happyvertical/smrt-core'; import { ContentReference } from './content-reference'; export interface ContentReferencesOptions extends SmrtCollectionOptions { } /** * The `attach()` override below restores find-or-create idempotency for * `(sourceId, targetId)` — duplicate calls return the existing row * unchanged, preserving `id` and `createdAt`. This matters because * `ContentReference` rows are externally addressable via * `/api/v1/contentreferences/[id]`. * * Two REST entry points (both auto-generated by the scanner): * - `POST /api/v1/contentreferences` (from model CRUD) calls * `collection.create()` which is upsert-based — id/createdAt get * rewritten on conflict. Convenient for callers that don't care * about row id stability. * - `POST /api/v1/contentreferences/attach` (from the override below) * is idempotent. Use this for stable URLs. * * Internal callers (`Content.addReference()`) always hit the idempotent * path because they call the collection directly. * * The `/attach` route exists because R2 round-7 added `@smrt()` to this * class, which made the scanner pick up the override as a custom * collection method route. Pre-R2 had a `/link` route from the * pre-rename method name. */ export declare class ContentReferences extends SmrtJunction { static readonly _itemClass: typeof ContentReference; protected leftField: string; protected rightField: string; protected sortField: string | null; protected positionField: string | null; getForSource(sourceId: string): Promise; getForTarget(targetId: string): Promise; /** * Find-or-create idempotency: if a reference already exists for * (sourceId, targetId), return the existing row unchanged instead of * upserting a new row. This preserves the existing row's `id` and * `createdAt`, which is important because reference rows are * externally addressable via `/api/v1/contentreferences/[id]`. * * The base `SmrtJunction.attach` flow (this.create → db.upsert) would * overwrite both columns on every duplicate call. * * Reference pinning (main): `opts.targetVersion` pins the citation to a * specific `ContentVersion.version` for drift detection. Re-attaching an * existing edge with a different `targetVersion` updates the pin in place; * `undefined` leaves an existing pin untouched, while a brand-new row * defaults the pin to `null` (unpinned). */ attach(sourceId: string, targetId: string, opts?: JunctionAttachOptions): Promise; unlink(sourceId: string, targetId: string): Promise; } //# sourceMappingURL=content-references.d.ts.map