@intuned/runtime-dev 0.1.0-test.1 → 0.1.0-test.11

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 (50) hide show
  1. package/.babelrc +3 -1
  2. package/Intuned.json +1 -1
  3. package/api/test2.ts +1 -4
  4. package/dist/commands/api/run.js +27 -35
  5. package/dist/commands/auth-sessions/load.js +11 -13
  6. package/dist/commands/auth-sessions/run-check.js +14 -19
  7. package/dist/commands/auth-sessions/run-create.js +23 -28
  8. package/dist/commands/browser/save-state.js +7 -10
  9. package/dist/commands/browser/start-browser.js +7 -10
  10. package/dist/commands/build.js +25 -30
  11. package/dist/commands/common/browserUtils.js +15 -28
  12. package/dist/commands/common/getDefaultExportFromFile.js +2 -10
  13. package/dist/commands/common/getFirstLineNumber.js +13 -20
  14. package/dist/commands/common/getFirstLineNumber.test.js +46 -51
  15. package/dist/commands/common/sendMessageToClient.js +2 -9
  16. package/dist/commands/common/utils/fileUtils.js +6 -16
  17. package/dist/commands/common/utils/settings.js +7 -13
  18. package/dist/commands/common/utils/unixSocket.js +2 -9
  19. package/dist/commands/common/utils/webTemplate.js +7 -16
  20. package/dist/commands/interface/run.js +34 -39
  21. package/dist/commands/ts-check.js +8 -12
  22. package/dist/common/Logger/Logger/index.js +9 -16
  23. package/dist/common/Logger/Logger/types.js +1 -5
  24. package/dist/common/Logger/index.js +9 -16
  25. package/dist/common/Logger/types.js +1 -5
  26. package/dist/common/asyncLocalStorage/index.js +4 -12
  27. package/dist/common/cleanEnvironmentVariables.js +1 -7
  28. package/dist/common/constants.js +1 -7
  29. package/dist/common/contextStorageStateHelpers.js +2 -9
  30. package/dist/common/getPlaywrightConstructs.js +28 -39
  31. package/dist/common/jwtTokenManager.js +8 -18
  32. package/dist/common/runApi/errors.js +24 -42
  33. package/dist/common/runApi/index.js +53 -88
  34. package/dist/common/runApi/types.js +31 -38
  35. package/dist/common/settingsSchema.js +2 -10
  36. package/dist/common/telemetry.js +3 -12
  37. package/dist/index.js +4 -69
  38. package/dist/runtime/RunError.js +1 -8
  39. package/dist/runtime/downloadDirectory.js +5 -11
  40. package/dist/runtime/enums.d.js +1 -5
  41. package/dist/runtime/enums.js +2 -8
  42. package/dist/runtime/executionHelpers.test.js +20 -22
  43. package/dist/runtime/export.d.js +1 -5
  44. package/dist/runtime/extendPayload.js +5 -11
  45. package/dist/runtime/extendTimeout.js +3 -9
  46. package/dist/runtime/index.js +6 -53
  47. package/dist/runtime/requestMoreInfo.js +2 -9
  48. package/dist/runtime/runInfo.js +5 -11
  49. package/package.json +3 -1
  50. package/preserve-dynamic-imports.js +16 -0
@@ -1,12 +1,5 @@
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");
1
+ import { ts, Project, ModuleKind, ScriptTarget, Node } from "ts-morph";
2
+ import { SourceMapConsumer } from "source-map";
10
3
  function compileTypeScript(apiFilePath) {
11
4
  const compilerOptions = {
12
5
  lib: ["dom", "es2020"],
@@ -15,10 +8,10 @@ function compileTypeScript(apiFilePath) {
15
8
  inlineSources: true,
16
9
  declaration: false,
17
10
  noEmit: false,
18
- module: _tsMorph.ModuleKind.CommonJS,
19
- target: _tsMorph.ScriptTarget.ES2020
11
+ module: ModuleKind.CommonJS,
12
+ target: ScriptTarget.ES2020
20
13
  };
21
- const project = new _tsMorph.Project({
14
+ const project = new Project({
22
15
  compilerOptions
23
16
  });
24
17
  const sourceFile = project.addSourceFileAtPath(apiFilePath);
@@ -31,36 +24,36 @@ function compileTypeScript(apiFilePath) {
31
24
  outputJSText
32
25
  };
33
26
  }
34
- function findFirstExecutableLine(sourceFile) {
27
+ export function findFirstExecutableLine(sourceFile) {
35
28
  var _defaultExportSymbol$;
36
29
  let functionBody;
37
30
  const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
38
31
  const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
39
32
  if (defaultExportDeclaration) {
40
- if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
33
+ if (defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration) {
41
34
  functionBody = defaultExportDeclaration.getBody();
42
35
  } else {
43
36
  const exportAssignments = sourceFile.getExportAssignments();
44
37
  for (const exportAssignment of exportAssignments) {
45
38
  const expression = exportAssignment.getExpression();
46
39
  if (!expression) continue;
47
- if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
40
+ if (expression.getKind() === ts.SyntaxKind.Identifier || expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction) {
48
41
  var _sourceFile$getVariab;
49
42
  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));
43
+ const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() === ts.SyntaxKind.FunctionExpression || node.getKind() === ts.SyntaxKind.ArrowFunction));
51
44
  if (possiblyExportedFunction) {
52
45
  functionBody = possiblyExportedFunction.getBody();
53
46
  break;
54
47
  }
55
48
  }
56
- if (_tsMorph.Node.hasBody(expression) && (expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction)) {
49
+ if (Node.hasBody(expression) && (expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
57
50
  functionBody = expression.getBody();
58
51
  break;
59
52
  }
60
53
  }
61
54
  }
62
55
  }
63
- if (!functionBody || !_tsMorph.Node.isStatemented(functionBody)) {
56
+ if (!functionBody || !Node.isStatemented(functionBody)) {
64
57
  return -1;
65
58
  }
66
59
  if (functionBody.getStatements().length === 0) {
@@ -73,7 +66,7 @@ async function getSourceMap(jsCode) {
73
66
  const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
74
67
  const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
75
68
  const sourceMap = JSON.parse(sourceMapText);
76
- return new _sourceMap.SourceMapConsumer(sourceMap);
69
+ return new SourceMapConsumer(sourceMap);
77
70
  }
78
71
  async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
79
72
  const sourceMap = await getSourceMap(jsCode);
@@ -85,7 +78,7 @@ async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, colum
85
78
  if (!generatedLineNumber) return -1;
86
79
  return generatedLineNumber;
87
80
  }
88
- async function getFirstLineNumber(apiFilePath) {
81
+ export default async function getFirstLineNumber(apiFilePath) {
89
82
  const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
90
83
  const {
91
84
  sourceFile,
@@ -1,29 +1,24 @@
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 _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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- (0, _vitest.describe)("getFirstLineNumber", () => {
1
+ import { expect, describe, it, beforeAll, afterAll } from "vitest";
2
+ import getFirstLineNumber from "./getFirstLineNumber";
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ describe("getFirstLineNumber", () => {
11
6
  const testFilesDir = path.join(__dirname, "testFiles");
12
7
  const createTestFile = (fileName, content) => {
13
8
  const filePath = path.join(testFilesDir, fileName);
14
9
  fs.writeFileSync(filePath, content);
15
10
  return filePath;
16
11
  };
17
- (0, _vitest.beforeAll)(() => {
12
+ beforeAll(() => {
18
13
  if (!fs.existsSync(testFilesDir)) {
19
14
  fs.mkdirSync(testFilesDir);
20
15
  }
21
16
  });
22
- (0, _vitest.afterAll)(() => {
17
+ afterAll(() => {
23
18
  fs.readdirSync(testFilesDir).forEach(file => fs.unlinkSync(path.join(testFilesDir, file)));
24
19
  fs.rmdirSync(testFilesDir);
25
20
  });
26
- (0, _vitest.it)("correctly identifies first line in a default exported named function", async () => {
21
+ it("correctly identifies first line in a default exported named function", async () => {
27
22
  const filePath = createTestFile("defaultFunction.ts", `import {
28
23
  EnhancedPlaywrightPage,
29
24
  EnhancedPlaywrightBrowserContext,
@@ -46,10 +41,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
41
  return { done: "true", name: "custom name from api1" };
47
42
  }
48
43
  `);
49
- const result = await (0, _getFirstLineNumber.default)(filePath);
50
- (0, _vitest.expect)(result.lineNumber).toBe(4);
44
+ const result = await getFirstLineNumber(filePath);
45
+ expect(result.lineNumber).toBe(4);
51
46
  });
52
- (0, _vitest.it)("correctly identifies first line in a default exported anonymous function", async () => {
47
+ it("correctly identifies first line in a default exported anonymous function", async () => {
53
48
  const filePath = createTestFile("defaultFunction.ts", `import {
54
49
  EnhancedPlaywrightPage,
55
50
  EnhancedPlaywrightBrowserContext,
@@ -72,10 +67,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
72
67
  return { done: "true", name: "custom name from api1" };
73
68
  }
74
69
  `);
75
- const result = await (0, _getFirstLineNumber.default)(filePath);
76
- (0, _vitest.expect)(result.lineNumber).toBe(4);
70
+ const result = await getFirstLineNumber(filePath);
71
+ expect(result.lineNumber).toBe(4);
77
72
  });
78
- (0, _vitest.it)("correctly identifies first line in a default exported function identifier", async () => {
73
+ it("correctly identifies first line in a default exported function identifier", async () => {
79
74
  const filePath = createTestFile("defaultFunction.ts", `import {
80
75
  EnhancedPlaywrightPage,
81
76
  EnhancedPlaywrightBrowserContext,
@@ -99,10 +94,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
99
94
  }
100
95
  export default runApi;
101
96
  `);
102
- const result = await (0, _getFirstLineNumber.default)(filePath);
103
- (0, _vitest.expect)(result.lineNumber).toBe(4);
97
+ const result = await getFirstLineNumber(filePath);
98
+ expect(result.lineNumber).toBe(4);
104
99
  });
105
- (0, _vitest.it)("correctly identifies first line in a file with multiple exports including a default function", async () => {
100
+ it("correctly identifies first line in a file with multiple exports including a default function", async () => {
106
101
  const filePath = createTestFile("multipleExports.ts", `import {
107
102
  EnhancedPlaywrightPage,
108
103
  EnhancedPlaywrightBrowserContext,
@@ -126,10 +121,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
126
121
  return { done: "true", name: "custom name from api1" };
127
122
  }
128
123
  export default runApi;`);
129
- const result = await (0, _getFirstLineNumber.default)(filePath);
130
- (0, _vitest.expect)(result.lineNumber).toBe(7);
124
+ const result = await getFirstLineNumber(filePath);
125
+ expect(result.lineNumber).toBe(7);
131
126
  });
132
- (0, _vitest.it)("correctly identifies first line in a default exported arrow function identifier", async () => {
127
+ it("correctly identifies first line in a default exported arrow function identifier", async () => {
133
128
  const filePath = createTestFile("multipleExports.ts", `import {
134
129
  EnhancedPlaywrightPage,
135
130
  EnhancedPlaywrightBrowserContext,
@@ -152,10 +147,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
152
147
  return { done: "true", name: "custom name from api1" };
153
148
  }
154
149
  export default runApi;`);
155
- const result = await (0, _getFirstLineNumber.default)(filePath);
156
- (0, _vitest.expect)(result.lineNumber).toBe(4);
150
+ const result = await getFirstLineNumber(filePath);
151
+ expect(result.lineNumber).toBe(4);
157
152
  });
158
- (0, _vitest.it)("correctly identifies first line in a default exported anonymous arrow function", async () => {
153
+ it("correctly identifies first line in a default exported anonymous arrow function", async () => {
159
154
  const filePath = createTestFile("multipleExports.ts", `import {
160
155
  EnhancedPlaywrightPage,
161
156
  EnhancedPlaywrightBrowserContext,
@@ -177,52 +172,52 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
177
172
  await page.getByLabel("Search Wikipedia").press("Enter");
178
173
  return { done: "true", name: "custom name from api1" };
179
174
  };`);
180
- const result = await (0, _getFirstLineNumber.default)(filePath);
181
- (0, _vitest.expect)(result.lineNumber).toBe(4);
175
+ const result = await getFirstLineNumber(filePath);
176
+ expect(result.lineNumber).toBe(4);
182
177
  });
183
- (0, _vitest.it)("identifies first executable line in a default exported arrow function", async () => {
178
+ it("identifies first executable line in a default exported arrow function", async () => {
184
179
  const filePath = createTestFile("defaultArrowFunction.ts", `export default () => {
185
180
  console.log("Hello, Arrow World!");
186
181
  };`);
187
- const result = await (0, _getFirstLineNumber.default)(filePath);
188
- (0, _vitest.expect)(result.lineNumber).toBe(4);
182
+ const result = await getFirstLineNumber(filePath);
183
+ expect(result.lineNumber).toBe(4);
189
184
  });
190
- (0, _vitest.it)("identifies first executable line within nested functions of a default export", async () => {
185
+ it("identifies first executable line within nested functions of a default export", async () => {
191
186
  const filePath = createTestFile("nestedFunctions.ts", `const x = 4;
192
187
  export default function() {
193
188
  const nested = (x) => console.log("Nested function call");
194
189
  nested(x);
195
190
  }`);
196
- const result = await (0, _getFirstLineNumber.default)(filePath);
197
- (0, _vitest.expect)(result.lineNumber).toBe(5);
191
+ const result = await getFirstLineNumber(filePath);
192
+ expect(result.lineNumber).toBe(5);
198
193
  });
199
- (0, _vitest.it)("handles async default exported function correctly", async () => {
194
+ it("handles async default exported function correctly", async () => {
200
195
  const filePath = createTestFile("asyncDefaultFunction.ts", `export default async function() {
201
196
  await Promise.resolve(console.log("Async Hello, World!"));
202
197
  }`);
203
- const result = await (0, _getFirstLineNumber.default)(filePath);
204
- (0, _vitest.expect)(result.lineNumber).toBe(4);
198
+ const result = await getFirstLineNumber(filePath);
199
+ expect(result.lineNumber).toBe(4);
205
200
  });
206
- (0, _vitest.it)("returns -1 for a default exported class", async () => {
201
+ it("returns -1 for a default exported class", async () => {
207
202
  const filePath = createTestFile("defaultClass.ts", `export default class MyClass {
208
203
  constructor() {}
209
204
  }`);
210
- const result = await (0, _getFirstLineNumber.default)(filePath);
211
- (0, _vitest.expect)(result.lineNumber).toBe(-1);
205
+ const result = await getFirstLineNumber(filePath);
206
+ expect(result.lineNumber).toBe(-1);
212
207
  });
213
- (0, _vitest.it)("returns -1 for a default exported variable", async () => {
208
+ it("returns -1 for a default exported variable", async () => {
214
209
  const filePath = createTestFile("defaultVariable.ts", `export default 42;`);
215
- const result = await (0, _getFirstLineNumber.default)(filePath);
216
- (0, _vitest.expect)(result.lineNumber).toBe(-1);
210
+ const result = await getFirstLineNumber(filePath);
211
+ expect(result.lineNumber).toBe(-1);
217
212
  });
218
- (0, _vitest.it)("returns -1 when there is no default export", async () => {
213
+ it("returns -1 when there is no default export", async () => {
219
214
  const filePath = createTestFile("noDefaultExport.ts", `export const foo = () => console.log("bar");`);
220
- const result = await (0, _getFirstLineNumber.default)(filePath);
221
- (0, _vitest.expect)(result.lineNumber).toBe(-1);
215
+ const result = await getFirstLineNumber(filePath);
216
+ expect(result.lineNumber).toBe(-1);
222
217
  });
223
- (0, _vitest.it)("returns -1 for an empty file", async () => {
218
+ it("returns -1 for an empty file", async () => {
224
219
  const filePath = createTestFile("emptyFile.ts", ``);
225
- const result = await (0, _getFirstLineNumber.default)(filePath);
226
- (0, _vitest.expect)(result.lineNumber).toBe(-1);
220
+ const result = await getFirstLineNumber(filePath);
221
+ expect(result.lineNumber).toBe(-1);
227
222
  });
228
223
  });
@@ -1,10 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sendBreakPointOnToClient = void 0;
7
- const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
1
+ export const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
8
2
  console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
9
- };
10
- exports.sendBreakPointOnToClient = sendBreakPointOnToClient;
3
+ };
@@ -1,21 +1,11 @@
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) {
1
+ import * as path from "path";
2
+ import * as fs from "fs-extra";
3
+ import dotenv from "dotenv";
4
+ dotenv.config();
5
+ export function getFullPathInProject(...paths) {
16
6
  return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
17
7
  }
18
- async function listProjectFilesAndFolders() {
8
+ export async function listProjectFilesAndFolders() {
19
9
  const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
20
10
  try {
21
11
  const files = await fs.readdir(projectPath, {
@@ -1,18 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSettings = getSettings;
7
- var _fileUtils = require("./fileUtils");
8
- var _settingsSchema = require("../../../common/settingsSchema");
9
- var _fsExtra = require("fs-extra");
10
- async function getSettings() {
11
- const settingsFilePath = (0, _fileUtils.getFullPathInProject)("Intuned.json");
1
+ import { getFullPathInProject } from "./fileUtils";
2
+ import { settingsSchema } from "../../../common/settingsSchema";
3
+ import { readJSON } from "fs-extra";
4
+ export async function getSettings() {
5
+ const settingsFilePath = getFullPathInProject("Intuned.json");
12
6
  console.log("loading settings");
13
- const settings = await (0, _fsExtra.readJSON)(settingsFilePath);
7
+ const settings = await readJSON(settingsFilePath);
14
8
  if (settings) {
15
- const parsed = _settingsSchema.settingsSchema.safeParse(settings);
9
+ const parsed = settingsSchema.safeParse(settings);
16
10
  console.log(parsed);
17
11
  if (parsed.success) {
18
12
  return parsed.data;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.JSONUnixSocket = void 0;
7
- class JSONUnixSocket {
1
+ export class JSONUnixSocket {
8
2
  static LENGTH_HEADER_LENGTH = 4;
9
3
  constructor(socket) {
10
4
  this.socket = socket;
@@ -41,5 +35,4 @@ class JSONUnixSocket {
41
35
  yield JSON.parse(data.toString());
42
36
  }
43
37
  }
44
- }
45
- exports.JSONUnixSocket = JSONUnixSocket;
38
+ }
@@ -1,15 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.moveWebTemplateFiles = void 0;
7
- var fs = _interopRequireWildcard(require("fs-extra"));
8
- var path = _interopRequireWildcard(require("path"));
9
- var _fileUtils = require("./fileUtils");
10
- 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); }
11
- 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; }
12
- const moveWebTemplateFiles = async () => {
1
+ import * as fs from "fs-extra";
2
+ import * as path from "path";
3
+ import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils";
4
+ export const moveWebTemplateFiles = async () => {
13
5
  await fs.remove("./intuned");
14
6
  await fs.ensureDir("./intuned");
15
7
  const currentFileLocation = path.resolve(__dirname, "..", "..", "..", "..", "WebTemplate");
@@ -21,11 +13,10 @@ const moveWebTemplateFiles = async () => {
21
13
  return true;
22
14
  }
23
15
  });
24
- const filesAndFolders = await (0, _fileUtils.listProjectFilesAndFolders)();
25
- const pathsIgnoreList = [(0, _fileUtils.getFullPathInProject)("intuned"), (0, _fileUtils.getFullPathInProject)("node_modules"), (0, _fileUtils.getFullPathInProject)("package.json"), (0, _fileUtils.getFullPathInProject)("yarn.lock"), (0, _fileUtils.getFullPathInProject)(".env")];
16
+ const filesAndFolders = await listProjectFilesAndFolders();
17
+ const pathsIgnoreList = [getFullPathInProject("intuned"), getFullPathInProject("node_modules"), getFullPathInProject("package.json"), getFullPathInProject("yarn.lock"), getFullPathInProject(".env")];
26
18
  const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
27
19
  for (const file of filesToCopy) {
28
20
  await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
29
21
  }
30
- };
31
- exports.moveWebTemplateFiles = moveWebTemplateFiles;
22
+ };
@@ -1,45 +1,40 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
7
- var net = _interopRequireWildcard(require("net"));
8
- var _zod = _interopRequireDefault(require("zod"));
9
- var _runApi = require("../../common/runApi");
10
- var _enums = require("src/runtime/enums");
11
- var _unixSocket = require("../common/utils/unixSocket");
12
- var _promises = require("timers/promises");
13
- 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); }
14
- 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; }
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- const startRunApiSchema = _zod.default.object({
17
- type: _zod.default.literal("start"),
18
- parameters: _runApi.runApiParametersSchema.extend({
19
- retrieveSession: _zod.default.boolean(),
20
- context: _zod.default.object({
21
- jobId: _zod.default.string().optional(),
22
- jobRunId: _zod.default.string().optional(),
23
- runId: _zod.default.string().optional(),
24
- queueId: _zod.default.string().optional()
2
+ import { program } from "commander";
3
+ import dotenv from "dotenv";
4
+ import { runWithContext } from "../../common/asyncLocalStorage";
5
+ import * as net from "net";
6
+ import z from "zod";
7
+ import { runApiGenerator, runApiParametersSchema } from "../../common/runApi";
8
+ import { RunEnvironment } from "src/runtime/enums";
9
+ import { JSONUnixSocket } from "../common/utils/unixSocket";
10
+ import { setTimeout } from "timers/promises";
11
+ const startRunApiSchema = z.object({
12
+ type: z.literal("start"),
13
+ parameters: runApiParametersSchema.extend({
14
+ retrieveSession: z.boolean(),
15
+ context: z.object({
16
+ jobId: z.string().optional(),
17
+ jobRunId: z.string().optional(),
18
+ runId: z.string().optional(),
19
+ queueId: z.string().optional()
25
20
  }).optional()
26
21
  })
27
22
  });
28
- const nextRunApiSchema = _zod.default.object({
29
- type: _zod.default.literal("next"),
30
- parameters: _zod.default.object({
31
- value: _zod.default.string()
23
+ const nextRunApiSchema = z.object({
24
+ type: z.literal("next"),
25
+ parameters: z.object({
26
+ value: z.string()
32
27
  })
33
28
  });
34
- const abortRunApiSchema = _zod.default.object({
35
- type: _zod.default.literal("abort"),
36
- parameters: _zod.default.object({}).optional()
29
+ const abortRunApiSchema = z.object({
30
+ type: z.literal("abort"),
31
+ parameters: z.object({}).optional()
37
32
  });
38
- const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
39
- _dotenv.default.config({
33
+ const inputSchema = z.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
34
+ dotenv.config({
40
35
  path: `.env`
41
36
  });
42
- _commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
37
+ program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
43
38
  let context;
44
39
  const throttleTime = 1_000;
45
40
  let timeoutTimestamp = Date.now();
@@ -63,10 +58,10 @@ _commander.program.description("run user automation and communicate using unix s
63
58
  client.end();
64
59
  process.exit(1);
65
60
  });
66
- const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
61
+ const jsonUnixSocket = new JSONUnixSocket(client);
67
62
  async function runGeneratorAndSendResult(next) {
68
63
  if (!generator) return;
69
- const result = await (0, _asyncLocalStorage.runWithContext)(context, () => generator.next(next));
64
+ const result = await runWithContext(context, () => generator.next(next));
70
65
  if (result.done) {
71
66
  const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
72
67
  const success = result.value.isOk();
@@ -104,7 +99,7 @@ _commander.program.description("run user automation and communicate using unix s
104
99
  const input = inputParseResult.data;
105
100
  if (input.type === "abort") {
106
101
  abortController.abort();
107
- await (0, _promises.setTimeout)(10);
102
+ await setTimeout(10);
108
103
  jsonUnixSocket.sendJSON({
109
104
  type: "done",
110
105
  result: null
@@ -112,14 +107,14 @@ _commander.program.description("run user automation and communicate using unix s
112
107
  break;
113
108
  }
114
109
  if (input.type === "start") {
115
- const gen = (0, _runApi.runApiGenerator)({
110
+ const gen = runApiGenerator({
116
111
  ...input.parameters,
117
112
  abortSignal: abortController.signal
118
113
  });
119
114
  generator = gen;
120
115
  context = {
121
116
  extendedPayloads: [],
122
- runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
117
+ runEnvironment: input.parameters.runOptions.environment === "deployed" ? RunEnvironment.DEPLOYED : RunEnvironment.IDE,
123
118
  timeoutInfo: {
124
119
  extendTimeoutCallback: async () => {
125
120
  if (Date.now() - timeoutTimestamp < throttleTime) return;
@@ -149,7 +144,7 @@ _commander.program.description("run user automation and communicate using unix s
149
144
  }
150
145
  process.exit(0);
151
146
  });
152
- _commander.program.parse(process.argv);
147
+ program.parse(process.argv);
153
148
  function getProxyUrlFromRunOptions(runOptions) {
154
149
  if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
155
150
  const proxy = runOptions.proxy;
@@ -1,15 +1,11 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
-
4
- var ts = _interopRequireWildcard(require("typescript"));
5
- var _commander = require("commander");
6
- var fs = _interopRequireWildcard(require("fs-extra"));
7
- var path = _interopRequireWildcard(require("path"));
8
- var _webTemplate = require("./common/utils/webTemplate");
9
- 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); }
10
- 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; }
11
- _commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
12
- await (0, _webTemplate.moveWebTemplateFiles)();
2
+ import * as ts from "typescript";
3
+ import { program } from "commander";
4
+ import * as fs from "fs-extra";
5
+ import * as path from "path";
6
+ import { moveWebTemplateFiles } from "./common/utils/webTemplate";
7
+ program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
8
+ await moveWebTemplateFiles();
13
9
  const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
14
10
  await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
15
11
  checkTypes();
@@ -51,4 +47,4 @@ function checkTypes() {
51
47
  process.exit(1);
52
48
  }
53
49
  }
54
- _commander.program.parse(process.argv);
50
+ program.parse(process.argv);
@@ -1,21 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.logger = void 0;
7
- var _nodeUtil = require("node:util");
8
- var _chalk = _interopRequireDefault(require("chalk"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const format = _nodeUtil.formatWithOptions.bind(undefined, {
1
+ import { formatWithOptions } from "node:util";
2
+ import chalk from "chalk";
3
+ const format = formatWithOptions.bind(undefined, {
11
4
  colors: true
12
5
  });
13
6
  const LOG_LEVEL_COLORS = {
14
- TRACE: _chalk.default.gray,
15
- DEBUG: _chalk.default.blue,
16
- INFO: _chalk.default.green,
17
- WARN: _chalk.default.yellow,
18
- ERROR: _chalk.default.red
7
+ TRACE: chalk.gray,
8
+ DEBUG: chalk.blue,
9
+ INFO: chalk.green,
10
+ WARN: chalk.yellow,
11
+ ERROR: chalk.red
19
12
  };
20
13
  class Logger {
21
14
  logFunction(entry) {
@@ -57,4 +50,4 @@ class Logger {
57
50
  this.log("ERROR", message, meta);
58
51
  }
59
52
  }
60
- const logger = exports.logger = new Logger();
53
+ export const logger = new Logger();
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
@@ -1,21 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.logger = void 0;
7
- var _nodeUtil = require("node:util");
8
- var _chalk = _interopRequireDefault(require("chalk"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const format = _nodeUtil.formatWithOptions.bind(undefined, {
1
+ import { formatWithOptions } from "node:util";
2
+ import chalk from "chalk";
3
+ const format = formatWithOptions.bind(undefined, {
11
4
  colors: true
12
5
  });
13
6
  const LOG_LEVEL_COLORS = {
14
- TRACE: _chalk.default.gray,
15
- DEBUG: _chalk.default.blue,
16
- INFO: _chalk.default.green,
17
- WARN: _chalk.default.yellow,
18
- ERROR: _chalk.default.red
7
+ TRACE: chalk.gray,
8
+ DEBUG: chalk.blue,
9
+ INFO: chalk.green,
10
+ WARN: chalk.yellow,
11
+ ERROR: chalk.red
19
12
  };
20
13
  class Logger {
21
14
  logFunction(entry) {
@@ -57,4 +50,4 @@ class Logger {
57
50
  this.log("ERROR", message, meta);
58
51
  }
59
52
  }
60
- const logger = exports.logger = new Logger();
53
+ export const logger = new Logger();