@intuned/runtime-dev 1.3.18-interface.9 → 1.3.19-new-cli.0

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 (211) hide show
  1. package/.babelrc +27 -0
  2. package/.claude/settings.local.json +7 -0
  3. package/.eslintignore +10 -0
  4. package/.eslintrc.js +39 -0
  5. package/CHANGELOG.md +1 -1
  6. package/InterfaceTemplate/__utils.ts +63 -0
  7. package/InterfaceTemplate/index.playwright.ts +6 -0
  8. package/bin/intuned +20 -2
  9. package/dist/commands/api/run.d.ts +6 -0
  10. package/dist/commands/api/run.js +119 -0
  11. package/dist/commands/auth-sessions/load.d.ts +2 -0
  12. package/dist/commands/auth-sessions/load.js +35 -0
  13. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  14. package/dist/commands/auth-sessions/run-check.js +74 -0
  15. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  16. package/dist/commands/auth-sessions/run-create.js +78 -0
  17. package/dist/commands/browser/save-state.d.ts +2 -0
  18. package/dist/commands/browser/save-state.js +17 -0
  19. package/dist/commands/browser/start-browser.d.ts +2 -0
  20. package/dist/commands/browser/start-browser.js +14 -0
  21. package/dist/commands/build.d.ts +1 -0
  22. package/dist/commands/build.js +83 -0
  23. package/dist/commands/common/browserUtils.d.ts +14 -0
  24. package/dist/commands/common/browserUtils.js +57 -0
  25. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  26. package/dist/commands/common/getFirstLineNumber.js +101 -0
  27. package/dist/commands/common/getFirstLineNumber.test.js +227 -0
  28. package/dist/commands/common/projectExclusions.d.ts +2 -0
  29. package/dist/commands/common/projectExclusions.js +8 -0
  30. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  31. package/dist/commands/common/sendMessageToClient.js +10 -0
  32. package/dist/commands/common/tsNodeImport.d.ts +2 -5
  33. package/dist/commands/common/tsNodeImport.js +15 -56
  34. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  35. package/dist/commands/common/utils/fileUtils.js +32 -0
  36. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  37. package/dist/commands/common/utils/interfaceClient.js +98 -0
  38. package/dist/commands/common/utils/settings.d.ts +2 -0
  39. package/dist/commands/common/utils/settings.js +31 -0
  40. package/dist/commands/common/utils/template.d.ts +2 -0
  41. package/dist/commands/common/utils/template.js +30 -0
  42. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  43. package/dist/commands/get-headless-user-agent.js +18 -0
  44. package/dist/commands/interface/run.d.ts +1 -3
  45. package/dist/commands/interface/run.js +139 -2047
  46. package/dist/commands/ts-check.d.ts +2 -0
  47. package/dist/commands/ts-check.js +55 -0
  48. package/dist/common/Logger/Logger/index.d.ts +12 -0
  49. package/dist/common/Logger/Logger/index.js +60 -0
  50. package/dist/common/Logger/Logger/types.d.ts +8 -0
  51. package/dist/common/Logger/Logger/types.js +5 -0
  52. package/dist/common/Logger/index.d.ts +12 -0
  53. package/dist/common/Logger/index.js +60 -0
  54. package/dist/common/Logger/types.d.ts +8 -0
  55. package/dist/common/Logger/types.js +5 -0
  56. package/dist/common/asyncLocalStorage/index.d.ts +8 -9
  57. package/dist/common/asyncLocalStorage/index.js +9 -34
  58. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  59. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  60. package/dist/common/binStartupScript.d.ts +1 -2
  61. package/dist/common/binStartupScript.js +25 -132
  62. package/dist/common/browserTabs.d.ts +72 -0
  63. package/dist/common/browserTabs.js +74 -0
  64. package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
  65. package/dist/common/cleanEnvironmentVariables.js +7 -30
  66. package/dist/common/constants.d.ts +11 -13
  67. package/dist/common/constants.js +15 -58
  68. package/dist/common/contextStorageStateHelpers.d.ts +6 -8
  69. package/dist/common/contextStorageStateHelpers.js +26 -48
  70. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  71. package/dist/common/extension/extensionsHelpers.js +147 -0
  72. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  73. package/dist/common/extension/intunedExtensionServer.js +178 -0
  74. package/dist/common/extension/types.d.ts +219 -0
  75. package/dist/common/extension/types.js +51 -0
  76. package/dist/common/formatZodError.d.ts +2 -0
  77. package/dist/{chunk-NDMVGENG.mjs → common/formatZodError.js} +9 -9
  78. package/dist/common/intunedJson.d.ts +244 -0
  79. package/dist/common/intunedJson.js +154 -0
  80. package/dist/common/jwtTokenManager.d.ts +4 -6
  81. package/dist/common/jwtTokenManager.js +40 -108
  82. package/dist/common/launchBrowser.d.ts +36 -0
  83. package/dist/common/launchBrowser.js +269 -0
  84. package/dist/common/playwrightContext.d.ts +29 -0
  85. package/dist/common/playwrightContext.js +148 -0
  86. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  87. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  88. package/dist/common/runApi/index.d.ts +6 -9
  89. package/dist/common/runApi/index.js +73 -1782
  90. package/dist/common/settingsSchema.d.ts +6 -9
  91. package/dist/common/settingsSchema.js +18 -54
  92. package/dist/common/setupContextHook.d.ts +16 -0
  93. package/dist/common/setupContextHook.js +22 -0
  94. package/dist/common/telemetry.d.ts +3 -6
  95. package/dist/common/telemetry.js +8 -41
  96. package/dist/index.d.ts +4 -6
  97. package/dist/index.js +92 -784
  98. package/dist/runtime/RunError.d.ts +5 -0
  99. package/dist/runtime/RunError.js +19 -0
  100. package/dist/runtime/attemptStore.d.ts +2 -0
  101. package/dist/runtime/attemptStore.js +23 -0
  102. package/dist/runtime/captcha.d.ts +15 -0
  103. package/dist/runtime/captcha.js +191 -0
  104. package/dist/runtime/captcha.test.js +821 -0
  105. package/dist/runtime/downloadDirectory.d.ts +1 -0
  106. package/dist/runtime/downloadDirectory.js +19 -0
  107. package/dist/runtime/enums.d.js +5 -0
  108. package/dist/runtime/enums.d.ts +11 -0
  109. package/dist/runtime/enums.js +18 -0
  110. package/dist/runtime/executionHelpers.test.js +52 -0
  111. package/dist/runtime/export.d.js +5 -0
  112. package/dist/runtime/export.d.ts +284 -0
  113. package/dist/runtime/extendPayload.d.ts +2 -0
  114. package/dist/runtime/extendPayload.js +21 -0
  115. package/dist/runtime/extendTimeout.d.ts +1 -0
  116. package/dist/runtime/extendTimeout.js +23 -0
  117. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  118. package/dist/runtime/getAiGatewayConfig.js +16 -0
  119. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  120. package/dist/runtime/getAuthSessionParameters.js +20 -0
  121. package/dist/runtime/index.d.ts +10 -168
  122. package/dist/runtime/index.js +88 -779
  123. package/dist/runtime/persistentStore.d.ts +2 -0
  124. package/dist/runtime/persistentStore.js +37 -0
  125. package/dist/runtime/persistentStore.test.js +101 -0
  126. package/dist/runtime/runInfo.d.ts +2 -0
  127. package/dist/runtime/runInfo.js +21 -0
  128. package/dist/vendor/runtime-interface.d.ts +1 -0
  129. package/dist/vendor/runtime-interface.js +479 -0
  130. package/package.json +20 -74
  131. package/template.tsconfig.json +11 -0
  132. package/tsconfig.eslint.json +5 -0
  133. package/tsconfig.json +25 -0
  134. package/tsup.config.ts +12 -0
  135. package/typedoc.json +49 -0
  136. package/dist/chunk-3AGSY4RT.mjs +0 -1108
  137. package/dist/chunk-3AGSY4RT.mjs.map +0 -1
  138. package/dist/chunk-6ZRJOUQS.mjs +0 -16
  139. package/dist/chunk-6ZRJOUQS.mjs.map +0 -1
  140. package/dist/chunk-7YL2JUTE.mjs +0 -146
  141. package/dist/chunk-7YL2JUTE.mjs.map +0 -1
  142. package/dist/chunk-BF45RZ32.mjs +0 -13
  143. package/dist/chunk-BF45RZ32.mjs.map +0 -1
  144. package/dist/chunk-FGV5T6SI.mjs +0 -27
  145. package/dist/chunk-FGV5T6SI.mjs.map +0 -1
  146. package/dist/chunk-G4PO5RIV.mjs +0 -85
  147. package/dist/chunk-G4PO5RIV.mjs.map +0 -1
  148. package/dist/chunk-LZOMFHX3.mjs +0 -38
  149. package/dist/chunk-LZOMFHX3.mjs.map +0 -1
  150. package/dist/chunk-NDMVGENG.mjs.map +0 -1
  151. package/dist/chunk-UO2E7T7T.mjs +0 -787
  152. package/dist/chunk-UO2E7T7T.mjs.map +0 -1
  153. package/dist/chunk-W4UX6G4X.mjs +0 -17
  154. package/dist/chunk-W4UX6G4X.mjs.map +0 -1
  155. package/dist/chunk-XOAZ2MGA.mjs +0 -59
  156. package/dist/chunk-XOAZ2MGA.mjs.map +0 -1
  157. package/dist/commands/common/tsNodeImport.d.mts +0 -5
  158. package/dist/commands/common/tsNodeImport.js.map +0 -1
  159. package/dist/commands/common/tsNodeImport.mjs +0 -45
  160. package/dist/commands/common/tsNodeImport.mjs.map +0 -1
  161. package/dist/commands/interface/run.d.mts +0 -3
  162. package/dist/commands/interface/run.js.map +0 -1
  163. package/dist/commands/interface/run.mjs +0 -256
  164. package/dist/commands/interface/run.mjs.map +0 -1
  165. package/dist/common/asyncLocalStorage/index.d.mts +0 -17
  166. package/dist/common/asyncLocalStorage/index.js.map +0 -1
  167. package/dist/common/asyncLocalStorage/index.mjs +0 -12
  168. package/dist/common/asyncLocalStorage/index.mjs.map +0 -1
  169. package/dist/common/binStartupScript.d.mts +0 -2
  170. package/dist/common/binStartupScript.js.map +0 -1
  171. package/dist/common/binStartupScript.mjs +0 -135
  172. package/dist/common/binStartupScript.mjs.map +0 -1
  173. package/dist/common/cleanEnvironmentVariables.d.mts +0 -3
  174. package/dist/common/cleanEnvironmentVariables.js.map +0 -1
  175. package/dist/common/cleanEnvironmentVariables.mjs +0 -8
  176. package/dist/common/cleanEnvironmentVariables.mjs.map +0 -1
  177. package/dist/common/constants.d.mts +0 -13
  178. package/dist/common/constants.js.map +0 -1
  179. package/dist/common/constants.mjs +0 -28
  180. package/dist/common/constants.mjs.map +0 -1
  181. package/dist/common/contextStorageStateHelpers.d.mts +0 -24
  182. package/dist/common/contextStorageStateHelpers.js.map +0 -1
  183. package/dist/common/contextStorageStateHelpers.mjs +0 -10
  184. package/dist/common/contextStorageStateHelpers.mjs.map +0 -1
  185. package/dist/common/jwtTokenManager.d.mts +0 -19
  186. package/dist/common/jwtTokenManager.js.map +0 -1
  187. package/dist/common/jwtTokenManager.mjs +0 -11
  188. package/dist/common/jwtTokenManager.mjs.map +0 -1
  189. package/dist/common/runApi/index.d.mts +0 -11
  190. package/dist/common/runApi/index.js.map +0 -1
  191. package/dist/common/runApi/index.mjs +0 -19
  192. package/dist/common/runApi/index.mjs.map +0 -1
  193. package/dist/common/settingsSchema.d.mts +0 -540
  194. package/dist/common/settingsSchema.js.map +0 -1
  195. package/dist/common/settingsSchema.mjs +0 -10
  196. package/dist/common/settingsSchema.mjs.map +0 -1
  197. package/dist/common/telemetry.d.mts +0 -6
  198. package/dist/common/telemetry.js.map +0 -1
  199. package/dist/common/telemetry.mjs +0 -31
  200. package/dist/common/telemetry.mjs.map +0 -1
  201. package/dist/export.d-BAUMB-lG.d.mts +0 -140
  202. package/dist/export.d-BAUMB-lG.d.ts +0 -140
  203. package/dist/index.d.mts +0 -6
  204. package/dist/index.js.map +0 -1
  205. package/dist/index.mjs +0 -48
  206. package/dist/index.mjs.map +0 -1
  207. package/dist/runtime/index.d.mts +0 -168
  208. package/dist/runtime/index.js.map +0 -1
  209. package/dist/runtime/index.mjs +0 -43
  210. package/dist/runtime/index.mjs.map +0 -1
  211. /package/dist/common/assets/{assets/browser_scripts.js → browser_scripts.js} +0 -0
@@ -0,0 +1,14 @@
1
+ import * as playwright from "playwright";
2
+ export declare const REMOTE_DEBUGGING_PORT = 9222;
3
+ export declare const getChromiumLaunchArgs: () => string[];
4
+ export declare function startOrRestartBrowser(): Promise<void>;
5
+ export interface SessionState {
6
+ cookies: any[];
7
+ storage: Record<string, {
8
+ localStorage: any;
9
+ sessionStorage: any;
10
+ }>;
11
+ }
12
+ export declare function saveSessionFromOpenedBrowser(path: string): Promise<void>;
13
+ export declare function loadState(path: string, context: playwright.BrowserContext): Promise<void>;
14
+ export declare function saveSession(path: string, context: playwright.BrowserContext): Promise<void>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getChromiumLaunchArgs = exports.REMOTE_DEBUGGING_PORT = void 0;
7
+ exports.loadState = loadState;
8
+ exports.saveSession = saveSession;
9
+ exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
10
+ exports.startOrRestartBrowser = startOrRestartBrowser;
11
+ var _child_process = require("child_process");
12
+ var fs = _interopRequireWildcard(require("fs-extra"));
13
+ var _fileUtils = require("./utils/fileUtils");
14
+ var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
15
+ var playwright = _interopRequireWildcard(require("playwright"));
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
+ const REMOTE_DEBUGGING_PORT = exports.REMOTE_DEBUGGING_PORT = 9222;
18
+ const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
19
+ exports.getChromiumLaunchArgs = getChromiumLaunchArgs;
20
+ async function getBrowser() {
21
+ let playwrightBrowser = null;
22
+ try {
23
+ playwrightBrowser = await playwright.chromium.connectOverCDP(`http://localhost:${REMOTE_DEBUGGING_PORT}`);
24
+ } catch (e) {
25
+ throw new Error("Browser is not running");
26
+ }
27
+ return playwrightBrowser;
28
+ }
29
+ async function startOrRestartBrowser() {
30
+ const chromiumPath = playwright.chromium.executablePath();
31
+ const chromeInstanceProcess = (0, _child_process.spawn)(chromiumPath, getChromiumLaunchArgs());
32
+ chromeInstanceProcess.stdout.on("data", data => {
33
+ console.log(`Chrome stdout: ${data}`);
34
+ });
35
+ chromeInstanceProcess.stderr.on("data", data => {
36
+ console.error(`Chrome stderr: ${data}`);
37
+ });
38
+ }
39
+ async function saveSessionFromOpenedBrowser(path) {
40
+ const browser = await getBrowser();
41
+ const context = await browser.contexts()[0];
42
+ return saveSession(path, context);
43
+ }
44
+ async function loadState(path, context) {
45
+ const fullPath = (0, _fileUtils.getFullPathInProject)(path);
46
+ if (!(await fs.pathExists(fullPath))) {
47
+ throw new Error("session file does not exist");
48
+ }
49
+ const data = await fs.readJson(fullPath);
50
+ await context.addCookies(data.cookies);
51
+ }
52
+ async function saveSession(path, context) {
53
+ const fullState = await (0, _contextStorageStateHelpers.getStorageState)(context);
54
+ const fullPath = (0, _fileUtils.getFullPathInProject)(path);
55
+ fs.ensureFileSync(fullPath);
56
+ await fs.writeJSON(fullPath, fullState);
57
+ }
@@ -0,0 +1,9 @@
1
+ import { SourceFile } from "ts-morph";
2
+ export declare function findFirstExecutableLine(sourceFile: SourceFile): -1 | {
3
+ line: number;
4
+ column: number;
5
+ };
6
+ export default function getFirstLineNumber(apiFilePath: string): Promise<{
7
+ sourceFileName: string;
8
+ lineNumber: number;
9
+ }>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getFirstLineNumber;
7
+ exports.findFirstExecutableLine = findFirstExecutableLine;
8
+ var _tsMorph = require("ts-morph");
9
+ var _sourceMap = require("source-map");
10
+ function compileTypeScript(apiFilePath) {
11
+ const compilerOptions = {
12
+ lib: ["dom", "es2020"],
13
+ sourceMap: true,
14
+ inlineSourceMap: true,
15
+ inlineSources: true,
16
+ declaration: false,
17
+ noEmit: false,
18
+ module: _tsMorph.ModuleKind.CommonJS,
19
+ target: _tsMorph.ScriptTarget.ES2020
20
+ };
21
+ const project = new _tsMorph.Project({
22
+ compilerOptions
23
+ });
24
+ const sourceFile = project.addSourceFileAtPath(apiFilePath);
25
+ const outputJS = project.emitToMemory({
26
+ targetSourceFile: sourceFile
27
+ });
28
+ const outputJSText = outputJS.getFiles()[0].text;
29
+ return {
30
+ sourceFile,
31
+ outputJSText
32
+ };
33
+ }
34
+ function findFirstExecutableLine(sourceFile) {
35
+ let functionBody;
36
+ const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
37
+ const defaultExportDeclaration = defaultExportSymbol?.getDeclarations()?.[0];
38
+ if (defaultExportDeclaration) {
39
+ if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
40
+ functionBody = defaultExportDeclaration.getBody();
41
+ } else {
42
+ const exportAssignments = sourceFile.getExportAssignments();
43
+ for (const exportAssignment of exportAssignments) {
44
+ const expression = exportAssignment.getExpression();
45
+ if (!expression) continue;
46
+ if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
47
+ const identifier = expression.getText();
48
+ const possiblyExportedFunction = sourceFile.getFunction(identifier) || sourceFile.getVariableStatement(identifier)?.getDescendants().find(node => node.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction);
49
+ if (possiblyExportedFunction) {
50
+ functionBody = possiblyExportedFunction.getBody();
51
+ break;
52
+ }
53
+ }
54
+ if (_tsMorph.Node.hasBody(expression) && (expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction)) {
55
+ functionBody = expression.getBody();
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ if (!functionBody || !_tsMorph.Node.isStatemented(functionBody)) {
62
+ return -1;
63
+ }
64
+ if (functionBody.getStatements().length === 0) {
65
+ return -1;
66
+ }
67
+ const position = functionBody.getStatements()[0].getStart();
68
+ return sourceFile.getLineAndColumnAtPos(position);
69
+ }
70
+ async function getSourceMap(jsCode) {
71
+ const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
72
+ const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
73
+ const sourceMap = JSON.parse(sourceMapText);
74
+ return new _sourceMap.SourceMapConsumer(sourceMap);
75
+ }
76
+ async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
77
+ const sourceMap = await getSourceMap(jsCode);
78
+ const generatedLineNumber = sourceMap.generatedPositionFor({
79
+ source: sourceFileName,
80
+ line,
81
+ column
82
+ }).line;
83
+ if (!generatedLineNumber) return -1;
84
+ return generatedLineNumber;
85
+ }
86
+ async function getFirstLineNumber(apiFilePath) {
87
+ const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
88
+ const {
89
+ sourceFile,
90
+ outputJSText
91
+ } = compileTypeScript(apiFilePath);
92
+ const result = findFirstExecutableLine(sourceFile);
93
+ if (result === -1) return {
94
+ sourceFileName,
95
+ lineNumber: -1
96
+ };
97
+ return {
98
+ sourceFileName,
99
+ lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column)
100
+ };
101
+ }
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _getFirstLineNumber = _interopRequireDefault(require("./getFirstLineNumber"));
5
+ var fs = _interopRequireWildcard(require("fs"));
6
+ var path = _interopRequireWildcard(require("path"));
7
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ (0, _vitest.describe)("getFirstLineNumber", () => {
10
+ const testFilesDir = path.join(__dirname, "testFiles");
11
+ const createTestFile = (fileName, content) => {
12
+ const filePath = path.join(testFilesDir, fileName);
13
+ fs.writeFileSync(filePath, content);
14
+ return filePath;
15
+ };
16
+ (0, _vitest.beforeAll)(() => {
17
+ if (!fs.existsSync(testFilesDir)) {
18
+ fs.mkdirSync(testFilesDir);
19
+ }
20
+ });
21
+ (0, _vitest.afterAll)(() => {
22
+ fs.readdirSync(testFilesDir).forEach(file => fs.unlinkSync(path.join(testFilesDir, file)));
23
+ fs.rmdirSync(testFilesDir);
24
+ });
25
+ (0, _vitest.it)("correctly identifies first line in a default exported named function", async () => {
26
+ const filePath = createTestFile("defaultFunction.ts", `import {
27
+ EnhancedPlaywrightPage,
28
+ EnhancedPlaywrightBrowserContext,
29
+ ExecutionHelpers,
30
+ } from "@intuned/runner";
31
+ interface Params {
32
+ name: string;
33
+ [key: string]: string | number | undefined;
34
+ }
35
+ export default async function runApi(
36
+ params: Params,
37
+ page: EnhancedPlaywrightPage,
38
+ context: EnhancedPlaywrightBrowserContext,
39
+ executionHelpers: ExecutionHelpers
40
+ ) {
41
+ await page.goto("https://www.wikipedia.org/");
42
+ await page.getByLabel("Search Wikipedia").click();
43
+ await page.getByLabel("Search Wikipedia").type(params.name);
44
+ await page.getByLabel("Search Wikipedia").press("Enter");
45
+ return { done: "true", name: "custom name from api1" };
46
+ }
47
+ `);
48
+ const result = await (0, _getFirstLineNumber.default)(filePath);
49
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
50
+ });
51
+ (0, _vitest.it)("correctly identifies first line in a default exported anonymous function", async () => {
52
+ const filePath = createTestFile("defaultFunction.ts", `import {
53
+ EnhancedPlaywrightPage,
54
+ EnhancedPlaywrightBrowserContext,
55
+ ExecutionHelpers,
56
+ } from "@intuned/runner";
57
+ interface Params {
58
+ name: string;
59
+ [key: string]: string | number | undefined;
60
+ }
61
+ export default async function(
62
+ params: Params,
63
+ page: EnhancedPlaywrightPage,
64
+ context: EnhancedPlaywrightBrowserContext,
65
+ executionHelpers: ExecutionHelpers
66
+ ) {
67
+ await page.goto("https://www.wikipedia.org/");
68
+ await page.getByLabel("Search Wikipedia").click();
69
+ await page.getByLabel("Search Wikipedia").type(params.name);
70
+ await page.getByLabel("Search Wikipedia").press("Enter");
71
+ return { done: "true", name: "custom name from api1" };
72
+ }
73
+ `);
74
+ const result = await (0, _getFirstLineNumber.default)(filePath);
75
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
76
+ });
77
+ (0, _vitest.it)("correctly identifies first line in a default exported function identifier", async () => {
78
+ const filePath = createTestFile("defaultFunction.ts", `import {
79
+ EnhancedPlaywrightPage,
80
+ EnhancedPlaywrightBrowserContext,
81
+ ExecutionHelpers,
82
+ } from "@intuned/runner";
83
+ interface Params {
84
+ name: string;
85
+ [key: string]: string | number | undefined;
86
+ }
87
+ async function runApi(
88
+ params: Params,
89
+ page: EnhancedPlaywrightPage,
90
+ context: EnhancedPlaywrightBrowserContext,
91
+ executionHelpers: ExecutionHelpers
92
+ ) {
93
+ await page.goto("https://www.wikipedia.org/");
94
+ await page.getByLabel("Search Wikipedia").click();
95
+ await page.getByLabel("Search Wikipedia").type(params.name);
96
+ await page.getByLabel("Search Wikipedia").press("Enter");
97
+ return { done: "true", name: "custom name from api1" };
98
+ }
99
+ export default runApi;
100
+ `);
101
+ const result = await (0, _getFirstLineNumber.default)(filePath);
102
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
103
+ });
104
+ (0, _vitest.it)("correctly identifies first line in a file with multiple exports including a default function", async () => {
105
+ const filePath = createTestFile("multipleExports.ts", `import {
106
+ EnhancedPlaywrightPage,
107
+ EnhancedPlaywrightBrowserContext,
108
+ ExecutionHelpers,
109
+ } from "@intuned/runner";
110
+ interface Params {
111
+ name: string;
112
+ [key: string]: string | number | undefined;
113
+ }
114
+ export const foo = () => {};
115
+ async function runApi(
116
+ params: Params,
117
+ page: EnhancedPlaywrightPage,
118
+ context: EnhancedPlaywrightBrowserContext,
119
+ executionHelpers: ExecutionHelpers
120
+ ) {
121
+ await page.goto("https://www.wikipedia.org/");
122
+ await page.getByLabel("Search Wikipedia").click();
123
+ await page.getByLabel("Search Wikipedia").type(params.name);
124
+ await page.getByLabel("Search Wikipedia").press("Enter");
125
+ return { done: "true", name: "custom name from api1" };
126
+ }
127
+ export default runApi;`);
128
+ const result = await (0, _getFirstLineNumber.default)(filePath);
129
+ (0, _vitest.expect)(result.lineNumber).toBe(7);
130
+ });
131
+ (0, _vitest.it)("correctly identifies first line in a default exported arrow function identifier", async () => {
132
+ const filePath = createTestFile("multipleExports.ts", `import {
133
+ EnhancedPlaywrightPage,
134
+ EnhancedPlaywrightBrowserContext,
135
+ ExecutionHelpers,
136
+ } from "@intuned/runner";
137
+ interface Params {
138
+ name: string;
139
+ [key: string]: string | number | undefined;
140
+ }
141
+ const runApi = async (
142
+ params: Params,
143
+ page: EnhancedPlaywrightPage,
144
+ context: EnhancedPlaywrightBrowserContext,
145
+ executionHelpers: ExecutionHelpers
146
+ ) => {
147
+ await page.goto("https://www.wikipedia.org/");
148
+ await page.getByLabel("Search Wikipedia").click();
149
+ await page.getByLabel("Search Wikipedia").type(params.name);
150
+ await page.getByLabel("Search Wikipedia").press("Enter");
151
+ return { done: "true", name: "custom name from api1" };
152
+ }
153
+ export default runApi;`);
154
+ const result = await (0, _getFirstLineNumber.default)(filePath);
155
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
156
+ });
157
+ (0, _vitest.it)("correctly identifies first line in a default exported anonymous arrow function", async () => {
158
+ const filePath = createTestFile("multipleExports.ts", `import {
159
+ EnhancedPlaywrightPage,
160
+ EnhancedPlaywrightBrowserContext,
161
+ ExecutionHelpers,
162
+ } from "@intuned/runner";
163
+ interface Params {
164
+ name: string;
165
+ [key: string]: string | number | undefined;
166
+ }
167
+ export default async (
168
+ params: Params,
169
+ page: EnhancedPlaywrightPage,
170
+ context: EnhancedPlaywrightBrowserContext,
171
+ executionHelpers: ExecutionHelpers
172
+ ) => {
173
+ await page.goto("https://www.wikipedia.org/");
174
+ await page.getByLabel("Search Wikipedia").click();
175
+ await page.getByLabel("Search Wikipedia").type(params.name);
176
+ await page.getByLabel("Search Wikipedia").press("Enter");
177
+ return { done: "true", name: "custom name from api1" };
178
+ };`);
179
+ const result = await (0, _getFirstLineNumber.default)(filePath);
180
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
181
+ });
182
+ (0, _vitest.it)("identifies first executable line in a default exported arrow function", async () => {
183
+ const filePath = createTestFile("defaultArrowFunction.ts", `export default () => {
184
+ console.log("Hello, Arrow World!");
185
+ };`);
186
+ const result = await (0, _getFirstLineNumber.default)(filePath);
187
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
188
+ });
189
+ (0, _vitest.it)("identifies first executable line within nested functions of a default export", async () => {
190
+ const filePath = createTestFile("nestedFunctions.ts", `const x = 4;
191
+ export default function() {
192
+ const nested = (x) => console.log("Nested function call");
193
+ nested(x);
194
+ }`);
195
+ const result = await (0, _getFirstLineNumber.default)(filePath);
196
+ (0, _vitest.expect)(result.lineNumber).toBe(5);
197
+ });
198
+ (0, _vitest.it)("handles async default exported function correctly", async () => {
199
+ const filePath = createTestFile("asyncDefaultFunction.ts", `export default async function() {
200
+ await Promise.resolve(console.log("Async Hello, World!"));
201
+ }`);
202
+ const result = await (0, _getFirstLineNumber.default)(filePath);
203
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
204
+ });
205
+ (0, _vitest.it)("returns -1 for a default exported class", async () => {
206
+ const filePath = createTestFile("defaultClass.ts", `export default class MyClass {
207
+ constructor() {}
208
+ }`);
209
+ const result = await (0, _getFirstLineNumber.default)(filePath);
210
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
211
+ });
212
+ (0, _vitest.it)("returns -1 for a default exported variable", async () => {
213
+ const filePath = createTestFile("defaultVariable.ts", `export default 42;`);
214
+ const result = await (0, _getFirstLineNumber.default)(filePath);
215
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
216
+ });
217
+ (0, _vitest.it)("returns -1 when there is no default export", async () => {
218
+ const filePath = createTestFile("noDefaultExport.ts", `export const foo = () => console.log("bar");`);
219
+ const result = await (0, _getFirstLineNumber.default)(filePath);
220
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
221
+ });
222
+ (0, _vitest.it)("returns -1 for an empty file", async () => {
223
+ const filePath = createTestFile("emptyFile.ts", ``);
224
+ const result = await (0, _getFirstLineNumber.default)(filePath);
225
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
226
+ });
227
+ });
@@ -0,0 +1,2 @@
1
+ declare const exclusions: string[];
2
+ export default exclusions;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const exclusions = ["node_modules/**", ".vscode/**", ".idea/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo", "tsconfig.json", "output/**", "auth-sessions-instances/**", "README.md", "traces/**"];
8
+ var _default = exports.default = exclusions;
@@ -0,0 +1 @@
1
+ export declare const sendBreakPointOnToClient: (sourceFileName: string, lineNumber: number) => void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendBreakPointOnToClient = void 0;
7
+ const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
8
+ console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
9
+ };
10
+ exports.sendBreakPointOnToClient = sendBreakPointOnToClient;
@@ -1,5 +1,2 @@
1
- import { ExtendedRunApiParameters } from '@intuned/runtime-interface';
2
-
3
- declare const tsNodeImport: ExtendedRunApiParameters["importFunction"];
4
-
5
- export { tsNodeImport };
1
+ import { ExtendedRunApiParameters } from "@intuned/runtime-interface";
2
+ export declare const tsNodeImport: ExtendedRunApiParameters["importFunction"];
@@ -1,83 +1,42 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/commands/common/tsNodeImport.ts
30
- var tsNodeImport_exports = {};
31
- __export(tsNodeImport_exports, {
32
- tsNodeImport: () => tsNodeImport
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
33
5
  });
34
- module.exports = __toCommonJS(tsNodeImport_exports);
35
- var import_neverthrow = require("neverthrow");
36
-
37
- // src/commands/common/utils/fileUtils.ts
38
- var path = __toESM(require("path"));
39
- var fs = __toESM(require("fs-extra"));
40
- var import_dotenv = __toESM(require("dotenv"));
41
- import_dotenv.default.config();
42
- function getFullPathInProject(...paths) {
43
- return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
44
- }
45
-
46
- // src/commands/common/tsNodeImport.ts
47
- var tsNodeImport = async (apiName) => {
6
+ exports.tsNodeImport = void 0;
7
+ var _neverthrow = require("neverthrow");
8
+ var _fileUtils = require("./utils/fileUtils");
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
+ const tsNodeImport = async apiName => {
48
11
  require("ts-node").register({
49
12
  transpileOnly: true,
50
13
  compilerOptions: {
51
14
  lib: ["dom", "es2020"]
52
15
  }
53
16
  });
54
- const path2 = getFullPathInProject(...apiName.split("/"));
17
+ const path = (0, _fileUtils.getFullPathInProject)(...apiName.split("/"));
55
18
  try {
56
- const imported = await import(path2);
57
- return (0, import_neverthrow.ok)(imported);
19
+ const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(path);
20
+ return (0, _neverthrow.ok)(imported);
58
21
  } catch (e) {
59
22
  if ("code" in e && e.code.includes("MODULE_NOT_FOUND")) {
60
23
  if ("requireStack" in e && Array.isArray(e.requireStack)) {
61
24
  const isStackTopThisFile = e.requireStack[0] === __filename;
62
25
  if (!isStackTopThisFile) {
63
- return (0, import_neverthrow.err)({
26
+ return (0, _neverthrow.err)({
64
27
  type: "other",
65
28
  error: e
66
29
  });
67
30
  }
68
31
  }
69
- return (0, import_neverthrow.err)({
32
+ return (0, _neverthrow.err)({
70
33
  type: "not_found"
71
34
  });
72
35
  }
73
- return (0, import_neverthrow.err)({
36
+ return (0, _neverthrow.err)({
74
37
  type: "other",
75
38
  error: e
76
39
  });
77
40
  }
78
41
  };
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- tsNodeImport
82
- });
83
- //# sourceMappingURL=tsNodeImport.js.map
42
+ exports.tsNodeImport = tsNodeImport;
@@ -0,0 +1,6 @@
1
+ export declare function getFullPathInProject(...paths: string[]): string;
2
+ export declare function listProjectFilesAndFolders(): Promise<{
3
+ type: "Folder" | "File";
4
+ fullPath: string;
5
+ name: string;
6
+ }[]>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFullPathInProject = getFullPathInProject;
7
+ exports.listProjectFilesAndFolders = listProjectFilesAndFolders;
8
+ var path = _interopRequireWildcard(require("path"));
9
+ var fs = _interopRequireWildcard(require("fs-extra"));
10
+ var _dotenv = _interopRequireDefault(require("dotenv"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ _dotenv.default.config();
14
+ function getFullPathInProject(...paths) {
15
+ return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
16
+ }
17
+ async function listProjectFilesAndFolders() {
18
+ const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
19
+ try {
20
+ const files = await fs.readdir(projectPath, {
21
+ withFileTypes: true
22
+ });
23
+ return files.map(file => ({
24
+ type: file.isDirectory() ? "Folder" : "File",
25
+ fullPath: path.join(projectPath, file.name),
26
+ name: file.name
27
+ }));
28
+ } catch (err) {
29
+ console.error("Error reading the directory:", err);
30
+ throw err;
31
+ }
32
+ }
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import * as net from "net";
3
+ export interface InterfaceClient {
4
+ sendJSON(data: any): void;
5
+ receiveJSON(): AsyncGenerator<any, void, unknown>;
6
+ close(): void;
7
+ get closed(): boolean;
8
+ }
9
+ export declare class SocketClient implements InterfaceClient {
10
+ static readonly LENGTH_HEADER_LENGTH = 4;
11
+ protected readonly socket: net.Socket;
12
+ constructor(socket: net.Socket);
13
+ sendJSON(data: any): void;
14
+ receiveJSON(): AsyncGenerator<any, void, unknown>;
15
+ close(): Promise<void>;
16
+ get closed(): boolean;
17
+ }
18
+ export declare class UnixSocketClient extends SocketClient {
19
+ constructor(path: string);
20
+ }
21
+ export declare class TCPSocketClient extends SocketClient {
22
+ constructor(host: string, port: number);
23
+ }
24
+ export declare class JSONLFileClient implements InterfaceClient {
25
+ private readonly fileStream;
26
+ constructor(filePath: string);
27
+ sendJSON(data: any): void;
28
+ receiveJSON(): AsyncGenerator<any, void, unknown>;
29
+ close(): Promise<void>;
30
+ get closed(): boolean;
31
+ }