import { U as Uuid, d as RelationFlavor, O as OnDelete, f as RelationBinding, e as RelationCardinality, g as Timestamp, R as RecordsResult } from './record-C3thPhpR.js'; import { c as RecordsDataSource } from './ports-uIDHLgZN.js'; /** * REL-6. Whether Visibility flows along this relation and the MAXIMUM access * level it carries. Default off on `referenced`, on for `owned`. */ interface RelationCarries { carries: boolean; /** The ceiling — a relation never carries more access than this. */ max_access: string | null; } /** The seven properties, each its own question. */ interface RelationProperties { /** REL-1. Stored once on the contained table, read from the field's side. */ flavor: RelationFlavor; /** REL-2. Separate from flavour. */ on_delete: OnDelete; /** REL-3. A snapshot is a frozen copy in the relation's payload — never a pointer into History. */ binding: RelationBinding; /** REL-4. */ ordered: boolean; /** REL-5. */ loops: "allowed" | "refused"; /** REL-6. */ carries: RelationCarries; /** REL-7. */ cardinality: RelationCardinality; } /** * REL-8 / REL-N-1. A target is a REFERENCE, written that way from the first * line of code, because it may name a row outside our database. One Table, * several, or any — polymorphic without restriction. External targets are * read-only in v1. */ type RelationTarget = { kind: "ours"; entity_token: string; row_id: Uuid; } | { kind: "external"; connection_token: string; external_table: string; external_key: string; } | { kind: "any"; }; /** One edge, as the store holds it in `platform.associations`. */ interface Relation { id: Uuid; organization_id: Uuid; /** REL-10. The field key, which is what `role` holds. */ role: string; source: RelationTarget; target: RelationTarget; properties: RelationProperties; /** REL-4. Meaningful only when `ordered`. */ position: number | null; /** REL-3. The frozen copy, when `binding` is `snapshot`. */ payload: Record | null; /** REL-14. Hydrated from the target's title field AT READ — never stored. */ label: string | null; created_at: Timestamp; updated_at: Timestamp; /** REL-13 / REL-16. Associations are versioned, so relation history exists. */ version: number; } /** * DOOR-6. A query coordinate: "related to THIS, along THAT role, in that * direction". Any combination, and any subset of them. */ interface RelationCoordinate { /** The record at the other end. */ record_id: Uuid; /** The field key the edge carries as its role. Omit to mean any role. */ role?: string; /** Which way to walk. `out` is this record's own relation fields. */ direction?: "out" | "in" | "either"; } /** * The arguments of the ONE relation-words resolver: the FIELD, because that is where its display * spec is declared and judged (`custom._display_of_field` reads it server-side; the caller never * carries it), and the ids of a page of cells. */ /** A linked record's icon, and its table's icon for a record that has none (`relationWordsMany`). */ interface RelationIcons { icon: string | null; tableIcon: string | null; } interface RelationWordsManyArgs { field_id: Uuid; record_ids: Uuid[]; } /** One reference as the store keeps it. */ interface EntityRef { /** The `platform.entity_types` token: `note`, `web_site`, `agent` … */ token: string; id: Uuid; } /** One reference as a read door answers it. */ interface EntityRefWithWords extends EntityRef { /** * The thing's own title — or the store's withheld sentence when the reader * may not open it; `null` when the kind names no title. */ label: string | null; } /** One kind of platform thing a record may point at (`custom.entity_reference_kinds`). */ interface EntityReferenceKind { token: string; /** What a person reads: "Note", "Site", "Agent". */ label: string; /** The picker's grouping: the admin-assigned reference category, else the schema. */ category: string; } /** * The references a cell holds, whichever shape it arrived in — one object, a * list, or what a read door rendered (with labels). Anything that is not a * reference is left out, never guessed at. */ declare function entityRefsOf(value: unknown): EntityRefWithWords[]; /** * What to WRITE for an entity-reference cell: `{token, id}` only, each thing * once, first mention first — the label a read door added is dropped, because * the store reads it and never keeps it (REL-14). A single-valued column gets * the one object (or `null`), a multi-valued one the list. */ declare function entityRefsToWrite(value: unknown, multi: boolean): EntityRef | EntityRef[] | null; /** * The kinds of platform thing a record may point at — what the field editor's * kind picker lists. `custom.entity_reference_kinds()`. */ declare function entityReferenceKinds(source: RecordsDataSource): Promise>; /** * THE SEARCH DOOR (lane REFERENCE-CARRY). The platform things of these kinds whose words hold * `search`, that THIS person may point a record at — each one a thing the store's own write check * (`custom._entity_reference_target_ok`) would accept, so a picked reference is never refused on * save. `custom.entity_reference_search`. An empty search lists the first things by name. */ declare function entityReferenceSearch(source: RecordsDataSource, organizationId: Uuid | null, tokens: readonly string[], search: string, limit?: number): Promise>; /** * THE WORDS HELPER. The words of each `{token, id}` for a picker or a chip * before anything is saved — each label read by the store for THIS person and * withheld when they may not open the thing. `custom.entity_reference_words`. * A saved cell needs no call: every read door already answers its labels. */ declare function entityReferenceWords(source: RecordsDataSource, organizationId: Uuid | null, refs: readonly EntityRef[]): Promise>; /** One reverse column of a Table, as `custom.reverse_columns` answers it. */ interface ReverseColumn { /** Stable key: the linking Field's `inverse_key`, else `linked_`. Never a Field key of B. */ key: string; /** What the column is called on B: the linking table's name (plus the column's when ambiguous). */ label: string; /** The relation Field on the linking table. */ source_field_id: Uuid; source_field_key: string; source_field_label: string; /** The linking table. */ source_table_id: Uuid; source_table_name: string; /** Always `many`: any number of records may link to one. */ cardinality: "many"; /** * True for a virtual back-link (written only from the linking table's side). False for a TWO-WAY * LINK (NOTION-PROPS): the reverse end is a real Field on this table — `key` is its key, `label` * its label — and `relationReverseSet` writes its links from here. */ read_only: boolean; } /** * NOTION-PROPS. A two-way link's reverse Field: a relation whose `config.reverse_of` names the * forward relation it mirrors. It holds no value of its own — its links are the forward Field's. */ declare function isReverseField(field: { type?: unknown; config?: unknown; } | null | undefined): boolean; /** One linking record, as a chip shows it. */ interface ReverseLink { id: Uuid; /** The linking record's name, read by the store for this reader. */ words: string; } /** The links of one record through one reverse column: how many the reader may see, and one page. */ interface ReverseLinks { total: number; links: ReverseLink[]; } interface ReverseLinksManyArgs { /** The Table whose records are being shown (B). */ table_id: Uuid; /** `ReverseColumn.source_field_id`. */ source_field_id: Uuid; /** A page of B's record ids — up to 200 a call; more are sent in groups by the client. */ record_ids: readonly Uuid[]; /** Links per record, 1–50 (the store holds it there). Default 10. */ limit?: number; /** Skip this many links of each record — the next page of one hub record. Default 0. */ offset?: number; } /** `reverseLinksFields`: the links of a page through several reverse columns, in one call. */ interface ReverseLinksFieldsArgs { table_id: Uuid; /** Each `ReverseColumn.source_field_id` — at most 20. */ source_field_ids: readonly Uuid[]; record_ids: readonly Uuid[]; limit?: number; offset?: number; } /** The store's per-call ceiling on records for `custom.reverse_links_many`. */ declare const REVERSE_LINKS_RECORDS_PER_CALL = 200; /** The store's ceiling on links a record per call. */ declare const REVERSE_LINKS_PAGE_MAX = 50; /** The store's typed "source archived" answer for a lookup or roll-up. */ interface SourceArchived { __unavailable: "source_archived"; /** `link`: the relation it reads through is archived; `column`: the far column it reads is. */ reads: "link" | "column"; /** The archived Field. Absent when the reader may not know its Table. */ field_id?: Uuid; /** Its label. Absent when the reader may not know its Table. */ label?: string; table_id?: Uuid; /** Its Table's name. Absent when the reader may not know that Table. */ table?: string; } /** The typed "source archived" answer, when `value` is one; null for any other value. */ declare function sourceArchivedOf(value: unknown): SourceArchived | null; export { REVERSE_LINKS_PAGE_MAX as R, REVERSE_LINKS_RECORDS_PER_CALL as c, entityReferenceKinds as p, entityReferenceSearch as q, entityReferenceWords as r, entityRefsOf as s, entityRefsToWrite as t, isReverseField as u, sourceArchivedOf as v }; export type { EntityRefWithWords as E, SourceArchived as S, EntityRef as a, EntityReferenceKind as b, Relation as d, RelationCarries as e, RelationCoordinate as f, RelationIcons as g, RelationProperties as h, RelationTarget as i, RelationWordsManyArgs as j, ReverseColumn as k, ReverseLink as l, ReverseLinks as m, ReverseLinksFieldsArgs as n, ReverseLinksManyArgs as o };