@intuned/runtime-dev 1.2.0-cli.4 → 1.2.0-cli.6

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 (86) hide show
  1. package/dist/commands/api/run.js +2 -1
  2. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  3. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +1 -1
  4. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  5. package/dist/commands/intuned-cli/commands/build.command.js +1 -1
  6. package/dist/commands/intuned-cli/commands/deploy.command.js +3 -4
  7. package/dist/commands/intuned-cli/commands/init.command.js +1 -1
  8. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  9. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -1
  10. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
  11. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +1 -1
  12. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +1 -1
  13. package/dist/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +2 -4
  14. package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +22 -5
  15. package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
  16. package/dist/{common/cli/cliReadme.js → commands/intuned-cli/constants/readme.js} +13 -15
  17. package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
  18. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
  19. package/dist/commands/intuned-cli/controller/api.d.ts +25 -0
  20. package/dist/commands/intuned-cli/controller/api.js +28 -31
  21. package/dist/commands/intuned-cli/controller/authSession.d.ts +176 -10
  22. package/dist/commands/intuned-cli/controller/authSession.js +116 -126
  23. package/dist/commands/intuned-cli/controller/build.js +1 -1
  24. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -1
  25. package/dist/commands/intuned-cli/controller/deploy.js +9 -11
  26. package/dist/commands/intuned-cli/controller/index.js +5 -4
  27. package/dist/commands/intuned-cli/controller/init.d.ts +1 -1
  28. package/dist/commands/intuned-cli/controller/init.js +12 -15
  29. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  30. package/dist/commands/intuned-cli/helpers/api.js +19 -0
  31. package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
  32. package/dist/commands/intuned-cli/helpers/auth.js +129 -0
  33. package/dist/{common/cli/utils.d.ts → commands/intuned-cli/helpers/backend.d.ts} +0 -1
  34. package/dist/commands/intuned-cli/helpers/backend.js +26 -0
  35. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  36. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  37. package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
  38. package/dist/commands/intuned-cli/helpers/errors.js +55 -0
  39. package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
  40. package/dist/commands/intuned-cli/helpers/index.js +115 -0
  41. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
  42. package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -20
  43. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  44. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  45. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  46. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  47. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  48. package/dist/commands/intuned-cli/helpers/validation.js +12 -0
  49. package/dist/commands/intuned-cli/main.js +4 -1
  50. package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -32
  51. package/dist/common/runApi/types.d.ts +140 -9
  52. package/dist/common/runApi/types.js +28 -27
  53. package/package.json +2 -7
  54. package/tsconfig.json +2 -1
  55. package/bin/check-auth-session +0 -3
  56. package/bin/cli-build +0 -3
  57. package/bin/create-auth-session +0 -3
  58. package/bin/deploy +0 -3
  59. package/bin/init +0 -3
  60. package/bin/run-api +0 -3
  61. package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
  62. package/dist/commands/cli-auth-sessions/check.js +0 -40
  63. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  64. package/dist/commands/cli-auth-sessions/create.js +0 -53
  65. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  66. package/dist/commands/cli-auth-sessions/utils.js +0 -284
  67. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  68. package/dist/commands/cli-build/cli-build.js +0 -20
  69. package/dist/commands/deploy/deploy.d.ts +0 -2
  70. package/dist/commands/deploy/deploy.js +0 -47
  71. package/dist/commands/deploy/utils.d.ts +0 -16
  72. package/dist/commands/deploy/utils.js +0 -407
  73. package/dist/commands/init/init.d.ts +0 -2
  74. package/dist/commands/init/init.js +0 -22
  75. package/dist/commands/init/utils.d.ts +0 -11
  76. package/dist/commands/init/utils.js +0 -175
  77. package/dist/commands/intuned-cli/commands/helpers.d.ts +0 -28
  78. package/dist/commands/intuned-cli/commands/helpers.js +0 -138
  79. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  80. package/dist/commands/run-api-cli/run-api.js +0 -57
  81. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  82. package/dist/commands/run-api-cli/utils.js +0 -144
  83. package/dist/common/cli/cliReadme.d.ts +0 -1
  84. /package/dist/commands/intuned-cli/{terminal.d.ts → helpers/terminal.d.ts} +0 -0
  85. /package/dist/commands/intuned-cli/{terminal.js → helpers/terminal.js} +0 -0
  86. /package/dist/{common/cli → commands/intuned-cli}/types.js +0 -0
@@ -18,6 +18,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
18
18
  var _runApi = require("../../common/runApi");
19
19
  var _tsNodeImport = require("../common/tsNodeImport");
20
20
  var _isNil = _interopRequireDefault(require("lodash/isNil"));
21
+ var _constants = require("../../common/constants");
21
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
23
  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); }
23
24
  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; }
@@ -40,7 +41,7 @@ async function executeCLI(apiName, mode, inputData, options) {
40
41
  }
41
42
  const runApiResult = await (0, _runApi.runApi)({
42
43
  automationFunction: {
43
- name: `api/${apiName}`,
44
+ name: `${_constants.API_FOLDER_NAME}/${apiName}`,
44
45
  params: inputData
45
46
  },
46
47
  auth: authSessionPathToUse ? {
@@ -8,7 +8,7 @@ var _api = require("../controller/api");
8
8
  var _controller = require("../controller");
9
9
  var _zod = require("zod");
10
10
  var _types = require("./types");
11
- var _helpers = require("./helpers");
11
+ var _helpers = require("../helpers");
12
12
  var _attempt = require("./attempt.command");
13
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
14
  authSession: _zod.z.string().optional(),
@@ -7,7 +7,7 @@ exports.attemptAuthSessionCheckCommand = void 0;
7
7
  var _zod = require("zod");
8
8
  var _authSession = require("../controller/authSession");
9
9
  var _attempt_authsession = require("./attempt_authsession.command");
10
- var _helpers = require("./helpers");
10
+ var _helpers = require("../helpers");
11
11
  var _types = require("./types");
12
12
  const attemptAuthSessionCheckSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _types.baseCommandOptionsSchema]);
13
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) => {
@@ -8,7 +8,7 @@ var _controller = require("../controller");
8
8
  var _zod = require("zod");
9
9
  var _authSession = require("../controller/authSession");
10
10
  var _attempt_authsession = require("./attempt_authsession.command");
11
- var _helpers = require("./helpers");
11
+ var _helpers = require("../helpers");
12
12
  var _types = require("./types");
13
13
  const attemptAuthSessionCreateInputSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
14
14
  id: _zod.z.string().optional()
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.buildCommand = void 0;
7
7
  var _command = require("./command");
8
8
  var _build = require("../controller/build");
9
- var _helpers = require("./helpers");
9
+ var _helpers = require("../helpers");
10
10
  const buildCommand = exports.buildCommand = _command.program.command("build").description("Build Intuned project").action((0, _helpers.withErrorLogging)(async () => {
11
11
  await (0, _build.runBuild)();
12
12
  }));
@@ -7,9 +7,8 @@ exports.deployCommand = void 0;
7
7
  var _command = require("./command");
8
8
  var _dotenv = _interopRequireDefault(require("dotenv"));
9
9
  var _deploy = require("../controller/deploy");
10
- var _utils = require("../../../common/cli/utils");
10
+ var _helpers = require("../helpers");
11
11
  var _zod = require("zod");
12
- var _helpers = require("./helpers");
13
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
13
  _dotenv.default.config({
15
14
  path: `.env`
@@ -34,7 +33,7 @@ const deployCommand = exports.deployCommand = _command.program.command("deploy")
34
33
  autoColor: false
35
34
  });
36
35
  }
37
- const _projectName = projectName || (await (0, _utils.getSettingIntunedJSON)("projectName"));
36
+ const _projectName = projectName || (await (0, _helpers.getSettingIntunedJSON)("projectName"));
38
37
  if (!_projectName) {
39
38
  throw new _helpers.CLIError("Project name is required");
40
39
  }
@@ -42,6 +41,6 @@ const deployCommand = exports.deployCommand = _command.program.command("deploy")
42
41
  if (!projectNameValidation.isValid) {
43
42
  throw new _helpers.CLIError(projectNameValidation.errorMessage);
44
43
  }
45
- const auth = await (0, _utils.getAuthCredentials)(options);
44
+ const auth = await (0, _helpers.getAuthCredentials)(options);
46
45
  await (0, _deploy.runDeployProject)(_projectName, auth);
47
46
  }));
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.initCommand = void 0;
7
7
  var _init = require("../controller/init");
8
8
  var _command = require("./command");
9
- var _helpers = require("./helpers");
9
+ var _helpers = require("../helpers");
10
10
  const initCommand = exports.initCommand = _command.program.command("init").description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").action((0, _helpers.withErrorLogging)(async templateName => {
11
11
  const template = await (0, _init.selectTemplate)(templateName);
12
12
  const isTargetDirectoryEmpty = await (0, _init.checkEmptyDirectory)();
@@ -9,7 +9,7 @@ var _api = require("../controller/api");
9
9
  var _controller = require("../controller");
10
10
  var _zod = require("zod");
11
11
  var _types = require("./types");
12
- var _helpers = require("./helpers");
12
+ var _helpers = require("../helpers");
13
13
  const runApiCommandInputSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
14
14
  retries: _zod.z.coerce.number().default(1),
15
15
  authSession: _zod.z.string().optional(),
@@ -1,4 +1,3 @@
1
- /// <reference types="ms" />
2
1
  export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
3
2
  proxy: import("zod").ZodOptional<import("zod").ZodString>;
4
3
  headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
@@ -8,7 +8,7 @@ var _controller = require("../controller");
8
8
  var _zod = require("zod");
9
9
  var _authSession = require("../controller/authSession");
10
10
  var _run_authsession = require("./run_authsession.command");
11
- var _helpers = require("./helpers");
11
+ var _helpers = require("../helpers");
12
12
  const runAuthSessionCreateInputSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
13
13
  id: _zod.z.string().optional()
14
14
  })]);
@@ -8,7 +8,7 @@ var _controller = require("../controller");
8
8
  var _zod = require("zod");
9
9
  var _authSession = require("../controller/authSession");
10
10
  var _run_authsession = require("./run_authsession.command");
11
- var _helpers = require("./helpers");
11
+ var _helpers = require("../helpers");
12
12
  const runAuthSessionUpdateSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
13
13
  parameters: _zod.z.string().optional()
14
14
  })]);
@@ -7,7 +7,7 @@ exports.runAuthSessionValidateCommand = void 0;
7
7
  var _zod = require("zod");
8
8
  var _authSession = require("../controller/authSession");
9
9
  var _run_authsession = require("./run_authsession.command");
10
- var _helpers = require("./helpers");
10
+ var _helpers = require("../helpers");
11
11
  const runAuthSessionValidateSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
12
12
  autoRecreate: _zod.z.boolean().default(true)
13
13
  })]);
@@ -10,15 +10,12 @@ export declare const userCLIScripts: {
10
10
  "pre-publish": string;
11
11
  start: string;
12
12
  "run-api": string;
13
- "cli-build": string;
14
- deploy: string;
15
- "cli-create-auth-session": string;
16
- "cli-check-auth-session": string;
17
13
  "browser-save-state": string;
18
14
  "auth-session-check": string;
19
15
  "auth-session-create": string;
20
16
  "auth-session-refresh": string;
21
17
  "auth-session-load": string;
18
+ intuned: string;
22
19
  };
23
20
  export declare const tsConfigCli: {
24
21
  compilerOptions: {
@@ -33,3 +30,4 @@ export declare const tsConfigCli: {
33
30
  include: string[];
34
31
  exclude: string[];
35
32
  };
33
+ export * from "./readme";
@@ -3,8 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ CURRENT_PLAYWRIGHT_VERSION: true,
8
+ ProjectDeploymentStatus: true,
9
+ PROJECT_DEPLOY_TIMEOUT: true,
10
+ PROJECT_DEPLOY_CHECK_PERIOD: true,
11
+ userCLIScripts: true,
12
+ tsConfigCli: true
13
+ };
6
14
  exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_CHECK_PERIOD = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
7
15
  var _ms = _interopRequireDefault(require("ms"));
16
+ var _readme = require("./readme");
17
+ Object.keys(_readme).forEach(function (key) {
18
+ if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
+ if (key in exports && exports[key] === _readme[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _readme[key];
25
+ }
26
+ });
27
+ });
8
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
29
  const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
10
30
  const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
@@ -18,15 +38,12 @@ const userCLIScripts = exports.userCLIScripts = {
18
38
  "pre-publish": "intuned-ts-check && intuned-build",
19
39
  start: "node ./output/bundle_v2.js",
20
40
  "run-api": "run-api",
21
- "cli-build": "cli-build",
22
- deploy: "deploy",
23
- "cli-create-auth-session": "create-auth-session",
24
- "cli-check-auth-session": "check-auth-session",
25
41
  "browser-save-state": "intuned-browser-save-state",
26
42
  "auth-session-check": "intuned-auth-session-check",
27
43
  "auth-session-create": "intuned-auth-session-create",
28
44
  "auth-session-refresh": "intuned-auth-session-refresh",
29
- "auth-session-load": "intuned-auth-session-load"
45
+ "auth-session-load": "intuned-auth-session-load",
46
+ intuned: "intuned"
30
47
  };
31
48
  const tsConfigCli = exports.tsConfigCli = {
32
49
  compilerOptions: {
@@ -0,0 +1 @@
1
+ export declare const readme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a variety of commands to develop your Intuned projects locally\n\n## Development Commands\n\nFor each command, add `--help` to see more details and options.\n\n### Initialize a Project\n`npx -p @intuned/runtime intuned init`\n\n### Run an API\n`yarn intuned run api <api-name> <parameters>`\nor\n`npm run intuned run api <api-name> <parameters>`\n\n\n### Build a Project\n`yarn intuned build`\n\n### Deploy a Project\n`yarn intuned deploy [project-name]`\nor\n`npm run intuned deploy [project-name]`\n\n\n\n### Create an auth session\n`yarn intuned run authsession create <parameters>`\nor\n`npm run intuned run authsession create <parameters>`\n\n\n\n### Validate an auth session\n`yarn intuned run authsession validate <auth-session-name>`\nor\n`npm run intuned run authsession validate <auth-session-name>`\n\n## Configuration\n\n### Environment Variables and Settings\n- `workspaceId`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))\n - Set in `intuned.json` file under the `workspaceId` property\n - Or provide via CLI with `--workspace-id` flag during deployment\n \n- `projectName`: The name of your Intuned project\n - Set in `intuned.json` file under the `projectName` property\n - Or override via command line when deploying with `yarn intuned deploy my-project-name` or `npm run intuned deploy my-project-name`\n\n- `INTUNED_API_KEY`: Your Intuned API key\n - Set as an environment variable: `export INTUNED_API_KEY=your_api_key_here`\n - Or include in your .env file for development\n - Or provide via CLI with `--api-key` flag during deployment\n\n## Project Structure\n\n### Generated Artifacts\n- `./intuned.json`: Project configuration file\n- `./api`: Folder containing API implementation files\n- `./auth-sessions`: Folder containing auth-session APIs if you use them\n- `./auth-sessions-instances`: Folder containing auth session instances\n\n## Types of auth sessions\n- `MANUAL`: Manual auth session, records the session using a recorder and stores it in the `auth-sessions-instances` folder\n- `API`: Auth session created via create API, stores the session in the `auth-sessions-instances` folder\n\n### Notes\n- You can use either `yarn` or `npm run` to execute commands\n- All commands must be run from the project root directory\n- Verify you're in the correct location by confirming the presence of package.json and intuned.json\n- Running commands from subdirectories may result in errors\n- You can manage your deployed projects through the Intuned platform\n- \u26A0\uFE0F WARNING: Changes to TS Config may break some Intuned functionalities\n";
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.cliReadme = void 0;
7
- const cliReadme = exports.cliReadme = `# Intuned CLI
6
+ exports.readme = void 0;
7
+ const readme = exports.readme = `# Intuned CLI
8
8
  ## Introduction
9
9
  The Intuned CLI exposes a variety of commands to develop your Intuned projects locally
10
10
 
@@ -13,12 +13,12 @@ The Intuned CLI exposes a variety of commands to develop your Intuned projects l
13
13
  For each command, add \`--help\` to see more details and options.
14
14
 
15
15
  ### Initialize a Project
16
- \`npx -p @intuned/runtime init\`
16
+ \`npx -p @intuned/runtime intuned init\`
17
17
 
18
18
  ### Run an API
19
- \`yarn intuned run <api-name>\`
19
+ \`yarn intuned run api <api-name> <parameters>\`
20
20
  or
21
- \`npm run intuned run <api-name>\`
21
+ \`npm run intuned run api <api-name> <parameters>\`
22
22
 
23
23
 
24
24
  ### Build a Project
@@ -32,16 +32,16 @@ or
32
32
 
33
33
 
34
34
  ### Create an auth session
35
- \`yarn intuned authsession create <parameters>\`
35
+ \`yarn intuned run authsession create <parameters>\`
36
36
  or
37
- \`npm intuned authsession create <parameters>\`
37
+ \`npm run intuned run authsession create <parameters>\`
38
38
 
39
39
 
40
40
 
41
41
  ### Validate an auth session
42
- \`yarn intuned authsession validate <auth-session-name>\`
42
+ \`yarn intuned run authsession validate <auth-session-name>\`
43
43
  or
44
- \`npm intuned authsession validate <auth-session-name>\`
44
+ \`npm run intuned run authsession validate <auth-session-name>\`
45
45
 
46
46
  ## Configuration
47
47
 
@@ -52,8 +52,8 @@ or
52
52
 
53
53
  - \`projectName\`: The name of your Intuned project
54
54
  - Set in \`intuned.json\` file under the \`projectName\` property
55
- - Or override via command line when deploying with \`yarn deploy my-project-name\` or \`npm run deploy my-project-name\`
56
-
55
+ - Or override via command line when deploying with \`yarn intuned deploy my-project-name\` or \`npm run intuned deploy my-project-name\`
56
+
57
57
  - \`INTUNED_API_KEY\`: Your Intuned API key
58
58
  - Set as an environment variable: \`export INTUNED_API_KEY=your_api_key_here\`
59
59
  - Or include in your .env file for development
@@ -64,9 +64,7 @@ or
64
64
  ### Generated Artifacts
65
65
  - \`./intuned.json\`: Project configuration file
66
66
  - \`./api\`: Folder containing API implementation files
67
- - \`./auth-sessions\`: Folder containing auth APIs
68
- - \`./parameters\`: Folder for API parameters injection
69
- - \`./output\`: Folder containing generated output files
67
+ - \`./auth-sessions\`: Folder containing auth-session APIs if you use them
70
68
  - \`./auth-sessions-instances\`: Folder containing auth session instances
71
69
 
72
70
  ## Types of auth sessions
@@ -79,5 +77,5 @@ or
79
77
  - Verify you're in the correct location by confirming the presence of package.json and intuned.json
80
78
  - Running commands from subdirectories may result in errors
81
79
  - You can manage your deployed projects through the Intuned platform
82
- - WARNING: ⚠️ Changes to TS Config may break some Intuned functionalities
80
+ - ⚠️ WARNING: Changes to TS Config may break some Intuned functionalities
83
81
  `;
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _api = require("../api");
5
+ var _authSession = require("../authSession");
6
+ var _helpers = require("../../helpers");
7
+ var _neverthrow = require("neverthrow");
8
+ var _runApi = require("../../../../common/runApi");
9
+ var _fsExtra = require("fs-extra");
10
+ function getTerminal() {
11
+ return new Proxy(() => ({}), {
12
+ get: () => getTerminal(),
13
+ apply: () => ({})
14
+ });
15
+ }
16
+ _vitest.vi.mock("fs-extra", () => ({
17
+ writeJSON: _vitest.vi.fn()
18
+ }));
19
+ _vitest.vi.mock("../authSession", async importOriginal => {
20
+ const original = await importOriginal();
21
+ return {
22
+ ...original,
23
+ executeRunValidateAuthSessionCLI: _vitest.vi.fn()
24
+ };
25
+ });
26
+ _vitest.vi.mock("../../../../common/runApi", async importOriginal => {
27
+ const original = await importOriginal();
28
+ return {
29
+ ...original,
30
+ runApi: _vitest.vi.fn().mockImplementation(() => (0, _neverthrow.ok)({}))
31
+ };
32
+ });
33
+ _vitest.vi.mock("../../helpers/terminal", () => ({
34
+ terminal: getTerminal()
35
+ }));
36
+ _vitest.vi.mock("../../helpers", async importOriginal => {
37
+ const original = await importOriginal();
38
+ return {
39
+ ...original,
40
+ terminal: getTerminal(),
41
+ assertApiFileExists: _vitest.vi.fn(),
42
+ withCLIContext: _vitest.vi.fn(fn => fn()),
43
+ withTimeout: _vitest.vi.fn(fn => fn()),
44
+ parseUrlProxy: _vitest.vi.fn(),
45
+ registerGetAuthSessionParameters: _vitest.vi.fn()
46
+ };
47
+ });
48
+ (0, _vitest.describe)("API controller", () => {
49
+ (0, _vitest.beforeEach)(() => {
50
+ _vitest.vi.clearAllMocks();
51
+ });
52
+ (0, _vitest.describe)("attemptApi", () => {
53
+ (0, _vitest.it)("calls timeout middleware with timeout", async () => {
54
+ await (0, _api._attemptApi)({
55
+ apiName: "testApi",
56
+ inputData: {},
57
+ headless: false,
58
+ timeout: 6000
59
+ });
60
+ (0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
61
+ });
62
+ (0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
63
+ _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
64
+ await (0, _api._attemptApi)({
65
+ apiName: "testApi",
66
+ inputData: "inputData",
67
+ headless: "headless",
68
+ auth: "auth",
69
+ proxy: "proxy",
70
+ timeout: 999999999
71
+ });
72
+ (0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
73
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
74
+ automationFunction: {
75
+ name: "api/testApi",
76
+ params: "inputData"
77
+ },
78
+ runOptions: {
79
+ headless: "headless",
80
+ environment: "standalone",
81
+ proxy: "parsed-proxy"
82
+ },
83
+ auth: {
84
+ session: {
85
+ type: "state",
86
+ state: "auth"
87
+ },
88
+ runCheck: false
89
+ },
90
+ importFunction: _vitest.expect.anything()
91
+ }));
92
+ });
93
+ (0, _vitest.it)("returns the result and extended payloads if runApi succeeds", async () => {
94
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.ok)({
95
+ result: "result",
96
+ extendedPayloads: "extendedPayloads"
97
+ }));
98
+ const result = await (0, _api._attemptApi)({
99
+ apiName: "testApi",
100
+ inputData: "inputData",
101
+ headless: "headless",
102
+ auth: "auth",
103
+ timeout: 999999999
104
+ });
105
+ (0, _vitest.expect)(result).toEqual({
106
+ result: "result",
107
+ payloadToAppend: "extendedPayloads"
108
+ });
109
+ });
110
+ (0, _vitest.it)("throws the error runApi fails with an error", async () => {
111
+ const error = new Error("runApi failed");
112
+ _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
113
+ await (0, _vitest.expect)((0, _api._attemptApi)({
114
+ apiName: "testApi",
115
+ inputData: "inputData",
116
+ headless: "headless",
117
+ auth: "auth",
118
+ timeout: 999999999
119
+ })).rejects.toThrow(error);
120
+ });
121
+ });
122
+ (0, _vitest.describe)("executeRunApiCLI", () => {
123
+ (0, _vitest.it)("calls attemptApi once if success", async () => {
124
+ await (0, _api.executeRunApiCLI)({
125
+ apiName: "testApi",
126
+ inputData: {},
127
+ retries: 3
128
+ });
129
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
130
+ });
131
+ (0, _vitest.it)("stops retrying after max retries", async () => {
132
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
133
+ await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
134
+ apiName: "testApi",
135
+ inputData: {},
136
+ retries: 10
137
+ })).rejects.toThrow(_helpers.CLIError);
138
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
139
+ });
140
+ (0, _vitest.it)("stops retrying on non-automation errors", async () => {
141
+ _vitest.vi.mocked(_runApi.runApi).mockRejectedValue(new Error("runApi failed"));
142
+ await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
143
+ apiName: "testApi",
144
+ inputData: {},
145
+ retries: 3
146
+ })).rejects.toThrow("runApi failed");
147
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
148
+ });
149
+ (0, _vitest.it)("stops retrying on success", async () => {
150
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
151
+ result: "success"
152
+ }));
153
+ await (0, _api.executeRunApiCLI)({
154
+ apiName: "testApi",
155
+ inputData: {},
156
+ retries: 10
157
+ });
158
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
159
+ });
160
+ (0, _vitest.it)("validates auth session before each attempt if provided", async () => {
161
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
162
+ result: "success"
163
+ }));
164
+ await (0, _api.executeRunApiCLI)({
165
+ apiName: "testApi",
166
+ inputData: {},
167
+ authSession: {
168
+ id: "authSessionId",
169
+ autoRecreate: false,
170
+ checkRetries: 1,
171
+ createRetries: 2
172
+ },
173
+ retries: 10
174
+ });
175
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toBeCalledTimes(2);
176
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
177
+ id: "authSessionId",
178
+ autoRecreate: false,
179
+ checkRetries: 1,
180
+ createRetries: 2
181
+ });
182
+ });
183
+ (0, _vitest.it)("doesn't validate auth session if not provided", async () => {
184
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
185
+ result: "success"
186
+ }));
187
+ await (0, _api.executeRunApiCLI)({
188
+ apiName: "testApi",
189
+ inputData: {},
190
+ retries: 1
191
+ });
192
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).not.toHaveBeenCalled();
193
+ });
194
+ (0, _vitest.it)("fails if auth session is provided but not valid", async () => {
195
+ _vitest.vi.mocked(_authSession.executeRunValidateAuthSessionCLI).mockRejectedValue(new _helpers.CLIError("Auth session validation failed"));
196
+ await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
197
+ apiName: "testApi",
198
+ inputData: {},
199
+ authSession: {
200
+ id: "authSessionId",
201
+ autoRecreate: false,
202
+ checkRetries: 1,
203
+ createRetries: 2
204
+ },
205
+ retries: 10
206
+ })).rejects.toThrow("Auth session validation failed");
207
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
208
+ id: "authSessionId",
209
+ autoRecreate: false,
210
+ checkRetries: 1,
211
+ createRetries: 2
212
+ });
213
+ (0, _vitest.expect)(_runApi.runApi).not.toHaveBeenCalled();
214
+ });
215
+ (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
216
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
217
+ result: "result",
218
+ extendedPayloads: "extendedPayloads"
219
+ }));
220
+ await (0, _api.executeRunApiCLI)({
221
+ apiName: "testApi",
222
+ inputData: {},
223
+ outputFile: "output.json",
224
+ retries: 1
225
+ });
226
+ (0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
227
+ result: "result",
228
+ extendedPayloads: "extendedPayloads"
229
+ }, _vitest.expect.anything());
230
+ });
231
+ (0, _vitest.it)("asserts API file exists", async () => {
232
+ await (0, _api.executeRunApiCLI)({
233
+ apiName: "testApi",
234
+ inputData: {},
235
+ retries: 1
236
+ });
237
+ (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
238
+ });
239
+ });
240
+ (0, _vitest.describe)("executeAttemptApiCLI", () => {
241
+ (0, _vitest.it)("calls attemptApi once", async () => {
242
+ await (0, _api.executeAttemptApiCLI)({
243
+ apiName: "testApi",
244
+ inputData: {},
245
+ retries: 3
246
+ });
247
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
248
+ _vitest.vi.mocked(_runApi.runApi).mockReset();
249
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
250
+ await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
251
+ apiName: "testApi",
252
+ inputData: {}
253
+ })).rejects.toThrow(_runApi.AutomationError);
254
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
255
+ });
256
+ (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
257
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
258
+ result: "result",
259
+ extendedPayloads: "extendedPayloads"
260
+ }));
261
+ await (0, _api.executeAttemptApiCLI)({
262
+ apiName: "testApi",
263
+ inputData: {},
264
+ outputFile: "output.json"
265
+ });
266
+ (0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
267
+ result: "result",
268
+ extendedPayloads: "extendedPayloads"
269
+ }, _vitest.expect.anything());
270
+ });
271
+ (0, _vitest.it)("asserts API file exists", async () => {
272
+ await (0, _api.executeRunApiCLI)({
273
+ apiName: "testApi",
274
+ inputData: {},
275
+ retries: 1
276
+ });
277
+ (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
278
+ });
279
+ });
280
+ });