import type * as Context from 'effect/Context'; import type * as Effect from 'effect/Effect'; import { type MakeOptional } from '@dxos/util'; /** * Root node ID. */ export declare const RootId = "root"; /** * Root node type. */ export declare const RootType = "org.dxos.type.graphRoot"; /** * Action node type. */ export declare const ActionType = "org.dxos.type.graphAction"; /** * Action group node type. */ export declare const ActionGroupType = "org.dxos.type.graphActionGroup"; /** * Represents a node in the graph. */ export type Node = Record> = Readonly<{ /** * Globally unique ID. */ id: string; /** * Typename of the data the node represents. */ type: string; /** * Keys in of the properties which should be cached. * If defined, the node will be included in the cache. * If undefined, the node will not be included in the cache. */ cacheable?: string[]; /** * Properties of the node relevant to displaying the node. */ properties: Readonly; /** * Data the node represents. */ data: TData; }>; export type NodeFilter = Record> = (node: Node>, connectedNode: Node) => node is Node; export type RelationDirection = 'outbound' | 'inbound'; export type Relation = Readonly<{ kind: string; direction: RelationDirection; }>; export type RelationInput = Relation | string; export declare const relation: (kind: string, direction?: RelationDirection) => Relation; export declare const childRelation: (direction?: RelationDirection) => Relation; export declare const actionRelation: (direction?: RelationDirection) => Relation; export declare const isGraphNode: (data: unknown) => data is Node; export type NodeArg = Record> = MakeOptional, 'data' | 'properties' | 'cacheable'> & { /** Will automatically add nodes with an edge from this node to each. */ nodes?: NodeArg[]; /** Will automatically add actions with an edge from this node to each. An action child may itself * be an action group (e.g. a toolbar dropdown group), so groups are accepted alongside actions. */ actions?: NodeArg | typeof actionGroupSymbol>[]; /** Will automatically add specified edges. */ edges?: [string, RelationInput][]; }; export type InvokeProps = { /** Node the invoked action is connected to. */ parent?: Node; /** Path from root to the node in the current tree context. */ path?: string[]; caller?: string; /** Input modifiers held during the gesture that triggered the action (e.g. shift-clicking a menu item). */ modifiers?: { shift?: boolean; }; }; /** * Action data is an Effect-returning function. * The Effect is provided with captured context at execution time. */ export type ActionData = (params?: InvokeProps) => Effect.Effect; /** * Context captured at extension creation time. * Automatically provided to action Effects at execution. */ export type ActionContext = Context.Context; export type Action = Record> = Readonly, 'properties'> & { properties: Readonly; /** Captured context from extension creation. Provided automatically at action execution. */ _actionContext?: ActionContext; }>; export declare const isAction: (data: unknown) => data is Action; export declare const actionGroupSymbol: unique symbol; export type ActionGroup = Record> = Readonly, 'properties'> & { properties: Readonly; }>; export declare const isActionGroup: (data: unknown) => data is ActionGroup; export type ActionLike = Action | ActionGroup; export declare const isActionLike: (data: unknown) => data is Action | ActionGroup; /** * Tests whether a node's `disposition` property (a single string or an array, letting one node opt * into multiple surfaces at once) includes any of `key`. Every surface that routes nodes/actions by * disposition (toolbar, nav-tree list-item, sigil menu, …) should filter through this rather than * comparing `properties.disposition` directly, so a node can multi-target surfaces. */ export declare const hasDisposition: (node: Pick, key: string | string[]) => boolean; /** Typed factory for constructing a NodeArg. Provides auto-complete and type validation. */ export declare const make: = Record>(arg: NodeArg) => NodeArg; /** Create an action node. Automatically sets `type: ActionType`. */ export declare const makeAction: (arg: Omit>, 'type' | 'nodes' | 'edges'>) => NodeArg>; /** Create an action group node. Automatically sets `type` and `data`. */ export declare const makeActionGroup: (arg: Omit, 'type' | 'data' | 'nodes' | 'edges'>) => NodeArg; //# sourceMappingURL=node.d.ts.map