@intuned/runtime-dev 0.1.0-test.15 → 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 (61) 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/dist/commands/api/run.js +41 -29
  13. package/dist/commands/auth-sessions/load.js +13 -11
  14. package/dist/commands/auth-sessions/run-check.js +21 -14
  15. package/dist/commands/auth-sessions/run-create.js +32 -25
  16. package/dist/commands/browser/save-state.js +10 -7
  17. package/dist/commands/browser/start-browser.js +10 -7
  18. package/dist/commands/build.js +28 -23
  19. package/dist/commands/common/browserUtils.js +28 -15
  20. package/dist/commands/common/getFirstLineNumber.js +20 -13
  21. package/dist/commands/common/getFirstLineNumber.test.js +53 -48
  22. package/dist/commands/common/sendMessageToClient.js +9 -2
  23. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  24. package/dist/commands/common/tsNodeImport.js +18 -0
  25. package/dist/commands/common/utils/fileUtils.js +16 -6
  26. package/dist/commands/common/utils/settings.js +13 -7
  27. package/dist/commands/common/utils/unixSocket.js +9 -2
  28. package/dist/commands/common/utils/webTemplate.js +18 -9
  29. package/dist/commands/interface/run.js +163 -134
  30. package/dist/commands/ts-check.js +14 -10
  31. package/dist/common/Logger/Logger/index.js +16 -9
  32. package/dist/common/Logger/Logger/types.js +5 -1
  33. package/dist/common/Logger/index.js +16 -9
  34. package/dist/common/Logger/types.js +5 -1
  35. package/dist/common/asyncLocalStorage/index.js +12 -4
  36. package/dist/common/cleanEnvironmentVariables.js +7 -1
  37. package/dist/common/constants.js +7 -1
  38. package/dist/common/contextStorageStateHelpers.js +9 -2
  39. package/dist/common/getPlaywrightConstructs.js +40 -29
  40. package/dist/common/jwtTokenManager.js +18 -8
  41. package/dist/common/runApi/errors.js +42 -24
  42. package/dist/common/runApi/index.js +97 -103
  43. package/dist/common/runApi/types.d.ts +19 -5
  44. package/dist/common/runApi/types.js +42 -31
  45. package/dist/common/settingsSchema.js +10 -2
  46. package/dist/common/telemetry.js +12 -3
  47. package/dist/index.js +69 -4
  48. package/dist/runtime/RunError.js +8 -1
  49. package/dist/runtime/downloadDirectory.js +11 -5
  50. package/dist/runtime/enums.d.js +5 -1
  51. package/dist/runtime/enums.js +8 -2
  52. package/dist/runtime/executionHelpers.test.js +22 -20
  53. package/dist/runtime/export.d.js +5 -1
  54. package/dist/runtime/extendPayload.js +11 -5
  55. package/dist/runtime/extendTimeout.js +9 -3
  56. package/dist/runtime/index.js +53 -6
  57. package/dist/runtime/requestMoreInfo.js +9 -2
  58. package/dist/runtime/runInfo.js +11 -5
  59. package/package.json +3 -5
  60. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -0
  61. package/dist/commands/common/getDefaultExportFromFile.js +0 -0
@@ -1,24 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import { program } from "commander";
3
- import { getRemotePlaywrightContext } from "../../common/getPlaywrightConstructs";
4
- import { getSettings } from "../common/utils/settings";
5
- import dotenv from "dotenv";
6
- import { loadSessionToContext } from "../../common/getPlaywrightConstructs";
7
- dotenv.config({
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _getPlaywrightConstructs = require("../../common/getPlaywrightConstructs");
6
+ var _settings = require("../common/utils/settings");
7
+ var _dotenv = _interopRequireDefault(require("dotenv"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ _dotenv.default.config({
8
10
  path: `.env`
9
11
  });
10
- program.description("load auth session to browser").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").allowUnknownOption().action(async ({
12
+ _commander.program.description("load auth session to browser").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").allowUnknownOption().action(async ({
11
13
  cdpAddress,
12
14
  authSessionPath
13
15
  }) => {
14
- const setting = await getSettings();
16
+ const setting = await (0, _settings.getSettings)();
15
17
  if (!setting.authSessions.enabled) {
16
18
  throw new Error("Auth session is not enabled");
17
19
  }
18
20
  const {
19
21
  context
20
- } = await getRemotePlaywrightContext(cdpAddress);
21
- await loadSessionToContext({
22
+ } = await (0, _getPlaywrightConstructs.getRemotePlaywrightContext)(cdpAddress);
23
+ await (0, _getPlaywrightConstructs.loadSessionToContext)({
22
24
  context,
23
25
  session: {
24
26
  type: "file",
@@ -27,4 +29,4 @@ program.description("load auth session to browser").option("--cdpAddress <cdpAdd
27
29
  });
28
30
  process.exit(0);
29
31
  });
30
- program.parse(process.argv);
32
+ _commander.program.parse(process.argv);
@@ -1,29 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import { Argument, program } from "commander";
3
- import * as fs from "fs-extra";
4
- import { getFullPathInProject } from "../common/utils/fileUtils";
5
- import { getSettings } from "../common/utils/settings";
6
- import dotenv from "dotenv";
7
- import { AUTH_SESSIONS_FOLDER_NAME } from "../../common/constants";
8
- import { runApi } from "../../common/runApi";
9
- dotenv.config({
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var fs = _interopRequireWildcard(require("fs-extra"));
6
+ var _fileUtils = require("../common/utils/fileUtils");
7
+ var _settings = require("../common/utils/settings");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _constants = require("../../common/constants");
10
+ var _runApi = require("../../common/runApi");
11
+ var _tsNodeImport = require("../common/tsNodeImport");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+ _dotenv.default.config({
10
16
  path: `.env`
11
17
  });
12
- program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").allowUnknownOption().addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
18
+ _commander.program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
13
19
  cdpAddress,
14
20
  authSessionPath
15
21
  }) => {
16
- const setting = await getSettings();
22
+ const setting = await (0, _settings.getSettings)();
17
23
  if (!setting.authSessions.enabled) {
18
24
  throw new Error("auth session is not enabled");
19
25
  }
20
- const checkFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "check");
26
+ const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
21
27
  if (!fs.exists(checkFilePath)) {
22
28
  throw new Error("auth session check file not found");
23
29
  }
24
- const runApiResult = await runApi({
30
+ const checkModule = await (0, _tsNodeImport.tsNodeImport)(checkFilePath);
31
+ const runApiResult = await (0, _runApi.runApi)({
25
32
  automationFunction: {
26
- name: `${AUTH_SESSIONS_FOLDER_NAME}/check`
33
+ module: checkModule
27
34
  },
28
35
  runOptions: {
29
36
  environment: "ide",
@@ -48,4 +55,4 @@ program.description("run auth session check").option("--cdpAddress <cdpAddress>"
48
55
  }
49
56
  process.exit(0);
50
57
  });
51
- program.parse(process.argv);
58
+ _commander.program.parse(process.argv);
@@ -1,19 +1,25 @@
1
1
  #!/usr/bin/env node
2
- import { Argument, program } from "commander";
3
- import * as fs from "fs-extra";
4
- import { prompt } from "promptly";
5
- import { getFullPathInProject } from "../common/utils/fileUtils";
6
- import { getSettings } from "../common/utils/settings";
7
- import dotenv from "dotenv";
8
- import { AUTH_SESSIONS_FOLDER_NAME } from "../../common/constants";
9
- import { runApiGenerator } from "../../common/runApi";
10
- import { runWithContext } from "../../common/asyncLocalStorage";
11
- import { nanoid } from "nanoid";
12
- import { RunEnvironment } from "../../runtime/enums";
13
- dotenv.config({
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var fs = _interopRequireWildcard(require("fs-extra"));
6
+ var _promptly = require("promptly");
7
+ var _fileUtils = require("../common/utils/fileUtils");
8
+ var _settings = require("../common/utils/settings");
9
+ var _dotenv = _interopRequireDefault(require("dotenv"));
10
+ var _constants = require("../../common/constants");
11
+ var _runApi = require("../../common/runApi");
12
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
13
+ var _nanoid = require("nanoid");
14
+ var _enums = require("../../runtime/enums");
15
+ var _tsNodeImport = require("../common/tsNodeImport");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ 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); }
18
+ 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; }
19
+ _dotenv.default.config({
14
20
  path: `.env`
15
21
  });
16
- program.description("run auth session create").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--pathToSave <pathToSave>", "path to save the auth session, if not provided, will discard the auth session").allowUnknownOption().addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
22
+ _commander.program.description("run auth session create").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--pathToSave <pathToSave>", "path to save the auth session, if not provided, will discard the auth session").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
17
23
  cdpAddress,
18
24
  pathToSave,
19
25
  input,
@@ -27,19 +33,20 @@ program.description("run auth session create").option("--cdpAddress <cdpAddress>
27
33
  } else {
28
34
  inputData = {};
29
35
  }
30
- const setting = await getSettings();
36
+ const setting = await (0, _settings.getSettings)();
31
37
  if (!setting.authSessions.enabled) {
32
38
  throw new Error("auth sessions feature is not enabled");
33
39
  }
34
- const createFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "create.ts");
40
+ const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
35
41
  if (!fs.exists(createFilePath)) {
36
42
  throw new Error("auth session create file not found");
37
43
  }
44
+ const createModule = await (0, _tsNodeImport.tsNodeImport)(createFilePath);
38
45
  async function runCreate() {
39
- const generator = runApiGenerator({
46
+ const generator = (0, _runApi.runApiGenerator)({
40
47
  automationFunction: {
41
- name: "auth-sessions/create",
42
- params: inputData ?? {}
48
+ module: createModule,
49
+ params: inputData
43
50
  },
44
51
  runOptions: {
45
52
  environment: "ide",
@@ -61,14 +68,14 @@ program.description("run auth session create").option("--cdpAddress <cdpAddress>
61
68
  }
62
69
  const fullState = value.value.session;
63
70
  if (pathToSave) {
64
- const fullPath = getFullPathInProject(pathToSave);
71
+ const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
65
72
  fs.ensureFileSync(fullPath);
66
73
  await fs.writeJSON(fullPath, fullState);
67
74
  }
68
75
  break;
69
76
  }
70
77
  if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
71
- nextGeneratorParam = await prompt(value.messageToUser + `, choices: ${value.choices}`, {
78
+ nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
72
79
  validator: input => {
73
80
  if (!value.choices.includes(input)) {
74
81
  throw new Error("Please type on of the allowed choices");
@@ -77,15 +84,15 @@ program.description("run auth session create").option("--cdpAddress <cdpAddress>
77
84
  }
78
85
  });
79
86
  } else if (value.action === "request_more_info" && value.requestType == "otp") {
80
- nextGeneratorParam = await prompt(value.messageToUser, {});
87
+ nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
81
88
  }
82
89
  }
83
90
  }
84
- await runWithContext({
85
- runEnvironment: RunEnvironment.IDE,
91
+ await (0, _asyncLocalStorage.runWithContext)({
92
+ runEnvironment: _enums.RunEnvironment.IDE,
86
93
  extendedPayloads: [],
87
- runId: nanoid()
94
+ runId: (0, _nanoid.nanoid)()
88
95
  }, runCreate);
89
96
  process.exit(0);
90
97
  });
91
- program.parse(process.argv);
98
+ _commander.program.parse(process.argv);
@@ -1,14 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { program } from "commander";
3
- import { saveSessionFromOpenedBrowser } from "../common/browserUtils";
4
- import dotenv from "dotenv";
5
- dotenv.config({
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _browserUtils = require("../common/browserUtils");
6
+ var _dotenv = _interopRequireDefault(require("dotenv"));
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ _dotenv.default.config({
6
9
  path: `.env`
7
10
  });
8
- program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
11
+ _commander.program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
9
12
  path
10
13
  }) => {
11
- await saveSessionFromOpenedBrowser(path);
14
+ await (0, _browserUtils.saveSessionFromOpenedBrowser)(path);
12
15
  process.exit(0);
13
16
  });
14
- program.parse(process.argv);
17
+ _commander.program.parse(process.argv);
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { program } from "commander";
3
- import { startOrRestartBrowser } from "../common/browserUtils";
4
- import dotenv from "dotenv";
5
- dotenv.config({
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _browserUtils = require("../common/browserUtils");
6
+ var _dotenv = _interopRequireDefault(require("dotenv"));
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ _dotenv.default.config({
6
9
  path: `.env`
7
10
  });
8
- program.description("start browser testing purposes").allowUnknownOption().action(async () => {
9
- await startOrRestartBrowser();
11
+ _commander.program.description("start browser testing purposes").allowUnknownOption().action(async () => {
12
+ await (0, _browserUtils.startOrRestartBrowser)();
10
13
  });
11
- program.parse(process.argv);
14
+ _commander.program.parse(process.argv);
@@ -1,25 +1,30 @@
1
1
  #!/usr/bin/env node
2
- import { program, Argument } from "commander";
3
- import { rollup } from "rollup";
4
- import typescript from "@rollup/plugin-typescript";
5
- import commonjs from "@rollup/plugin-commonjs";
6
- import { nodeResolve } from "@rollup/plugin-node-resolve";
7
- import dynamicImportVars from "@rollup/plugin-dynamic-import-vars";
8
- import json from "@rollup/plugin-json";
9
- import * as fs from "fs-extra";
10
- import * as path from "path";
11
- import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
12
- import { fileURLToPath } from "url";
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _rollup = require("rollup");
6
+ var _pluginTypescript = _interopRequireDefault(require("@rollup/plugin-typescript"));
7
+ var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
8
+ var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
9
+ var _pluginDynamicImportVars = _interopRequireDefault(require("@rollup/plugin-dynamic-import-vars"));
10
+ var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
11
+ var fs = _interopRequireWildcard(require("fs-extra"));
12
+ var path = _interopRequireWildcard(require("path"));
13
+ var _webTemplate = require("./common/utils/webTemplate.js");
14
+ var _url = require("url");
15
+ var _dotenv = _interopRequireDefault(require("dotenv"));
16
+ 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); }
17
+ 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; }
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
19
  function isThirdPartyWarning(warning) {
14
20
  if (warning.id && /node_modules/.test(warning.id)) return true;
15
21
  if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
16
22
  return false;
17
23
  }
18
- import dotenv from "dotenv";
19
- dotenv.config();
20
- program.description("build the intuned server").addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright"]).default("playwright").argOptional()).argument("[outfile]", "output bundle", "./output/bundle_v2.js").allowUnknownOption().action(async (mode, outfile) => {
21
- await moveWebTemplateFiles();
22
- const currentTemplateTsConfig = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "template.tsconfig.json");
24
+ _dotenv.default.config();
25
+ _commander.program.description("build the intuned server").addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright"]).default("playwright").argOptional()).argument("[outfile]", "output bundle", "./output/bundle_v2.js").allowUnknownOption().action(async (mode, outfile) => {
26
+ await (0, _webTemplate.moveWebTemplateFiles)();
27
+ const currentTemplateTsConfig = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "template.tsconfig.json");
23
28
  await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
24
29
  await build(outfile, mode);
25
30
  });
@@ -27,20 +32,20 @@ async function build(outfile, mode) {
27
32
  let bundle = null;
28
33
  let buildFailed = false;
29
34
  try {
30
- bundle = await rollup({
35
+ bundle = await (0, _rollup.rollup)({
31
36
  input: `./intuned/WebTemplate/index.${mode}.ts`,
32
37
  output: {
33
38
  globals: {
34
39
  crypto: "crypto"
35
40
  }
36
41
  },
37
- plugins: [json(), nodeResolve({
42
+ plugins: [(0, _pluginJson.default)(), (0, _pluginNodeResolve.nodeResolve)({
38
43
  exportConditions: ["node"],
39
44
  preferBuiltins: true
40
- }), typescript({
45
+ }), (0, _pluginTypescript.default)({
41
46
  tsconfig: "./intuned/WebTemplate/tsconfig.json",
42
47
  exclude: ["**/*.d.ts"]
43
- }), commonjs({
48
+ }), (0, _pluginCommonjs.default)({
44
49
  include: ["node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**"],
45
50
  extensions: [".js"],
46
51
  ignoreGlobal: false,
@@ -48,7 +53,7 @@ async function build(outfile, mode) {
48
53
  dynamicRequireTargets: ["api/**/*.js", "auth-sessions/**/*.js"],
49
54
  requireReturnsDefault: "auto",
50
55
  transformMixedEsModules: true
51
- }), dynamicImportVars({
56
+ }), (0, _pluginDynamicImportVars.default)({
52
57
  include: ["**/*.js"],
53
58
  exclude: ["**/*.d.ts", "**/*.js.map"]
54
59
  })],
@@ -60,7 +65,7 @@ async function build(outfile, mode) {
60
65
  });
61
66
  console.log(`📦 Building ${outfile}`);
62
67
  const outfileFolder = path.dirname(outfile);
63
- const assetsDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "assets");
68
+ const assetsDir = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "common", "assets");
64
69
  await fs.copy(assetsDir, `${outfileFolder}/assets`);
65
70
  await bundle.write({
66
71
  format: "cjs",
@@ -77,4 +82,4 @@ async function build(outfile, mode) {
77
82
  process.exit(1);
78
83
  }
79
84
  }
80
- program.parse(process.argv);
85
+ _commander.program.parse(process.argv);
@@ -1,10 +1,23 @@
1
- import { spawn } from "child_process";
2
- import * as playwright from "@intuned/playwright-core";
3
- import * as fs from "fs-extra";
4
- import { getFullPathInProject } from "./utils/fileUtils.js";
5
- import { getContextStorageState } from "../../common/contextStorageStateHelpers";
6
- export const REMOTE_DEBUGGING_PORT = 9222;
7
- export const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
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 playwright = _interopRequireWildcard(require("@intuned/playwright-core"));
13
+ var fs = _interopRequireWildcard(require("fs-extra"));
14
+ var _fileUtils = require("./utils/fileUtils.js");
15
+ var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
16
+ 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); }
17
+ 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; }
18
+ const REMOTE_DEBUGGING_PORT = exports.REMOTE_DEBUGGING_PORT = 9222;
19
+ const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
20
+ exports.getChromiumLaunchArgs = getChromiumLaunchArgs;
8
21
  async function getBrowser() {
9
22
  let playwrightBrowser = null;
10
23
  try {
@@ -14,9 +27,9 @@ async function getBrowser() {
14
27
  }
15
28
  return playwrightBrowser;
16
29
  }
17
- export async function startOrRestartBrowser() {
30
+ async function startOrRestartBrowser() {
18
31
  const chromiumPath = await playwright.chromium.executablePath();
19
- const chromeInstanceProcess = spawn(chromiumPath, getChromiumLaunchArgs());
32
+ const chromeInstanceProcess = (0, _child_process.spawn)(chromiumPath, getChromiumLaunchArgs());
20
33
  chromeInstanceProcess.stdout.on("data", data => {
21
34
  console.log(`Chrome stdout: ${data}`);
22
35
  });
@@ -24,22 +37,22 @@ export async function startOrRestartBrowser() {
24
37
  console.error(`Chrome stderr: ${data}`);
25
38
  });
26
39
  }
27
- export async function saveSessionFromOpenedBrowser(path) {
40
+ async function saveSessionFromOpenedBrowser(path) {
28
41
  const browser = await getBrowser();
29
42
  const context = await browser.contexts()[0];
30
43
  return saveSession(path, context);
31
44
  }
32
- export async function loadState(path, context) {
33
- const fullPath = getFullPathInProject(path);
45
+ async function loadState(path, context) {
46
+ const fullPath = (0, _fileUtils.getFullPathInProject)(path);
34
47
  if (!(await fs.pathExists(fullPath))) {
35
48
  throw new Error("session file does not exist");
36
49
  }
37
50
  const data = await fs.readJson(fullPath);
38
51
  await context.addCookies(data.cookies);
39
52
  }
40
- export async function saveSession(path, context) {
41
- const fullState = await getContextStorageState(context);
42
- const fullPath = getFullPathInProject(path);
53
+ async function saveSession(path, context) {
54
+ const fullState = await (0, _contextStorageStateHelpers.getContextStorageState)(context);
55
+ const fullPath = (0, _fileUtils.getFullPathInProject)(path);
43
56
  fs.ensureFileSync(fullPath);
44
57
  await fs.writeJSON(fullPath, fullState);
45
58
  }
@@ -1,5 +1,12 @@
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
11
  const compilerOptions = {
5
12
  lib: ["dom", "es2020"],
@@ -8,10 +15,10 @@ function compileTypeScript(apiFilePath) {
8
15
  inlineSources: true,
9
16
  declaration: false,
10
17
  noEmit: false,
11
- module: ModuleKind.CommonJS,
12
- target: ScriptTarget.ES2020
18
+ module: _tsMorph.ModuleKind.CommonJS,
19
+ target: _tsMorph.ScriptTarget.ES2020
13
20
  };
14
- const project = new Project({
21
+ const project = new _tsMorph.Project({
15
22
  compilerOptions
16
23
  });
17
24
  const sourceFile = project.addSourceFileAtPath(apiFilePath);
@@ -24,36 +31,36 @@ function compileTypeScript(apiFilePath) {
24
31
  outputJSText
25
32
  };
26
33
  }
27
- export function findFirstExecutableLine(sourceFile) {
34
+ function findFirstExecutableLine(sourceFile) {
28
35
  var _defaultExportSymbol$;
29
36
  let functionBody;
30
37
  const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
31
38
  const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
32
39
  if (defaultExportDeclaration) {
33
- if (defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration) {
40
+ if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
34
41
  functionBody = defaultExportDeclaration.getBody();
35
42
  } else {
36
43
  const exportAssignments = sourceFile.getExportAssignments();
37
44
  for (const exportAssignment of exportAssignments) {
38
45
  const expression = exportAssignment.getExpression();
39
46
  if (!expression) continue;
40
- if (expression.getKind() === ts.SyntaxKind.Identifier || expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction) {
47
+ if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
41
48
  var _sourceFile$getVariab;
42
49
  const identifier = expression.getText();
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));
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));
44
51
  if (possiblyExportedFunction) {
45
52
  functionBody = possiblyExportedFunction.getBody();
46
53
  break;
47
54
  }
48
55
  }
49
- if (Node.hasBody(expression) && (expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
56
+ if (_tsMorph.Node.hasBody(expression) && (expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction)) {
50
57
  functionBody = expression.getBody();
51
58
  break;
52
59
  }
53
60
  }
54
61
  }
55
62
  }
56
- if (!functionBody || !Node.isStatemented(functionBody)) {
63
+ if (!functionBody || !_tsMorph.Node.isStatemented(functionBody)) {
57
64
  return -1;
58
65
  }
59
66
  if (functionBody.getStatements().length === 0) {
@@ -66,7 +73,7 @@ async function getSourceMap(jsCode) {
66
73
  const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
67
74
  const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
68
75
  const sourceMap = JSON.parse(sourceMapText);
69
- return new SourceMapConsumer(sourceMap);
76
+ return new _sourceMap.SourceMapConsumer(sourceMap);
70
77
  }
71
78
  async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
72
79
  const sourceMap = await getSourceMap(jsCode);
@@ -78,7 +85,7 @@ async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, colum
78
85
  if (!generatedLineNumber) return -1;
79
86
  return generatedLineNumber;
80
87
  }
81
- export default async function getFirstLineNumber(apiFilePath) {
88
+ async function getFirstLineNumber(apiFilePath) {
82
89
  const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
83
90
  const {
84
91
  sourceFile,