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

138 lines
2.9 KiB
TypeScript
Raw Normal View History

2024-10-09 03:27:04 +05:30
import { Model, DataTypes, Optional } from 'sequelize';
2024-10-14 23:46:24 +05:30
import sequelize from '../storage/db';
2024-10-09 03:27:04 +05:30
import Robot from './Robot';
2024-10-15 01:46:49 +05:30
2024-10-09 14:43:48 +05:30
interface InterpreterSettings {
maxConcurrency: number;
maxRepeats: number;
debug: boolean;
}
2024-10-09 03:27:04 +05:30
interface RunAttributes {
2024-10-09 14:43:48 +05:30
id: string;
status: string;
name: string;
robotId: string;
2024-10-10 01:21:49 +05:30
robotMetaId: string;
2024-10-09 14:43:48 +05:30
startedAt: string;
finishedAt: string;
browserId: string;
interpreterSettings: InterpreterSettings;
log: string;
runId: string;
runByUserId?: string;
runByScheduleId?: string;
2024-10-21 18:58:45 +05:30
runByAPI?: boolean;
2024-10-09 14:43:48 +05:30
serializableOutput: Record<string, any[]>;
binaryOutput: Record<string, string>;
2025-09-10 00:12:11 +05:30
retryCount?: number;
2024-10-09 03:27:04 +05:30
}
2024-10-09 03:27:19 +05:30
interface RunCreationAttributes extends Optional<RunAttributes, 'id'> { }
2024-10-09 03:27:04 +05:30
class Run extends Model<RunAttributes, RunCreationAttributes> implements RunAttributes {
2024-10-09 14:43:48 +05:30
public id!: string;
public status!: string;
public name!: string;
public robotId!: string;
2024-10-10 01:21:49 +05:30
public robotMetaId!: string;
2024-10-09 14:43:48 +05:30
public startedAt!: string;
public finishedAt!: string;
public browserId!: string;
public interpreterSettings!: InterpreterSettings;
public log!: string;
public runId!: string;
public runByUserId!: string;
public runByScheduleId!: string;
2024-10-21 18:58:45 +05:30
public runByAPI!: boolean;
2024-10-09 14:43:48 +05:30
public serializableOutput!: Record<string, any[]>;
public binaryOutput!: Record<string, any>;
2025-09-10 00:12:11 +05:30
public retryCount!: number;
2024-10-09 03:27:04 +05:30
}
Run.init(
2024-10-09 14:43:48 +05:30
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
status: {
type: DataTypes.STRING(50),
allowNull: false,
},
name: {
type: DataTypes.STRING(255),
allowNull: false,
},
robotId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: Robot,
key: 'id',
},
},
2024-10-10 01:21:49 +05:30
robotMetaId: {
type: DataTypes.UUID,
allowNull: false,
},
2024-10-09 14:43:48 +05:30
startedAt: {
type: DataTypes.STRING(255),
allowNull: false,
},
finishedAt: {
type: DataTypes.STRING(255),
allowNull: false,
},
browserId: {
type: DataTypes.UUID,
allowNull: false,
},
interpreterSettings: {
type: DataTypes.JSONB,
allowNull: false,
},
log: {
type: DataTypes.TEXT,
allowNull: true,
},
runId: {
type: DataTypes.UUID,
allowNull: false,
},
runByUserId: {
type: DataTypes.INTEGER,
allowNull: true,
},
runByScheduleId: {
type: DataTypes.UUID,
allowNull: true,
},
runByAPI: {
2024-10-21 18:58:45 +05:30
type: DataTypes.BOOLEAN,
allowNull: true,
},
2024-10-09 14:43:48 +05:30
serializableOutput: {
type: DataTypes.JSONB,
allowNull: true,
},
binaryOutput: {
type: DataTypes.JSONB,
allowNull: true,
defaultValue: {},
2024-10-09 03:27:04 +05:30
},
2025-09-10 00:12:11 +05:30
retryCount: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: 0,
},
2024-10-09 14:43:48 +05:30
},
{
sequelize,
tableName: 'run',
timestamps: false,
}
2024-10-09 03:27:04 +05:30
);
2024-10-09 14:43:48 +05:30
export default Run;