@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16

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 (114) hide show
  1. package/.babelrc +1 -2
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/authSessions/create.ts +2 -2
  4. package/WebTemplate/controllers/authSessions/store.ts +1 -1
  5. package/WebTemplate/controllers/runApi/helpers.ts +14 -12
  6. package/WebTemplate/index.playwright.ts +32 -42
  7. package/WebTemplate/jobs.ts +13 -2
  8. package/WebTemplate/utils.ts +53 -1
  9. package/api/test2.ts +6 -1
  10. package/auth-sessions/check.ts +3 -1
  11. package/auth-sessions/create.ts +10 -10
  12. package/bin/intuned-api-run +1 -1
  13. package/bin/intuned-auth-session-check +1 -1
  14. package/bin/intuned-auth-session-create +1 -1
  15. package/bin/intuned-auth-session-load +1 -1
  16. package/bin/intuned-auth-session-refresh +1 -1
  17. package/bin/intuned-browser-save-state +1 -1
  18. package/bin/intuned-browser-start +1 -1
  19. package/bin/intuned-build +1 -1
  20. package/bin/intuned-ts-check +1 -1
  21. package/dist/commands/api/run.js +109 -170
  22. package/dist/commands/auth-sessions/load.js +28 -26
  23. package/dist/commands/auth-sessions/run-check.js +54 -53
  24. package/dist/commands/auth-sessions/run-create.js +93 -96
  25. package/dist/commands/browser/save-state.js +14 -16
  26. package/dist/commands/browser/start-browser.js +11 -11
  27. package/dist/commands/build.js +79 -109
  28. package/dist/commands/common/browserUtils.js +53 -51
  29. package/dist/commands/common/getFirstLineNumber.js +93 -93
  30. package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
  31. package/dist/commands/common/sendMessageToClient.js +9 -4
  32. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  33. package/dist/commands/common/tsNodeImport.js +18 -0
  34. package/dist/commands/common/utils/fileUtils.js +32 -22
  35. package/dist/commands/common/utils/settings.js +27 -19
  36. package/dist/commands/common/utils/unixSocket.js +43 -43
  37. package/dist/commands/common/utils/webTemplate.js +30 -28
  38. package/dist/commands/interface/run.js +162 -139
  39. package/dist/commands/ts-check.js +50 -50
  40. package/dist/common/Logger/Logger/index.js +55 -42
  41. package/dist/common/Logger/Logger/types.js +5 -1
  42. package/dist/common/Logger/index.js +55 -42
  43. package/dist/common/Logger/types.js +5 -1
  44. package/dist/common/asyncLocalStorage/index.js +16 -8
  45. package/dist/common/cleanEnvironmentVariables.js +16 -12
  46. package/dist/common/constants.js +7 -1
  47. package/dist/common/contextStorageStateHelpers.js +47 -38
  48. package/dist/common/getPlaywrightConstructs.js +178 -197
  49. package/dist/common/jwtTokenManager.js +76 -79
  50. package/dist/common/runApi/errors.js +159 -150
  51. package/dist/common/runApi/index.js +240 -232
  52. package/dist/common/runApi/types.d.ts +19 -5
  53. package/dist/common/runApi/types.js +53 -56
  54. package/dist/common/settingsSchema.js +15 -10
  55. package/dist/common/telemetry.js +28 -30
  56. package/dist/index.js +69 -4
  57. package/dist/runtime/RunError.js +18 -11
  58. package/dist/runtime/downloadDirectory.js +19 -13
  59. package/dist/runtime/enums.d.js +5 -0
  60. package/dist/runtime/enums.d.ts +11 -1
  61. package/dist/runtime/enums.js +18 -12
  62. package/dist/runtime/executionHelpers.test.js +53 -0
  63. package/dist/runtime/export.d.js +5 -0
  64. package/dist/runtime/export.d.ts +202 -1
  65. package/dist/runtime/extendPayload.js +21 -15
  66. package/dist/runtime/extendTimeout.js +28 -21
  67. package/dist/runtime/index.js +53 -6
  68. package/dist/runtime/requestMoreInfo.js +23 -16
  69. package/dist/runtime/runInfo.js +21 -14
  70. package/package.json +4 -7
  71. package/dist/commands/api/run.ts +0 -105
  72. package/dist/commands/auth-sessions/load.ts +0 -30
  73. package/dist/commands/auth-sessions/run-check.ts +0 -51
  74. package/dist/commands/auth-sessions/run-create.ts +0 -91
  75. package/dist/commands/browser/save-state.ts +0 -14
  76. package/dist/commands/browser/start-browser.ts +0 -11
  77. package/dist/commands/build.ts +0 -79
  78. package/dist/commands/common/browserUtils.ts +0 -45
  79. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
  80. package/dist/commands/common/getDefaultExportFromFile.js +0 -12
  81. package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
  82. package/dist/commands/common/getFirstLineNumber.ts +0 -96
  83. package/dist/commands/common/sendMessageToClient.ts +0 -3
  84. package/dist/commands/common/utils/fileUtils.ts +0 -23
  85. package/dist/commands/common/utils/settings.ts +0 -22
  86. package/dist/commands/common/utils/unixSocket.ts +0 -38
  87. package/dist/commands/common/utils/webTemplate.ts +0 -23
  88. package/dist/commands/interface/run.ts +0 -156
  89. package/dist/commands/ts-check.ts +0 -51
  90. package/dist/common/Logger/Logger/index.ts +0 -53
  91. package/dist/common/Logger/Logger/types.ts +0 -1
  92. package/dist/common/Logger/index.ts +0 -53
  93. package/dist/common/Logger/types.ts +0 -1
  94. package/dist/common/asyncLocalStorage/index.ts +0 -9
  95. package/dist/common/cleanEnvironmentVariables.ts +0 -10
  96. package/dist/common/constants.ts +0 -1
  97. package/dist/common/contextStorageStateHelpers.ts +0 -43
  98. package/dist/common/getPlaywrightConstructs.ts +0 -182
  99. package/dist/common/jwtTokenManager.ts +0 -71
  100. package/dist/common/runApi/errors.ts +0 -154
  101. package/dist/common/runApi/index.ts +0 -253
  102. package/dist/common/runApi/types.ts +0 -43
  103. package/dist/common/settingsSchema.ts +0 -9
  104. package/dist/common/telemetry.ts +0 -23
  105. package/dist/index.ts +0 -4
  106. package/dist/runtime/RunError.ts +0 -12
  107. package/dist/runtime/downloadDirectory.ts +0 -13
  108. package/dist/runtime/enums.ts +0 -12
  109. package/dist/runtime/executionHelpers.test.ts +0 -51
  110. package/dist/runtime/extendPayload.ts +0 -15
  111. package/dist/runtime/extendTimeout.ts +0 -24
  112. package/dist/runtime/index.ts +0 -6
  113. package/dist/runtime/requestMoreInfo.ts +0 -18
  114. package/dist/runtime/runInfo.ts +0 -15
@@ -1,103 +1,103 @@
1
- import { ts, Project, ModuleKind, ScriptTarget, Node, } from "ts-morph";
2
- import { SourceMapConsumer } from "source-map";
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");
3
10
  function compileTypeScript(apiFilePath) {
4
- const compilerOptions = {
5
- lib: ["dom", "es2020"],
6
- sourceMap: true,
7
- inlineSourceMap: true,
8
- inlineSources: true,
9
- declaration: false,
10
- noEmit: false,
11
- module: ModuleKind.CommonJS,
12
- target: ScriptTarget.ES2020,
13
- };
14
- const project = new Project({
15
- compilerOptions,
16
- });
17
- const sourceFile = project.addSourceFileAtPath(apiFilePath);
18
- const outputJS = project.emitToMemory({ targetSourceFile: sourceFile });
19
- const outputJSText = outputJS.getFiles()[0].text;
20
- return { sourceFile, outputJSText };
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
+ };
21
33
  }
22
- export function findFirstExecutableLine(sourceFile) {
23
- let functionBody;
24
- // Directly find the default exported function's body
25
- const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
26
- const defaultExportDeclaration = defaultExportSymbol?.getDeclarations()?.[0];
27
- if (defaultExportDeclaration) {
28
- // Check if the default export is a function
29
- if (defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration) {
30
- functionBody = defaultExportDeclaration.getBody();
34
+ function findFirstExecutableLine(sourceFile) {
35
+ var _defaultExportSymbol$;
36
+ let functionBody;
37
+ const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
38
+ const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
39
+ if (defaultExportDeclaration) {
40
+ if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
41
+ functionBody = defaultExportDeclaration.getBody();
42
+ } else {
43
+ const exportAssignments = sourceFile.getExportAssignments();
44
+ for (const exportAssignment of exportAssignments) {
45
+ const expression = exportAssignment.getExpression();
46
+ if (!expression) continue;
47
+ if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
48
+ var _sourceFile$getVariab;
49
+ const identifier = expression.getText();
50
+ const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction));
51
+ if (possiblyExportedFunction) {
52
+ functionBody = possiblyExportedFunction.getBody();
53
+ break;
54
+ }
31
55
  }
32
- else {
33
- // Handle ExportAssignment specifically for cases like `export default identifier;`
34
- const exportAssignments = sourceFile.getExportAssignments();
35
- for (const exportAssignment of exportAssignments) {
36
- const expression = exportAssignment.getExpression();
37
- if (!expression)
38
- continue;
39
- if (expression.getKind() === ts.SyntaxKind.Identifier ||
40
- expression.getKind() === ts.SyntaxKind.FunctionExpression ||
41
- expression.getKind() === ts.SyntaxKind.ArrowFunction) {
42
- const identifier = expression.getText();
43
- const possiblyExportedFunction = sourceFile.getFunction(identifier) ||
44
- sourceFile
45
- .getVariableStatement(identifier)
46
- ?.getDescendants()
47
- .find((node) => node.getKind() === ts.SyntaxKind.FunctionExpression ||
48
- node.getKind() === ts.SyntaxKind.ArrowFunction);
49
- if (possiblyExportedFunction) {
50
- functionBody = possiblyExportedFunction.getBody();
51
- break;
52
- }
53
- }
54
- if (Node.hasBody(expression) &&
55
- (expression.getKind() === ts.SyntaxKind.FunctionExpression ||
56
- expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
57
- // As these are anonymous, we directly access their body
58
- functionBody = expression.getBody();
59
- break;
60
- }
61
- }
56
+ if (_tsMorph.Node.hasBody(expression) && (expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction)) {
57
+ functionBody = expression.getBody();
58
+ break;
62
59
  }
60
+ }
63
61
  }
64
- if (!functionBody || !Node.isStatemented(functionBody)) {
65
- return -1;
66
- }
67
- if (functionBody.getStatements().length === 0) {
68
- return -1;
69
- }
70
- const position = functionBody.getStatements()[0].getStart();
71
- return sourceFile.getLineAndColumnAtPos(position);
62
+ }
63
+ if (!functionBody || !_tsMorph.Node.isStatemented(functionBody)) {
64
+ return -1;
65
+ }
66
+ if (functionBody.getStatements().length === 0) {
67
+ return -1;
68
+ }
69
+ const position = functionBody.getStatements()[0].getStart();
70
+ return sourceFile.getLineAndColumnAtPos(position);
72
71
  }
73
72
  async function getSourceMap(jsCode) {
74
- const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") +
75
- "//# sourceMappingURL=data:application/json;base64,".length);
76
- const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
77
- const sourceMap = JSON.parse(sourceMapText);
78
- return new SourceMapConsumer(sourceMap);
73
+ const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
74
+ const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
75
+ const sourceMap = JSON.parse(sourceMapText);
76
+ return new _sourceMap.SourceMapConsumer(sourceMap);
79
77
  }
80
78
  async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
81
- const sourceMap = await getSourceMap(jsCode);
82
- const generatedLineNumber = sourceMap.generatedPositionFor({
83
- source: sourceFileName,
84
- line,
85
- column,
86
- }).line;
87
- if (!generatedLineNumber)
88
- return -1;
89
- return generatedLineNumber;
90
- }
91
- export default async function getFirstLineNumber(apiFilePath) {
92
- const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
93
- // Compile TypeScript to JavaScript and get the Typescript AST
94
- const { sourceFile, outputJSText } = compileTypeScript(apiFilePath);
95
- // Find the first line of code in the default export ts code
96
- const result = findFirstExecutableLine(sourceFile);
97
- if (result === -1)
98
- return { sourceFileName, lineNumber: -1 };
99
- return {
100
- sourceFileName,
101
- lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column),
102
- };
79
+ const sourceMap = await getSourceMap(jsCode);
80
+ const generatedLineNumber = sourceMap.generatedPositionFor({
81
+ source: sourceFileName,
82
+ line,
83
+ column
84
+ }).line;
85
+ if (!generatedLineNumber) return -1;
86
+ return generatedLineNumber;
103
87
  }
88
+ async function getFirstLineNumber(apiFilePath) {
89
+ const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
90
+ const {
91
+ sourceFile,
92
+ outputJSText
93
+ } = compileTypeScript(apiFilePath);
94
+ const result = findFirstExecutableLine(sourceFile);
95
+ if (result === -1) return {
96
+ sourceFileName,
97
+ lineNumber: -1
98
+ };
99
+ return {
100
+ sourceFileName,
101
+ lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column)
102
+ };
103
+ }
@@ -1,25 +1,30 @@
1
- import { expect, describe, it, beforeAll, afterAll } from "vitest";
2
- import getFirstLineNumber from "./getFirstLineNumber.js";
3
- import * as fs from "fs";
4
- import * as path from "path";
5
- import { fileURLToPath } from "url";
6
- describe("getFirstLineNumber", () => {
7
- const testFilesDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "testFiles");
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _getFirstLineNumber = _interopRequireDefault(require("./getFirstLineNumber.js"));
5
+ var fs = _interopRequireWildcard(require("fs"));
6
+ var path = _interopRequireWildcard(require("path"));
7
+ var _url = require("url");
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ (0, _vitest.describe)("getFirstLineNumber", () => {
12
+ const testFilesDir = path.join(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "testFiles");
8
13
  const createTestFile = (fileName, content) => {
9
14
  const filePath = path.join(testFilesDir, fileName);
10
15
  fs.writeFileSync(filePath, content);
11
16
  return filePath;
12
17
  };
13
- beforeAll(() => {
18
+ (0, _vitest.beforeAll)(() => {
14
19
  if (!fs.existsSync(testFilesDir)) {
15
20
  fs.mkdirSync(testFilesDir);
16
21
  }
17
22
  });
18
- afterAll(() => {
23
+ (0, _vitest.afterAll)(() => {
19
24
  fs.readdirSync(testFilesDir).forEach(file => fs.unlinkSync(path.join(testFilesDir, file)));
20
25
  fs.rmdirSync(testFilesDir);
21
26
  });
22
- it("correctly identifies first line in a default exported named function", async () => {
27
+ (0, _vitest.it)("correctly identifies first line in a default exported named function", async () => {
23
28
  const filePath = createTestFile("defaultFunction.ts", `import {
24
29
  EnhancedPlaywrightPage,
25
30
  EnhancedPlaywrightBrowserContext,
@@ -42,10 +47,10 @@ describe("getFirstLineNumber", () => {
42
47
  return { done: "true", name: "custom name from api1" };
43
48
  }
44
49
  `);
45
- const result = await getFirstLineNumber(filePath);
46
- expect(result.lineNumber).toBe(4);
50
+ const result = await (0, _getFirstLineNumber.default)(filePath);
51
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
47
52
  });
48
- it("correctly identifies first line in a default exported anonymous function", async () => {
53
+ (0, _vitest.it)("correctly identifies first line in a default exported anonymous function", async () => {
49
54
  const filePath = createTestFile("defaultFunction.ts", `import {
50
55
  EnhancedPlaywrightPage,
51
56
  EnhancedPlaywrightBrowserContext,
@@ -68,10 +73,10 @@ describe("getFirstLineNumber", () => {
68
73
  return { done: "true", name: "custom name from api1" };
69
74
  }
70
75
  `);
71
- const result = await getFirstLineNumber(filePath);
72
- expect(result.lineNumber).toBe(4);
76
+ const result = await (0, _getFirstLineNumber.default)(filePath);
77
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
73
78
  });
74
- it("correctly identifies first line in a default exported function identifier", async () => {
79
+ (0, _vitest.it)("correctly identifies first line in a default exported function identifier", async () => {
75
80
  const filePath = createTestFile("defaultFunction.ts", `import {
76
81
  EnhancedPlaywrightPage,
77
82
  EnhancedPlaywrightBrowserContext,
@@ -95,10 +100,10 @@ describe("getFirstLineNumber", () => {
95
100
  }
96
101
  export default runApi;
97
102
  `);
98
- const result = await getFirstLineNumber(filePath);
99
- expect(result.lineNumber).toBe(4);
103
+ const result = await (0, _getFirstLineNumber.default)(filePath);
104
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
100
105
  });
101
- it("correctly identifies first line in a file with multiple exports including a default function", async () => {
106
+ (0, _vitest.it)("correctly identifies first line in a file with multiple exports including a default function", async () => {
102
107
  const filePath = createTestFile("multipleExports.ts", `import {
103
108
  EnhancedPlaywrightPage,
104
109
  EnhancedPlaywrightBrowserContext,
@@ -122,10 +127,10 @@ describe("getFirstLineNumber", () => {
122
127
  return { done: "true", name: "custom name from api1" };
123
128
  }
124
129
  export default runApi;`);
125
- const result = await getFirstLineNumber(filePath);
126
- expect(result.lineNumber).toBe(7);
130
+ const result = await (0, _getFirstLineNumber.default)(filePath);
131
+ (0, _vitest.expect)(result.lineNumber).toBe(7);
127
132
  });
128
- it("correctly identifies first line in a default exported arrow function identifier", async () => {
133
+ (0, _vitest.it)("correctly identifies first line in a default exported arrow function identifier", async () => {
129
134
  const filePath = createTestFile("multipleExports.ts", `import {
130
135
  EnhancedPlaywrightPage,
131
136
  EnhancedPlaywrightBrowserContext,
@@ -148,10 +153,10 @@ describe("getFirstLineNumber", () => {
148
153
  return { done: "true", name: "custom name from api1" };
149
154
  }
150
155
  export default runApi;`);
151
- const result = await getFirstLineNumber(filePath);
152
- expect(result.lineNumber).toBe(4);
156
+ const result = await (0, _getFirstLineNumber.default)(filePath);
157
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
153
158
  });
154
- it("correctly identifies first line in a default exported anonymous arrow function", async () => {
159
+ (0, _vitest.it)("correctly identifies first line in a default exported anonymous arrow function", async () => {
155
160
  const filePath = createTestFile("multipleExports.ts", `import {
156
161
  EnhancedPlaywrightPage,
157
162
  EnhancedPlaywrightBrowserContext,
@@ -173,52 +178,52 @@ describe("getFirstLineNumber", () => {
173
178
  await page.getByLabel("Search Wikipedia").press("Enter");
174
179
  return { done: "true", name: "custom name from api1" };
175
180
  };`);
176
- const result = await getFirstLineNumber(filePath);
177
- expect(result.lineNumber).toBe(4);
181
+ const result = await (0, _getFirstLineNumber.default)(filePath);
182
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
178
183
  });
179
- it("identifies first executable line in a default exported arrow function", async () => {
184
+ (0, _vitest.it)("identifies first executable line in a default exported arrow function", async () => {
180
185
  const filePath = createTestFile("defaultArrowFunction.ts", `export default () => {
181
186
  console.log("Hello, Arrow World!");
182
187
  };`);
183
- const result = await getFirstLineNumber(filePath);
184
- expect(result.lineNumber).toBe(4);
188
+ const result = await (0, _getFirstLineNumber.default)(filePath);
189
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
185
190
  });
186
- it("identifies first executable line within nested functions of a default export", async () => {
191
+ (0, _vitest.it)("identifies first executable line within nested functions of a default export", async () => {
187
192
  const filePath = createTestFile("nestedFunctions.ts", `const x = 4;
188
193
  export default function() {
189
194
  const nested = (x) => console.log("Nested function call");
190
195
  nested(x);
191
196
  }`);
192
- const result = await getFirstLineNumber(filePath);
193
- expect(result.lineNumber).toBe(5);
197
+ const result = await (0, _getFirstLineNumber.default)(filePath);
198
+ (0, _vitest.expect)(result.lineNumber).toBe(5);
194
199
  });
195
- it("handles async default exported function correctly", async () => {
200
+ (0, _vitest.it)("handles async default exported function correctly", async () => {
196
201
  const filePath = createTestFile("asyncDefaultFunction.ts", `export default async function() {
197
202
  await Promise.resolve(console.log("Async Hello, World!"));
198
203
  }`);
199
- const result = await getFirstLineNumber(filePath);
200
- expect(result.lineNumber).toBe(4);
204
+ const result = await (0, _getFirstLineNumber.default)(filePath);
205
+ (0, _vitest.expect)(result.lineNumber).toBe(4);
201
206
  });
202
- it("returns -1 for a default exported class", async () => {
207
+ (0, _vitest.it)("returns -1 for a default exported class", async () => {
203
208
  const filePath = createTestFile("defaultClass.ts", `export default class MyClass {
204
209
  constructor() {}
205
210
  }`);
206
- const result = await getFirstLineNumber(filePath);
207
- expect(result.lineNumber).toBe(-1);
211
+ const result = await (0, _getFirstLineNumber.default)(filePath);
212
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
208
213
  });
209
- it("returns -1 for a default exported variable", async () => {
214
+ (0, _vitest.it)("returns -1 for a default exported variable", async () => {
210
215
  const filePath = createTestFile("defaultVariable.ts", `export default 42;`);
211
- const result = await getFirstLineNumber(filePath);
212
- expect(result.lineNumber).toBe(-1);
216
+ const result = await (0, _getFirstLineNumber.default)(filePath);
217
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
213
218
  });
214
- it("returns -1 when there is no default export", async () => {
219
+ (0, _vitest.it)("returns -1 when there is no default export", async () => {
215
220
  const filePath = createTestFile("noDefaultExport.ts", `export const foo = () => console.log("bar");`);
216
- const result = await getFirstLineNumber(filePath);
217
- expect(result.lineNumber).toBe(-1);
221
+ const result = await (0, _getFirstLineNumber.default)(filePath);
222
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
218
223
  });
219
- it("returns -1 for an empty file", async () => {
224
+ (0, _vitest.it)("returns -1 for an empty file", async () => {
220
225
  const filePath = createTestFile("emptyFile.ts", ``);
221
- const result = await getFirstLineNumber(filePath);
222
- expect(result.lineNumber).toBe(-1);
226
+ const result = await (0, _getFirstLineNumber.default)(filePath);
227
+ (0, _vitest.expect)(result.lineNumber).toBe(-1);
223
228
  });
224
229
  });
@@ -1,5 +1,10 @@
1
- // Send information to the parent process where it should continue the debugger
2
- // This is handled by DebuggingProcessManager
3
- export const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
4
- console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
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}`);
5
9
  };
10
+ exports.sendBreakPointOnToClient = sendBreakPointOnToClient;
@@ -0,0 +1 @@
1
+ export declare function tsNodeImport(apiFilePath: string): Promise<any>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tsNodeImport = tsNodeImport;
7
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
8
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
+ async function tsNodeImport(apiFilePath) {
10
+ require("ts-node").register({
11
+ transpileOnly: true,
12
+ compilerOptions: {
13
+ lib: ["dom", "es2020"]
14
+ }
15
+ });
16
+ const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(apiFilePath);
17
+ return imported.default;
18
+ }
@@ -1,23 +1,33 @@
1
- import * as path from "path";
2
- import * as fs from "fs-extra";
3
- import dotenv from "dotenv";
4
- dotenv.config();
5
- // TODO: todo-identity handle identity instances
6
- export function getFullPathInProject(...paths) {
7
- return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
8
- }
9
- export async function listProjectFilesAndFolders() {
10
- const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
11
- try {
12
- const files = await fs.readdir(projectPath, { withFileTypes: true });
13
- return files.map((file) => ({
14
- type: file.isDirectory() ? "Folder" : "File",
15
- fullPath: path.join(projectPath, file.name),
16
- name: file.name,
17
- }));
18
- }
19
- catch (err) {
20
- console.error("Error reading the directory:", err);
21
- throw err;
22
- }
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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ _dotenv.default.config();
15
+ function getFullPathInProject(...paths) {
16
+ return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
23
17
  }
18
+ async function listProjectFilesAndFolders() {
19
+ const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
20
+ try {
21
+ const files = await fs.readdir(projectPath, {
22
+ withFileTypes: true
23
+ });
24
+ return files.map(file => ({
25
+ type: file.isDirectory() ? "Folder" : "File",
26
+ fullPath: path.join(projectPath, file.name),
27
+ name: file.name
28
+ }));
29
+ } catch (err) {
30
+ console.error("Error reading the directory:", err);
31
+ throw err;
32
+ }
33
+ }
@@ -1,20 +1,28 @@
1
- import { getFullPathInProject } from "./fileUtils.js";
2
- import { settingsSchema, } from "../../../common/settingsSchema";
3
- import { readJSON } from "fs-extra";
4
- export async function getSettings() {
5
- const settingsFilePath = getFullPathInProject("Intuned.json");
6
- console.log("loading settings");
7
- const settings = await readJSON(settingsFilePath);
8
- if (settings) {
9
- const parsed = settingsSchema.safeParse(settings);
10
- console.log(parsed);
11
- if (parsed.success) {
12
- return parsed.data;
13
- }
14
- else {
15
- // ToDo: why does the type not work here?
16
- throw new Error(parsed.error.message);
17
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSettings = getSettings;
7
+ var _fileUtils = require("./fileUtils.js");
8
+ var _settingsSchema = require("../../../common/settingsSchema");
9
+ var _fsExtra = require("fs-extra");
10
+ async function getSettings() {
11
+ const settingsFilePath = (0, _fileUtils.getFullPathInProject)("Intuned.json");
12
+ console.log("loading settings");
13
+ const settings = await (0, _fsExtra.readJSON)(settingsFilePath);
14
+ if (settings) {
15
+ const parsed = _settingsSchema.settingsSchema.safeParse(settings);
16
+ console.log(parsed);
17
+ if (parsed.success) {
18
+ return parsed.data;
19
+ } else {
20
+ throw new Error(parsed.error.message);
18
21
  }
19
- return { authSessions: { enabled: false } };
20
- }
22
+ }
23
+ return {
24
+ authSessions: {
25
+ enabled: false
26
+ }
27
+ };
28
+ }
@@ -1,45 +1,45 @@
1
- export class JSONUnixSocket {
2
- constructor(socket) {
3
- this.socket = socket;
4
- }
5
- sendJSON(data) {
6
- const dataToSend = JSON.stringify(data);
7
- // calculate length
8
- const length = Buffer.byteLength(dataToSend);
9
- // create buffer
10
- const buffer = Buffer.alloc(JSONUnixSocket.LENGTH_HEADER_LENGTH + length);
11
- // write length in big endian
12
- buffer.writeUInt32BE(length, 0);
13
- // write data
14
- buffer.write(dataToSend, JSONUnixSocket.LENGTH_HEADER_LENGTH);
15
- this.socket.write(buffer);
16
- }
17
- async *receiveJSON() {
18
- let buffer = Buffer.alloc(0);
19
- const endPromise = new Promise((resolve, reject) => {
20
- this.socket.once("end", () => {
21
- console.log("end");
22
- resolve();
23
- });
24
- this.socket.once("error", reject);
25
- });
26
- while (true) {
27
- const chunk = await Promise.race([
28
- new Promise((resolve) => this.socket.once("data", (data) => resolve(data))),
29
- endPromise,
30
- ]);
31
- if (!(chunk instanceof Buffer)) {
32
- break;
33
- }
34
- buffer = Buffer.concat([buffer, chunk]);
35
- const length = buffer.readUInt32BE(0);
36
- if (buffer.length < length + JSONUnixSocket.LENGTH_HEADER_LENGTH) {
37
- continue;
38
- }
39
- const data = buffer.subarray(JSONUnixSocket.LENGTH_HEADER_LENGTH, length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
40
- buffer = buffer.subarray(length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
41
- yield JSON.parse(data.toString());
42
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JSONUnixSocket = void 0;
7
+ class JSONUnixSocket {
8
+ static LENGTH_HEADER_LENGTH = 4;
9
+ constructor(socket) {
10
+ this.socket = socket;
11
+ }
12
+ sendJSON(data) {
13
+ const dataToSend = JSON.stringify(data);
14
+ const length = Buffer.byteLength(dataToSend);
15
+ const buffer = Buffer.alloc(JSONUnixSocket.LENGTH_HEADER_LENGTH + length);
16
+ buffer.writeUInt32BE(length, 0);
17
+ buffer.write(dataToSend, JSONUnixSocket.LENGTH_HEADER_LENGTH);
18
+ this.socket.write(buffer);
19
+ }
20
+ async *receiveJSON() {
21
+ let buffer = Buffer.alloc(0);
22
+ const endPromise = new Promise((resolve, reject) => {
23
+ this.socket.once("end", () => {
24
+ console.log("end");
25
+ resolve();
26
+ });
27
+ this.socket.once("error", reject);
28
+ });
29
+ while (true) {
30
+ const chunk = await Promise.race([new Promise(resolve => this.socket.once("data", data => resolve(data))), endPromise]);
31
+ if (!(chunk instanceof Buffer)) {
32
+ break;
33
+ }
34
+ buffer = Buffer.concat([buffer, chunk]);
35
+ const length = buffer.readUInt32BE(0);
36
+ if (buffer.length < length + JSONUnixSocket.LENGTH_HEADER_LENGTH) {
37
+ continue;
38
+ }
39
+ const data = buffer.subarray(JSONUnixSocket.LENGTH_HEADER_LENGTH, length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
40
+ buffer = buffer.subarray(length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
41
+ yield JSON.parse(data.toString());
43
42
  }
43
+ }
44
44
  }
45
- JSONUnixSocket.LENGTH_HEADER_LENGTH = 4;
45
+ exports.JSONUnixSocket = JSONUnixSocket;