@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
package/.babelrc CHANGED
@@ -7,13 +7,15 @@
7
7
  "chrome": 115,
8
8
  "node": "16"
9
9
  },
10
- "modules": "commonjs"
10
+ "modules": false
11
11
  }
12
12
  ],
13
13
  "@babel/preset-typescript"
14
14
  ],
15
15
  "plugins": [
16
+ // ["./preserve-dynamic-imports.js"],
16
17
  "babel-plugin-macros",
18
+ "@babel/plugin-syntax-dynamic-import",
17
19
  "@babel/plugin-transform-export-namespace-from"
18
20
  ],
19
21
  "sourceMaps": false,
package/Intuned.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "authSessions": {
3
- "enabled": true
3
+ "enabled": false
4
4
  }
5
5
  }
package/api/test2.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Page, BrowserContext } from "@intuned/playwright-core";
2
2
  import { extendTimeout } from "../src/runtime/extendTimeout";
3
- import { requestOTP } from "../src/runtime/requestMoreInfo";
4
3
 
5
- export default async function* test2(
4
+ export default async function test2(
6
5
  { n }: { n?: number },
7
6
  page: Page,
8
7
  context: BrowserContext
@@ -10,8 +9,6 @@ export default async function* test2(
10
9
  await page.goto("https://wikipedia.org/");
11
10
  await page.waitForTimeout(1000);
12
11
 
13
- yield requestOTP("Please enter the OTP");
14
-
15
12
  const titles: string[] = [];
16
13
 
17
14
  for (let i = 0; i < (n ?? 2); i++) {
@@ -1,31 +1,23 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.executeCLI = executeCLI;
8
- var _commander = require("commander");
9
- var fs = _interopRequireWildcard(require("fs-extra"));
10
- var _settings = require("../common/utils/settings");
11
- var _dotenv = _interopRequireDefault(require("dotenv"));
12
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
13
- var _enums = require("../../runtime/enums");
14
- var _cleanEnvironmentVariables = require("../../common/cleanEnvironmentVariables");
15
- var _Logger = require("../../common/Logger");
16
- var _nanoid = require("nanoid");
17
- var _chalk = _interopRequireDefault(require("chalk"));
18
- var _runApi = require("../../common/runApi");
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- 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); }
21
- 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; }
22
- _dotenv.default.config({
2
+ import { program, Argument } from "commander";
3
+ import * as fs from "fs-extra";
4
+ import { getSettings } from "../common/utils/settings";
5
+ import dotenv from "dotenv";
6
+ import { runWithContext } from "../../common/asyncLocalStorage";
7
+ import { RunEnvironment } from "../../runtime/enums";
8
+ import { cleanEnvironmentVariables } from "../../common/cleanEnvironmentVariables";
9
+ import { logger } from "../../common/Logger";
10
+ import { nanoid } from "nanoid";
11
+ import chalk from "chalk";
12
+ import { runApi } from "../../common/runApi";
13
+ import { AutomationError } from "../../common/runApi";
14
+ dotenv.config({
23
15
  path: `.env`
24
16
  });
25
- async function executeCLI(apiName, mode, inputData, options) {
26
- (0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
17
+ export async function executeCLI(apiName, mode, inputData, options) {
18
+ cleanEnvironmentVariables();
27
19
  let authSessionPathToUse = null;
28
- const settings = await (0, _settings.getSettings)();
20
+ const settings = await getSettings();
29
21
  if (settings.authSessions.enabled) {
30
22
  if (!options.authSessionPath) {
31
23
  throw new Error("Auth session is enabled but no auth session provided");
@@ -36,7 +28,7 @@ async function executeCLI(apiName, mode, inputData, options) {
36
28
  throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
37
29
  }
38
30
  }
39
- const runApiResult = await (0, _runApi.runApi)({
31
+ const runApiResult = await runApi({
40
32
  automationFunction: {
41
33
  name: `api/${apiName}`,
42
34
  params: inputData ?? {}
@@ -55,7 +47,7 @@ async function executeCLI(apiName, mode, inputData, options) {
55
47
  }
56
48
  });
57
49
  if (runApiResult.isErr()) {
58
- if (runApiResult.error instanceof _runApi.AutomationError) {
50
+ if (runApiResult.error instanceof AutomationError) {
59
51
  throw runApiResult.error.error;
60
52
  }
61
53
  console.error("An error occurred while running the API", runApiResult.error);
@@ -71,7 +63,7 @@ async function executeCLI(apiName, mode, inputData, options) {
71
63
  const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
72
64
  const resultsDir = "/tmp/run-results";
73
65
  if (options.outputFileId && shouldWriteToFile) {
74
- _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
66
+ logger.info(chalk.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
75
67
  fs.ensureDirSync(resultsDir);
76
68
  const path = `${resultsDir}/${options.outputFileId}.json`;
77
69
  await fs.writeJson(path, result, {
@@ -82,18 +74,18 @@ async function executeCLI(apiName, mode, inputData, options) {
82
74
  }
83
75
  const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
84
76
  if (hasPayloadToAppend && options.outputFileId) {
85
- _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
77
+ logger.info(chalk.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
86
78
  fs.ensureDirSync(resultsDir);
87
79
  const path = `${resultsDir}/${options.outputFileId}-payloads-to-append.json`;
88
80
  await fs.writeJson(path, payloadToAppend, {
89
81
  spaces: 2
90
82
  });
91
83
  } else if (hasPayloadToAppend) {
92
- _Logger.logger.info("payload to append:", payloadToAppend);
93
- _Logger.logger.info("This will only take an effect if this API run was part of a job.");
84
+ logger.info("payload to append:", payloadToAppend);
85
+ logger.info("This will only take an effect if this API run was part of a job.");
94
86
  }
95
87
  }
96
- _commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
88
+ program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
97
89
  let inputData = null;
98
90
  if (options.input) {
99
91
  inputData = await fs.readJSON(options.input);
@@ -102,12 +94,12 @@ _commander.program.description("run the user function in the cli for testing pur
102
94
  } else {
103
95
  inputData = {};
104
96
  }
105
- await (0, _asyncLocalStorage.runWithContext)({
106
- runEnvironment: _enums.RunEnvironment.IDE,
97
+ await runWithContext({
98
+ runEnvironment: RunEnvironment.IDE,
107
99
  extendedPayloads: [],
108
- runId: (0, _nanoid.nanoid)(),
100
+ runId: nanoid(),
109
101
  proxy: options.proxy
110
102
  }, () => executeCLI(apiName, mode, inputData, options));
111
103
  process.exit(0);
112
104
  });
113
- _commander.program.parse(process.argv);
105
+ program.parse(process.argv);
@@ -1,26 +1,24 @@
1
1
  #!/usr/bin/env node
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({
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({
10
8
  path: `.env`
11
9
  });
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 ({
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 ({
13
11
  cdpAddress,
14
12
  authSessionPath
15
13
  }) => {
16
- const setting = await (0, _settings.getSettings)();
14
+ const setting = await getSettings();
17
15
  if (!setting.authSessions.enabled) {
18
16
  throw new Error("Auth session is not enabled");
19
17
  }
20
18
  const {
21
19
  context
22
- } = await (0, _getPlaywrightConstructs.getRemotePlaywrightContext)(cdpAddress);
23
- await (0, _getPlaywrightConstructs.loadSessionToContext)({
20
+ } = await getRemotePlaywrightContext(cdpAddress);
21
+ await loadSessionToContext({
24
22
  context,
25
23
  session: {
26
24
  type: "file",
@@ -29,4 +27,4 @@ _commander.program.description("load auth session to browser").option("--cdpAddr
29
27
  });
30
28
  process.exit(0);
31
29
  });
32
- _commander.program.parse(process.argv);
30
+ program.parse(process.argv);
@@ -1,34 +1,29 @@
1
1
  #!/usr/bin/env node
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
- 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({
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({
15
10
  path: `.env`
16
11
  });
17
- _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, {
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
13
  cdpAddress,
19
14
  authSessionPath
20
15
  }) => {
21
- const setting = await (0, _settings.getSettings)();
16
+ const setting = await getSettings();
22
17
  if (!setting.authSessions.enabled) {
23
18
  throw new Error("auth session is not enabled");
24
19
  }
25
- const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
20
+ const checkFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "check");
26
21
  if (!fs.exists(checkFilePath)) {
27
22
  throw new Error("auth session check file not found");
28
23
  }
29
- const runApiResult = await (0, _runApi.runApi)({
24
+ const runApiResult = await runApi({
30
25
  automationFunction: {
31
- name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
26
+ name: `${AUTH_SESSIONS_FOLDER_NAME}/check`
32
27
  },
33
28
  runOptions: {
34
29
  environment: "ide",
@@ -53,4 +48,4 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
53
48
  }
54
49
  process.exit(0);
55
50
  });
56
- _commander.program.parse(process.argv);
51
+ program.parse(process.argv);
@@ -1,24 +1,19 @@
1
1
  #!/usr/bin/env node
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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
- _dotenv.default.config({
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({
19
14
  path: `.env`
20
15
  });
21
- _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, {
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
17
  cdpAddress,
23
18
  pathToSave,
24
19
  input,
@@ -32,16 +27,16 @@ _commander.program.description("run auth session create").option("--cdpAddress <
32
27
  } else {
33
28
  inputData = {};
34
29
  }
35
- const setting = await (0, _settings.getSettings)();
30
+ const setting = await getSettings();
36
31
  if (!setting.authSessions.enabled) {
37
32
  throw new Error("auth sessions feature is not enabled");
38
33
  }
39
- const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
34
+ const createFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "create.ts");
40
35
  if (!fs.exists(createFilePath)) {
41
36
  throw new Error("auth session create file not found");
42
37
  }
43
38
  async function runCreate() {
44
- const generator = (0, _runApi.runApiGenerator)({
39
+ const generator = runApiGenerator({
45
40
  automationFunction: {
46
41
  name: "auth-sessions/create",
47
42
  params: inputData ?? {}
@@ -66,14 +61,14 @@ _commander.program.description("run auth session create").option("--cdpAddress <
66
61
  }
67
62
  const fullState = value.value.session;
68
63
  if (pathToSave) {
69
- const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
64
+ const fullPath = getFullPathInProject(pathToSave);
70
65
  fs.ensureFileSync(fullPath);
71
66
  await fs.writeJSON(fullPath, fullState);
72
67
  }
73
68
  break;
74
69
  }
75
70
  if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
76
- nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
71
+ nextGeneratorParam = await prompt(value.messageToUser + `, choices: ${value.choices}`, {
77
72
  validator: input => {
78
73
  if (!value.choices.includes(input)) {
79
74
  throw new Error("Please type on of the allowed choices");
@@ -82,15 +77,15 @@ _commander.program.description("run auth session create").option("--cdpAddress <
82
77
  }
83
78
  });
84
79
  } else if (value.action === "request_more_info" && value.requestType == "otp") {
85
- nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
80
+ nextGeneratorParam = await prompt(value.messageToUser, {});
86
81
  }
87
82
  }
88
83
  }
89
- await (0, _asyncLocalStorage.runWithContext)({
90
- runEnvironment: _enums.RunEnvironment.IDE,
84
+ await runWithContext({
85
+ runEnvironment: RunEnvironment.IDE,
91
86
  extendedPayloads: [],
92
- runId: (0, _nanoid.nanoid)()
87
+ runId: nanoid()
93
88
  }, runCreate);
94
89
  process.exit(0);
95
90
  });
96
- _commander.program.parse(process.argv);
91
+ program.parse(process.argv);
@@ -1,17 +1,14 @@
1
1
  #!/usr/bin/env node
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({
2
+ import { program } from "commander";
3
+ import { saveSessionFromOpenedBrowser } from "../common/browserUtils";
4
+ import dotenv from "dotenv";
5
+ dotenv.config({
9
6
  path: `.env`
10
7
  });
11
- _commander.program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
8
+ program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
12
9
  path
13
10
  }) => {
14
- await (0, _browserUtils.saveSessionFromOpenedBrowser)(path);
11
+ await saveSessionFromOpenedBrowser(path);
15
12
  process.exit(0);
16
13
  });
17
- _commander.program.parse(process.argv);
14
+ program.parse(process.argv);
@@ -1,14 +1,11 @@
1
1
  #!/usr/bin/env node
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({
2
+ import { program } from "commander";
3
+ import { startOrRestartBrowser } from "../common/browserUtils";
4
+ import dotenv from "dotenv";
5
+ dotenv.config({
9
6
  path: `.env`
10
7
  });
11
- _commander.program.description("start browser testing purposes").allowUnknownOption().action(async () => {
12
- await (0, _browserUtils.startOrRestartBrowser)();
8
+ program.description("start browser testing purposes").allowUnknownOption().action(async () => {
9
+ await startOrRestartBrowser();
13
10
  });
14
- _commander.program.parse(process.argv);
11
+ program.parse(process.argv);
@@ -1,28 +1,23 @@
1
1
  #!/usr/bin/env node
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");
14
- var _dotenv = _interopRequireDefault(require("dotenv"));
15
- 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); }
16
- 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; }
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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";
18
12
  function isThirdPartyWarning(warning) {
19
13
  if (warning.id && /node_modules/.test(warning.id)) return true;
20
14
  if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
21
15
  return false;
22
16
  }
23
- _dotenv.default.config();
24
- _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) => {
25
- await (0, _webTemplate.moveWebTemplateFiles)();
17
+ import dotenv from "dotenv";
18
+ dotenv.config();
19
+ 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) => {
20
+ await moveWebTemplateFiles();
26
21
  const currentTemplateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
27
22
  await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
28
23
  await build(outfile, mode);
@@ -31,27 +26,27 @@ async function build(outfile, mode) {
31
26
  let bundle = null;
32
27
  let buildFailed = false;
33
28
  try {
34
- bundle = await (0, _rollup.rollup)({
29
+ bundle = await rollup({
35
30
  input: `./intuned/WebTemplate/index.${mode}.ts`,
36
31
  output: {
37
32
  globals: {
38
33
  crypto: "crypto"
39
34
  }
40
35
  },
41
- plugins: [(0, _pluginJson.default)(), (0, _pluginNodeResolve.nodeResolve)({
36
+ plugins: [json(), nodeResolve({
42
37
  exportConditions: ["node"],
43
38
  preferBuiltins: true
44
- }), (0, _pluginTypescript.default)({
39
+ }), typescript({
45
40
  tsconfig: "./intuned/WebTemplate/tsconfig.json"
46
- }), (0, _pluginCommonjs.default)({
47
- include: [path.resolve("/Users/omarhurani/Documents/GitHub/WebApp/apps/typescript-runtime"), "node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**", "../typescript-runtime/**"],
41
+ }), commonjs({
42
+ include: ["node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**", "../typescript-runtime/**"],
48
43
  extensions: [".js"],
49
44
  ignoreGlobal: false,
50
45
  sourceMap: false,
51
- transformMixedEsModules: true,
52
- ignoreTryCatch: true,
53
- requireReturnsDefault: "auto"
54
- }), (0, _pluginDynamicImportVars.default)({
46
+ dynamicRequireTargets: ["api/**/*.js", "auth-sessions/**/*.js"],
47
+ requireReturnsDefault: "auto",
48
+ transformMixedEsModules: true
49
+ }), dynamicImportVars({
55
50
  include: ["**/*.js", "**/*.ts"],
56
51
  exclude: ["**/*.d.ts", "**/*.js.map"]
57
52
  })],
@@ -59,7 +54,7 @@ async function build(outfile, mode) {
59
54
  if (isThirdPartyWarning(warning)) return;
60
55
  warn(warning);
61
56
  },
62
- external: ["@intuned/playwright", "@intuned/playwright-core", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector"]
57
+ external: ["@intuned/playwright", "@intuned/playwright-core", "@intuned/runtime", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector"]
63
58
  });
64
59
  console.log(`📦 Building ${outfile}`);
65
60
  const outfileFolder = path.dirname(outfile);
@@ -80,4 +75,4 @@ async function build(outfile, mode) {
80
75
  process.exit(1);
81
76
  }
82
77
  }
83
- _commander.program.parse(process.argv);
78
+ program.parse(process.argv);
@@ -1,23 +1,10 @@
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");
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;
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";
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"];
21
8
  async function getBrowser() {
22
9
  let playwrightBrowser = null;
23
10
  try {
@@ -27,9 +14,9 @@ async function getBrowser() {
27
14
  }
28
15
  return playwrightBrowser;
29
16
  }
30
- async function startOrRestartBrowser() {
17
+ export async function startOrRestartBrowser() {
31
18
  const chromiumPath = await playwright.chromium.executablePath();
32
- const chromeInstanceProcess = (0, _child_process.spawn)(chromiumPath, getChromiumLaunchArgs());
19
+ const chromeInstanceProcess = spawn(chromiumPath, getChromiumLaunchArgs());
33
20
  chromeInstanceProcess.stdout.on("data", data => {
34
21
  console.log(`Chrome stdout: ${data}`);
35
22
  });
@@ -37,22 +24,22 @@ async function startOrRestartBrowser() {
37
24
  console.error(`Chrome stderr: ${data}`);
38
25
  });
39
26
  }
40
- async function saveSessionFromOpenedBrowser(path) {
27
+ export async function saveSessionFromOpenedBrowser(path) {
41
28
  const browser = await getBrowser();
42
29
  const context = await browser.contexts()[0];
43
30
  return saveSession(path, context);
44
31
  }
45
- async function loadState(path, context) {
46
- const fullPath = (0, _fileUtils.getFullPathInProject)(path);
32
+ export async function loadState(path, context) {
33
+ const fullPath = getFullPathInProject(path);
47
34
  if (!(await fs.pathExists(fullPath))) {
48
35
  throw new Error("session file does not exist");
49
36
  }
50
37
  const data = await fs.readJson(fullPath);
51
38
  await context.addCookies(data.cookies);
52
39
  }
53
- async function saveSession(path, context) {
54
- const fullState = await (0, _contextStorageStateHelpers.getContextStorageState)(context);
55
- const fullPath = (0, _fileUtils.getFullPathInProject)(path);
40
+ export async function saveSession(path, context) {
41
+ const fullState = await getContextStorageState(context);
42
+ const fullPath = getFullPathInProject(path);
56
43
  fs.ensureFileSync(fullPath);
57
44
  await fs.writeJSON(fullPath, fullState);
58
45
  }
@@ -1,19 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDefaultExportFromFile = getDefaultExportFromFile;
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 getDefaultExportFromFile(apiFilePath) {
1
+ export async function getDefaultExportFromFile(apiFilePath) {
10
2
  require("ts-node").register({
11
3
  transpileOnly: true,
12
4
  compilerOptions: {
13
5
  lib: ["dom", "es2020"]
14
6
  }
15
7
  });
16
- const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(apiFilePath);
8
+ const imported = await import(apiFilePath);
17
9
  const defaultExport = imported.default;
18
10
  return defaultExport;
19
11
  }