/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ /** * Relation projection helpers. * * Translate a source collection's relation fields into a `PopulateMap` * projection that fetches just enough data from each target to render * a relation-summary tile on the admin edit view (picker columns, * `useAsTitle`, plus an optional source-side `displayField` override). * * Consumed by the admin webapp's edit-route server fn so relation tiles * arrive pre-hydrated on first paint — no client-side fetch per relation. */ import type { CollectionAdminConfig, CollectionDefinition, FieldSet, RelationField } from '../@types/index.js'; import type { PopulateMap } from './populate.js'; /** * Union of the target-collection field names needed to render a * relation-summary tile for the given source relation field. * * - `sourceField.displayField` (explicit per-relation override) * - target's `useAsTitle` * - target's first declared text field (safety fallback) * - every item-view column `fieldName` on the target admin config that * maps to a real schema field (item-view columns may reference metadata * like `status` or `updated_at` which ride on the document row and don't * need a projection entry) */ export declare function resolveRelationProjection(sourceField: RelationField, targetDef: CollectionDefinition | null, targetAdmin: CollectionAdminConfig | null): string[]; export type RelationTargetResolver = (targetPath: string) => { def: CollectionDefinition | null; admin: CollectionAdminConfig | null; }; /** * Walk a source collection's `FieldSet` (recursing into `group`, `array`, * and `blocks`), locate every `RelationField`, and produce a `PopulateMap` * keyed by relation field name with a `{ select }` projection suitable * for rendering the summary tile on the admin edit view. * * Relation field names must be unique within the source schema; if the * same name appears twice with different targets the first wins. * * Relations whose target is unknown fall back to `true` (default * projection — identity field + row metadata) so populate still attaches * *something* to the leaf. */ export declare function buildRelationSummaryPopulateMap(fields: FieldSet, resolve: RelationTargetResolver): PopulateMap;