2024-06-07 23:19:43 +05:30
|
|
|
import { Action, ActionType, Coordinates, TagName } from "../../types";
|
|
|
|
|
import { WhereWhatPair, WorkflowFile } from '@wbr-project/wbr-interpret';
|
|
|
|
|
import logger from "../../logger";
|
|
|
|
|
import { Socket } from "socket.io";
|
|
|
|
|
import { Page } from "playwright";
|
|
|
|
|
import {
|
|
|
|
|
getElementInformation,
|
|
|
|
|
getRect,
|
|
|
|
|
getSelectors,
|
|
|
|
|
isRuleOvershadowing,
|
|
|
|
|
selectorAlreadyInWorkflow
|
|
|
|
|
} from "../selector";
|
|
|
|
|
import { CustomActions } from "../../../../src/shared/types";
|
|
|
|
|
import { workflow } from "../../routes";
|
|
|
|
|
import { saveFile } from "../storage";
|
|
|
|
|
import fs from "fs";
|
|
|
|
|
import { getBestSelectorForAction } from "../utils";
|
|
|
|
|
import { browserPool } from "../../server";
|
|
|
|
|
|
2024-06-07 23:24:18 +05:30
|
|
|
interface PersistedGeneratedData {
|
|
|
|
|
lastUsedSelector: string;
|
|
|
|
|
lastIndex: number|null;
|
|
|
|
|
lastAction: string;
|
|
|
|
|
}
|
2024-06-07 23:19:43 +05:30
|
|
|
|
|
|
|
|
interface MetaData {
|
|
|
|
|
name: string;
|
|
|
|
|
create_date: string;
|
|
|
|
|
pairs: number;
|
|
|
|
|
update_date: string;
|
|
|
|
|
params: string[],
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-07 23:26:57 +05:30
|
|
|
/**
|
|
|
|
|
* Workflow generator is used to transform the user's interactions into an automatically
|
|
|
|
|
* generated correct workflows, using the ability of internal state persistence and
|
|
|
|
|
* heuristic generative algorithms.
|
|
|
|
|
* This class also takes care of the selector generation.
|
|
|
|
|
* @category WorkflowManagement
|
|
|
|
|
*/
|
2024-06-07 23:26:08 +05:30
|
|
|
export class WorkflowGenerator {
|
|
|
|
|
|
|
|
|
|
private socket : Socket;
|
|
|
|
|
|
|
|
|
|
public constructor(socket: Socket) {
|
|
|
|
|
this.socket = socket;
|
|
|
|
|
this.registerEventHandlers(socket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|