fix: revert integrations model
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Model, DataTypes, Optional } from "sequelize";
|
import { Model, DataTypes, Optional } from 'sequelize';
|
||||||
import sequelize from "../storage/db";
|
import sequelize from '../storage/db';
|
||||||
import { WorkflowFile, Where, What, WhereWhatPair } from "maxun-core";
|
import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core';
|
||||||
|
|
||||||
interface RobotMeta {
|
interface RobotMeta {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -15,42 +15,23 @@ interface RobotWorkflow {
|
|||||||
workflow: WhereWhatPair[];
|
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 {
|
interface RobotAttributes {
|
||||||
id: string;
|
id: string;
|
||||||
userId?: number;
|
userId?: number;
|
||||||
recording_meta: RobotMeta;
|
recording_meta: RobotMeta;
|
||||||
recording: RobotWorkflow;
|
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;
|
schedule?: ScheduleConfig | null;
|
||||||
integrations?: IntegrationData | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ScheduleConfig {
|
interface ScheduleConfig {
|
||||||
runEvery: number;
|
runEvery: number;
|
||||||
runEveryUnit: "MINUTES" | "HOURS" | "DAYS" | "WEEKS" | "MONTHS";
|
runEveryUnit: 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS';
|
||||||
startFrom:
|
startFrom: 'SUNDAY' | 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY';
|
||||||
| "SUNDAY"
|
|
||||||
| "MONDAY"
|
|
||||||
| "TUESDAY"
|
|
||||||
| "WEDNESDAY"
|
|
||||||
| "THURSDAY"
|
|
||||||
| "FRIDAY"
|
|
||||||
| "SATURDAY";
|
|
||||||
atTimeStart?: string;
|
atTimeStart?: string;
|
||||||
atTimeEnd?: string;
|
atTimeEnd?: string;
|
||||||
timezone: string;
|
timezone: string;
|
||||||
@@ -60,18 +41,19 @@ interface ScheduleConfig {
|
|||||||
cronExpression?: string;
|
cronExpression?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RobotCreationAttributes extends Optional<RobotAttributes, "id"> {}
|
interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { }
|
||||||
|
|
||||||
class Robot
|
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
|
||||||
extends Model<RobotAttributes, RobotCreationAttributes>
|
|
||||||
implements RobotAttributes
|
|
||||||
{
|
|
||||||
public id!: string;
|
public id!: string;
|
||||||
public userId!: number;
|
public userId!: number;
|
||||||
public recording_meta!: RobotMeta;
|
public recording_meta!: RobotMeta;
|
||||||
public recording!: RobotWorkflow;
|
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 schedule!: ScheduleConfig | null;
|
||||||
public integrations!: IntegrationData | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Robot.init(
|
Robot.init(
|
||||||
@@ -93,10 +75,25 @@ Robot.init(
|
|||||||
type: DataTypes.JSONB,
|
type: DataTypes.JSONB,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
integrations: {
|
google_sheet_email: {
|
||||||
type: DataTypes.JSONB,
|
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,
|
allowNull: true,
|
||||||
defaultValue: {},
|
|
||||||
},
|
},
|
||||||
schedule: {
|
schedule: {
|
||||||
type: DataTypes.JSONB,
|
type: DataTypes.JSONB,
|
||||||
@@ -105,7 +102,7 @@ Robot.init(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
tableName: "robot",
|
tableName: 'robot',
|
||||||
timestamps: false,
|
timestamps: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user