← All procedures

dag.getAncestors

This function gives all ancestors of a node: the nodes that this node depends on, transitively.

CLI
Package
@procedures/dag · README
Path
["dag","getAncestors"]
CLI
mark dag getAncestors --nodes <any[][]> --id <string>
As data
{"$proc":["dag","getAncestors"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/dag/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["dag","getAncestors"], { nodes: [], id: "<id>" });
console.log(JSON.stringify(result));

From the command line

$ mark dag getAncestors --nodes <any[][]> --id <string>

As data, in a program

{
  "$proc": ["dag", "getAncestors"],
  "input": { "nodes": [], "id": "<id>" }
}

Input

FieldTypeRequiredDefaultDescription
nodesany[][]yes
idstringyes

Output

The schema does not list fields (string[]).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "nodes": {
        "type": "array",
        "items": {
          "type": "array",
          "items": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier for this node"
                },
                "dependencies": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Names/IDs of nodes this node depends on"
                },
                "level": {
                  "type": "number",
                  "description": "Topological level (0 = leaves, computed by Kahn's algorithm)"
                },
                "data": {
                  "description": "Optional user data associated with this node"
                }
              },
              "required": [
                "id",
                "dependencies"
              ],
              "additionalProperties": {}
            }
          ],
          "additionalItems": {},
          "minItems": 2,
          "maxItems": 2
        },
        "x-procedures-codec": "map"
      },
      "id": {
        "type": "string"
      }
    },
    "required": [
      "nodes",
      "id"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "array",
    "items": {
      "type": "string"
    },
    "x-procedures-codec": "set"
  }
}