From a35b5ade603982ce769e7b575c7f9896d058ffca Mon Sep 17 00:00:00 2001 From: amhsirak Date: Mon, 11 Nov 2024 04:40:00 +0530 Subject: [PATCH] fix: revert integrations model --- server/src/models/Robot.ts | 77 ++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/server/src/models/Robot.ts b/server/src/models/Robot.ts index 4d6ef427..3b2717d6 100644 --- a/server/src/models/Robot.ts +++ b/server/src/models/Robot.ts @@ -1,6 +1,6 @@ -import { Model, DataTypes, Optional } from "sequelize"; -import sequelize from "../storage/db"; -import { WorkflowFile, Where, What, WhereWhatPair } from "maxun-core"; +import { Model, DataTypes, Optional } from 'sequelize'; +import sequelize from '../storage/db'; +import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core'; interface RobotMeta { name: string; @@ -15,42 +15,23 @@ interface RobotWorkflow { workflow: WhereWhatPair[]; } -interface IntegrationData { - google_sheets?: { - email: string; - sheet_id: string; - sheet_name: string; - access_token: string; - refresh_token: string; - }; - airtable?: { - base_id: string; - table_name: string; - access_token: string; - refresh_token: string; - }; -} - interface RobotAttributes { id: string; userId?: number; 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; schedule?: ScheduleConfig | null; - integrations?: IntegrationData | null; } interface ScheduleConfig { runEvery: number; - runEveryUnit: "MINUTES" | "HOURS" | "DAYS" | "WEEKS" | "MONTHS"; - startFrom: - | "SUNDAY" - | "MONDAY" - | "TUESDAY" - | "WEDNESDAY" - | "THURSDAY" - | "FRIDAY" - | "SATURDAY"; + runEveryUnit: 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS'; + startFrom: 'SUNDAY' | 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY'; atTimeStart?: string; atTimeEnd?: string; timezone: string; @@ -60,18 +41,19 @@ interface ScheduleConfig { cronExpression?: string; } -interface RobotCreationAttributes extends Optional {} +interface RobotCreationAttributes extends Optional { } -class Robot - extends Model - implements RobotAttributes -{ +class Robot extends Model implements RobotAttributes { public id!: string; public userId!: number; 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 schedule!: ScheduleConfig | null; - public integrations!: IntegrationData | null; } Robot.init( @@ -93,10 +75,25 @@ Robot.init( type: DataTypes.JSONB, allowNull: false, }, - integrations: { - type: DataTypes.JSONB, + google_sheet_email: { + type: DataTypes.STRING, + allowNull: true, + }, + google_sheet_name: { + type: DataTypes.STRING, + allowNull: true, + }, + google_sheet_id: { + type: DataTypes.STRING, + allowNull: true, + }, + google_access_token: { + type: DataTypes.STRING, + allowNull: true, + }, + google_refresh_token: { + type: DataTypes.STRING, allowNull: true, - defaultValue: {}, }, schedule: { type: DataTypes.JSONB, @@ -105,7 +102,7 @@ Robot.init( }, { sequelize, - tableName: "robot", + tableName: 'robot', timestamps: false, } ); @@ -115,4 +112,4 @@ Robot.init( // as: 'runs', // Alias for the relation // }); -export default Robot; +export default Robot; \ No newline at end of file