Files
parcer/server/src/models/Robot.ts

85 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-10-09 03:22:36 +05:30
import { Model, DataTypes, Optional } from 'sequelize';
2024-10-14 23:46:24 +05:30
import sequelize from '../storage/db';
2024-10-09 14:34:43 +05:30
import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core';
2024-10-09 03:22:36 +05:30
2024-10-09 03:59:31 +05:30
interface RobotMeta {
name: string;
id: string;
createdAt: string;
pairs: number;
updatedAt: string;
params: any[];
}
interface RobotWorkflow {
2024-10-09 14:34:43 +05:30
workflow: WhereWhatPair[];
}
2024-10-09 03:22:36 +05:30
interface RobotAttributes {
id: string;
2024-10-09 03:59:31 +05:30
recording_meta: RobotMeta;
recording: RobotWorkflow;
2024-10-16 23:38:18 +05:30
google_sheets_email?: string | null;
2024-10-17 19:22:14 +05:30
google_sheets_name?: string | null;
2024-10-16 23:38:18 +05:30
google_sheet_id?: string | null;
google_access_token?: string | null;
google_refresh_token?: string | null;
2024-10-09 03:22:36 +05:30
}
2024-10-09 14:34:58 +05:30
interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { }
2024-10-09 03:22:36 +05:30
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
public id!: string;
2024-10-09 03:59:31 +05:30
public recording_meta!: RobotMeta;
public recording!: RobotWorkflow;
2024-10-16 23:38:18 +05:30
public google_sheets_email!: string | null;
2024-10-17 19:22:14 +05:30
public google_sheets_name?: string | null;
2024-10-16 23:38:18 +05:30
public google_sheet_id?: string | null;
public google_access_token!: string | null;
public google_refresh_token!: string | null;
2024-10-09 03:22:36 +05:30
}
Robot.init(
{
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-16 23:38:18 +05:30
google_sheets_email: {
type: DataTypes.STRING,
allowNull: true,
2024-10-16 23:38:34 +05:30
},
2024-10-17 19:22:14 +05:30
google_sheets_name: {
type: DataTypes.STRING,
allowNull: true,
},
2024-10-16 23:38:34 +05:30
google_sheet_id: {
2024-10-16 23:38:18 +05:30
type: DataTypes.STRING,
allowNull: true,
2024-10-16 23:38:34 +05:30
},
google_access_token: {
2024-10-16 23:38:18 +05:30
type: DataTypes.STRING,
allowNull: true,
2024-10-16 23:38:34 +05:30
},
google_refresh_token: {
2024-10-16 23:38:18 +05:30
type: DataTypes.STRING,
allowNull: true,
2024-10-16 23:38:34 +05:30
},
},
{
sequelize,
tableName: 'robot',
2024-10-09 14:34:58 +05:30
timestamps: false,
}
2024-10-09 03:22:36 +05:30
);
2024-10-09 14:34:43 +05:30
export default Robot;