feat: match exact format of file system robot

This commit is contained in:
karishmas6
2024-10-09 03:50:53 +05:30
parent 14d5de8084
commit 6acde9d958

View File

@@ -2,14 +2,35 @@ import { Model, DataTypes, Optional } from 'sequelize';
import sequelize from '../db/config';
import Run from './Run';
interface RecordingMeta {
name: string;
id: string;
createdAt: Date;
pairs: number;
updatedAt: Date;
params: object[];
}
interface Recording {
workflow: Array<{
where: {
url: string;
};
what: Array<{
action: string;
args: any[];
}>;
}>;
}
interface RobotAttributes {
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
pairs: number;
params: object;
workflow: object; // Store workflow details as JSONB
recording_meta: RecordingMeta;
recording: Recording;
}
interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { }
@@ -20,8 +41,8 @@ class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements R
public createdAt!: Date;
public updatedAt!: Date;
public pairs!: number;
public params!: object;
public workflow!: object;
public recording_meta!: RecordingMeta;
public recording!: Recording;
}
Robot.init(
@@ -49,13 +70,15 @@ Robot.init(
type: DataTypes.INTEGER,
allowNull: false,
},
params: {
// JSONB field for recording_meta (storing as a structured object)
recording_meta: {
type: DataTypes.JSONB,
allowNull: true,
allowNull: false,
},
workflow: {
// JSONB field for recording (storing as a structured object)
recording: {
type: DataTypes.JSONB,
allowNull: true,
allowNull: false,
},
},
{