UNPKG

@comyata/run

Version:

Simplify data workflows and management with data templates, for browser and server.

40 lines (39 loc) 1.79 kB
/** * @todo add fileId as global root identifier */ export interface IDataNode { readonly engine?: string; readonly computed?: boolean; readonly path: (string | number)[]; readonly valueType: string; readonly value: any; readonly parent: (() => IDataNode) | undefined; hydrate?: () => any; children?: IDataNodeChildren; } export interface IDataNodeComputed extends IDataNode { readonly engine: string; readonly computed?: true; } export type ExtractExprFn = (value: string) => string; export type IDataNodeChildren<TNode extends IDataNode = IDataNode> = Map<string | number, TNode>; export declare class DataNode implements IDataNode { static readonly engine: IDataNode['engine']; readonly engine?: IDataNode['engine']; readonly computed?: IDataNode['computed']; readonly path: IDataNode['path']; readonly valueType: IDataNode['valueType']; readonly value: IDataNode['value']; readonly parent: IDataNode['parent']; children?: IDataNode['children']; hydrate?: IDataNode['hydrate']; protected readonly extractExpr?: ExtractExprFn; constructor(parent: DataNodeObject | undefined, path: IDataNode['path'], valueType: IDataNode['valueType'], value: IDataNode['value'], extractExpr?: ExtractExprFn); withHydrate(hydrate: () => any): this; } export declare class DataNodeObject extends DataNode { children: NonNullable<IDataNode['children']>; constructor(parent: DataNodeObject | undefined, path: IDataNode['path'], valueType: IDataNode['valueType'], value: IDataNode['value']); append(key: string | number, dataNode: IDataNode): void; } export declare function isComputedNode<TNode extends IDataNode>(node: TNode): node is (TNode extends IDataNodeComputed ? TNode & IDataNodeComputed : never);