I am not sure what is the real benefit implement a js to retrieve the deleted files. it would be simple for the user to simply go to their trashcan and restore the deleted file as needed. But it may be a particular use case for you which is fine.
You need to also understand the lifecycle of a node/file/folder etc.
Refer these posts , they are old but helpful:
If you still want to use your custom js to restore files, you would have make a lot of customizations to list of files which are deleted and then restore them based on their nodeIds. You might have to implement some sort of UI as well.
Have a look at these rest apis which can be a reference for your customization in order to list deleted files and retrieve them:
"When a site is created, it is the result of a duplication of a xx model. In my opinion, we should compare with the source model and copy the missing files from the model" ----> Seems you are confusing between site and content model with this statement you mentioned above. It is not correct. Content model is created/deployed at repository level. You create/configure, types, aspects, constraints, associations etc. in your content model and when you create sites, you could utilize your custom types aspects etc. to create content/metadata/associations.
I would recommend to go through these docs and understand the site and content model:
(ACSCE, AWS SAA, Azure Admin)