The definition that I've seen most often (composition, harmony, analysis, counterpoint, and form books for the most part) relates to the Common Practice Period key structure. Some extension are made to earlier forms. (I don't remember seeing the term used much for post-romantic music.)
In major keys, "diatonic" refers to melodies and harmonies using notes from that key. For minor keys, "diatonic" refers to scale steps 1,2,b3,4,5 and both b6 and b7 and 7. Both form of the mutable steps (6 and 7) are termed "diatonic." If a modulation or even a tonicization occurs, one may use diatonic to refer to either key depending on what's needed. This leads to the next paragraph.
One cannot define "diatonic" without some reference to the term "chromatic." Music that stays in a single key for the most part with a few chromatically altered notes may be said to use "inessential chromaticism.""Inessential" means that one can analyze the piece without worrying about the chromatic notes. Perhaps Schenkeristas would say that the chromaticism disappears in deeper structures. These would things like a secondary dominant, a Neapolitan Sixth, an Augmented Sixth, perhaps an augmented or diminished chord now and then. (I would like to extend "diatonic" to these harmonic structures and to using accidentals to create a half-step in things like trills or neighbor tones, but I haven't found anyone else doing this. I just use the idea for myself in composition.)
Some music (Wagner, Chopin, Mozart, Bach, Gesualdo, Beethoven, etc.) write music where the chromatic parts are fundamental to the structure. (Schenker's deep structures contain these chromaticisms.) They are not small-scale deviations from the "diatonic" structure but essential. (Called in some of the books, "essential chromaticism.")
In pre-Baroque music, I've seen the term diatonic used to refer to pieces that do not need accidentals to switch modes. Of course, the Bb vs B (or B vs H) contrast seems to be called diatonic by some authors and chromatic by other.
The original usage for Greek tetrachords classifies them by the terms diatonic, chromatic, and enharmonic. The meanings of these terms has changed but he words linger on.