Divine Revelation came first, before the magisterium. Of course, the OT books were revealed prior to Christ. In the early Church, the NT books, including the letters, were passed around by the faithful, and gradually came to be understood as also the Word of God. The use of these books in the Church is what brought the Magisterium to the understanding as to which ones were inspired and canonical.
Tradition, according to Vatican II, is “the deeds wrought by God in the history of salvation” (Dei Verbum 2). Tradition is unwritten truths because it is deeds. And we could extend the deeds of God in salvation history to include those deeds prior to the writing of Scripture, for certainly the deeds happened before they could be written down. So Tradition is first, then Scripture, then the Magisterium.