@finos/legend-application-studio
Version:
Legend Studio application core
104 lines • 5.03 kB
TypeScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type NodeProps } from '@xyflow/react';
import type { Column, Table, View } from '@finos/legend-graph';
/**
* Discriminator for the two relation kinds the canvas renders. Drives icon
* choice, column-row content (type vs. formula), and the SCSS color tint.
*/
export type DatabaseTableNodeKind = 'table' | 'view';
export interface DatabaseTableNodeData extends Record<string, unknown> {
/** The underlying Table or View — narrow with `kind` before accessing
* kind-specific fields like `Table.primaryKey` or `View.columnMappings`. */
relation: Table | View;
kind: DatabaseTableNodeKind;
schemaName: string;
/** True when THIS relation is the currently selected one (blue ring). */
isSelected: boolean;
/** True when THIS relation is one of the two endpoints of the currently
* selected join (yellow ring — visually distinct from blue selection). */
isJoinEndpoint: boolean;
/** Columns that participate in any join in the database. Used to tint
* table columns in blue ("FK-like"). Doesn't apply to views. */
fkColumns: Set<Column>;
/** Column currently focused via the side-panel. Drives the single-row
* highlight inside the matching table node. Tables only — views use
* `selectedViewColumnName` since their "columns" are mapping names. */
selectedColumn: Column | undefined;
/** Name of the view column-mapping currently focused via the side panel.
* Mirrors `selectedColumn` but for views, where mappings don't have
* `Column` instances. Always `undefined` for table-kind nodes. */
selectedViewColumnName: string | undefined;
/**
* Lookup table for view-column Pure-code formulas, keyed by
* `<schema>.<view>.<column>`. Forwarded from the editor state via the
* canvas. Empty until `loadViewColumnFormulas` resolves; consumers fall
* back to a static placeholder per `resolveViewColumnFormula`. Empty for
* table-kind nodes (we still pass it for prop-shape stability).
*/
viewColumnFormulas: ReadonlyMap<string, string>;
/**
* Lookup table for view groupBy Pure-code expressions, keyed by
* `<schema>.<view>.groupBy[<index>]`. Forwarded from the editor state
* via the canvas alongside `viewColumnFormulas`; same lazy-load story
* with a separate static placeholder per `resolveViewGroupByFormula`.
* Empty for table-kind nodes and for views with no groupBy.
*/
viewGroupByFormulas: ReadonlyMap<string, string>;
}
/**
* View-only React Flow node representing a single relation (Table or View).
*
* Layout: header (icon + relation name + schema badge + optional VIEW tag) +
* a list of column rows. Each row is a fixed-height grid:
* - Tables: [PK key icon | column name | column type]
* - Views: [bullet | column name | formula placeholder]
*
* Two invisible Handles (left/right) let React Flow route edges into either
* side of the box without committing to a specific column anchor.
*/
export declare const DatabaseTableNode: ((props: NodeProps & {
data: DatabaseTableNodeData;
}) => import("react/jsx-runtime").JSX.Element) & {
displayName: string;
};
/**
* Data attached to the placeholder node that stands in for a relation that
* lives in another database (cross-database join endpoint). Rendered
* smaller and visually distinct so users can tell at a glance that the
* actual relation isn't part of this database's schema tree.
*/
export interface DatabaseForeignRelationStubNodeData extends Record<string, unknown> {
schemaName: string;
relationName: string;
/** Path of the database that actually owns the relation. Surfaced in the
* tooltip so users know where to navigate to see the real definition. */
ownerPath: string;
isJoinEndpoint: boolean;
}
/**
* Compact stub rendered when a join references a relation in another
* database. Shows the schema/name plus the owning database path, with a
* dashed border to distinguish it from real in-database table nodes. Two
* invisible Handles let React Flow attach edges to either side. Not
* selectable — the canvas swallows clicks on stubs.
*/
export declare const DatabaseForeignRelationStubNode: ((props: NodeProps & {
data: DatabaseForeignRelationStubNodeData;
}) => import("react/jsx-runtime").JSX.Element) & {
displayName: string;
};
//# sourceMappingURL=DatabaseTableNode.d.ts.map