@grouparoo/core
Version:
The Grouparoo Core
58 lines (57 loc) • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetupStepEdit = exports.SetupStepsList = void 0;
const authenticatedAction_1 = require("../classes/actions/authenticatedAction");
const SetupStep_1 = require("../models/SetupStep");
const apiData_1 = require("../modules/apiData");
const GrouparooModel_1 = require("../models/GrouparooModel");
class SetupStepsList extends authenticatedAction_1.AuthenticatedAction {
constructor() {
super(...arguments);
this.name = "setupSteps:list";
this.description = "List the SetupSteps and their status";
this.permission = { topic: "setupStep", mode: "read" };
this.outputExample = {};
}
isWriteTransaction() {
// setupStep.performCheck() can do an update
return true;
}
async runWithinTransaction() {
const responseSetupSteps = [];
const setupSteps = await SetupStep_1.SetupStep.findAll({
order: [["position", "asc"]],
});
const firstModel = await GrouparooModel_1.GrouparooModel.findOne({
order: [["createdAt", "asc"]],
});
for (const i in setupSteps) {
await setupSteps[i].performCheck();
responseSetupSteps.push(await setupSteps[i].apiData(firstModel === null || firstModel === void 0 ? void 0 : firstModel.id));
}
return { setupSteps: responseSetupSteps };
}
}
exports.SetupStepsList = SetupStepsList;
class SetupStepEdit extends authenticatedAction_1.AuthenticatedAction {
constructor() {
super(...arguments);
this.name = "setupStep:edit";
this.description = "List the SetupSteps and their status";
this.permission = { topic: "setupStep", mode: "write" };
this.outputExample = {};
this.inputs = {
id: { required: true },
skipped: { required: false, formatter: apiData_1.APIData.ensureBoolean },
};
}
async runWithinTransaction({ params, }) {
const setupStep = await SetupStep_1.SetupStep.findById(params.id);
if (params.skipped !== null) {
await setupStep.update({ skipped: params.skipped });
}
await setupStep.performCheck();
return { setupStep: await setupStep.apiData() };
}
}
exports.SetupStepEdit = SetupStepEdit;