2024-10-18 07:04:57 -04:00
|
|
|
import ProjectEntityRestoreHandler from '../app/src/Features/Project/ProjectEntityRestoreHandler.js'
|
|
|
|
import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js'
|
2020-10-27 06:44:11 -04:00
|
|
|
|
|
|
|
const ARGV = process.argv.slice(2)
|
|
|
|
const DEVELOPER_USER_ID = ARGV.shift()
|
|
|
|
const PROJECT_ID = ARGV.shift()
|
|
|
|
const FILE_NAMES_TO_RESTORE = ARGV
|
|
|
|
|
|
|
|
async function main() {
|
2024-03-25 06:51:40 -04:00
|
|
|
const deletedDocs =
|
|
|
|
await DocstoreManager.promises.getAllDeletedDocs(PROJECT_ID)
|
2021-05-21 07:32:30 -04:00
|
|
|
const docsToRestore = deletedDocs.filter(doc =>
|
2020-10-27 06:44:11 -04:00
|
|
|
FILE_NAMES_TO_RESTORE.includes(doc.name)
|
|
|
|
)
|
|
|
|
for (const deletedDoc of docsToRestore) {
|
2023-04-13 06:08:27 -04:00
|
|
|
const newDoc = await ProjectEntityRestoreHandler.promises.restoreDeletedDoc(
|
2021-10-25 09:57:16 -04:00
|
|
|
PROJECT_ID,
|
|
|
|
deletedDoc._id,
|
2023-04-13 06:08:27 -04:00
|
|
|
deletedDoc.name,
|
2021-10-25 09:57:16 -04:00
|
|
|
DEVELOPER_USER_ID
|
|
|
|
)
|
2020-10-27 06:44:11 -04:00
|
|
|
console.log(newDoc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-18 07:04:57 -04:00
|
|
|
try {
|
|
|
|
await main()
|
|
|
|
process.exit(0)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
}
|