ff-automationv2 2.2.29 → 2.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/ai/llmcalls/llmAction.js +49 -13
  2. package/dist/ai/llmcalls/parseLlmOputput.js +5 -5
  3. package/dist/ai/llmprompts/promptRegistry.js +4 -0
  4. package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +39 -11
  5. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +6 -6
  6. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +32 -0
  7. package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +17 -8
  8. package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.d.ts +1 -0
  9. package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.js +22 -0
  10. package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.js +3 -1
  11. package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +14 -6
  12. package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +3 -0
  13. package/dist/ai/llmprompts/userPrompts/userPrompt.js +1 -0
  14. package/dist/automation/actions/executor.d.ts +4 -0
  15. package/dist/automation/actions/executor.js +20 -0
  16. package/dist/automation/actions/interaction/clear/clear.js +1 -1
  17. package/dist/automation/actions/interaction/clear/clearAndEnter.js +1 -1
  18. package/dist/automation/actions/interaction/click/click.js +10 -3
  19. package/dist/automation/actions/interaction/click/clickNtimes.js +1 -1
  20. package/dist/automation/actions/interaction/click/doubleClick.js +1 -1
  21. package/dist/automation/actions/interaction/click/rightClick.js +1 -1
  22. package/dist/automation/actions/interaction/elementlessActions/getOtp.d.ts +2 -0
  23. package/dist/automation/actions/interaction/elementlessActions/getOtp.js +101 -0
  24. package/dist/automation/actions/interaction/enterActions/enterInput.js +11 -6
  25. package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +2 -2
  26. package/dist/automation/actions/interaction/enterActions/enterusingJs.js +2 -2
  27. package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +1 -1
  28. package/dist/automation/actions/interaction/upload/uploadfile.js +1 -1
  29. package/dist/automation/actions/interaction/verify/VerifyNavigateURL.js +38 -11
  30. package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +12 -0
  31. package/dist/automation/actions/interface/FireFlinkResponseSchema.js +19 -3
  32. package/dist/automation/actions/interface/getOtpInterface.d.ts +15 -0
  33. package/dist/automation/actions/interface/getOtpInterface.js +2 -0
  34. package/dist/automation/browserSession/initiateBrowserSession.d.ts +1 -1
  35. package/dist/automation/browserSession/initiateBrowserSession.js +15 -7
  36. package/dist/automation/driverState.d.ts +2 -0
  37. package/dist/automation/driverState.js +4 -0
  38. package/dist/automation/mobileSession/initiateMobileSession.d.ts +4 -5
  39. package/dist/automation/mobileSession/initiateMobileSession.js +83 -19
  40. package/dist/core/constants/allAction.js +5 -1
  41. package/dist/core/constants/supportedActions.js +5 -2
  42. package/dist/core/interfaces/actionInterface.d.ts +4 -0
  43. package/dist/core/interfaces/browserConfigurationInterface.d.ts +0 -4
  44. package/dist/core/interfaces/browserConfigurationInterface.js +0 -1
  45. package/dist/core/interfaces/executionDetails.d.ts +6 -3
  46. package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +22 -16
  47. package/dist/core/interfaces/llmResponseInterface.d.ts +1 -0
  48. package/dist/core/interfaces/promptInterface.d.ts +1 -0
  49. package/dist/core/main/SessionManager.d.ts +9 -0
  50. package/dist/core/main/SessionManager.js +23 -0
  51. package/dist/core/main/actionHandlerFactory.js +261 -64
  52. package/dist/core/main/executionContext.d.ts +7 -1
  53. package/dist/core/main/executionContext.js +94 -3
  54. package/dist/core/main/runAutomationScript.d.ts +1 -0
  55. package/dist/core/main/runAutomationScript.js +912 -304
  56. package/dist/core/main/stepProcessor.js +7 -2
  57. package/dist/core/types/browserType.d.ts +3 -3
  58. package/dist/core/types/browserType.js +2 -2
  59. package/dist/core/types/messageType.d.ts +13 -0
  60. package/dist/core/types/messageType.js +15 -0
  61. package/dist/core/types/promptType.d.ts +2 -1
  62. package/dist/core/types/promptType.js +1 -0
  63. package/dist/domAnalysis/searchBest.js +15 -16
  64. package/dist/domAnalysis/simplifyAndFlatten.js +6 -4
  65. package/dist/fireflinkData/fireflinkLocators/getListOfLocators.d.ts +3 -0
  66. package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +23 -15
  67. package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.d.ts +3 -3
  68. package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.js +134 -118
  69. package/dist/fireflinkData/fireflinkLocators/types/locator.d.ts +11 -1
  70. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.d.ts +1 -1
  71. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.js +35 -9
  72. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.d.ts +10 -10
  73. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.js +56 -59
  74. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.d.ts +1 -1
  75. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.js +53 -29
  76. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.d.ts +8 -8
  77. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.js +113 -190
  78. package/dist/fireflinkData/fireflinkLocators/utils/xpath.d.ts +17 -26
  79. package/dist/fireflinkData/fireflinkLocators/utils/xpath.js +314 -786
  80. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.d.ts +68 -70
  81. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.js +498 -517
  82. package/dist/fireflinkData/fireflinkScript/appendScriptData.d.ts +1 -1
  83. package/dist/fireflinkData/fireflinkScript/appendScriptData.js +5 -8
  84. package/dist/fireflinkData/fireflinkScript/scriptGenrationData.d.ts +2 -2
  85. package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +17 -27
  86. package/dist/llmConfig/llmConfiguration.js +13 -6
  87. package/dist/service/api/fireflinkApi.service.d.ts +1 -1
  88. package/dist/service/api/fireflinkApi.service.js +1 -2
  89. package/dist/service/fireflink.service.d.ts +3 -3
  90. package/dist/service/fireflink.service.js +23 -21
  91. package/dist/service/kafka/fireflinkKafka.service.d.ts +1 -2
  92. package/dist/service/kafka/fireflinkKafka.service.js +6 -4
  93. package/dist/tests/test12.d.ts +0 -1
  94. package/dist/tests/test12.js +65 -78
  95. package/dist/tests/testkaf.d.ts +0 -1
  96. package/dist/tests/testkaf.js +51 -55
  97. package/dist/utils/InstancesDetails/getInstancesInfo.js +1 -1
  98. package/dist/utils/browserCap/capability.d.ts +5 -1
  99. package/dist/utils/browserCap/capability.js +91 -15
  100. package/dist/utils/helpers/domSanitizer.d.ts +1 -0
  101. package/dist/utils/helpers/domSanitizer.js +9 -0
  102. package/dist/utils/helpers/enterActionHelper.js +23 -4
  103. package/dist/utils/helpers/xpathcreation.js +2 -2
  104. package/dist/utils/javascript/jsFindElement.d.ts +1 -1
  105. package/dist/utils/javascript/jsFindElement.js +2 -2
  106. package/dist/utils/newTab/newTabTracker.js +18 -6
  107. package/dist/utils/workers/LocatorWorkerInterface.d.ts +22 -0
  108. package/dist/utils/workers/LocatorWorkerInterface.js +2 -0
  109. package/dist/utils/workers/LocatorWorkerPool.d.ts +13 -0
  110. package/dist/utils/workers/LocatorWorkerPool.js +89 -0
  111. package/dist/utils/workers/locatorWorker.d.ts +1 -0
  112. package/dist/utils/workers/locatorWorker.js +44 -0
  113. package/package.json +3 -1
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MobileSession = void 0;
4
4
  const webdriverio_1 = require("webdriverio");
5
5
  const child_process_1 = require("child_process");
6
- const logData_js_1 = require("../../utils/logger/logData.js");
7
6
  const initiateCloudSession_js_1 = require("../cloudSession/initiateCloudSession.js");
8
7
  class MobileSession {
9
8
  constructor(appiumPort, isCloud, capabilities, CloudConfig, adbPath) {
10
9
  this.driver = null;
11
10
  this.currentAppPackage = "";
11
+ this.deviceId = "";
12
12
  this.appiumPort = appiumPort;
13
13
  this.isCloud = isCloud;
14
14
  this.cloudSessionInstances = new initiateCloudSession_js_1.CloudSession(capabilities, CloudConfig);
@@ -30,14 +30,12 @@ class MobileSession {
30
30
  throw new Error(`${platform} App failed to open`, { cause: error });
31
31
  }
32
32
  }
33
- async open(arg) {
33
+ async createDriver(capabilities) {
34
34
  if (this.isCloud) {
35
35
  this.driver = await this.cloudSessionInstances.initialize();
36
36
  return;
37
37
  }
38
- const appPackage = arg.keywords[0];
39
- const appActivity = arg.keywords?.[1];
40
- this.currentAppPackage = appPackage;
38
+ this.deviceId = capabilities["appium:udid"];
41
39
  try {
42
40
  const response = await fetch(`http://127.0.0.1:${this.appiumPort}/wd/hub/status`);
43
41
  if (response.status !== 200) {
@@ -47,26 +45,89 @@ class MobileSession {
47
45
  catch (error) {
48
46
  throw new Error("Appium server is not running or unreachable.", { cause: error });
49
47
  }
48
+ this.driver = await this.openApp({ capabilities });
49
+ }
50
+ async launchApp(appPackage, appActivity) {
51
+ const driver = await this.getCurrentDriver();
52
+ this.currentAppPackage = appPackage || await driver.getCurrentPackage();
53
+ if (this.isCloud || driver.isIOS) {
54
+ await driver.activateApp(appPackage);
55
+ return;
56
+ }
50
57
  try {
51
- if (arg.capabilities.platformName === "Android") {
52
- await (0, child_process_1.execSync)(`${this.adbPath} -s ${arg.capabilities["appium:udid"]} shell pm clear ${appPackage}`).toString();
53
- await (0, child_process_1.execSync)(`${this.adbPath} -s ${arg.capabilities["appium:udid"]} shell am start -n ${appPackage}/${appActivity}`).toString();
58
+ // let output: string = execSync(
59
+ // `${this.adbPath} -s ${this.deviceId} shell pm clear ${appPackage} 2>&1`
60
+ // ).toString();
61
+ if (appActivity) {
62
+ const output = (0, child_process_1.execSync)(`${this.adbPath} -s ${this.deviceId} shell am start -n ${appPackage}/${appActivity} 2>&1`).toString();
63
+ if (output.toLowerCase().includes("device") && output.toLowerCase().includes("not found")) {
64
+ throw new Error(`Device '${this.deviceId}' not found or offline.`);
65
+ }
66
+ if (output.includes("Error type 3") || output.includes("does not exist") || output.includes("Failed")) {
67
+ throw new Error(`App not found or invalid activity: ${appPackage}/${appActivity} is not installed on the device`);
68
+ }
69
+ }
70
+ else {
71
+ if (appPackage) {
72
+ await driver.activateApp(this.currentAppPackage);
73
+ }
54
74
  }
55
75
  }
56
76
  catch (error) {
57
- const output = error.stderr?.toString() || error.message || "";
58
- if (output.toLowerCase().includes("device") && output.toLowerCase().includes("not found")) {
59
- throw new Error(`Device '${arg.capabilities["appium:udid"]}' not found or offline.`, { cause: error });
60
- }
61
- if (output.includes("Error type 3") || output.includes("does not exist") || output.includes("Failed")) {
62
- throw new Error(`App not found or invalid activity: ${appPackage}/${appActivity} is not installed on the device`, { cause: error });
63
- }
64
- throw new Error(`ADB execution failed: ${output}`, { cause: error });
77
+ throw new Error(`App launch failed: ${error.message}`, { cause: error });
65
78
  }
66
- const startTime = Date.now();
67
- this.driver = await this.openApp({ capabilities: arg.capabilities });
68
- logData_js_1.logger.info(`Application launched in ${Date.now() - startTime} ms`);
69
79
  }
80
+ // async open(arg: { capabilities: IMobileCapabilities, keywords: string[] }): Promise<void> {
81
+ // if (this.isCloud) {
82
+ // this.driver = await this.cloudSessionInstances.initialize();
83
+ // return;
84
+ // }
85
+ // const appPackage = arg.keywords[0];
86
+ // const appActivity = arg.keywords?.[1];
87
+ // this.currentAppPackage = appPackage;
88
+ // try {
89
+ // const response = await fetch(`http://127.0.0.1:${this.appiumPort}/wd/hub/status`);
90
+ // if (response.status !== 200) {
91
+ // throw new Error("Appium server is not running.");
92
+ // }
93
+ // } catch (error: any) {
94
+ // throw new Error(
95
+ // "Appium server is not running or unreachable.",
96
+ // { cause: error }
97
+ // );
98
+ // }
99
+ // try {
100
+ // if (arg.capabilities.platformName === "Android") {
101
+ // await execSync(
102
+ // `${this.adbPath} -s ${arg.capabilities["appium:udid"]} shell pm clear ${appPackage}`
103
+ // ).toString();
104
+ // await execSync(
105
+ // `${this.adbPath} -s ${arg.capabilities["appium:udid"]} shell am start -n ${appPackage}/${appActivity}`
106
+ // ).toString();
107
+ // }
108
+ // } catch (error: any) {
109
+ // const output = error.stderr?.toString() || error.message || "";
110
+ // if (output.toLowerCase().includes("device") && output.toLowerCase().includes("not found")) {
111
+ // throw new Error(
112
+ // `Device '${arg.capabilities["appium:udid"]}' not found or offline.`,
113
+ // { cause: error }
114
+ // );
115
+ // }
116
+ // if (output.includes("Error type 3") || output.includes("does not exist") || output.includes("Failed")) {
117
+ // throw new Error(
118
+ // `App not found or invalid activity: ${appPackage}/${appActivity} is not installed on the device`,
119
+ // { cause: error }
120
+ // );
121
+ // }
122
+ // throw new Error(
123
+ // `ADB execution failed: ${output}`,
124
+ // { cause: error }
125
+ // );
126
+ // }
127
+ // const startTime = Date.now();
128
+ // this.driver = await this.openApp({ capabilities: arg.capabilities });
129
+ // logger.info(`Application launched in ${Date.now() - startTime} ms`);
130
+ // }
70
131
  async close() {
71
132
  if (this.driver) {
72
133
  if (this.isCloud) {
@@ -80,6 +141,9 @@ class MobileSession {
80
141
  // this.driver = null;
81
142
  }
82
143
  }
144
+ else {
145
+ throw new Error("Driver is not initialized");
146
+ }
83
147
  }
84
148
  async getCurrentDriver() {
85
149
  if (!this.driver) {
@@ -23,5 +23,9 @@ exports.allKeywordAction = [
23
23
  "cleartext",
24
24
  "tap",
25
25
  "combined",
26
- "mouseAction"
26
+ "mouseAction",
27
+ "switchToAndroid",
28
+ "switchToWeb",
29
+ "getOtp",
30
+ "enterOtp"
27
31
  ];
@@ -10,7 +10,9 @@ exports.INPUTLESS_ACTIONS = [
10
10
  "maximize",
11
11
  "minimize",
12
12
  "close",
13
- "closeApp"
13
+ "closeApp",
14
+ "switchToAndroid",
15
+ "switchToWeb"
14
16
  ];
15
17
  exports.SKIPPED_ACTIONS = [
16
18
  "VerifyIfBrowserWindowIsClosed",
@@ -222,5 +224,6 @@ exports.ELEMENTLESS_ACTION = [
222
224
  "MOB_GetAltitude",
223
225
  "MouseClickOnCurrentCursorPoint",
224
226
  "MouseDoubleClickAtCursorPoint",
225
- "MouseClickOnCurrentCursorPointNTimes"
227
+ "MouseClickOnCurrentCursorPointNTimes",
228
+ "getOtp"
226
229
  ];
@@ -343,4 +343,8 @@ export interface IActionExecutor {
343
343
  mouseHover(pageDOM: string, selector: string, fireflinkIndex: string, elementName: string, elementType: string): Promise<void>;
344
344
  MouseClickOnCurrentCursorPoint(): Promise<void>;
345
345
  MouseDoubleClickAtCursorPoint(): Promise<void>;
346
+ getOtp(selector: string, timeFrom: string, waitTime: string, activity: string, otpExtractor?: (smsBody: string) => Promise<{
347
+ otp: string;
348
+ regex: string;
349
+ } | null>): Promise<void>;
346
350
  }
@@ -1,4 +0,0 @@
1
- import { BrowserName } from "../../core/types/browserType";
2
- export interface BrowserConfig {
3
- browserName: BrowserName;
4
- }
@@ -1,2 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +1,12 @@
1
- import { BrowserConfig } from "./browserConfigurationInterface.js";
1
+ import { BrowserName } from "../../core/types/browserType";
2
2
  import { CloudConfig } from "./cloudConfigInterface.js";
3
3
  import { platform } from "../types/scriptTypesType.js";
4
4
  export interface AutomationRequest {
5
5
  sessionPath: string;
6
+ kafkaMessageKey: string;
6
7
  userStory: string[][];
7
8
  scriptName: string;
8
- version: string;
9
+ scenario: boolean;
9
10
  type: string;
10
11
  scriptType: string;
11
12
  projectId: string;
@@ -21,7 +22,7 @@ export interface AutomationRequest {
21
22
  env: string;
22
23
  userName: string;
23
24
  serverHost: string;
24
- browser: BrowserConfig;
25
+ browserName: BrowserName;
25
26
  platform: platform;
26
27
  token: string;
27
28
  appiumPort: number;
@@ -35,4 +36,6 @@ export interface AutomationRequest {
35
36
  cloudConfig?: CloudConfig;
36
37
  serverData?: any;
37
38
  adbPath?: string;
39
+ topic: string;
40
+ aiExecutionAction: string;
38
41
  }
@@ -8,18 +8,14 @@ export interface IStep {
8
8
  export interface IPayload {
9
9
  scriptName: string;
10
10
  scriptType: string;
11
- type: string;
12
- version: string;
13
- projectId: string;
14
- testCaseId: string;
15
- promptId: string;
16
- pageDetails: any;
17
- generatedBy: string;
18
- webSocketId: string;
19
- licenseType: string;
20
- licenseId: string;
21
- userId: string;
22
- projectType: string;
11
+ type?: string;
12
+ projectId?: string;
13
+ testCaseId?: string;
14
+ pageDetails?: any;
15
+ licenseType?: string;
16
+ licenseId?: string;
17
+ userId?: string;
18
+ projectType?: string;
23
19
  tokensConsumed?: number;
24
20
  error?: IErrorInfo;
25
21
  platform?: string;
@@ -27,15 +23,25 @@ export interface IPayload {
27
23
  model?: string;
28
24
  }
29
25
  export interface IFireFlinkApiService {
30
- getInstancesDetailsApi(headers: Record<string, string>, url: string): Promise<any>;
26
+ getInstancesDetailsApi(url: string): Promise<any>;
31
27
  }
32
28
  export interface IFireflinkService {
33
29
  runGetInstancesDetails(projectId: string, token: string, serverData: string, licenseId: string): Promise<any>;
34
30
  }
35
31
  export interface IKafkaPayload {
36
- message: IPayload & {
37
- stepData: IScriptGenerationData[];
38
- serverHost: string;
32
+ message: (IPayload & {
33
+ stepData?: IScriptGenerationData[];
34
+ serverHost?: string;
35
+ liveLogs: string;
36
+ executionId: string;
37
+ messageType: string;
38
+ }) | {
39
+ liveLogs: string | {
40
+ error: string;
41
+ errorDescription: string;
42
+ };
43
+ executionId: string;
44
+ messageType: string;
39
45
  };
40
46
  topic: string;
41
47
  }
@@ -2,6 +2,7 @@ export interface IKeywordAction {
2
2
  keywords: string[];
3
3
  elementName: string;
4
4
  action: string;
5
+ liveLog: string;
5
6
  }
6
7
  export interface IDragDropAction {
7
8
  drag: string;
@@ -36,4 +36,5 @@ export interface PromptArgsMap {
36
36
  extractedDomJson: any;
37
37
  priorAndNextSteps: string[];
38
38
  };
39
+ [PromptType.OTP_EXTRACTOR]: Record<string, never>;
39
40
  }
@@ -0,0 +1,9 @@
1
+ import { ExecutionContext } from "./executionContext";
2
+ import { AutomationRequest } from "../interfaces/executionDetails";
3
+ export declare class SessionManager {
4
+ private static sessions;
5
+ private static workerPool;
6
+ static create(request: AutomationRequest): ExecutionContext;
7
+ static get(request: AutomationRequest): ExecutionContext | undefined;
8
+ static remove(request: AutomationRequest): void;
9
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionManager = void 0;
4
+ const executionContext_1 = require("./executionContext");
5
+ const LocatorWorkerPool_js_1 = require("../../utils/workers/LocatorWorkerPool.js");
6
+ class SessionManager {
7
+ static create(request) {
8
+ if (!this.workerPool) {
9
+ this.workerPool = new LocatorWorkerPool_js_1.LocatorWorkerPool(request.sessionPath);
10
+ }
11
+ const context = new executionContext_1.ExecutionContext(request, this.workerPool);
12
+ this.sessions.set(request.kafkaMessageKey, context);
13
+ return context;
14
+ }
15
+ static get(request) {
16
+ return this.sessions.get(request.kafkaMessageKey);
17
+ }
18
+ static remove(request) {
19
+ this.sessions.delete(request.kafkaMessageKey);
20
+ }
21
+ }
22
+ exports.SessionManager = SessionManager;
23
+ SessionManager.sessions = new Map();