```ts
/**
 * Perform topological sorting on a list of nodes with directed edges.
 * @param nodes - Array of node names.
 * @param edges - Array of [from, to] edges indicating dependencies.
 * @returns An ordered array of node names satisfying all edges.
 * @throws Error if a cycle is detected or an edge references an invalid node.
 */
export function topologicalSort(nodes: readonly string[], edges: readonly (readonly [string, string])[]): string[] {
    const adjacencyList = new Map<string, Set<string>>();
    const inDegree = new Map<string, number>();

    // Initialize the graphs with nodes and set default in-degrees to 0
    for (const node of nodes) {
        adjacencyList.set(node, new Set());
        inDegree.set(node, 0);
    }

    // Build adjacency list and in-degree map from edges
    for (const [from, to] of edges) {
        if (!adjacencyList.has(from) || !adjacencyList.has(to)) {
            throw new Error(`Invalid edge: ${from} or ${to} not in nodes.`);
        }
        adjacencyList.get(from)!.add(to);
        inDegree.set(to, (inDegree.get(to) || 0) + 1);
    }

    // Queue for nodes with no unmet dependencies
    const queue: string[] = [];
    for (const [node, degree] of inDegree.entries()) {
        if (degree === 0) {
            queue.push(node);
        }
    }

    // Process the nodes in topological order
    const sortedOrder: string[] = [];
    while (queue.length > 0) {
        const node = queue.shift()!;
        sortedOrder.push(node);

        for (const neighbor of adjacencyList.get(node)!) {
            inDegree.set(neighbor, inDegree.get(neighbor)! - 1);
            if (inDegree.get(neighbor)! === 0) {
                queue.push(neighbor);
            }
        }
    }

    // Check for cycles
    if (sortedOrder.length !== nodes.length) {
        throw new Error('Cycle detected in the graph.');
    }

    return sortedOrder;
}
```