```ts
/**
 * Perform a topological sort on a set of nodes given a list of directed edges.
 * @param nodes - Array of node names.
 * @param edges - Array of tuples representing directed edges.
 * @returns A sorted array of node names that satisfies all the edges.
 */
export function topologicalSort(nodes: readonly string[], edges: readonly (readonly [string, string])[]): string[] {
    const graph: { [key: string]: string[] } = {};
    const inDegree: { [key: string]: number } = {};

    // Initialize graph and in-degree count
    for (const node of nodes) {
        graph[node] = [];
        inDegree[node] = 0;
    }

    // Build the graph and calculate in-degrees
    for (const [from, to] of edges) {
        if (!nodes.includes(from)) throw new Error(`Node '${from}' not found in nodes.`);
        if (!nodes.includes(to)) throw new Error(`Node '${to}' not found in nodes.`);
        graph[from].push(to);
        inDegree[to]++;
    }

    // Queue for nodes with zero in-degree
    const queue: string[] = [];
    for (const node of nodes) {
        if (inDegree[node] === 0) {
            queue.push(node);
        }
    }

    // Perform topological sort
    const result: string[] = [];
    while (queue.length > 0) {
        const node = queue.shift()!;
        result.push(node);

        for (const neighbor of graph[node]) {
            inDegree[neighbor]--;
            if (inDegree[neighbor] === 0) {
                queue.push(neighbor);
            }
        }
    }

    // Check if all nodes are included in the result
    if (result.length !== nodes.length) {
        throw new Error('Cycle detected');
    }

    return result;
}
```