2024-10-09 03:22:36 +05:30
|
|
|
import { Model, DataTypes, Optional } from 'sequelize';
|
|
|
|
|
import sequelize from '../db/config';
|
2024-10-09 03:31:31 +05:30
|
|
|
import Run from './Run';
|
2024-10-09 03:22:36 +05:30
|
|
|
|
2024-10-09 03:59:31 +05:30
|
|
|
interface RobotMeta {
|
2024-10-09 03:50:53 +05:30
|
|
|
name: string;
|
|
|
|
|
id: string;
|
2024-10-09 04:03:45 +05:30
|
|
|
createdAt: string;
|
2024-10-09 03:50:53 +05:30
|
|
|
pairs: number;
|
2024-10-09 04:03:45 +05:30
|
|
|
updatedAt: string;
|
|
|
|
|
params: any[];
|
2024-10-09 03:50:53 +05:30
|
|
|
}
|
|
|
|
|
|
2024-10-09 04:03:45 +05:30
|
|
|
interface Workflow {
|
|
|
|
|
where: {
|
|
|
|
|
url: string;
|
|
|
|
|
};
|
|
|
|
|
what: Array<{
|
|
|
|
|
action: string;
|
|
|
|
|
args: any[];
|
2024-10-09 03:50:53 +05:30
|
|
|
}>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 04:03:45 +05:30
|
|
|
interface Robot {
|
|
|
|
|
workflow: Workflow[];
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 03:22:36 +05:30
|
|
|
interface RobotAttributes {
|
2024-10-09 03:50:53 +05:30
|
|
|
id: string;
|
2024-10-09 03:59:31 +05:30
|
|
|
recording_meta: RobotMeta;
|
|
|
|
|
recording: Robot;
|
2024-10-09 03:22:36 +05:30
|
|
|
}
|
|
|
|
|
|
2024-10-09 04:03:45 +05:30
|
|
|
interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> {}
|
2024-10-09 03:22:36 +05:30
|
|
|
|
|
|
|
|
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
|
2024-10-09 03:50:53 +05:30
|
|
|
public id!: string;
|
2024-10-09 03:59:31 +05:30
|
|
|
public recording_meta!: RobotMeta;
|
|
|
|
|
public recording!: Robot;
|
2024-10-09 03:22:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Robot.init(
|
2024-10-09 03:50:53 +05:30
|
|
|
{
|
|
|
|
|
id: {
|
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
|
primaryKey: true,
|
|
|
|
|
},
|
|
|
|
|
recording_meta: {
|
|
|
|
|
type: DataTypes.JSONB,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
},
|
|
|
|
|
recording: {
|
|
|
|
|
type: DataTypes.JSONB,
|
|
|
|
|
allowNull: false,
|
2024-10-09 03:22:36 +05:30
|
|
|
},
|
2024-10-09 03:50:53 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
sequelize,
|
|
|
|
|
tableName: 'robot',
|
2024-10-09 04:03:45 +05:30
|
|
|
timestamps: false, // We'll manage timestamps manually in recording_meta
|
2024-10-09 03:50:53 +05:30
|
|
|
}
|
2024-10-09 03:22:36 +05:30
|
|
|
);
|
|
|
|
|
|
2024-10-09 03:31:31 +05:30
|
|
|
Robot.hasMany(Run, { foreignKey: 'robotId' });
|
|
|
|
|
|
2024-10-09 03:22:36 +05:30
|
|
|
export default Robot;
|