import { type IAttributeDisplayFormMetadataObject, type IAttributeMetadataObject, type ICatalogAttribute, type ICatalogDateAttribute, type ICatalogDateDataset, type ICatalogMeasure, type IInsight, type Identifier, type ObjRef, type ObjectType } from "@gooddata/sdk-model"; /** * Configuration for the ObjRefMap. * * @alpha */ export interface IObjRefMapConfig { /** * Function that extracts `ref` from object */ readonly refExtract: (obj: T) => ObjRef; /** * Function that extracts `id` from object */ readonly idExtract: (obj: T) => Identifier; /** * Function that extracts `uri` from object */ readonly uriExtract: (obj: T) => string; /** * Indicates whether strict idRef type-checking is desired. Some backends (e.g. tiger) have identifier * refs use combination of `id` and `type` and have type-level `id` uniqueness constraints. On those backends, * strict type checks are essential to correctly match objects. * * On other backends, the `type` information coming in the idRef is superfluous and should not be influencing * anything. */ readonly strictTypeCheck: boolean; /** * Type of object stored in the map. */ readonly type?: ObjectType; } /** * Utility class that assists with type-agnostic mapping of metadata objects by ObjRef. * * Problem * ======= * * The challenges with ObjRef's start in context of backend that supports both uri and id ref (e.g. bear) and the client. * * Backend according to contract creates one type of ref - uri ref - so that is fine. However when instances of `ref` are created * by the client code and are passed in through the public API (as is the case with the dashboard component) - problems start. * * For clients it is often more convenient to use ID refs.. because they are transferable across workspaces and because * they appear in the catalog export. * * Doing strict ref-to-ref matching between user input and the data stored in state will result in no matches because * the types of ref's do not match. * * --- * * This class addresses the problem by having the `get` method check the type of ObjRef first and then perform * lookups into either id to item or uri to item mapping. * * @alpha */ export declare class ObjRefMap { private readonly config; readonly [Symbol.toStringTag]: string; size: number; private items; private itemsByIdentifier; private itemsByUri; constructor(config: IObjRefMapConfig); private idRefToKey; private addItem; private cleanupUnmappedItems; fromItems: (items: readonly T[]) => ObjRefMap; [Symbol.iterator](): IterableIterator<[ObjRef, T]>; entries(): IterableIterator<[ObjRef, T]>; get(key: ObjRef): T | undefined; has(key: ObjRef): boolean; keys(): IterableIterator; values(): IterableIterator; } /** * Creates {@link ObjRefMap} for catalog date datasets. Either normal attributes or catalog date attributes. * * @param items - items to add into mapping * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newCatalogDateDatasetMap(items: ReadonlyArray, strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for catalog attribute items. Either normal attributes or catalog date attributes. * * @param items - items to add into mapping * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newCatalogAttributeMap(items: ReadonlyArray, strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for catalog measure items. * * @param items - items to add into mapping * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newCatalogMeasureMap(items: ReadonlyArray, strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for attribute display form metadata objects. * * @param items - items to add into map * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newDisplayFormMap(items: ReadonlyArray, strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for attribute metadata objects. * * @param items - items to add into map * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newAttributeMap(items: IAttributeMetadataObject[], strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for any object of any type granted that it contains `ref` property with ObjRef. * * The map will be setup so that it extracts id and uri from the `ref` - thus ensuring that objects that are * both uri and identifier refs are indexed properly. * * Storing objects whose `ref` is of both types then allows lookup of those objects externally using either id * or uri. * * @param items - items to insert * @param type - type of objects, may be undefined * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newMapForObjectWithIdentity(items: T[], type?: ObjectType, strictTypeCheck?: boolean): ObjRefMap; /** * Creates {@link ObjRefMap} for insights. * * @param items - items to add into mapping * @param strictTypeCheck - whether to do strict type checking when getting by identifierRef * @alpha */ export declare function newInsightMap(items: ReadonlyArray, strictTypeCheck?: boolean): ObjRefMap; //# sourceMappingURL=objRefMap.d.ts.map