feat: match exact format of file system robot

This commit is contained in:
karishmas6
2024-10-09 04:03:45 +05:30
parent 3baeb09d60
commit d303afc2af

View File

@@ -5,42 +5,36 @@ import Run from './Run';
interface RobotMeta { interface RobotMeta {
name: string; name: string;
id: string; id: string;
createdAt: Date; createdAt: string;
pairs: number; pairs: number;
updatedAt: Date; updatedAt: string;
params: object[]; params: any[];
}
interface Workflow {
where: {
url: string;
};
what: Array<{
action: string;
args: any[];
}>;
} }
interface Robot { interface Robot {
workflow: Array<{ workflow: Workflow[];
where: {
url: string;
};
what: Array<{
action: string;
args: any[];
}>;
}>;
} }
interface RobotAttributes { interface RobotAttributes {
id: string; id: string;
name: string;
createdAt: Date;
updatedAt: Date;
pairs: number;
recording_meta: RobotMeta; recording_meta: RobotMeta;
recording: Robot; recording: Robot;
} }
interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { } interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> {}
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes { class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
public id!: string; public id!: string;
public name!: string;
public createdAt!: Date;
public updatedAt!: Date;
public pairs!: number;
public recording_meta!: RobotMeta; public recording_meta!: RobotMeta;
public recording!: Robot; public recording!: Robot;
} }
@@ -52,30 +46,10 @@ Robot.init(
defaultValue: DataTypes.UUIDV4, defaultValue: DataTypes.UUIDV4,
primaryKey: true, primaryKey: true,
}, },
name: {
type: DataTypes.STRING(255),
allowNull: false,
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
pairs: {
type: DataTypes.INTEGER,
allowNull: false,
},
// JSONB field for recording_meta (storing as a structured object)
recording_meta: { recording_meta: {
type: DataTypes.JSONB, type: DataTypes.JSONB,
allowNull: false, allowNull: false,
}, },
// JSONB field for recording (storing as a structured object)
recording: { recording: {
type: DataTypes.JSONB, type: DataTypes.JSONB,
allowNull: false, allowNull: false,
@@ -84,7 +58,7 @@ Robot.init(
{ {
sequelize, sequelize,
tableName: 'robot', tableName: 'robot',
timestamps: true, timestamps: false, // We'll manage timestamps manually in recording_meta
} }
); );