import { ChildKey, Context, ContextValues, GraphNode, NodeDefinition, NodeLike, StatelessGraphNode, StatelessNodeDefinition, StatelessNodeType } from '../../types/graph'; import { ListKeyNode } from '../collection/utils/is-list-key-node'; /** * An instance of the [[get]] node. * See the [[get]] documentation to find out more. */ export interface GetNode extends StatelessGraphNode<'get', GetNodeProperties> { } /** * A definition of the [[get]] node. * See the [[get]] documentation to find out more. */ export interface GetNodeDefinition extends StatelessNodeDefinition<'get', GetNodeProperties> { } export interface GetNodeProperties { subject: NodeDefinition; key: NodeDefinition; } /** * The implementation of the [[get]]. * See the [[get]] documentation page for more information. */ export declare const GetNodeType: StatelessNodeType<'get', GetNodeProperties>; export declare type PathKey = string | GraphNode | ListKeyNode; /** * Creates a new instance of the [[get]] node, which is a node used for traversing a graph. * It can be used for getting `child` node from a given "container-like" node. It's used internally by [ref](_nodes_graph_ref_.html#ref). * * Muster has a number of nodes which can be considered "container-like" nodes: * [[tree]], [[placeholder]], [[extend]], etc. * * * @example **Getting a child from a branch** * ```js * import muster, { get, tree, value } from '@dws/muster'; * * const app = muster({ * name: 'from muster graph', * }); * * const name = await app.resolve(get( * tree({ name: value('from test branch') }), * value('name'), * )); * // name === 'from test branch' * ``` * [[get]]s operate in the context of a given root node. In this example we've chosen a new * [[tree]] to be our root node. * * If you want to access the name from the root of the muster graph, you can use a special * type of [[NodeDefinition]]: [[root]]. See the "**Using root node**" example for more information. * * * @example **Using the root node** * ```js * import muster, { get, root, value } from '@dws/muster'; * * const app = muster({ * name: 'from muster graph', * }); * * const name = await app.resolve(get(root(), value('name'))); * // name === 'from muster graph' * ``` * * * @example **Nesting get nodes** * ```js * import muster, { get, root, value } from '@dws/muster'; * * const app = muster({ * user: { * firstName: 'Bob', * }, * }); * * const firstName = await app.resolve( * get( * get(root(), value('user')), * value('firstName'), * ), * ); * // firstName === 'Bob' * // These nested get nodes are equivalent to: ref('user', 'firstName') * ``` * Because the root of the [[get]] can be any [[NodeDefinition]], one can * make nested [[get]]s - the result of the inner get is used as the root of the outer. * * As this syntax is a bit clunky, Muster includes a [ref](_nodes_graph_ref_.html#ref) to help.. */ export declare function get(subject: NodeLike, path: Array | NodeLike): GetNodeDefinition; export declare function isGetNodeDefinition(value: NodeDefinition): value is GetNodeDefinition; export declare const PARENT: unique symbol; export declare const PARENT_SCOPE_PATH_KEY: unique symbol; export declare function getPath(context: Context): Array; export declare function getParentPathContext(context: Context): Context | undefined; export declare function createChildPathContext(parentNode: GraphNode, key: ChildKey, values?: ContextValues): Context;