@fjell/lib
Version:
Server-side Library for Fjell
26 lines (25 loc) • 1.13 kB
TypeScript
import { Item } from "@fjell/types";
import type { Registry } from "../Registry";
import { OperationContext } from "./OperationContext";
/**
* Definition for an aggregation relationship.
* Aggregations are location-based queries that populate properties with related items.
*/
export interface AggregationDefinition {
/** Key type array of the items to aggregate */
kta: string[];
/** Property name to populate with the aggregated result */
property: string;
/** Whether to return one item or many */
cardinality: 'one' | 'many';
}
/**
* Build an aggregation by querying for related items at the same location.
*
* @param item - The item to populate with aggregated data
* @param aggregationDefinition - Definition of what to aggregate
* @param registry - Registry to look up library instances
* @param context - Optional operation context for caching and cycle detection
* @returns The item with the aggregation property populated
*/
export declare const buildAggregation: (item: Item, aggregationDefinition: AggregationDefinition, registry: Registry, context?: OperationContext) => Promise<any>;