I do not know if I was dreaming but I can swear I read a book about a medieval planet where the technology level was medieval, but that the elite or the rulers knew of the space-faring civilizations and traded with them. A Star Trek book seems a likely candidate with the Prime Directive but I know it was not Star Trek. It could have been a Star Wars EU book but I doubt it.
The book seems to follow two or three different characters. One is a regular character unaware living daily life on the planet, another is a merchant or agent of a space-faring civilization, and another is of the nobility, perhaps.
If I recall, in a similar way to the Prime Directive, there is some kind of strict blockade around the planet and strict rules regarding contact as well as trade. Perhaps there is no trade at all but rather traveling agents.