I was in very similar position once upon a time. Had done the job for FREE on my managers making very obvious insinuations I'd get a permanent paid promotion at the end. And I quite literally created that role from scratch. Not one person other than me knew how to do it.
I didn't get that promotion. It was awarded to one of the area managers friends who had zero experience.
When asked why I'd not got the job, and why only two people had been interviewed (just me and this friend of the area managers) despite making it an external application, and literally hundreds of applications had been made, I was simply told "she did better than you in the interview". The fact I'd successfully created and carried out the job, and they'd refused to interview anyone else, went unanswered.
When I refused to train the person who had been awarded the job over me (because, why would she need training by me if I was so unsuitable for the role, even though they'd happily allowed me to do it for 8 months without any problems or criticisms) and I'd done it for no extra pay, they had the nerve to pull me into a room and bollock me. I distinctly remember the words "How dare you refuse!! You do as you're told. You're just an assistant, and your job is to assist!!" ...I wasn't employed as an assistant.
I signed off with work related stress for 2 months while I looked for another job. I did not train their friend. And I did not hand over all MY data, records and files that I had worked my arse off creating to evolve that job into what it was.
I'm not suggesting you take it to my level and leave, but YANBU to not let someone else walk into the job you created and train them. If they're so much better than you, they can do it without you.