UNPKG

@grouparoo/core

Version:
39 lines (38 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppDestroy = void 0; const clsTask_1 = require("../../classes/tasks/clsTask"); const App_1 = require("../../models/App"); class AppDestroy extends clsTask_1.CLSTask { constructor() { super(...arguments); this.name = "app:destroy"; this.description = "wait for dependencies to finish being deleted, then delete the app"; this.frequency = 0; this.queue = "apps"; this.inputs = { appId: { required: true }, }; } async runWithinTransaction({ appId }) { const app = await App_1.App.scope(null).findOne({ where: { id: appId, state: "deleted" }, }); // the app may have been force-deleted if (!app) return; // check if we're still being used by something try { await App_1.App.ensureNotInUse(app); } catch (error) { if (error.message.match(/cannot delete this app,/)) { return; // check back later } throw error; } // all things that depend on this app have been cleaned up await app.destroy(); } } exports.AppDestroy = AppDestroy;