@intuned/runtime-dev 1.3.17-ws.0 → 1.3.17

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 (119) hide show
  1. package/.babelrc +6 -0
  2. package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
  3. package/InterfaceTemplate/index.playwright.ts +1 -1
  4. package/bin/intuned +0 -0
  5. package/bin/intuned-interface +7 -0
  6. package/dist/commands/api/run.js +7 -11
  7. package/dist/commands/auth-sessions/load.js +2 -2
  8. package/dist/commands/auth-sessions/run-check.js +8 -8
  9. package/dist/commands/auth-sessions/run-create.js +6 -6
  10. package/dist/commands/build.js +2 -3
  11. package/dist/commands/common/browserUtils.d.ts +3 -3
  12. package/dist/commands/common/browserUtils.js +3 -4
  13. package/dist/commands/common/getFirstLineNumber.test.js +1 -2
  14. package/dist/commands/common/projectExclusions.js +1 -1
  15. package/dist/commands/common/tsNodeImport.d.ts +1 -1
  16. package/dist/commands/common/tsNodeImport.js +10 -2
  17. package/dist/commands/common/utils/fileUtils.js +1 -2
  18. package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
  19. package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
  20. package/dist/commands/common/utils/template.js +1 -2
  21. package/dist/commands/interface/run.js +23 -49
  22. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  23. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +1 -1
  24. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -2
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  26. package/dist/commands/intuned-cli/commands/authsession.command.js +1 -1
  27. package/dist/commands/intuned-cli/commands/authsession_record.command.js +1 -1
  28. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
  29. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
  30. package/dist/commands/intuned-cli/commands/deploy.command.js +13 -9
  31. package/dist/commands/intuned-cli/commands/index.d.ts +2 -2
  32. package/dist/commands/intuned-cli/commands/index.js +15 -15
  33. package/dist/commands/intuned-cli/commands/{save.command.d.ts → provision.command.d.ts} +3 -3
  34. package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
  35. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  36. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +5 -1
  37. package/dist/commands/intuned-cli/commands/run_authsession.command.js +2 -2
  38. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
  39. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +2 -2
  40. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +2 -2
  41. package/dist/commands/intuned-cli/commands/types.d.ts +5 -1
  42. package/dist/commands/intuned-cli/commands/types.js +7 -5
  43. package/dist/commands/intuned-cli/controller/__test__/api.test.js +12 -10
  44. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +18 -16
  45. package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
  46. package/dist/commands/intuned-cli/controller/api.js +6 -3
  47. package/dist/commands/intuned-cli/controller/authSession.d.ts +13 -13
  48. package/dist/commands/intuned-cli/controller/authSession.js +31 -30
  49. package/dist/commands/intuned-cli/controller/build.js +1 -2
  50. package/dist/commands/intuned-cli/controller/deploy.js +53 -12
  51. package/dist/commands/intuned-cli/controller/index.js +2 -3
  52. package/dist/commands/intuned-cli/controller/{save.d.ts → provision.d.ts} +5 -1
  53. package/dist/commands/intuned-cli/controller/provision.js +299 -0
  54. package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
  55. package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
  56. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +40 -2
  57. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +4 -3
  58. package/dist/commands/intuned-cli/helpers/api.js +4 -7
  59. package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
  60. package/dist/commands/intuned-cli/helpers/auth.js +24 -21
  61. package/dist/commands/intuned-cli/helpers/backend.js +12 -4
  62. package/dist/commands/intuned-cli/helpers/browser.d.ts +3 -4
  63. package/dist/commands/intuned-cli/helpers/browser.js +31 -2
  64. package/dist/commands/intuned-cli/helpers/context.js +2 -2
  65. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  66. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  67. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
  68. package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
  69. package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
  70. package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
  71. package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
  72. package/dist/commands/intuned-cli/helpers/wrapper.js +14 -4
  73. package/dist/commands/intuned-cli/main.js +1 -2
  74. package/dist/commands/intuned-cli/types.d.ts +41 -12
  75. package/dist/commands/intuned-cli/types.js +12 -2
  76. package/dist/commands/ts-check.js +1 -2
  77. package/dist/common/backendFunctions/getAuthSessionParameters.js +1 -1
  78. package/dist/common/binStartupScript.js +16 -7
  79. package/dist/common/browserTabs.d.ts +72 -0
  80. package/dist/common/browserTabs.js +74 -0
  81. package/dist/common/constants.d.ts +1 -0
  82. package/dist/common/constants.js +2 -1
  83. package/dist/common/contextStorageStateHelpers.d.ts +4 -3
  84. package/dist/common/contextStorageStateHelpers.js +4 -1
  85. package/dist/common/extension/extensionsHelpers.d.ts +1 -1
  86. package/dist/common/extension/types.d.ts +14 -7
  87. package/dist/common/formatZodError.d.ts +1 -1
  88. package/dist/common/intunedJson.d.ts +29 -14
  89. package/dist/common/intunedJson.js +26 -5
  90. package/dist/common/jwtTokenManager.js +10 -6
  91. package/dist/common/launchBrowser.d.ts +3 -0
  92. package/dist/common/launchBrowser.js +60 -5
  93. package/dist/common/playwrightContext.d.ts +3 -5
  94. package/dist/common/playwrightContext.js +16 -12
  95. package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
  96. package/dist/common/runApi/importUsingImportFunction.js +7 -7
  97. package/dist/common/runApi/index.d.ts +3 -6
  98. package/dist/common/runApi/index.js +26 -52
  99. package/dist/common/settingsSchema.d.ts +49 -45
  100. package/dist/common/settingsSchema.js +1 -2
  101. package/dist/common/setupContextHook.d.ts +1 -2
  102. package/dist/common/setupContextHook.js +2 -2
  103. package/dist/common/telemetry.js +1 -2
  104. package/dist/index.d.ts +0 -1
  105. package/dist/index.js +0 -7
  106. package/dist/runtime/downloadDirectory.js +2 -2
  107. package/dist/vendor/runtime-interface.d.ts +1 -0
  108. package/dist/vendor/runtime-interface.js +491 -0
  109. package/package.json +19 -11
  110. package/tsup.config.ts +12 -0
  111. package/WebTemplate.zip +0 -0
  112. package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  113. package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  114. package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  115. package/dist/commands/intuned-cli/controller/save.js +0 -357
  116. package/dist/common/runApi/errors.d.ts +0 -72
  117. package/dist/common/runApi/errors.js +0 -169
  118. package/dist/common/runApi/types.d.ts +0 -830
  119. package/dist/common/runApi/types.js +0 -73
@@ -9,8 +9,8 @@ var _authSession = require("../controller/authSession");
9
9
  var _attempt_authsession = require("./attempt_authsession.command");
10
10
  var _helpers = require("../helpers");
11
11
  var _types = require("./types");
12
- const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required")]);
13
- const attemptAuthSessionCheckCommand = exports.attemptAuthSessionCheckCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("check").description("Check an existing auth session").argument("<id>", "ID of the auth session to check")).action((0, _helpers.cliCommandWrapper)(argsSchema, _types.baseCommandOptionsSchema, async ([id], options) => {
12
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the AuthSession is required")]);
13
+ const attemptAuthSessionCheckCommand = exports.attemptAuthSessionCheckCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("check").description("Check an existing AuthSession").argument("<id>", "ID of the AuthSession to check")).action((0, _helpers.cliCommandWrapper)(argsSchema, _types.baseCommandOptionsSchema, async ([id], options) => {
14
14
  await (0, _helpers.assertAuthEnabled)();
15
15
  await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
16
16
  id,
@@ -14,7 +14,7 @@ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required
14
14
  const optionsSchema = _types.baseCommandOptionsSchema.extend({
15
15
  id: _zod.z.string().optional()
16
16
  });
17
- const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = (0, _types.withBaseOptions)(_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-sessions-instances/[current timestamp].json")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], options) => {
17
+ const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new AuthSession").argument("<parameters>", "Parameters for the AuthSession command").option("--id <id>", "ID of the AuthSession to use for the command. Defaults to ./auth-sessions-instances/[current timestamp].json")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], options) => {
18
18
  await (0, _helpers.assertAuthEnabled)();
19
19
  const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
20
20
  await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.authSessionCommand = void 0;
7
7
  var _command = require("./command");
8
- const authSessionCommand = exports.authSessionCommand = _command.program.command("authsession").description("Manage Auth Sessions");
8
+ const authSessionCommand = exports.authSessionCommand = _command.program.command("authsession").description("Manage AuthSessions");
@@ -14,7 +14,7 @@ const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.ex
14
14
  id: _zod.z.string().optional()
15
15
  });
16
16
  const isAuthSessionRecorderEnabled = process.env.INTUNED_AUTH_SESSION_RECORDER_ENABLED === "true";
17
- const authSessionRecordCommand = exports.authSessionRecordCommand = isAuthSessionRecorderEnabled ? (0, _types.withBaseOptions)(_authsession.authSessionCommand.command("record").description("Record a new auth session").option("--id <id>", "ID of the auth session to use for the command. Defaults to auth-session-[current timestamp]").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1")).action((0, _helpers.cliCommandWrapper)(undefined, optionsSchema, async (_, {
17
+ const authSessionRecordCommand = exports.authSessionRecordCommand = isAuthSessionRecorderEnabled ? (0, _types.withBaseOptions)(_authsession.authSessionCommand.command("record").description("Record a new AuthSession").option("--id <id>", "ID of the AuthSession to use for the command. Defaults to auth-session-[current timestamp]").option("--check-attempts <number>", "Number of attempts to check the AuthSession validity", "1")).action((0, _helpers.cliCommandWrapper)(undefined, optionsSchema, async (_, {
18
18
  checkAttempts,
19
19
  ...rest
20
20
  }) => {
@@ -0,0 +1 @@
1
+ export declare const authSessionScaffoldCommand: import("commander").Command;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.authSessionScaffoldCommand = void 0;
7
+ var _zod = require("zod");
8
+ var _helpers = require("../helpers");
9
+ var _authsession = require("./authsession.command");
10
+ var _types = require("./types");
11
+ var _scaffold = require("../controller/scaffold");
12
+ const optionsSchema = _zod.z.object({});
13
+ const authSessionScaffoldCommand = exports.authSessionScaffoldCommand = (0, _types.withBaseOptions)(_authsession.authSessionCommand.command("scaffold").description("Scaffold AuthSession files")).action((0, _helpers.cliCommandWrapper)(undefined, optionsSchema, async _ => {
14
+ await (0, _helpers.assertAuthEnabled)();
15
+ await (0, _scaffold.scaffoldAuthSessionFiles)();
16
+ }));
@@ -6,32 +6,36 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.deployCommand = void 0;
7
7
  var _command = require("./command");
8
8
  var _dotenv = _interopRequireDefault(require("dotenv"));
9
- var _save = require("../controller/save");
9
+ var _provision = require("../controller/provision");
10
10
  var _deploy = require("../controller/deploy");
11
11
  var _helpers = require("../helpers");
12
- var _save2 = require("./save.command");
12
+ var _provision2 = require("./provision.command");
13
+ var _prompts = require("../helpers/prompts");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  _dotenv.default.config({
15
16
  path: `.env`
16
17
  });
17
- const deployCommand = exports.deployCommand = _command.program.command("deploy").description("Save and 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.cliCommandWrapper)(_save2.saveOrDeployArgsSchema, _save2.saveOrDeployOptionsSchema, async ([projectName], options) => {
18
+ 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.cliCommandWrapper)(_provision2.saveOrDeployArgsSchema, _provision2.saveOrDeployOptionsSchema, async ([projectName], options) => {
18
19
  const {
19
20
  isValid,
20
21
  errorMessage
21
- } = await (0, _save.validateIntunedProject)();
22
+ } = await (0, _provision.validateIntunedProject)();
22
23
  if (!isValid) {
23
- const message = `^r^+Project to be deployed is not a valid Intuned project:^:^R ${errorMessage}:\n`;
24
+ const message = `^r^+Project to be deployed is not valid:^:^R ${errorMessage}:\n`;
24
25
  throw new _helpers.CLIError(message, {
25
26
  autoColor: false
26
27
  });
27
28
  }
28
- const _projectName = projectName || (await (0, _helpers.loadIntunedJson)()).projectName;
29
+ const _projectName = projectName || (await (0, _helpers.loadIntunedJson)()).projectName || (await (0, _prompts.promptForProjectName)(name => {
30
+ const result = (0, _provision.validateProjectName)(name);
31
+ return result.isValid || result.errorMessage;
32
+ }));
29
33
  if (!_projectName) {
30
- throw new _helpers.CLIError("Project name is required");
34
+ throw new _helpers.CLIError(`Project name is required. Set it in ${await (0, _helpers.getIntunedSettingsFile)()} or provide it as an argument by running 'intuned deploy <project-name>'.`);
31
35
  }
32
- const projectNameValidation = (0, _save.validateProjectName)(_projectName);
36
+ const projectNameValidation = (0, _provision.validateProjectName)(_projectName);
33
37
  if (!projectNameValidation.isValid) {
34
- throw new _helpers.CLIError(projectNameValidation.errorMessage);
38
+ throw new _helpers.CLIError(`Invalid project name: ${projectNameValidation.errorMessage}`);
35
39
  }
36
40
  const auth = await (0, _helpers.getAuthCredentials)(options);
37
41
  await (0, _deploy.runDeployProject)(_projectName, auth);
@@ -1,8 +1,7 @@
1
1
  export * from "./command";
2
2
  export * from "./build.command";
3
3
  export * from "./deploy.command";
4
- export * from "./save.command";
5
- export * from "./init.command";
4
+ export * from "./provision.command";
6
5
  export * from "./run.command";
7
6
  export * from "./run_api.command";
8
7
  export * from "./run_authsession.command";
@@ -16,3 +15,4 @@ export * from "./attempt_authsession_create.command";
16
15
  export * from "./attempt_authsession_check.command";
17
16
  export * from "./authsession.command";
18
17
  export * from "./authsession_record.command";
18
+ export * from "./authsession_scaffold.command";
@@ -36,25 +36,14 @@ Object.keys(_deploy).forEach(function (key) {
36
36
  }
37
37
  });
38
38
  });
39
- var _save = require("./save.command");
40
- Object.keys(_save).forEach(function (key) {
39
+ var _provision = require("./provision.command");
40
+ Object.keys(_provision).forEach(function (key) {
41
41
  if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _save[key]) return;
42
+ if (key in exports && exports[key] === _provision[key]) return;
43
43
  Object.defineProperty(exports, key, {
44
44
  enumerable: true,
45
45
  get: function () {
46
- return _save[key];
47
- }
48
- });
49
- });
50
- var _init = require("./init.command");
51
- Object.keys(_init).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _init[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _init[key];
46
+ return _provision[key];
58
47
  }
59
48
  });
60
49
  });
@@ -200,4 +189,15 @@ Object.keys(_authsession_record).forEach(function (key) {
200
189
  return _authsession_record[key];
201
190
  }
202
191
  });
192
+ });
193
+ var _authsession_scaffold = require("./authsession_scaffold.command");
194
+ Object.keys(_authsession_scaffold).forEach(function (key) {
195
+ if (key === "default" || key === "__esModule") return;
196
+ if (key in exports && exports[key] === _authsession_scaffold[key]) return;
197
+ Object.defineProperty(exports, key, {
198
+ enumerable: true,
199
+ get: function () {
200
+ return _authsession_scaffold[key];
201
+ }
202
+ });
203
203
  });
@@ -4,10 +4,10 @@ export declare const saveOrDeployOptionsSchema: z.ZodObject<{
4
4
  workspaceId: z.ZodOptional<z.ZodString>;
5
5
  apiKey: z.ZodOptional<z.ZodString>;
6
6
  }, "strip", z.ZodTypeAny, {
7
- workspaceId?: string | undefined;
8
7
  apiKey?: string | undefined;
9
- }, {
10
8
  workspaceId?: string | undefined;
9
+ }, {
11
10
  apiKey?: string | undefined;
11
+ workspaceId?: string | undefined;
12
12
  }>;
13
- export declare const saveCommand: import("commander").Command;
13
+ export declare const provisionCommand: import("commander").Command, saveCommand: import("commander").Command;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.saveOrDeployOptionsSchema = exports.saveOrDeployArgsSchema = exports.saveCommand = exports.provisionCommand = void 0;
7
+ var _command = require("./command");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _provision = require("../controller/provision");
10
+ var _helpers = require("../helpers");
11
+ var _zod = require("zod");
12
+ var _prompts = require("../helpers/prompts");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ _dotenv.default.config({
15
+ path: `.env`
16
+ });
17
+ const saveOrDeployArgsSchema = exports.saveOrDeployArgsSchema = _zod.z.tuple([_zod.z.union([_zod.z.string(), _zod.z.undefined()])]);
18
+ const saveOrDeployOptionsSchema = exports.saveOrDeployOptionsSchema = _zod.z.object({
19
+ workspaceId: _zod.z.string().optional(),
20
+ apiKey: _zod.z.string().optional()
21
+ });
22
+ const description = "Provision an Intuned project to the platform";
23
+ const commands = [_command.program.command("save").description(`${description}. (Deprecated, use 'provision' instead)`), _command.program.command("provision").description(description)];
24
+ const [provisionCommand, saveCommand] = commands.map(command => command.argument("[project-name]", "Project name").option("-w, --workspace-id <id>", "Intuned Workspace ID").option("-k, --api-key <key>", "Intuned API key").action((0, _helpers.cliCommandWrapper)(saveOrDeployArgsSchema, saveOrDeployOptionsSchema, async ([projectName], options) => {
25
+ const {
26
+ isValid,
27
+ errorMessage
28
+ } = await (0, _provision.validateIntunedProject)();
29
+ if (!isValid) {
30
+ const message = `^r^+Project to be provisioned is not a valid Intuned project:^:^R ${errorMessage}:\n`;
31
+ throw new _helpers.CLIError(message, {
32
+ autoColor: false
33
+ });
34
+ }
35
+ const _projectName = projectName || (await (0, _helpers.loadIntunedJson)()).projectName || (await (0, _prompts.promptForProjectName)(name => {
36
+ const result = (0, _provision.validateProjectName)(name);
37
+ return result.isValid || result.errorMessage;
38
+ }));
39
+ if (!_projectName) {
40
+ throw new _helpers.CLIError(`Project name is required. Set it in ${await (0, _helpers.getIntunedSettingsFile)()} or provide it as an argument by running 'intuned provision <project-name>'.`);
41
+ }
42
+ const projectNameValidation = (0, _provision.validateProjectName)(_projectName);
43
+ if (!projectNameValidation.isValid) {
44
+ throw new _helpers.CLIError(`Invalid project name: ${projectNameValidation.errorMessage}`);
45
+ }
46
+ const auth = await (0, _helpers.getAuthCredentials)(options);
47
+ await (0, _provision.runProvisionProject)(_projectName, auth);
48
+ })));
49
+ exports.saveCommand = saveCommand;
50
+ exports.provisionCommand = provisionCommand;
@@ -19,7 +19,7 @@ const optionsSchema = _types.baseCommandOptionsSchema.extend({
19
19
  authSessionCheckAttempts: _types.authSessionCheckAttemptsSchema,
20
20
  authSessionCreateAttempts: _types.authSessionCreateAttemptsSchema
21
21
  });
22
- const runApiCommand = exports.runApiCommand = (0, _types.withBaseOptions)(_run.runCommand.command("api").description("Execute an Intuned API run 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-sessions-instances/<id>").option("--retries <number>", "Number of retries for the API call", "1").option("--no-auth-session-auto-recreate", "disable auto recreate for auth session").option("--auth-session-check-attempts <number>", "auth session check attempts", "1").option("--auth-session-create-attempts <number>", "auth session create attempts", "1").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
22
+ const runApiCommand = exports.runApiCommand = (0, _types.withBaseOptions)(_run.runCommand.command("api").description("Execute an Intuned API run 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 AuthSession to use for the API. This is expected to be in ./auth-sessions-instances/<id>").option("--retries <number>", "Number of retries for the API call", "1").option("--no-auth-session-auto-recreate", "disable auto recreate for AuthSession").option("--auth-session-check-attempts <number>", "AuthSession check attempts", "1").option("--auth-session-create-attempts <number>", "AuthSession create attempts", "1").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
23
23
  retries,
24
24
  outputFile,
25
25
  authSession,
@@ -2,10 +2,12 @@ import { Command } from "commander";
2
2
  export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
3
3
  proxy: import("zod").ZodOptional<import("zod").ZodString>;
4
4
  timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
5
- trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
6
5
  headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
6
+ trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
7
7
  keepBrowserOpen: import("zod").ZodDefault<import("zod").ZodBoolean>;
8
8
  cdpUrl: import("zod").ZodOptional<import("zod").ZodString>;
9
+ cdpTabId: import("zod").ZodOptional<import("zod").ZodString>;
10
+ } & {
9
11
  checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
10
12
  createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
11
13
  }, "strip", import("zod").ZodTypeAny, {
@@ -17,6 +19,7 @@ export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodOb
17
19
  createAttempts: number;
18
20
  proxy?: string | undefined;
19
21
  cdpUrl?: string | undefined;
22
+ cdpTabId?: string | undefined;
20
23
  }, {
21
24
  proxy?: string | undefined;
22
25
  timeout?: string | undefined;
@@ -24,6 +27,7 @@ export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodOb
24
27
  headless?: boolean | undefined;
25
28
  keepBrowserOpen?: boolean | undefined;
26
29
  cdpUrl?: string | undefined;
30
+ cdpTabId?: string | undefined;
27
31
  checkAttempts?: number | undefined;
28
32
  createAttempts?: number | undefined;
29
33
  }>;
@@ -11,7 +11,7 @@ const baseRunAuthSessionCommandOptionsSchema = exports.baseRunAuthSessionCommand
11
11
  checkAttempts: _types.authSessionCheckAttemptsSchema,
12
12
  createAttempts: _types.authSessionCreateAttemptsSchema
13
13
  });
14
- const runAuthSessionCommand = exports.runAuthSessionCommand = _run.runCommand.command("authsession").description("Manage authentication sessions");
14
+ const runAuthSessionCommand = exports.runAuthSessionCommand = _run.runCommand.command("authsession").description("Execute AuthSession Runs");
15
15
  function withAuthSessionBaseOptions(command) {
16
- return (0, _types.withBaseOptions)(command.option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1").option("--create-attempts <number>", "Number of attempts to create a new auth session if it is invalid", "1"));
16
+ return (0, _types.withBaseOptions)(command.option("--check-attempts <number>", "Number of attempts to check the AuthSession validity", "1").option("--create-attempts <number>", "Number of attempts to create a new AuthSession if it is invalid", "1"));
17
17
  }
@@ -15,7 +15,7 @@ const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.ex
15
15
  id: _zod.z.string().optional()
16
16
  });
17
17
  const commands = [_run_authsession.runAuthSessionCommand.command("create"), _authsession.authSessionCommand.command("create")];
18
- const [runAuthSessionCreateCommand, authSessionCreateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.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-[current timestamp]")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], {
18
+ const [runAuthSessionCreateCommand, authSessionCreateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.description("Create a new AuthSession").argument("<parameters>", "Parameters for the AuthSession command").option("--id <id>", "ID of the AuthSession to use for the command. Defaults to auth-session-[current timestamp]")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], {
19
19
  checkAttempts,
20
20
  createAttempts,
21
21
  id,
@@ -10,12 +10,12 @@ var _authSession = require("../controller/authSession");
10
10
  var _run_authsession = require("./run_authsession.command");
11
11
  var _helpers = require("../helpers");
12
12
  var _authsession = require("./authsession.command");
13
- const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required")]);
13
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the AuthSession is required")]);
14
14
  const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
15
15
  parameters: _zod.z.string().optional()
16
16
  });
17
17
  const commands = [_run_authsession.runAuthSessionCommand.command("update"), _authsession.authSessionCommand.command("update")];
18
- const [runAuthSessionUpdateCommand, authSessionUpdateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.description("Update an existing auth session").argument("<id>", "ID of the auth session to update").option("--parameters <parameters>", "Parameters for the auth session command. If not provided, it will use the existing parameters")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([id], {
18
+ const [runAuthSessionUpdateCommand, authSessionUpdateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.description("Update an existing AuthSession").argument("<id>", "ID of the AuthSession to update").option("--parameters <parameters>", "Parameters for the AuthSession command. If not provided, it will use the existing parameters")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([id], {
19
19
  checkAttempts,
20
20
  createAttempts,
21
21
  parameters,
@@ -9,12 +9,12 @@ var _authSession = require("../controller/authSession");
9
9
  var _run_authsession = require("./run_authsession.command");
10
10
  var _helpers = require("../helpers");
11
11
  var _authsession = require("./authsession.command");
12
- const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required")]);
12
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the AuthSession is required")]);
13
13
  const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
14
14
  autoRecreate: _zod.z.boolean().default(true)
15
15
  });
16
16
  const commands = [_run_authsession.runAuthSessionCommand.command("validate"), _authsession.authSessionCommand.command("validate")];
17
- const [runAuthSessionValidateCommand, authSessionValidateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.description("Validate an existing auth session").argument("<id>", "ID of the auth session to validate").option("--no-auto-recreate", "Disable auto recreation of the auth session if it is invalid")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([id], {
17
+ const [runAuthSessionValidateCommand, authSessionValidateCommand] = commands.map(command => (0, _run_authsession.withAuthSessionBaseOptions)(command.description("Validate an existing AuthSession").argument("<id>", "ID of the AuthSession to validate").option("--no-auto-recreate", "Disable auto recreation of the AuthSession if it is invalid")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([id], {
18
18
  autoRecreate,
19
19
  checkAttempts,
20
20
  createAttempts,
@@ -9,6 +9,7 @@ export declare const headlessSchema: z.ZodDefault<z.ZodBoolean>;
9
9
  export declare const traceSchema: z.ZodDefault<z.ZodBoolean>;
10
10
  export declare const keepBrowserOpenSchema: z.ZodDefault<z.ZodBoolean>;
11
11
  export declare const cdpUrlSchema: z.ZodOptional<z.ZodString>;
12
+ export declare const cdpTabIdSchema: z.ZodOptional<z.ZodString>;
12
13
  export declare const baseCommandOptionsSchema: z.ZodObject<{
13
14
  proxy: z.ZodOptional<z.ZodString>;
14
15
  timeout: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
@@ -16,6 +17,7 @@ export declare const baseCommandOptionsSchema: z.ZodObject<{
16
17
  trace: z.ZodDefault<z.ZodBoolean>;
17
18
  keepBrowserOpen: z.ZodDefault<z.ZodBoolean>;
18
19
  cdpUrl: z.ZodOptional<z.ZodString>;
20
+ cdpTabId: z.ZodOptional<z.ZodString>;
19
21
  }, "strip", z.ZodTypeAny, {
20
22
  timeout: number;
21
23
  trace: boolean;
@@ -23,13 +25,15 @@ export declare const baseCommandOptionsSchema: z.ZodObject<{
23
25
  keepBrowserOpen: boolean;
24
26
  proxy?: string | undefined;
25
27
  cdpUrl?: string | undefined;
28
+ cdpTabId?: string | undefined;
26
29
  }, {
27
30
  proxy?: string | undefined;
28
31
  timeout?: string | undefined;
29
- headless?: boolean | undefined;
30
32
  trace?: boolean | undefined;
33
+ headless?: boolean | undefined;
31
34
  keepBrowserOpen?: boolean | undefined;
32
35
  cdpUrl?: string | undefined;
36
+ cdpTabId?: string | undefined;
33
37
  }>;
34
38
  export type BaseCommandOptions = z.infer<typeof baseCommandOptionsSchema>;
35
39
  export declare function withBaseOptions(command: Command): Command;
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.traceSchema = exports.timeoutSchema = exports.proxySchema = exports.keepBrowserOpenSchema = exports.headlessSchema = exports.cdpUrlSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
6
+ exports.traceSchema = exports.timeoutSchema = exports.proxySchema = exports.keepBrowserOpenSchema = exports.headlessSchema = exports.cdpUrlSchema = exports.cdpTabIdSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
7
7
  exports.withBaseOptions = withBaseOptions;
8
8
  var _ms = _interopRequireDefault(require("ms"));
9
9
  var _zod = require("zod");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const authSessionCheckAttemptsSchema = exports.authSessionCheckAttemptsSchema = _zod.z.coerce.number().int().min(1, "Auth session check attempts must be at least 1").default(1);
12
- const authSessionCreateAttemptsSchema = exports.authSessionCreateAttemptsSchema = _zod.z.coerce.number().int().min(1, "Auth session create attempts must be at least 1").default(1);
11
+ const authSessionCheckAttemptsSchema = exports.authSessionCheckAttemptsSchema = _zod.z.coerce.number().int().min(1, "AuthSession check attempts must be at least 1").default(1);
12
+ const authSessionCreateAttemptsSchema = exports.authSessionCreateAttemptsSchema = _zod.z.coerce.number().int().min(1, "AuthSession create attempts must be at least 1").default(1);
13
13
  const proxySchema = exports.proxySchema = _zod.z.string().url("--proxy must be a valid URL").optional();
14
14
  const timeoutSchema = exports.timeoutSchema = _zod.z.string().default("10 mins").refine(val => {
15
15
  return (0, _ms.default)(val) !== undefined;
@@ -18,14 +18,16 @@ const headlessSchema = exports.headlessSchema = _zod.z.boolean().default(false);
18
18
  const traceSchema = exports.traceSchema = _zod.z.boolean().default(false);
19
19
  const keepBrowserOpenSchema = exports.keepBrowserOpenSchema = _zod.z.boolean().default(false);
20
20
  const cdpUrlSchema = exports.cdpUrlSchema = _zod.z.string().url().optional();
21
+ const cdpTabIdSchema = exports.cdpTabIdSchema = _zod.z.string().min(1).optional();
21
22
  const baseCommandOptionsSchema = exports.baseCommandOptionsSchema = _zod.z.object({
22
23
  proxy: proxySchema,
23
24
  timeout: timeoutSchema,
24
25
  headless: headlessSchema,
25
26
  trace: traceSchema,
26
27
  keepBrowserOpen: keepBrowserOpenSchema,
27
- cdpUrl: cdpUrlSchema
28
+ cdpUrl: cdpUrlSchema,
29
+ cdpTabId: cdpTabIdSchema
28
30
  });
29
31
  function withBaseOptions(command) {
30
- return command.option("--proxy <url>", "Proxy URL to use for browser").option("--timeout <time>", "Timeout for each attempt - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the attempts in a headless browser (default: false). This will not open a browser window.").option("--trace", "Capture a trace of each attempt, useful for debugging.").option("--keep-browser-open", "Keep the last browser open after the command completes, useful for debugging.").option("--cdp-url <url>", "[Experimental] Chrome DevTools Protocol URL to connect to an existing browser instance. Disables proxy, headless, keep_browser_open options.");
32
+ return command.option("--proxy <url>", "Proxy URL to use for browser").option("--timeout <time>", "Timeout for each attempt - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the attempts in a headless browser (default: false). This will not open a browser window.").option("--trace", "Capture a trace of each attempt, useful for debugging.").option("--keep-browser-open", "Keep the last browser open after the command completes, useful for debugging.").option("--cdp-url <url>", "Chrome DevTools Protocol URL to connect to an existing browser instance. Disables proxy, headless, keep_browser_open options.").option("--cdp-tab-id <tab_id>", "Browser tab ID to execute on. Requires --cdp-url. If not specified, uses the first tab. Defaults to None.");
31
33
  }
@@ -6,6 +6,7 @@ var _authSession = require("../authSession");
6
6
  var _helpers = require("../../helpers");
7
7
  var _neverthrow = require("neverthrow");
8
8
  var _runApi = require("../../../../common/runApi");
9
+ var _runtimeInterface = require("../../../../vendor/runtime-interface");
9
10
  var _fsExtra = require("fs-extra");
10
11
  var _browser = require("../../helpers/browser");
11
12
  function getTerminal() {
@@ -15,6 +16,7 @@ function getTerminal() {
15
16
  });
16
17
  }
17
18
  _vitest.vi.mock("fs-extra", () => ({
19
+ ensureDir: _vitest.vi.fn(),
18
20
  writeJSON: _vitest.vi.fn(),
19
21
  exists: _vitest.vi.fn().mockResolvedValue(true)
20
22
  }));
@@ -223,7 +225,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
223
225
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
224
226
  });
225
227
  (0, _vitest.it)("stops retrying after max retries", async () => {
226
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
228
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
227
229
  await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
228
230
  apiName: "testApi",
229
231
  inputData: {},
@@ -241,7 +243,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
241
243
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
242
244
  });
243
245
  (0, _vitest.it)("stops retrying on success", async () => {
244
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
246
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
245
247
  result: "success"
246
248
  }));
247
249
  await (0, _api.executeRunApiCLI)({
@@ -251,8 +253,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
251
253
  });
252
254
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
253
255
  });
254
- (0, _vitest.it)("validates auth session before each attempt if provided", async () => {
255
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
256
+ (0, _vitest.it)("validates AuthSession before each attempt if provided", async () => {
257
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
256
258
  result: "success"
257
259
  }));
258
260
  await (0, _api.executeRunApiCLI)({
@@ -274,7 +276,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
274
276
  createRetries: 2
275
277
  }));
276
278
  });
277
- (0, _vitest.it)("doesn't validate auth session if not provided", async () => {
279
+ (0, _vitest.it)("doesn't validate AuthSession if not provided", async () => {
278
280
  _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
279
281
  result: "success"
280
282
  }));
@@ -285,8 +287,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
285
287
  });
286
288
  (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).not.toHaveBeenCalled();
287
289
  });
288
- (0, _vitest.it)("fails if auth session is provided but not valid", async () => {
289
- _vitest.vi.mocked(_authSession.executeRunValidateAuthSessionCLI).mockRejectedValue(new _helpers.CLIError("Auth session validation failed"));
290
+ (0, _vitest.it)("fails if AuthSession is provided but not valid", async () => {
291
+ _vitest.vi.mocked(_authSession.executeRunValidateAuthSessionCLI).mockRejectedValue(new _helpers.CLIError("AuthSession validation failed"));
290
292
  await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
291
293
  apiName: "testApi",
292
294
  inputData: {},
@@ -297,7 +299,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
297
299
  createRetries: 2
298
300
  },
299
301
  retries: 10
300
- })).rejects.toThrow("Auth session validation failed");
302
+ })).rejects.toThrow("AuthSession validation failed");
301
303
  (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith(_vitest.expect.objectContaining({
302
304
  id: "authSessionId",
303
305
  autoRecreate: false,
@@ -363,11 +365,11 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
363
365
  });
364
366
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
365
367
  _vitest.vi.mocked(_runApi.runApi).mockReset();
366
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
368
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
367
369
  await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
368
370
  apiName: "testApi",
369
371
  inputData: {}
370
- })).rejects.toThrow(_runApi.AutomationError);
372
+ })).rejects.toThrow(_runtimeInterface.AutomationError);
371
373
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
372
374
  });
373
375
  (0, _vitest.it)("writes result to file if outputFile is provided", async () => {