@intuned/runtime-dev 1.1.8-bot-detection → 1.2.0-cli.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.babelrc +2 -2
  2. package/CHANGELOG.md +5 -1
  3. package/WebTemplate.zip +0 -0
  4. package/bin/intuned +2 -0
  5. package/dist/commands/api/run.js +8 -2
  6. package/dist/commands/auth-sessions/run-check.js +18 -4
  7. package/dist/commands/auth-sessions/run-create.js +2 -1
  8. package/dist/commands/cli-auth-sessions/create.js +1 -1
  9. package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
  10. package/dist/commands/cli-auth-sessions/utils.js +2 -3
  11. package/dist/commands/common/browserUtils.d.ts +1 -1
  12. package/dist/commands/common/browserUtils.js +1 -1
  13. package/dist/commands/common/getFirstLineNumber.js +2 -4
  14. package/dist/commands/deploy/utils.js +1 -2
  15. package/dist/commands/init/utils.js +1 -7
  16. package/dist/commands/interface/run.js +7 -6
  17. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  18. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  19. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  20. package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
  21. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  22. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  23. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  24. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  26. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
  27. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  28. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  29. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  30. package/dist/commands/intuned-cli/commands/command.js +9 -0
  31. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  32. package/dist/commands/intuned-cli/commands/deploy.command.js +47 -0
  33. package/dist/commands/intuned-cli/commands/helpers.d.ts +26 -0
  34. package/dist/commands/intuned-cli/commands/helpers.js +126 -0
  35. package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
  36. package/dist/commands/intuned-cli/commands/index.js +170 -0
  37. package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  38. package/dist/commands/intuned-cli/commands/init.command.js +14 -0
  39. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  40. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  41. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  42. package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
  43. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +21 -0
  44. package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
  45. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  46. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
  47. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  48. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
  49. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  50. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
  51. package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
  52. package/dist/commands/intuned-cli/commands/types.js +21 -0
  53. package/dist/commands/intuned-cli/controller/api.d.ts +19 -0
  54. package/dist/commands/intuned-cli/controller/api.js +179 -0
  55. package/dist/commands/intuned-cli/controller/authSession.d.ts +32 -0
  56. package/dist/commands/intuned-cli/controller/authSession.js +295 -0
  57. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  58. package/dist/commands/intuned-cli/controller/build.js +36 -0
  59. package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
  60. package/dist/commands/intuned-cli/controller/deploy.js +397 -0
  61. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  62. package/dist/commands/intuned-cli/controller/index.js +45 -0
  63. package/dist/commands/intuned-cli/controller/init.d.ts +5 -0
  64. package/dist/commands/intuned-cli/controller/init.js +139 -0
  65. package/dist/commands/intuned-cli/index.d.ts +1 -0
  66. package/dist/commands/intuned-cli/index.js +16 -0
  67. package/dist/commands/intuned-cli/main.d.ts +1 -0
  68. package/dist/commands/intuned-cli/main.js +12 -0
  69. package/dist/commands/intuned-cli/terminal.d.ts +1 -0
  70. package/dist/commands/intuned-cli/terminal.js +12 -0
  71. package/dist/commands/run-api-cli/utils.js +6 -6
  72. package/dist/common/assets/browser_scripts.js +2509 -2143
  73. package/dist/common/asyncLocalStorage/index.d.ts +1 -2
  74. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  75. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  76. package/dist/common/cli/cliReadme.d.ts +1 -1
  77. package/dist/common/cli/cliReadme.js +14 -23
  78. package/dist/common/cli/constants.d.ts +4 -2
  79. package/dist/common/cli/constants.js +7 -3
  80. package/dist/common/cli/types.d.ts +2 -2
  81. package/dist/common/cli/utils.d.ts +5 -2
  82. package/dist/common/cli/utils.js +6 -2
  83. package/dist/common/constants.d.ts +1 -0
  84. package/dist/common/constants.js +2 -1
  85. package/dist/common/contextStorageStateHelpers.d.ts +1 -1
  86. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  87. package/dist/common/getPlaywrightConstructs.js +12 -12
  88. package/dist/common/jwtTokenManager.js +3 -5
  89. package/dist/common/runApi/errors.d.ts +1 -1
  90. package/dist/common/runApi/errors.js +5 -6
  91. package/dist/common/runApi/index.d.ts +4 -1
  92. package/dist/common/runApi/index.js +21 -21
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +6 -0
  95. package/dist/runtime/executionHelpers.test.js +3 -4
  96. package/dist/runtime/export.d.ts +16 -0
  97. package/dist/runtime/extendPayload.js +1 -1
  98. package/dist/runtime/extendTimeout.js +0 -7
  99. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  100. package/dist/runtime/getAuthSessionParameters.js +20 -0
  101. package/dist/runtime/index.d.ts +1 -0
  102. package/dist/runtime/index.js +7 -0
  103. package/package.json +10 -7
  104. package/template.tsconfig.json +4 -7
package/.babelrc CHANGED
@@ -4,8 +4,8 @@
4
4
  "@babel/preset-env",
5
5
  {
6
6
  "targets": {
7
- "chrome": 115,
8
- "node": "16"
7
+ "chrome": 130,
8
+ "node": "20"
9
9
  },
10
10
  "modules": "commonjs"
11
11
  }
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # UNRELEASED
2
2
 
3
- -
3
+ -
4
+
5
+ # 1.2.0
6
+
7
+ - Release CLI v1
4
8
 
5
9
  # 1.0.3
6
10
 
Binary file
package/bin/intuned ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("../dist/commands/intuned-cli/main.js");
@@ -17,6 +17,7 @@ var _nanoid = require("nanoid");
17
17
  var _chalk = _interopRequireDefault(require("chalk"));
18
18
  var _runApi = require("../../common/runApi");
19
19
  var _tsNodeImport = require("../common/tsNodeImport");
20
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
20
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
22
  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); }
22
23
  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 && {}.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; }
@@ -95,7 +96,7 @@ async function executeCLI(apiName, mode, inputData, options) {
95
96
  _Logger.logger.info("This will only take an effect if this API run was part of a job.");
96
97
  }
97
98
  }
98
- _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) => {
99
+ _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").option("--authSessionParameters <authSessionParameters>", "parameters used to create the used auth session").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) => {
99
100
  let inputData = null;
100
101
  if (options.input) {
101
102
  inputData = await fs.readJSON(options.input);
@@ -104,11 +105,16 @@ _commander.program.description("run the user function in the cli for testing pur
104
105
  } else {
105
106
  inputData = {};
106
107
  }
108
+ let authSessionParametersJson = undefined;
109
+ if (!(0, _isNil.default)(options?.authSessionParameters)) {
110
+ authSessionParametersJson = JSON.parse(options.authSessionParameters);
111
+ }
107
112
  await (0, _asyncLocalStorage.runWithContext)({
108
113
  runEnvironment: _enums.RunEnvironment.IDE,
109
114
  extendedPayloads: [],
110
115
  runId: (0, _nanoid.nanoid)(),
111
- proxy: options.proxy
116
+ proxy: options.proxy,
117
+ getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
112
118
  }, () => executeCLI(apiName, mode, inputData, options));
113
119
  process.exit(0);
114
120
  });
@@ -9,15 +9,20 @@ var _dotenv = _interopRequireDefault(require("dotenv"));
9
9
  var _constants = require("../../common/constants");
10
10
  var _runApi = require("../../common/runApi");
11
11
  var _tsNodeImport = require("../common/tsNodeImport");
12
+ var _enums = require("../../runtime/enums");
13
+ var _nanoid = require("nanoid");
14
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
15
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
12
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
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); }
14
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 && {}.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
19
  _dotenv.default.config({
16
20
  path: `.env`
17
21
  });
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, {
22
+ _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").option("--authSessionParameters <authSessionParameters>", "parameters used to create the used auth session").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
19
23
  cdpAddress,
20
- authSessionPath
24
+ authSessionPath,
25
+ authSessionParameters
21
26
  }) => {
22
27
  const setting = await (0, _settings.getSettings)();
23
28
  if (!setting.authSessions.enabled) {
@@ -27,7 +32,16 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
27
32
  if (!fs.exists(checkFilePath)) {
28
33
  throw new Error("auth session check file not found");
29
34
  }
30
- const runApiResult = await (0, _runApi.runApi)({
35
+ let authSessionParametersJson = undefined;
36
+ if (!(0, _isNil.default)(authSessionParameters)) {
37
+ authSessionParametersJson = JSON.parse(authSessionParameters);
38
+ }
39
+ const runApiResult = await (0, _asyncLocalStorage.runWithContext)({
40
+ runEnvironment: _enums.RunEnvironment.IDE,
41
+ extendedPayloads: [],
42
+ runId: (0, _nanoid.nanoid)(),
43
+ getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
44
+ }, async () => await (0, _runApi.runApi)({
31
45
  automationFunction: {
32
46
  name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
33
47
  },
@@ -44,7 +58,7 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
44
58
  runCheck: false
45
59
  },
46
60
  importFunction: _tsNodeImport.tsNodeImport
47
- });
61
+ }));
48
62
  if (runApiResult.isErr()) {
49
63
  if (runApiResult.error instanceof _runApi.AutomationError) {
50
64
  throw runApiResult.error.error;
@@ -94,7 +94,8 @@ _commander.program.description("run auth session create").option("--cdpAddress <
94
94
  await (0, _asyncLocalStorage.runWithContext)({
95
95
  runEnvironment: _enums.RunEnvironment.IDE,
96
96
  extendedPayloads: [],
97
- runId: (0, _nanoid.nanoid)()
97
+ runId: (0, _nanoid.nanoid)(),
98
+ getAuthSessionParameters: async () => inputData
98
99
  }, runCreate);
99
100
  process.exit(0);
100
101
  });
@@ -32,7 +32,7 @@ _commander.program.description("Create an auth session").argument("[auth-session
32
32
  if (!createApiExists) {
33
33
  throw new Error("Auth session create API not implemented, please create it in the auth sessions specified directory");
34
34
  }
35
- const authSessionInput = (await (0, _utils2.loadParameters)(options === null || options === void 0 ? void 0 : options.input)) ?? {};
35
+ const authSessionInput = (await (0, _utils2.loadParameters)(options?.input)) ?? {};
36
36
  const session = await (0, _utils.runCreateApi)(authSessionInput);
37
37
  if (!session) {
38
38
  console.error(_chalk.default.red("Failed to create auth session."));
@@ -1,6 +1,6 @@
1
1
  import { StorageState } from "../../common/contextStorageStateHelpers";
2
2
  import { AuthSessionMetadata, AuthSessionType } from "../../common/cli/types";
3
- import * as playwright from "patchright";
3
+ import * as playwright from "playwright-core";
4
4
  export declare function isAuthEnabled(): Promise<boolean>;
5
5
  export declare function getAuthType(): Promise<AuthSessionType>;
6
6
  export declare function ensureRecorderURLs(): Promise<{
@@ -26,15 +26,14 @@ var _tsNodeImport = require("../common/tsNodeImport");
26
26
  var _promptly = require("promptly");
27
27
  var _utils = require("../../common/cli/utils");
28
28
  var _types = require("../../common/cli/types");
29
- var playwright = _interopRequireWildcard(require("patchright"));
29
+ var playwright = _interopRequireWildcard(require("playwright-core"));
30
30
  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); }
31
31
  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 && {}.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; }
32
32
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
33
  async function isAuthEnabled() {
34
34
  try {
35
- var _intunedJson$authSess;
36
35
  const intunedJson = await fs.readJSON(_path.default.join(process.cwd(), "Intuned.json"));
37
- return Boolean(intunedJson === null || intunedJson === void 0 || (_intunedJson$authSess = intunedJson.authSessions) === null || _intunedJson$authSess === void 0 ? void 0 : _intunedJson$authSess.enabled);
36
+ return Boolean(intunedJson?.authSessions?.enabled);
38
37
  } catch (error) {
39
38
  return false;
40
39
  }
@@ -1,4 +1,4 @@
1
- import { BrowserContext } from "patchright";
1
+ import { BrowserContext } from "playwright";
2
2
  export declare const REMOTE_DEBUGGING_PORT = 9222;
3
3
  export declare const getChromiumLaunchArgs: () => string[];
4
4
  export declare function startOrRestartBrowser(): Promise<void>;
@@ -9,7 +9,7 @@ exports.saveSession = saveSession;
9
9
  exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
10
10
  exports.startOrRestartBrowser = startOrRestartBrowser;
11
11
  var _child_process = require("child_process");
12
- var playwright = _interopRequireWildcard(require("patchright"));
12
+ var playwright = _interopRequireWildcard(require("playwright"));
13
13
  var fs = _interopRequireWildcard(require("fs-extra"));
14
14
  var _fileUtils = require("./utils/fileUtils");
15
15
  var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
@@ -32,10 +32,9 @@ function compileTypeScript(apiFilePath) {
32
32
  };
33
33
  }
34
34
  function findFirstExecutableLine(sourceFile) {
35
- var _defaultExportSymbol$;
36
35
  let functionBody;
37
36
  const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
38
- const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
37
+ const defaultExportDeclaration = defaultExportSymbol?.getDeclarations()?.[0];
39
38
  if (defaultExportDeclaration) {
40
39
  if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
41
40
  functionBody = defaultExportDeclaration.getBody();
@@ -45,9 +44,8 @@ function findFirstExecutableLine(sourceFile) {
45
44
  const expression = exportAssignment.getExpression();
46
45
  if (!expression) continue;
47
46
  if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
48
- var _sourceFile$getVariab;
49
47
  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));
48
+ const possiblyExportedFunction = sourceFile.getFunction(identifier) || sourceFile.getVariableStatement(identifier)?.getDescendants().find(node => node.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction);
51
49
  if (possiblyExportedFunction) {
52
50
  functionBody = possiblyExportedFunction.getBody();
53
51
  break;
@@ -228,13 +228,12 @@ const validateIntunedProject = async () => {
228
228
  name: "package.json",
229
229
  check: async () => {
230
230
  try {
231
- var _packageJson$dependen;
232
231
  const packageJsonPath = path.join(currentDirectoryToDeploy, "package.json");
233
232
  await fs.exists(packageJsonPath);
234
233
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, {
235
234
  encoding: "utf-8"
236
235
  }));
237
- const userCodePlaywrightVersion = (_packageJson$dependen = packageJson.dependencies) === null || _packageJson$dependen === void 0 ? void 0 : _packageJson$dependen.playwright;
236
+ const userCodePlaywrightVersion = packageJson.dependencies?.playwright;
238
237
  if (userCodePlaywrightVersion !== _constants.CURRENT_PLAYWRIGHT_VERSION) {
239
238
  return {
240
239
  isValid: false,
@@ -15,7 +15,6 @@ var _types = require("../../common/cli/types");
15
15
  var _chalk = _interopRequireDefault(require("chalk"));
16
16
  var _inquirer = _interopRequireDefault(require("inquirer"));
17
17
  var _path = _interopRequireDefault(require("path"));
18
- var _boxen = _interopRequireDefault(require("boxen"));
19
18
  var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
20
19
  var _constants = require("../../common/cli/constants");
21
20
  var _cliReadme = require("../../common/cli/cliReadme");
@@ -139,12 +138,7 @@ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
139
138
  await prepareCLITemplate(codeTree);
140
139
  await mountFiles(cwd, codeTree);
141
140
  console.log(_chalk.default.green("✓ Project files created"));
142
- console.log((0, _boxen.default)(_chalk.default.green(`✅ Project initialized successfully`) + `\n\n${_chalk.default.cyan("Project details:")}` + `\n• Template: ${_chalk.default.bold(templateId)}` + `\n• Directory: ${_chalk.default.bold(process.cwd())}` + `\n\n${_chalk.default.cyan("Next steps:")}` + `\n1. ${_chalk.default.bold("cd")} into your project directory (if not already there)` + `\n2. Run ${_chalk.default.bold("npm/yarn install")} to install dependencies` + `\n3. Develop, test and run your automation APIs`, {
143
- padding: 1,
144
- margin: 1,
145
- borderStyle: "round",
146
- borderColor: "green"
147
- }));
141
+ console.log(_chalk.default.cyan(`\n🎉 Project initialized successfully!`), _chalk.default.yellow(`\n\nRun ${_chalk.default.bold("yarn")} to install dependencies and start coding!`));
148
142
  }
149
143
  async function fetchProjectTemplate(templateId) {
150
144
  const baseUrl = (0, _utils.getBaseUrl)();
@@ -16,6 +16,7 @@ var _promises = require("timers/promises");
16
16
  var _jwtTokenManager = require("../../common/jwtTokenManager");
17
17
  var _formatZodError = require("../../common/formatZodError");
18
18
  var _neverthrow = require("neverthrow");
19
+ var _getAuthSessionParameters = require("../../common/backendFunctions/getAuthSessionParameters");
19
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
21
  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
22
  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 && {}.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; }
@@ -28,7 +29,8 @@ const startRunApiSchema = _zod.default.object({
28
29
  jobId: _zod.default.string().optional(),
29
30
  jobRunId: _zod.default.string().optional(),
30
31
  runId: _zod.default.string().optional(),
31
- queueId: _zod.default.string().optional()
32
+ queueId: _zod.default.string().optional(),
33
+ authSessionId: _zod.default.string().optional()
32
34
  }).optional()
33
35
  })
34
36
  });
@@ -65,14 +67,12 @@ function runAutomationCLI(importFunction) {
65
67
  let generator = null;
66
68
  const abortController = new AbortController();
67
69
  client.on("error", err => {
68
- var _generator;
69
- void ((_generator = generator) === null || _generator === void 0 ? void 0 : _generator.throw(err).catch(() => undefined));
70
+ void generator?.throw(err).catch(() => undefined);
70
71
  });
71
72
  const interruptSignalHandler = async () => {
72
- var _generator2;
73
73
  abortController.abort();
74
74
  await (0, _promises.setTimeout)(60_000);
75
- void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(new Error("Interrupted")).catch(() => undefined));
75
+ void generator?.throw(new Error("Interrupted")).catch(() => undefined);
76
76
  client.end();
77
77
  process.exit(1);
78
78
  };
@@ -124,6 +124,7 @@ function runAutomationCLI(importFunction) {
124
124
  });
125
125
  }
126
126
  },
127
+ getAuthSessionParameters: _getAuthSessionParameters.getAuthSessionParameters,
127
128
  ...(message.parameters.context ?? {}),
128
129
  proxy: getProxyUrlFromRunOptions(message.parameters.runOptions)
129
130
  };
@@ -212,7 +213,7 @@ function runAutomationCLI(importFunction) {
212
213
  _commander.program.parse(process.argv);
213
214
  }
214
215
  function getProxyUrlFromRunOptions(runOptions) {
215
- if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "standalone") return undefined;
216
+ if (runOptions?.environment !== "standalone") return undefined;
216
217
  const proxy = runOptions.proxy;
217
218
  if (!proxy) return undefined;
218
219
  const url = new URL(proxy.server);
@@ -0,0 +1 @@
1
+ export declare const attemptCommand: import("commander").Command;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptCommand = void 0;
7
+ var _command = require("./command");
8
+ const attemptCommand = exports.attemptCommand = _command.program.command("attempt").description("Execute an Intuned attempt");
@@ -0,0 +1 @@
1
+ export declare const attemptApiCommand: import("commander").Command;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptApiCommand = void 0;
7
+ var _api = require("../controller/api");
8
+ var _controller = require("../controller");
9
+ var _zod = require("zod");
10
+ var _types = require("./types");
11
+ var _helpers = require("./helpers");
12
+ var _attempt = require("./attempt.command");
13
+ const attemptApiCommandInputSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
14
+ authSession: _zod.z.string().optional(),
15
+ outputFile: _zod.z.string().optional()
16
+ })]);
17
+ const attemptApiCommand = exports.attemptApiCommand = _attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>.json").option("--proxy <url>", "proxy URL to use").option("--timeout <time>", "timeout - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").option("-o, --output-file <path>", "output file path").action((0, _helpers.withErrorLogging)(async (inputApiName, inputParameters, inputOptions) => {
18
+ const parseResult = attemptApiCommandInputSchema.safeParse([inputApiName, inputParameters, inputOptions]);
19
+ if (!parseResult.success) {
20
+ return (0, _helpers.logInvalidInput)(parseResult);
21
+ }
22
+ const [apiName, parameters, {
23
+ headless,
24
+ authSession,
25
+ outputFile,
26
+ timeout,
27
+ proxy
28
+ }] = parseResult.data;
29
+ await (0, _helpers.assertAuthConsistent)(authSession);
30
+ const inputData = await (0, _controller.loadParameters)(parameters);
31
+ await (0, _api.executeAttemptApiCLI)({
32
+ apiName,
33
+ inputData: inputData,
34
+ authSessionId: authSession,
35
+ proxy,
36
+ headless,
37
+ timeout,
38
+ outputFile
39
+ });
40
+ }));
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCommand: import("commander").Command;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCommand = void 0;
7
+ var _attempt = require("./attempt.command");
8
+ const attemptAuthSessionCommand = exports.attemptAuthSessionCommand = _attempt.attemptCommand.command("authsession").description("Manage authentication sessions");
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCheckCommand: import("commander").Command;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCheckCommand = void 0;
7
+ var _zod = require("zod");
8
+ var _authSession = require("../controller/authSession");
9
+ var _attempt_authsession = require("./attempt_authsession.command");
10
+ var _helpers = require("./helpers");
11
+ var _types = require("./types");
12
+ const attemptAuthSessionCheckSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _types.baseCommandOptionsSchema]);
13
+ const attemptAuthSessionCheckCommand = exports.attemptAuthSessionCheckCommand = _attempt_authsession.attemptAuthSessionCommand.command("check").description("Check an existing auth session").argument("<id>", "ID of the auth session to check").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputId, inputOptions) => {
14
+ const parseResult = attemptAuthSessionCheckSchema.safeParse([inputId, inputOptions]);
15
+ if (!parseResult.success) {
16
+ return (0, _helpers.logInvalidInput)(parseResult);
17
+ }
18
+ const [id, options] = parseResult.data;
19
+ await (0, _helpers.assertAuthEnabled)();
20
+ await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
21
+ id,
22
+ ...options
23
+ });
24
+ }));
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCreateCommand: import("commander").Command;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCreateCommand = void 0;
7
+ var _controller = require("../controller");
8
+ var _zod = require("zod");
9
+ var _authSession = require("../controller/authSession");
10
+ var _attempt_authsession = require("./attempt_authsession.command");
11
+ var _helpers = require("./helpers");
12
+ var _types = require("./types");
13
+ const attemptAuthSessionCreateInputSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
14
+ id: _zod.z.string().optional()
15
+ })]);
16
+ const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = _attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to ./auth-session-instances/[current timestamp].json").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputParameters, inputOptions) => {
17
+ const parseResult = attemptAuthSessionCreateInputSchema.safeParse([inputParameters, inputOptions]);
18
+ if (!parseResult.success) {
19
+ return (0, _helpers.logInvalidInput)(parseResult);
20
+ }
21
+ const [parameters, {
22
+ headless,
23
+ id,
24
+ timeout,
25
+ proxy
26
+ }] = parseResult.data;
27
+ await (0, _helpers.assertAuthEnabled)();
28
+ const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
29
+ await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
30
+ id,
31
+ input: authSessionInput,
32
+ headless,
33
+ timeout,
34
+ proxy
35
+ });
36
+ }));
@@ -0,0 +1 @@
1
+ export declare const buildCommand: import("commander").Command;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildCommand = void 0;
7
+ var _command = require("./command");
8
+ var _build = require("../controller/build");
9
+ var _helpers = require("./helpers");
10
+ const buildCommand = exports.buildCommand = _command.program.command("build").description("Build Intuned project").action((0, _helpers.withErrorLogging)(async () => {
11
+ await (0, _build.runBuild)();
12
+ }));
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const program: Command;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.program = void 0;
7
+ var _commander = require("commander");
8
+ const program = exports.program = new _commander.Command();
9
+ program.name("intuned").description("Intuned CLI for creating, developing and deploying Intuned projects").version("1.0.0").enablePositionalOptions(true);
@@ -0,0 +1 @@
1
+ export declare const deployCommand: import("commander").Command;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deployCommand = void 0;
7
+ var _command = require("./command");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _deploy = require("../controller/deploy");
10
+ var _utils = require("../../../common/cli/utils");
11
+ var _zod = require("zod");
12
+ var _helpers = require("./helpers");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ _dotenv.default.config({
15
+ path: `.env`
16
+ });
17
+ const deployCommandSchema = _zod.z.tuple([_zod.z.union([_zod.z.string(), _zod.z.undefined()]), _zod.z.object({
18
+ workspaceId: _zod.z.string().optional(),
19
+ apiKey: _zod.z.string().optional()
20
+ })]);
21
+ const deployCommand = exports.deployCommand = _command.program.command("deploy").description("Deploy an Intuned project to the platform").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action((0, _helpers.withErrorLogging)(async (inputProjectName, inputOptions) => {
22
+ const parseResult = deployCommandSchema.safeParse([inputProjectName, inputOptions]);
23
+ if (!parseResult.success) {
24
+ return (0, _helpers.logInvalidInput)(parseResult);
25
+ }
26
+ const [projectName, options] = parseResult.data;
27
+ const {
28
+ isValid,
29
+ errorMessage
30
+ } = await (0, _deploy.validateIntunedProject)();
31
+ if (!isValid) {
32
+ const message = `^r^+Project to be deployed is not a valid Intuned project:^:^R ${errorMessage}:\n`;
33
+ throw new _helpers.CLIError(message, {
34
+ autoColor: false
35
+ });
36
+ }
37
+ const _projectName = projectName || (await (0, _utils.getSettingIntunedJSON)("projectName"));
38
+ if (!_projectName) {
39
+ throw new _helpers.CLIError("Project name is required");
40
+ }
41
+ const projectNameValidation = (0, _deploy.validateProjectName)(_projectName);
42
+ if (!projectNameValidation.isValid) {
43
+ throw new _helpers.CLIError(projectNameValidation.errorMessage);
44
+ }
45
+ const auth = await (0, _utils.getAuthCredentials)(options);
46
+ await (0, _deploy.runDeployProject)(_projectName, auth);
47
+ }));
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
3
+ export declare class CLIError extends Error {
4
+ autoColor: boolean;
5
+ constructor(message: string, options?: {
6
+ autoColor?: boolean;
7
+ });
8
+ }
9
+ export declare class CLIAssertionError extends CLIError {
10
+ constructor(message: string, options?: {
11
+ autoColor?: boolean;
12
+ });
13
+ }
14
+ export declare function logInvalidInput(result: z.SafeParseError<unknown>): void;
15
+ export declare function assertAuthEnabled(): Promise<void>;
16
+ export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
17
+ export declare function withErrorLogging<T extends any[]>(fn: (...args: T) => Promise<unknown>): (...args: T) => Promise<never>;
18
+ export declare function parseUrlProxy(proxyUrl: string): {
19
+ password: string;
20
+ username: string;
21
+ server: string;
22
+ } | undefined;
23
+ export declare function withTimeout<R, P extends any[]>(fn: (...args: P) => Promise<R>, timeout: number): (...args: P) => Promise<R>;
24
+ export declare function withCLIContext<R, P extends any[]>(fn: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
25
+ export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
26
+ export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;