From d303afc2af372b882874b72c4d8682f992f89955 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 9 Oct 2024 04:03:45 +0530 Subject: [PATCH] feat: match exact format of file system robot --- server/src/models/Robot.ts | 58 +++++++++++--------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/server/src/models/Robot.ts b/server/src/models/Robot.ts index 68424f08..cdc67bdc 100644 --- a/server/src/models/Robot.ts +++ b/server/src/models/Robot.ts @@ -5,42 +5,36 @@ import Run from './Run'; interface RobotMeta { name: string; id: string; - createdAt: Date; + createdAt: string; pairs: number; - updatedAt: Date; - params: object[]; + updatedAt: string; + params: any[]; +} + +interface Workflow { + where: { + url: string; + }; + what: Array<{ + action: string; + args: any[]; + }>; } interface Robot { - workflow: Array<{ - where: { - url: string; - }; - what: Array<{ - action: string; - args: any[]; - }>; - }>; + workflow: Workflow[]; } interface RobotAttributes { id: string; - name: string; - createdAt: Date; - updatedAt: Date; - pairs: number; recording_meta: RobotMeta; recording: Robot; } -interface RobotCreationAttributes extends Optional { } +interface RobotCreationAttributes extends Optional {} class Robot extends Model implements RobotAttributes { public id!: string; - public name!: string; - public createdAt!: Date; - public updatedAt!: Date; - public pairs!: number; public recording_meta!: RobotMeta; public recording!: Robot; } @@ -52,30 +46,10 @@ Robot.init( defaultValue: DataTypes.UUIDV4, 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: { type: DataTypes.JSONB, allowNull: false, }, - // JSONB field for recording (storing as a structured object) recording: { type: DataTypes.JSONB, allowNull: false, @@ -84,7 +58,7 @@ Robot.init( { sequelize, tableName: 'robot', - timestamps: true, + timestamps: false, // We'll manage timestamps manually in recording_meta } );