Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions server/src/db/config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dotenv from 'dotenv';
dotenv.config({ path: './.env' });
// CommonJS format for database.js
require('dotenv').config({ path: './.env' });

// Validate required environment variables
const requiredEnvVars = ['DB_USER', 'DB_PASSWORD', 'DB_NAME', 'DB_HOST', 'DB_PORT'];
Expand All @@ -10,7 +10,6 @@ requiredEnvVars.forEach(envVar => {
}
});


module.exports = {
development: {
username: process.env.DB_USER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('robot', 'description', {
type: Sequelize.TEXT,
allowNull: true
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('robot', 'description');
}
};
28 changes: 17 additions & 11 deletions server/src/models/Robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ interface RobotWorkflow {
interface RobotAttributes {
id: string;
userId?: number;
description?: string | null;
recording_meta: RobotMeta;
recording: RobotWorkflow;
google_sheet_email?: string | null;
google_sheet_name?: string | null;
google_sheet_id?: string | null;
google_access_token?: string | null;
google_refresh_token?: string | null;
airtable_base_id?: string | null;
airtable_base_name?: string | null;
airtable_table_name?: string | null;
airtable_access_token?: string | null;
airtable_refresh_token?: string | null;
airtable_base_id?: string | null;
airtable_base_name?: string | null;
airtable_table_name?: string | null;
airtable_access_token?: string | null;
airtable_refresh_token?: string | null;
schedule?: ScheduleConfig | null;
airtable_table_id?: string | null;
}
Expand All @@ -52,19 +53,20 @@ interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { }
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
public id!: string;
public userId!: number;
public description!: string | null;
public recording_meta!: RobotMeta;
public recording!: RobotWorkflow;
public google_sheet_email!: string | null;
public google_sheet_name!: string | null;
public google_sheet_id!: string | null;
public google_access_token!: string | null;
public google_refresh_token!: string | null;
public airtable_base_id!: string | null;
public airtable_base_name!: string | null;
public airtable_table_name!: string | null;
public airtable_access_token!: string | null;
public airtable_refresh_token!: string | null;
public airtable_table_id!: string | null;
public airtable_base_id!: string | null;
public airtable_base_name!: string | null;
public airtable_table_name!: string | null;
public airtable_access_token!: string | null;
public airtable_refresh_token!: string | null;
public airtable_table_id!: string | null;
public schedule!: ScheduleConfig | null;
}

Expand All @@ -79,6 +81,10 @@ Robot.init(
type: DataTypes.INTEGER,
allowNull: false,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
recording_meta: {
type: DataTypes.JSONB,
allowNull: false,
Expand Down
9 changes: 8 additions & 1 deletion server/src/routes/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ function handleWorkflowActions(workflow: any[], credentials: Credentials) {
router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, res) => {
try {
const { id } = req.params;
const { name, limits, credentials, targetUrl } = req.body;

const { name, limit, credentials, targetUrl,description } = req.body;


// Validate input
if (!name && !limits && !credentials && !targetUrl) {
Expand All @@ -272,6 +274,10 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
if (name) {
robot.set('recording_meta', { ...robot.recording_meta, name });
}

if(description){
robot.set('description', description);
}

if (targetUrl) {
const updatedWorkflow = [...robot.recording.workflow];
Expand All @@ -294,6 +300,7 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
}
}
}

}

await robot.save();
Expand Down
12 changes: 7 additions & 5 deletions server/src/workflow-management/classes/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export class WorkflowGenerator {
*/
private registerEventHandlers = (socket: Socket) => {
socket.on('save', (data) => {
const { fileName, userId, isLogin, robotId } = data;
const { fileName, userId, isLogin, robotId,description } = data;
logger.log('debug', `Saving workflow ${fileName} for user ID ${userId}`);
this.saveNewWorkflow(fileName, userId, isLogin, robotId);
this.saveNewWorkflow(fileName, userId, isLogin, robotId,description);
});
socket.on('new-recording', (data) => {
this.workflowRecord = {
Expand Down Expand Up @@ -767,7 +767,7 @@ export class WorkflowGenerator {
* @param fileName The name of the file.
* @returns {Promise<void>}
*/
public saveNewWorkflow = async (fileName: string, userId: number, isLogin: boolean, robotId?: string) => {
public saveNewWorkflow = async (fileName: string, userId: number, isLogin: boolean, robotId?: string,description?: string) => {
const recording = this.optimizeWorkflow(this.workflowRecord);
let actionType = 'saved';

Expand All @@ -784,10 +784,11 @@ export class WorkflowGenerator {
params: this.getParams() || [],
updatedAt: new Date().toLocaleString(),
},
description: description,
})

actionType = 'retrained';
logger.log('info', `Robot retrained with id: ${robot.id}`);
logger.log('info', `Robot retrained with id: ${robot.id} and name: ${robot.description}`);
}
} else {
this.recordingMeta = {
Expand All @@ -803,6 +804,7 @@ export class WorkflowGenerator {
userId,
recording_meta: this.recordingMeta,
recording: recording,
description: description,
});
capture(
'maxun-oss-robot-created',
Expand All @@ -813,7 +815,7 @@ export class WorkflowGenerator {
)

actionType = 'saved';
logger.log('info', `Robot saved with id: ${robot.id}`);
logger.log('info', `Robot saved with id: ${robot.id} with description: ${robot.description}`);
}
}
catch (e) {
Expand Down
9 changes: 3 additions & 6 deletions src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ export const getStoredRecordings = async (): Promise<string[] | null> => {
}
};

export const updateRecording = async (id: string, data: {
name?: string;
limits?: Array<{pairIndex: number, actionIndex: number, argIndex: number, limit: number}>;
credentials?: Credentials;
targetUrl?: string
}): Promise<boolean> => {

export const updateRecording = async (id: string, data: { name?: string; limit?: number, credentials?: Credentials, targetUrl?: string,description?:string }): Promise<boolean> => {

try {
const response = await axios.put(`${apiUrl}/storage/recordings/${id}`, data);
if (response.status === 200) {
Expand Down
Loading