/** * Copyright Linkurious SAS 2012 - 2019 * * - Created on 2019-10-30. */ import { CommentMention, DeletableUser, GenericObject, IDataSourceParams, PaginationClause, PersistedItem, Tree } from '../commonTypes'; import { VizEdge, IVizEdgeInfo, VizNode, IVizNodeInfo, WidgetEdge, WidgetNode, IVizNodeGroupInfo } from '../graphItemTypes'; import { GraphQueryDialect } from '../graphQuery'; import { IRangeValues, ItemSelector, IStyles, IStyleIcon, IStyleImage } from '../displayTypes'; import { User } from '../user'; import { IAlternativeIdSettings } from '../dataSource'; import { ILeafletConfig } from '../config'; export interface IGetVisualizationParams extends IDataSourceParams { id: number; withDigest?: boolean; withDegree?: boolean; } export interface ReleaseVisualizationEditLockParams extends IDataSourceParams { id: number; } export declare enum VisualizationRight { READ = "read", WRITE = "write", WRITE_FILTERED = "write-filtered", OWNER = "owner", OWNER_FILTERED = "owner-filtered" } export declare enum ShareVisualizationRight { READ = "read", WRITE = "write", OWNER = "owner" } export declare enum VisualizationMode { NODE_LINK = "nodelink", GEO = "geo" } export interface ICaptionConfig { displayName: boolean; properties: string[]; active: boolean; } export type ItemFieldsCaptions = GenericObject; export interface IItemFields { captions: ItemFieldsCaptions; types: GenericObject>; } export interface IVisualizationDesign { palette: { default: string[]; }; styles: IStyles; } export interface IVisualizationGeo { layers: string[]; } export type VisualizationLayout = IForceAlgorithm | IHierarchicalAlgorithm | IRadialAlgorithm; export declare enum ForceLayoutMode { BEST = "best", FAST = "fast" } export declare enum HierarchicalLayoutMode { LR = "LR", RL = "RL", TB = "TB", BT = "BT" } export declare enum LayoutAlgorithm { FORCE = "force", HIERARCHICAL = "hierarchical", RADIAL = "radial" } export interface IForceParameters { mode: ForceLayoutMode; } export interface IHierarchicalParameters { mode: HierarchicalLayoutMode; rootNode?: string; } export interface IRadialParameters { rootNode: string; } export interface IForceAlgorithm extends IForceParameters { algorithm: LayoutAlgorithm.FORCE; } export interface IHierarchicalAlgorithm extends IHierarchicalParameters { algorithm: LayoutAlgorithm.HIERARCHICAL; } export interface IRadialAlgorithm extends IRadialParameters { algorithm: LayoutAlgorithm.RADIAL; } export interface IVisualizationFilters { node: ItemSelector[]; edge: ItemSelector[]; } export declare enum ZoomLevel { YEARS = "years", MONTHS = "months", DAYS = "days", HOURS = "hours", MINUTES = "minutes", SECONDS = "seconds" } /** A node category or an edge type. */ type ItemType = string; /** The key of a property of a node category or an edge type. */ type ItemPropertyKey = string; /** * Start/end date property keys delimiting the validity period of an item */ export interface IVisualizationTimelineLifespanBounds { start: ItemPropertyKey; end: ItemPropertyKey; } /** * Lifespan bounds indexed by node category / edge type */ export interface IVisualizationTimelineLifespan { node: Record; edge: Record; } export declare const TIMELINE_MODES: readonly ['range', 'asAt']; /** * How the timeline range is used: * - 'range': every configured item is filtered on the range * - 'asAt': the range is a single date and only the lifespans are filtered on it */ export type TimelineMode = (typeof TIMELINE_MODES)[number]; /** * The timeline of a visualization. Each node category / edge type is placed in time in one of two * ways, never both: * - with a single date property, when its items are events, in `node` and `edge`. For instance, * the birthday of a person or the date of a transaction. * - with a lifespan, when its items are valid over a period, in `lifespan`. The lifespan uses two * date properties, for the start and the end of the period. For instance, the start and end of * a contract, or the opening and closing of a bank account. * * @example * { * node: {Person: 'birthday'}, * edge: {TRANSFER: 'date'}, * lifespan: {node: {}, edge: {CONTRACT: {start: 'start_date', end: 'end_date'}}}, * range: {'<': 1577836800000, '>': 1609459199999}, * mode: 'range' * } */ export interface IVisualizationTimeline { node: Record; edge: Record; lifespan?: IVisualizationTimelineLifespan; range?: IRangeValues; mode?: TimelineMode; zoomLevel?: ZoomLevel; } export interface VisualizationThumbnailNode { id: string; attributes: { [key: string]: unknown; color?: unknown; }; } export interface VisualizationThumbnailEdge { id: string; source: string; target: string; attributes: unknown; } /** * The information needed to generate a thumbnail SVG render of the visualization (in the frontend or other clients). * * It is not directly a SVG for performance and access rights reasons. * When saving a visualization the frontend can add thumbnail information obtainned via `ogma.export.json(...)`. * This information provided on save must contain metadata such as categories or edge types (`VisualizationThumbnailWithMetadata` type) . * This data will be stored and then exposed via `VisualizationTreeItem.thumbnail` or `SharedVisualization.thumbnail`. * The exposed thumbnail data (`VisualizationThumbnail` type) is filtered according to user access rights and does not contain the metadata mentioned above. * This data can be then used to generate a thumbnail via the `svg` Ogma util. */ export interface VisualizationThumbnail { nodes: VisualizationThumbnailNode[]; edges: VisualizationThumbnailEdge[]; } export interface VisualizationThumbnailNodeWithMetadata extends VisualizationThumbnailNode { data: { colorByCategory: GenericObject; }; } export interface VisualizationThumbnailEdgeWithMetadata extends VisualizationThumbnailEdge { data: { type: string; }; } /** * The information needed to save a thumbnail with the visualization. * It will be later used to generate a thumbnail SVG render of the visualization (in the frontend or other clients). * * See also {@link VisualizationThumbnail} */ export interface VisualizationThumbnailWithMetadata { nodes: VisualizationThumbnailNodeWithMetadata[]; edges: VisualizationThumbnailEdgeWithMetadata[]; } export interface LkeStickyNoteContent { id?: string; type: 'sticky'; coordinates: [number, number]; content: string; width: number; height: number; fontSize: number; font?: string; fontWeight?: 'normal' | 'bold'; background: string; showAuthor?: boolean; locked?: boolean; bbox: [number, number, number, number]; } /** * Metadata generated/managed by the server for an annotation. */ export interface LkeAnnotationMetadata { createdBy?: DeletableUser; } export interface LkeStickyNote extends LkeStickyNoteContent, LkeAnnotationMetadata { } export type LkeAnnotation = LkeStickyNote; export interface BaseVisualization { nodes: IVizNodeInfo[]; nodeGroups?: IVizNodeGroupInfo[]; edges: IVizEdgeInfo[]; nodeFields: IItemFields; edgeFields: IItemFields; design: IVisualizationDesign; filters: IVisualizationFilters; edgeGrouping: GenericObject; nodeGroupingRuleIds: number[]; alternativeIds: IAlternativeIdSettings; mode: VisualizationMode; layout: VisualizationLayout; geo: IVisualizationGeo; timeline: IVisualizationTimeline; sandbox: boolean; annotations?: LkeAnnotation[] | null; } export interface Visualization extends BaseVisualization, PersistedItem { spaceId?: number; title: string; description?: string; folder: number; sourceKey: string; user?: Pick; right: VisualizationRight; widgetKey?: string; locked: boolean; lastLockedByUserId?: number; lastLockedByUser: Pick; lastEditedByUser: Pick; } export interface PopulatedVisualization extends Visualization { nodes: VizNode[]; edges: VizEdge[]; } export interface ICreateVisualizationParams extends IDataSourceParams { spaceId?: number; title: string; description?: string; folder?: number; nodes: IVizNodeInfo[]; nodeGroupingRuleIds?: number[]; nodeGroups?: IVizNodeGroupInfo[]; edges: IVizEdgeInfo[]; alternativeIds?: IAlternativeIdSettings; mode?: VisualizationMode; design?: IVisualizationDesign; nodeFields?: IItemFields; edgeFields?: IItemFields; filters?: IVisualizationFilters; edgeGrouping?: GenericObject; timeline?: IVisualizationTimeline; layout?: VisualizationLayout; geo?: IVisualizationGeo; thumbnail?: VisualizationThumbnailWithMetadata | null; annotations?: LkeAnnotation[] | null; } export interface IDuplicateVisualizationParams extends IDataSourceParams { id: number; title?: string; description?: string; folder?: number; } export type DuplicateVisualizationResponse = { visualizationId: number; }; export interface IDeleteVisualizationParams extends IDataSourceParams { id: number; } export interface IUpdateVisualizationParams extends IDataSourceParams { id: number; visualization: Partial; forceLock?: boolean; doLayout?: boolean; } export interface SharedVisualization { right: VisualizationRight; visualizationId: number; ownerId: number; ownerUsername: string; sourceKey: string; title: string; description?: string; updatedAt: string; locked: boolean; lastLockedByUser: Pick; lastEditedByUser: Pick; thumbnail?: VisualizationThumbnail; } export type GetSharedVisualizationsResponse = SharedVisualization[]; export interface ICreateVisualizationFolderParams extends IDataSourceParams { title: string; parent: number; spaceId?: number; } export interface VisualizationFolder extends PersistedItem { title: string; parent: number; sourceKey: string; spaceId?: number; } export interface IUpdateVisualizationFolderParams extends Partial { id: number; } export interface IDeleteVisualizationFolderParams extends IDataSourceParams { id: number; } export interface VisualizationTreeItem { id: number; title: string; description?: string; shareCount: number; widgetKey?: string; createdAt: string; updatedAt: string; lastLockedByUser: Pick; lastEditedByUser: Pick; locked: boolean; thumbnail?: VisualizationThumbnail; } export type VisualizationTree = Tree; export declare enum PopulateType { VISUALIZATION_ID = "visualizationId", EXPAND_NODE_ID = "expandNodeId", NODE_ID = "nodeId", EDGE_ID = "edgeId", SEARCH_NODE = "searchNodes", SEARCH_EDGE = "searchEdges", PATTERN = "pattern", CASE_ID = "caseId", IMPORT_ID = "importId" } export interface IGetVisualizationTreeParams extends IDataSourceParams { spaceId?: number; } export interface IGetSandboxParams extends IDataSourceParams { spaceId?: number; populate?: PopulateType; itemId?: string; caseId?: number; searchQuery?: string; searchFuzziness?: number; patternQuery?: string; patternDialect?: GraphQueryDialect; doLayout?: boolean; withDigest?: boolean; withDegree?: boolean; } export interface IUpdateSandboxParams extends IDataSourceParams { design?: IVisualizationDesign; nodeFields?: IItemFields; edgeFields?: IItemFields; geo?: IVisualizationGeo; } export interface IGetVisualizationSharesParams extends IDataSourceParams { id: number; } export interface GetVisualizationSharesResponse { owner: Pick; shares: Array<{ userId: number; visualizationId: number; username: string; email: string; right: ShareVisualizationRight; }>; } export interface IShareVisualizationParams extends IDataSourceParams { id: number; userId: number; right: ShareVisualizationRight; } export interface VisualizationSharesParams { userId: number; right: ShareVisualizationRight; } export interface IShareWithMultipleUsersParams extends IDataSourceParams { id: number; shares: VisualizationSharesParams[]; } export interface VisualizationShare { userId: number; right: VisualizationRight; visualizationId: number; createdAt: string; updatedAt: string; } export interface IUnshareVisualizationParams extends IDataSourceParams { id: number; userId: number; } export interface IGetWidgetParams { widgetKey: string; } export interface WidgetContent { graph: { nodes: WidgetNode[]; edges: WidgetEdge[]; }; legend: { nodes: Legend; edges: Legend; }; mapLayers: ILeafletConfig[]; mode: VisualizationMode; ui: { search: boolean; share: boolean; fullscreen: boolean; layout: boolean; zoom: boolean; legend: boolean; geo: boolean; }; } export interface Legend { [key: string]: Array<{ label: string; value: string | IStyleIcon | IStyleImage | number; }>; } export interface Widget { title: string; key: string; userId: number; visualizationId: number; password: boolean; url: string; createdAt: string; updatedAt: string; content: WidgetContent; } export interface ICreateWidgetParams { visualizationId: number; options?: { search?: boolean; share?: boolean; fullscreen?: boolean; zoom?: boolean; legend?: boolean; geo?: boolean; password?: string; }; } export type IUpdateWidgetParams = ICreateWidgetParams; export interface IDeleteWidgetParams { widgetKey: string; } export interface VisualizationCommentUser extends DeletableUser { hasAccess: boolean; } export interface VisualizationComment { id: number; content: string; user: VisualizationCommentUser; createdAt: string; metadata: CommentMetadata; } export interface CommentMetadata { mentions: CommentMention[]; } export interface CreateVisualizationCommentParams extends IDataSourceParams { visualizationId: number; content: string; } export interface GetVisualizationCommentsParams extends IDataSourceParams, PaginationClause { visualizationId: number; } export interface DeleteVisualizationCommentParams extends IDataSourceParams { commentId: number; } export {};