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

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 (120) hide show
  1. package/.babelrc +6 -0
  2. package/CHANGELOG.md +1 -1
  3. package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
  4. package/InterfaceTemplate/index.playwright.ts +1 -1
  5. package/bin/intuned +0 -0
  6. package/bin/intuned-interface +7 -0
  7. package/dist/commands/api/run.js +7 -11
  8. package/dist/commands/auth-sessions/load.js +2 -2
  9. package/dist/commands/auth-sessions/run-check.js +8 -8
  10. package/dist/commands/auth-sessions/run-create.js +6 -6
  11. package/dist/commands/build.js +2 -3
  12. package/dist/commands/common/browserUtils.d.ts +3 -3
  13. package/dist/commands/common/browserUtils.js +3 -4
  14. package/dist/commands/common/getFirstLineNumber.test.js +1 -2
  15. package/dist/commands/common/projectExclusions.js +1 -1
  16. package/dist/commands/common/tsNodeImport.d.ts +1 -1
  17. package/dist/commands/common/tsNodeImport.js +10 -2
  18. package/dist/commands/common/utils/fileUtils.js +1 -2
  19. package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
  20. package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
  21. package/dist/commands/common/utils/template.js +1 -2
  22. package/dist/commands/interface/run.js +23 -49
  23. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  24. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +1 -1
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -2
  26. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  27. package/dist/commands/intuned-cli/commands/authsession.command.js +1 -1
  28. package/dist/commands/intuned-cli/commands/authsession_record.command.js +1 -1
  29. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
  30. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
  31. package/dist/commands/intuned-cli/commands/deploy.command.js +13 -9
  32. package/dist/commands/intuned-cli/commands/index.d.ts +2 -2
  33. package/dist/commands/intuned-cli/commands/index.js +15 -15
  34. package/dist/commands/intuned-cli/commands/{save.command.d.ts → provision.command.d.ts} +3 -3
  35. package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
  36. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  37. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +8 -1
  38. package/dist/commands/intuned-cli/commands/run_authsession.command.js +2 -2
  39. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
  40. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +2 -2
  41. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +2 -2
  42. package/dist/commands/intuned-cli/commands/types.d.ts +9 -1
  43. package/dist/commands/intuned-cli/commands/types.js +9 -5
  44. package/dist/commands/intuned-cli/controller/__test__/api.test.js +30 -19
  45. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +140 -77
  46. package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
  47. package/dist/commands/intuned-cli/controller/api.js +6 -3
  48. package/dist/commands/intuned-cli/controller/authSession.d.ts +16 -16
  49. package/dist/commands/intuned-cli/controller/authSession.js +50 -39
  50. package/dist/commands/intuned-cli/controller/build.js +1 -2
  51. package/dist/commands/intuned-cli/controller/deploy.js +53 -12
  52. package/dist/commands/intuned-cli/controller/index.js +2 -3
  53. package/dist/commands/intuned-cli/controller/{save.d.ts → provision.d.ts} +5 -1
  54. package/dist/commands/intuned-cli/controller/provision.js +299 -0
  55. package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
  56. package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
  57. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +45 -5
  58. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +4 -3
  59. package/dist/commands/intuned-cli/helpers/api.js +4 -7
  60. package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
  61. package/dist/commands/intuned-cli/helpers/auth.js +24 -21
  62. package/dist/commands/intuned-cli/helpers/backend.js +12 -4
  63. package/dist/commands/intuned-cli/helpers/browser.d.ts +4 -4
  64. package/dist/commands/intuned-cli/helpers/browser.js +40 -5
  65. package/dist/commands/intuned-cli/helpers/context.js +2 -2
  66. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  67. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  68. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
  69. package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
  70. package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
  71. package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
  72. package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
  73. package/dist/commands/intuned-cli/helpers/wrapper.js +14 -4
  74. package/dist/commands/intuned-cli/main.js +1 -2
  75. package/dist/commands/intuned-cli/types.d.ts +41 -12
  76. package/dist/commands/intuned-cli/types.js +12 -2
  77. package/dist/commands/ts-check.js +1 -2
  78. package/dist/common/backendFunctions/getAuthSessionParameters.js +1 -1
  79. package/dist/common/binStartupScript.js +1 -2
  80. package/dist/common/browserTabs.d.ts +72 -0
  81. package/dist/common/browserTabs.js +74 -0
  82. package/dist/common/constants.d.ts +1 -0
  83. package/dist/common/constants.js +2 -1
  84. package/dist/common/contextStorageStateHelpers.d.ts +4 -3
  85. package/dist/common/contextStorageStateHelpers.js +4 -1
  86. package/dist/common/extension/extensionsHelpers.d.ts +1 -1
  87. package/dist/common/extension/types.d.ts +14 -7
  88. package/dist/common/formatZodError.d.ts +1 -1
  89. package/dist/common/intunedJson.d.ts +19 -14
  90. package/dist/common/intunedJson.js +4 -4
  91. package/dist/common/jwtTokenManager.js +10 -6
  92. package/dist/common/launchBrowser.d.ts +10 -0
  93. package/dist/common/launchBrowser.js +67 -7
  94. package/dist/common/playwrightContext.d.ts +5 -5
  95. package/dist/common/playwrightContext.js +24 -14
  96. package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
  97. package/dist/common/runApi/importUsingImportFunction.js +7 -7
  98. package/dist/common/runApi/index.d.ts +3 -6
  99. package/dist/common/runApi/index.js +28 -52
  100. package/dist/common/settingsSchema.d.ts +52 -45
  101. package/dist/common/settingsSchema.js +3 -3
  102. package/dist/common/setupContextHook.d.ts +1 -2
  103. package/dist/common/setupContextHook.js +2 -2
  104. package/dist/common/telemetry.js +1 -2
  105. package/dist/index.d.ts +0 -1
  106. package/dist/index.js +0 -7
  107. package/dist/runtime/downloadDirectory.js +2 -2
  108. package/dist/vendor/runtime-interface.d.ts +1 -0
  109. package/dist/vendor/runtime-interface.js +493 -0
  110. package/package.json +19 -11
  111. package/tsup.config.ts +12 -0
  112. package/WebTemplate.zip +0 -0
  113. package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  114. package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  115. package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  116. package/dist/commands/intuned-cli/controller/save.js +0 -357
  117. package/dist/common/runApi/errors.d.ts +0 -72
  118. package/dist/common/runApi/errors.js +0 -169
  119. package/dist/common/runApi/types.d.ts +0 -830
  120. package/dist/common/runApi/types.js +0 -73
@@ -15,30 +15,26 @@ var _path = _interopRequireDefault(require("path"));
15
15
  var _fsExtra = require("fs-extra");
16
16
  var _intunedJson = require("./intunedJson");
17
17
  var _errors = require("./errors");
18
- var _runApi = require("../../../common/runApi");
18
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
19
19
  var _formatZodError = require("../../../common/formatZodError");
20
20
  var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
22
  async function isAuthEnabled() {
23
- try {
24
- const intunedJson = await (0, _intunedJson.loadIntunedJson)();
25
- return Boolean(intunedJson?.authSessions?.enabled);
26
- } catch (error) {
27
- return false;
28
- }
23
+ const intunedJson = await (0, _intunedJson.loadIntunedJson)();
24
+ return Boolean(intunedJson?.authSessions?.enabled);
29
25
  }
30
26
  async function assertAuthEnabled() {
31
27
  if (!(await isAuthEnabled())) {
32
- throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
28
+ throw new _errors.CLIAssertionError(await getAuthNotEnabledErrorMessage());
33
29
  }
34
30
  }
35
31
  async function assertAuthConsistent(authSession) {
36
32
  const _isAuthEnabled = await isAuthEnabled();
37
33
  if (_isAuthEnabled && !authSession) {
38
- throw new _errors.CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
34
+ throw new _errors.CLIAssertionError("AuthSession is enabled, but no AuthSession is provided. Please provide an AuthSession using '--auth-session <id>' option.");
39
35
  }
40
36
  if (!_isAuthEnabled && authSession) {
41
- throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
37
+ throw new _errors.CLIAssertionError(await getAuthNotEnabledErrorMessage());
42
38
  }
43
39
  }
44
40
  async function loadAuthSessionInstance(authSessionId) {
@@ -47,12 +43,12 @@ async function loadAuthSessionInstance(authSessionId) {
47
43
  const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
48
44
  const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
49
45
  if (!(await (0, _fsExtra.exists)(authSessionInstanceStoragePath))) {
50
- throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} not found`);
46
+ throw new _errors.CLIError(`AuthSession instance with ID ${authSessionId} not found. Make sure the ID is correct.`);
51
47
  }
52
48
  const authSessionInstanceJson = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
53
- const authSessionInstanceParseResult = _runApi.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
49
+ const authSessionInstanceParseResult = _runtimeInterface.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
54
50
  if (!authSessionInstanceParseResult.success) {
55
- throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
51
+ throw new _errors.CLIError(`AuthSession instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
56
52
  }
57
53
  const metadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
58
54
  return {
@@ -60,7 +56,7 @@ async function loadAuthSessionInstance(authSessionId) {
60
56
  metadata
61
57
  };
62
58
  } catch (error) {
63
- throw new _errors.CLIError(`Error retrieving auth session instance: ${error.message}`);
59
+ throw new _errors.CLIError(`Error loading AuthSession instance: ${error.message}`);
64
60
  }
65
61
  }
66
62
  async function storeAuthSessionInstance({
@@ -81,7 +77,7 @@ async function storeAuthSessionInstance({
81
77
  });
82
78
  const projectAuthConfig = (await (0, _intunedJson.loadIntunedJson)()).authSessions;
83
79
  if (!projectAuthConfig.enabled) {
84
- throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
80
+ throw new _errors.CLIError(`AuthSessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}. Make sure they are enabled.`);
85
81
  }
86
82
  const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
87
83
  const authSessionMetadata = {
@@ -104,19 +100,19 @@ async function storeAuthSessionInstance({
104
100
  });
105
101
  return authSessionInstancePath;
106
102
  } catch (error) {
107
- throw new _errors.CLIError(`Error storing auth session instance: ${error.message}`);
103
+ throw new _errors.CLIError(`Error storing AuthSession instance: ${error.message}`);
108
104
  }
109
105
  }
110
106
  function registerGetAuthSessionParameters(authSessionId) {
111
107
  async function getAuthSessionParameters() {
112
108
  if (!authSessionId) {
113
- throw new Error("getAuthSessionParameters cannot be called without using an auth session");
109
+ throw new Error("getAuthSessionParameters cannot be called without using an AuthSession");
114
110
  }
115
111
  const {
116
112
  metadata
117
113
  } = await loadAuthSessionInstance(authSessionId);
118
114
  if (metadata?.authSessionType === "MANUAL") {
119
- throw new Error("Auth session is recorder-based, it does not have parameters.");
115
+ throw new Error("AuthSession is recorder-based, it does not have parameters.");
120
116
  }
121
117
  return metadata?.authSessionInput ?? {};
122
118
  }
@@ -125,20 +121,27 @@ function registerGetAuthSessionParameters(authSessionId) {
125
121
  async function getAuthSessionRecorderParameters() {
126
122
  const intunedJson = await (0, _intunedJson.loadIntunedJson)();
127
123
  if (!intunedJson.authSessions.enabled) {
128
- throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
124
+ throw new _errors.CLIError(`AuthSessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}. Make sure they are enabled.`);
129
125
  }
130
126
  if (intunedJson.authSessions.type !== "MANUAL") {
131
- throw new _errors.CLIError(`Auth session type is not recorder-based in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
127
+ throw new _errors.CLIError(`AuthSession type is not recorder-based in ${await (0, _intunedJson.getIntunedSettingsFileName)()}.
128
+ Make sure the AuthSession type is set to 'MANUAL'
129
+ For more details, check out https://docs.intunedhq.com/docs/05-references/intuned-json#configuration-properties.`);
132
130
  }
133
131
  const {
134
132
  startUrl,
135
133
  finishUrl
136
134
  } = intunedJson.authSessions;
137
135
  if (startUrl === undefined || finishUrl === undefined) {
138
- throw new _errors.CLIError(`Auth session type is recorder-based but start_url or finish_url is not set in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
136
+ throw new _errors.CLIError(`AuthSession type is recorder-based but start_url or finish_url is not set in ${await (0, _intunedJson.getIntunedSettingsFileName)()}.
137
+ Please set both values to use recorder-based AuthSessions.
138
+ For more details, check out https://docs.intunedhq.com/docs/05-references/intuned-json#configuration-properties`);
139
139
  }
140
140
  return {
141
141
  startUrl,
142
142
  finishUrl
143
143
  };
144
+ }
145
+ async function getAuthNotEnabledErrorMessage() {
146
+ return "AuthSessions are not enabled.\n" + `Enable AuthSessions in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use this feature.\n` + "See https://docs.intunedhq.com/docs/02-features/auth-sessions#1-enable-authsessions-for-your-project for more information.";
144
147
  }
@@ -8,14 +8,22 @@ exports.getBaseUrl = getBaseUrl;
8
8
  var _constants = require("../../../common/constants");
9
9
  var _errors = require("./errors");
10
10
  var _intunedJson = require("./intunedJson");
11
+ var _prompts = require("./prompts");
11
12
  async function getAuthCredentials(options) {
12
- const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId || process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
13
- const apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
13
+ const settings = await (0, _intunedJson.loadIntunedJson)();
14
+ let workspaceId = options.workspaceId || settings.workspaceId || process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
15
+ let apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
14
16
  if (!workspaceId) {
15
- throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
17
+ workspaceId = await (0, _prompts.promptForWorkspaceId)();
18
+ }
19
+ if (!workspaceId) {
20
+ throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}.\n` + `Expected format: UUID (e.g., 123e4567-e89b-12d3-a456-426614174000)\n` + `Find your workspace ID at: https://app.intuned.io/settings/api-keys`);
21
+ }
22
+ if (!apiKey) {
23
+ apiKey = await (0, _prompts.promptForApiKey)();
16
24
  }
17
25
  if (!apiKey) {
18
- throw new _errors.CLIError(`API key is required. Please provide it via command line options or ${_constants.API_KEY_ENV_VAR_KEY} environment variable.`);
26
+ throw new _errors.CLIError(`API key is required. Please provide it via command line options or ${_constants.API_KEY_ENV_VAR_KEY} environment variable.\n` + `Get your API key at: https://app.intuned.io/settings/api-keys`);
19
27
  }
20
28
  return {
21
29
  workspaceId,
@@ -1,14 +1,14 @@
1
1
  import type { BrowserContext } from "playwright";
2
- import type { runApiParametersSchema } from "../../../common/runApi";
3
- import { z } from "zod";
2
+ import type { RunApiRunOptions } from "@intuned/runtime-interface";
4
3
  declare let context: BrowserContext | null;
5
4
  export declare function _getContextForTest(): typeof context;
6
- type RunApiRunOptions = z.infer<typeof runApiParametersSchema>["runOptions"];
7
- export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, }: {
5
+ export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, cdpTabId, ignoreHttpErrors: cliIgnoreHttpErrors, }: {
8
6
  headless: boolean;
9
7
  proxy?: string;
10
8
  keepBrowserOpen: boolean;
11
9
  cdpUrl?: string;
10
+ cdpTabId?: string;
11
+ ignoreHttpErrors?: boolean;
12
12
  }): Promise<RunApiRunOptions>;
13
13
  export declare function isCliBrowserLaunched(): boolean;
14
14
  export declare function closeCliBrowser(): Promise<void>;
@@ -10,6 +10,8 @@ exports.isCliBrowserLaunched = isCliBrowserLaunched;
10
10
  var _launchBrowser = require("../../../common/launchBrowser");
11
11
  var _portfinder = require("portfinder");
12
12
  var _proxy = require("./proxy");
13
+ var _browserTabs = require("../../../common/browserTabs");
14
+ var _errors = require("./errors");
13
15
  let context = null;
14
16
  function _getContextForTest() {
15
17
  if (process.env.NODE_ENV !== "test") {
@@ -21,22 +23,31 @@ async function getCLIRunOptions({
21
23
  headless,
22
24
  proxy,
23
25
  keepBrowserOpen,
24
- cdpUrl
26
+ cdpUrl,
27
+ cdpTabId,
28
+ ignoreHttpErrors: cliIgnoreHttpErrors
25
29
  }) {
26
30
  if (context) {
27
31
  await closeCliBrowser();
28
32
  }
33
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)(cliIgnoreHttpErrors);
29
34
  if (cdpUrl) {
30
35
  return {
31
36
  environment: "cdp",
32
- cdpAddress: cdpUrl
37
+ cdpAddress: cdpUrl,
38
+ cdpTargetId: await resolveCdpTargetId({
39
+ cdpAddress: cdpUrl,
40
+ cdpTabId
41
+ }),
42
+ ignoreHttpErrors
33
43
  };
34
44
  }
35
45
  if (!keepBrowserOpen) {
36
46
  return {
37
47
  environment: "standalone",
38
48
  headless,
39
- proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined
49
+ proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
50
+ ignoreHttpErrors
40
51
  };
41
52
  }
42
53
  const port = await (0, _portfinder.getPort)({});
@@ -45,11 +56,13 @@ async function getCLIRunOptions({
45
56
  } = await (0, _launchBrowser.launchChromium)({
46
57
  headless,
47
58
  proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
48
- cdpPort: port
59
+ cdpPort: port,
60
+ ignoreHttpErrors
49
61
  }));
50
62
  return {
51
63
  environment: "cdp",
52
- cdpAddress: `http://localhost:${port}`
64
+ cdpAddress: `http://localhost:${port}`,
65
+ ignoreHttpErrors
53
66
  };
54
67
  }
55
68
  function isCliBrowserLaunched() {
@@ -61,4 +74,26 @@ async function closeCliBrowser() {
61
74
  await context.close();
62
75
  context = null;
63
76
  } catch (e) {}
77
+ }
78
+ async function resolveCdpTargetId({
79
+ cdpAddress,
80
+ cdpTabId
81
+ }) {
82
+ let tabs = [];
83
+ try {
84
+ tabs = await (0, _browserTabs.getCDPTabs)(cdpAddress);
85
+ } catch (e) {
86
+ if (cdpTabId) {
87
+ throw new _errors.CLIError(`Failed to fetch tabs from browser: ${e}`);
88
+ }
89
+ }
90
+ if (!cdpTabId) {
91
+ return tabs[0]?.id;
92
+ }
93
+ for (const tab of tabs) {
94
+ if (tab.id.startsWith(cdpTabId)) {
95
+ return tab.id;
96
+ }
97
+ }
98
+ throw new _errors.CLIError(`Tab ${cdpTabId} not found at ${cdpAddress}`);
64
99
  }
@@ -13,13 +13,13 @@ async function withCLIContext(fn, options) {
13
13
  async function getAuthSessionParameters() {
14
14
  const id = options?.authSessionId;
15
15
  if (!id) {
16
- throw new Error("getAuthSessionParameters cannot be called without using an auth session");
16
+ throw new Error("getAuthSessionParameters cannot be called without using an AuthSession");
17
17
  }
18
18
  const {
19
19
  metadata
20
20
  } = await (0, _auth.loadAuthSessionInstance)(id);
21
21
  if (metadata?.authSessionType === "MANUAL") {
22
- throw new Error("Auth session is recorder-based, it does not have parameters.");
22
+ throw new Error("AuthSession is recorder-based, it does not have parameters.");
23
23
  }
24
24
  return metadata?.authSessionInput ?? {};
25
25
  }
@@ -1,4 +1,4 @@
1
- import { RunAutomationError } from "../../../common/runApi/errors";
1
+ import { RunAutomationError } from "@intuned/runtime-interface";
2
2
  export declare class CLIError extends Error {
3
3
  autoColor: boolean;
4
4
  constructor(message: string, options?: {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CLIError = exports.CLIAssertionError = exports.AbortedCLIError = void 0;
7
7
  exports.logAutomationError = logAutomationError;
8
- var _errors = require("../../../common/runApi/errors");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  var _terminal = require("./terminal");
10
10
  class CLIError extends Error {
11
11
  constructor(message, options) {
@@ -31,7 +31,7 @@ class CLIAssertionError extends CLIError {
31
31
  exports.CLIAssertionError = CLIAssertionError;
32
32
  function logAutomationError(error) {
33
33
  (0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
34
- if (error instanceof _errors.AutomationError) {
34
+ if (error instanceof _runtimeInterface.AutomationError && error.error) {
35
35
  if (error.error.stack) {
36
36
  const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
37
37
  (0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
@@ -1,14 +1,15 @@
1
1
  export declare const loadIntunedJson: () => Promise<{
2
- projectName?: string | undefined;
2
+ stealthMode?: {
3
+ enabled: boolean;
4
+ } | undefined;
5
+ ignoreHttpErrors?: boolean | undefined;
3
6
  workspaceId?: string | undefined;
7
+ projectName?: string | undefined;
4
8
  metadata?: {
5
9
  defaultJobInput?: Record<string, any> | undefined;
6
10
  defaultRunPlaygroundInput?: Record<string, any> | undefined;
7
11
  testAuthSessionInput?: Record<string, any> | undefined;
8
12
  } | undefined;
9
- stealthMode?: {
10
- enabled: boolean;
11
- } | undefined;
12
13
  } & {
13
14
  [k: string]: unknown;
14
15
  } & ({
@@ -22,7 +23,7 @@ export declare const loadIntunedJson: () => Promise<{
22
23
  authSessions: {
23
24
  enabled: false;
24
25
  } | {
25
- type: "API" | "MANUAL";
26
+ type: "MANUAL" | "API";
26
27
  enabled: true;
27
28
  startUrl?: string | undefined;
28
29
  finishUrl?: string | undefined;
@@ -0,0 +1,3 @@
1
+ export declare function promptForProjectName(validate: (name: string) => boolean | string): Promise<string | undefined>;
2
+ export declare function promptForWorkspaceId(): Promise<string>;
3
+ export declare function promptForApiKey(): Promise<string>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.promptForApiKey = promptForApiKey;
7
+ exports.promptForProjectName = promptForProjectName;
8
+ exports.promptForWorkspaceId = promptForWorkspaceId;
9
+ var _prompts = _interopRequireDefault(require("prompts"));
10
+ var _zod = require("zod");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ async function promptForProjectName(validate) {
13
+ const {
14
+ projectName
15
+ } = await (0, _prompts.default)({
16
+ type: "text",
17
+ name: "projectName",
18
+ message: "Project name (required):",
19
+ validate
20
+ });
21
+ return projectName?.trim();
22
+ }
23
+ const workspaceIdSchema = _zod.z.string().uuid("Workspace ID must be a valid UUID");
24
+ async function promptForWorkspaceId() {
25
+ const {
26
+ workspaceId
27
+ } = await (0, _prompts.default)({
28
+ type: "text",
29
+ name: "workspaceId",
30
+ message: "Workspace ID (required):",
31
+ validate: value => {
32
+ const parsed = workspaceIdSchema.safeParse(String(value).trim());
33
+ return parsed.success ? true : parsed.error.errors[0].message;
34
+ }
35
+ });
36
+ return workspaceId.trim();
37
+ }
38
+ const apiKeySchema = _zod.z.string().min(1, "API Key cannot be empty").superRefine((val, ctx) => {
39
+ if (val.includes(" ")) {
40
+ ctx.addIssue({
41
+ code: "custom",
42
+ message: "API Key cannot contain spaces"
43
+ });
44
+ }
45
+ if (!val.startsWith("in1_")) {
46
+ ctx.addIssue({
47
+ code: "custom",
48
+ message: "API Key must start with 'in1_'"
49
+ });
50
+ }
51
+ if (val.length !== 36) {
52
+ ctx.addIssue({
53
+ code: "custom",
54
+ message: "API Key must be 36 characters long"
55
+ });
56
+ }
57
+ });
58
+ async function promptForApiKey() {
59
+ const {
60
+ apiKey
61
+ } = await (0, _prompts.default)({
62
+ type: "text",
63
+ name: "apiKey",
64
+ message: "API Key (required, get it at: https://app.intuned.io/settings/api-keys):",
65
+ validate: value => {
66
+ const parsed = apiKeySchema.safeParse(String(value).trim());
67
+ return parsed.success ? true : parsed.error.errors.map(e => e.message).join(", ");
68
+ }
69
+ });
70
+ return apiKey.trim();
71
+ }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.withTimeout = withTimeout;
7
7
  var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
8
- var _runApi = require("../../../common/runApi");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  function withTimeout(fn, timeout) {
10
10
  let reject;
11
11
  const abortController = new AbortController();
@@ -14,7 +14,7 @@ function withTimeout(fn, timeout) {
14
14
  });
15
15
  const timeoutId = setTimeout(() => {
16
16
  abortController.abort();
17
- reject(new _runApi.AutomationError(new Error("Timed out")));
17
+ reject(new _runtimeInterface.AutomationError(new Error("Timed out")));
18
18
  }, timeout);
19
19
  (0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
20
20
  timeoutId.refresh();
@@ -1,2 +1,2 @@
1
- import { RunApiParameters } from "../../../common/runApi";
1
+ import { RunApiParameters } from "@intuned/runtime-interface";
2
2
  export declare function withCLITrace<T>(fn: (tracing: NonNullable<RunApiParameters["tracing"]>) => T | Promise<T>, id: string | undefined): Promise<T>;
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cliCommandWrapper = cliCommandWrapper;
7
7
  var _terminal = require("./terminal");
8
- var _runApi = require("../../../common/runApi");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  var _browser = require("./browser");
10
10
  var _errors = require("./errors");
11
11
  var _zod = require("zod");
12
12
  var _validation = require("./validation");
13
+ var _pressAnyKey = _interopRequireDefault(require("press-any-key"));
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
15
  function cliCommandWrapper(argsSchema, optionsSchema, fn) {
14
16
  return async (...input) => {
15
17
  let keepBrowserOpen = false;
@@ -45,7 +47,7 @@ function cliCommandWrapper(argsSchema, optionsSchema, fn) {
45
47
  } else {
46
48
  (0, _terminal.terminal)(`${error.message}\n`);
47
49
  }
48
- } else if (error instanceof _runApi.AutomationError) {
50
+ } else if (error instanceof _runtimeInterface.AutomationError) {
49
51
  (0, _errors.logAutomationError)(error);
50
52
  } else {
51
53
  (0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
@@ -61,6 +63,14 @@ function cliCommandWrapper(argsSchema, optionsSchema, fn) {
61
63
  async function waitForUserInput() {
62
64
  if (!(0, _browser.isCliBrowserLaunched)()) return;
63
65
  if (!_terminal.terminalStdout.isTTY) return;
64
- (0, _terminal.terminal)("Press Enter to continue...");
65
- await _terminal.terminal.inputField().promise;
66
+ (0, _terminal.terminal)("Press any key to continue...");
67
+ try {
68
+ await (0, _pressAnyKey.default)("", {
69
+ ctrlC: "reject",
70
+ hideMessage: true
71
+ });
72
+ } catch {
73
+ throw new _errors.AbortedCLIError();
74
+ }
75
+ (0, _terminal.terminal)("\n");
66
76
  }
@@ -5,8 +5,7 @@ var _constants = require("../../common/constants");
5
5
  var _backend = require("./helpers/backend");
6
6
  var _intunedJson = require("../../common/intunedJson");
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
- 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); }
9
- 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; }
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
9
  require("../../common/binStartupScript");
11
10
  _dotenv.default.config({
12
11
  path: `.env`
@@ -1,17 +1,45 @@
1
- export interface FileSystemTree {
2
- [name: string]: DirectoryNode | FileNode;
3
- }
4
- export interface DirectoryNode {
5
- directory: FileSystemTree;
6
- }
7
- export interface FileNode {
1
+ import { z } from "zod";
2
+ declare const fileNodeSchema: z.ZodObject<{
3
+ file: z.ZodObject<{
4
+ contents: z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ contents: string | Uint8Array;
7
+ }, {
8
+ contents: string | Uint8Array;
9
+ }>;
10
+ }, "strip", z.ZodTypeAny, {
8
11
  file: {
9
- /**
10
- * The contents of the file, either as a UTF-8 string or as raw binary.
11
- */
12
12
  contents: string | Uint8Array;
13
13
  };
14
- }
14
+ }, {
15
+ file: {
16
+ contents: string | Uint8Array;
17
+ };
18
+ }>;
19
+ export type FileNode = z.infer<typeof fileNodeSchema>;
20
+ export type DirectoryNode = {
21
+ directory: {
22
+ [key: string]: FileNode | DirectoryNode;
23
+ };
24
+ };
25
+ export declare const fileSystemTreeSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodType<DirectoryNode, z.ZodTypeDef, DirectoryNode>, z.ZodObject<{
26
+ file: z.ZodObject<{
27
+ contents: z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ contents: string | Uint8Array;
30
+ }, {
31
+ contents: string | Uint8Array;
32
+ }>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ file: {
35
+ contents: string | Uint8Array;
36
+ };
37
+ }, {
38
+ file: {
39
+ contents: string | Uint8Array;
40
+ };
41
+ }>]>>;
42
+ export type FileSystemTree = z.infer<typeof fileSystemTreeSchema>;
15
43
  export interface AuthCredentials {
16
44
  workspaceId: string;
17
45
  apiKey: string;
@@ -20,7 +48,7 @@ export declare enum ApiAuthSessionBehavior {
20
48
  PERFORM_CHECK_AND_REFRESH = "PERFORM_CHECK_AND_REFRESH",
21
49
  SKIP_CHECK_AND_REFRESH = "SKIP_CHECK_AND_REFRESH"
22
50
  }
23
- export declare const CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
51
+ export declare const CHECK_FAILED_ERROR_MESSAGE = "AuthSession check failed";
24
52
  export type AuthSessionType = "API" | "MANUAL";
25
53
  export type AuthSessionMetadata = {
26
54
  createdAt: string;
@@ -39,3 +67,4 @@ export interface SessionStorageState {
39
67
  value: string;
40
68
  }[];
41
69
  }
70
+ export {};
@@ -3,10 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CHECK_FAILED_ERROR_MESSAGE = exports.ApiAuthSessionBehavior = void 0;
6
+ exports.fileSystemTreeSchema = exports.CHECK_FAILED_ERROR_MESSAGE = exports.ApiAuthSessionBehavior = void 0;
7
+ var _zod = require("zod");
8
+ const fileNodeSchema = _zod.z.object({
9
+ file: _zod.z.object({
10
+ contents: _zod.z.union([_zod.z.string(), _zod.z.instanceof(Uint8Array)])
11
+ })
12
+ });
13
+ const directoryNodeSchema = _zod.z.lazy(() => _zod.z.object({
14
+ directory: fileSystemTreeSchema
15
+ }));
16
+ const fileSystemTreeSchema = exports.fileSystemTreeSchema = _zod.z.record(_zod.z.union([directoryNodeSchema, fileNodeSchema]));
7
17
  let ApiAuthSessionBehavior = exports.ApiAuthSessionBehavior = function (ApiAuthSessionBehavior) {
8
18
  ApiAuthSessionBehavior["PERFORM_CHECK_AND_REFRESH"] = "PERFORM_CHECK_AND_REFRESH";
9
19
  ApiAuthSessionBehavior["SKIP_CHECK_AND_REFRESH"] = "SKIP_CHECK_AND_REFRESH";
10
20
  return ApiAuthSessionBehavior;
11
21
  }({});
12
- const CHECK_FAILED_ERROR_MESSAGE = exports.CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
22
+ const CHECK_FAILED_ERROR_MESSAGE = exports.CHECK_FAILED_ERROR_MESSAGE = "AuthSession check failed";
@@ -6,8 +6,7 @@ var _commander = require("commander");
6
6
  var fs = _interopRequireWildcard(require("fs-extra"));
7
7
  var path = _interopRequireWildcard(require("path"));
8
8
  var _template = require("./common/utils/template");
9
- 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); }
10
- 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; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
10
  _commander.program.description("Check TypeScript types in the project").option("-t, --template <type>", "template to use", "InterfaceTemplate").allowUnknownOption().action(async ({
12
11
  template
13
12
  }) => {
@@ -19,7 +19,7 @@ async function getAuthSessionParameters() {
19
19
  }
20
20
  const authSessionId = context.authSessionId;
21
21
  if ((0, _isNil.default)(authSessionId)) {
22
- throw new Error("Auth sessions are not enabled");
22
+ throw new Error("AuthSessions are not enabled");
23
23
  }
24
24
  const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`auth-session/${authSessionId}/parameters`, {
25
25
  method: "GET"
@@ -3,8 +3,7 @@
3
3
  var _dotenv = _interopRequireDefault(require("dotenv"));
4
4
  var path = _interopRequireWildcard(require("path"));
5
5
  var _intunedJson = require("./intunedJson");
6
- 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); }
7
- 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; }
6
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
8
  _dotenv.default.config({
10
9
  path: `.env`