feat: use robot model to save new workflow

This commit is contained in:
karishmas6
2024-10-09 23:09:04 +05:30
parent 7e22582997
commit 70c7938fad

View File

@@ -14,6 +14,8 @@ import {
} from "../selector"; } from "../selector";
import { CustomActions } from "../../../../src/shared/types"; import { CustomActions } from "../../../../src/shared/types";
import { workflow } from "../../routes"; import { workflow } from "../../routes";
import Robot from "../../models/Robot";
import Run from "../../models/Run";
import { saveFile } from "../storage"; import { saveFile } from "../storage";
import fs from "fs"; import fs from "fs";
import { getBestSelectorForAction } from "../utils"; import { getBestSelectorForAction } from "../utils";
@@ -486,11 +488,12 @@ export class WorkflowGenerator {
updatedAt: new Date().toLocaleString(), updatedAt: new Date().toLocaleString(),
params: this.getParams() || [], params: this.getParams() || [],
} }
fs.mkdirSync('../storage/recordings', { recursive: true }) const robot = await Robot.create({
await saveFile( recording_meta: this.recordingMeta,
`../storage/recordings/${fileName}.json`, recording: recording,
JSON.stringify({ recording_meta: this.recordingMeta, recording }, null, 2) });
);
logger.log('info', `Robot saved with id: ${robot.id}`);
} }
catch (e) { catch (e) {
const { message } = e as Error; const { message } = e as Error;