@intuned/runtime-dev 1.3.18-interface.9 → 1.3.21-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/.babelrc +27 -0
  2. package/.eslintignore +10 -0
  3. package/.eslintrc.js +39 -0
  4. package/CHANGELOG.md +2 -1
  5. package/InterfaceTemplate/__utils.ts +63 -0
  6. package/InterfaceTemplate/index.playwright.ts +6 -0
  7. package/bin/intuned +20 -2
  8. package/dist/commands/api/run.d.ts +6 -0
  9. package/dist/commands/api/run.js +119 -0
  10. package/dist/commands/auth-sessions/load.d.ts +2 -0
  11. package/dist/commands/auth-sessions/load.js +38 -0
  12. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  13. package/dist/commands/auth-sessions/run-check.js +83 -0
  14. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  15. package/dist/commands/auth-sessions/run-create.js +85 -0
  16. package/dist/commands/browser/save-state.d.ts +2 -0
  17. package/dist/commands/browser/save-state.js +17 -0
  18. package/dist/commands/browser/start-browser.d.ts +2 -0
  19. package/dist/commands/browser/start-browser.js +14 -0
  20. package/dist/commands/build.d.ts +1 -0
  21. package/dist/commands/build.js +83 -0
  22. package/dist/commands/common/browserUtils.d.ts +14 -0
  23. package/dist/commands/common/browserUtils.js +66 -0
  24. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  25. package/dist/commands/common/getFirstLineNumber.js +101 -0
  26. package/dist/commands/common/getFirstLineNumber.test.js +227 -0
  27. package/dist/commands/common/projectExclusions.d.ts +2 -0
  28. package/dist/commands/common/projectExclusions.js +8 -0
  29. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  30. package/dist/commands/common/sendMessageToClient.js +10 -0
  31. package/dist/commands/common/tsNodeImport.d.ts +2 -5
  32. package/dist/commands/common/tsNodeImport.js +15 -56
  33. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  34. package/dist/commands/common/utils/fileUtils.js +32 -0
  35. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  36. package/dist/commands/common/utils/interfaceClient.js +98 -0
  37. package/dist/commands/common/utils/settings.d.ts +2 -0
  38. package/dist/commands/common/utils/settings.js +31 -0
  39. package/dist/commands/common/utils/template.d.ts +2 -0
  40. package/dist/commands/common/utils/template.js +30 -0
  41. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  42. package/dist/commands/get-headless-user-agent.js +18 -0
  43. package/dist/commands/interface/run.d.ts +1 -3
  44. package/dist/commands/interface/run.js +139 -2047
  45. package/dist/commands/ts-check.d.ts +2 -0
  46. package/dist/commands/ts-check.js +55 -0
  47. package/dist/common/Logger/Logger/index.d.ts +12 -0
  48. package/dist/common/Logger/Logger/index.js +60 -0
  49. package/dist/common/Logger/Logger/types.d.ts +8 -0
  50. package/dist/common/Logger/Logger/types.js +5 -0
  51. package/dist/common/Logger/index.d.ts +12 -0
  52. package/dist/common/Logger/index.js +60 -0
  53. package/dist/common/Logger/types.d.ts +8 -0
  54. package/dist/common/Logger/types.js +5 -0
  55. package/dist/common/asyncLocalStorage/index.d.ts +8 -9
  56. package/dist/common/asyncLocalStorage/index.js +9 -34
  57. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  58. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  59. package/dist/common/binStartupScript.d.ts +1 -2
  60. package/dist/common/binStartupScript.js +25 -132
  61. package/dist/common/browserTabs.d.ts +72 -0
  62. package/dist/common/browserTabs.js +74 -0
  63. package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
  64. package/dist/common/cleanEnvironmentVariables.js +7 -30
  65. package/dist/common/constants.d.ts +11 -13
  66. package/dist/common/constants.js +15 -58
  67. package/dist/common/contextStorageStateHelpers.d.ts +6 -8
  68. package/dist/common/contextStorageStateHelpers.js +26 -48
  69. package/dist/common/env.d.ts +6 -0
  70. package/dist/common/env.js +17 -0
  71. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  72. package/dist/common/extension/extensionsHelpers.js +147 -0
  73. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  74. package/dist/common/extension/intunedExtensionServer.js +178 -0
  75. package/dist/common/extension/types.d.ts +219 -0
  76. package/dist/common/extension/types.js +51 -0
  77. package/dist/common/formatZodError.d.ts +2 -0
  78. package/dist/{chunk-NDMVGENG.mjs → common/formatZodError.js} +9 -9
  79. package/dist/common/intunedJson.d.ts +249 -0
  80. package/dist/common/intunedJson.js +155 -0
  81. package/dist/common/jwtTokenManager.d.ts +4 -6
  82. package/dist/common/jwtTokenManager.js +40 -108
  83. package/dist/common/launchBrowser.d.ts +43 -0
  84. package/dist/common/launchBrowser.js +301 -0
  85. package/dist/common/playwrightContext.d.ts +31 -0
  86. package/dist/common/playwrightContext.js +154 -0
  87. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  88. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  89. package/dist/common/runApi/index.d.ts +6 -9
  90. package/dist/common/runApi/index.js +75 -1782
  91. package/dist/common/settingsSchema.d.ts +9 -9
  92. package/dist/common/settingsSchema.js +20 -55
  93. package/dist/common/setupContextHook.d.ts +16 -0
  94. package/dist/common/setupContextHook.js +22 -0
  95. package/dist/common/telemetry.d.ts +3 -6
  96. package/dist/common/telemetry.js +8 -41
  97. package/dist/index.d.ts +4 -6
  98. package/dist/index.js +92 -784
  99. package/dist/runtime/RunError.d.ts +5 -0
  100. package/dist/runtime/RunError.js +19 -0
  101. package/dist/runtime/attemptStore.d.ts +2 -0
  102. package/dist/runtime/attemptStore.js +23 -0
  103. package/dist/runtime/captcha.d.ts +15 -0
  104. package/dist/runtime/captcha.js +191 -0
  105. package/dist/runtime/captcha.test.js +821 -0
  106. package/dist/runtime/downloadDirectory.d.ts +1 -0
  107. package/dist/runtime/downloadDirectory.js +19 -0
  108. package/dist/runtime/enums.d.js +5 -0
  109. package/dist/runtime/enums.d.ts +11 -0
  110. package/dist/runtime/enums.js +18 -0
  111. package/dist/runtime/executionHelpers.test.js +52 -0
  112. package/dist/runtime/export.d.js +5 -0
  113. package/dist/runtime/export.d.ts +284 -0
  114. package/dist/runtime/extendPayload.d.ts +2 -0
  115. package/dist/runtime/extendPayload.js +21 -0
  116. package/dist/runtime/extendTimeout.d.ts +1 -0
  117. package/dist/runtime/extendTimeout.js +23 -0
  118. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  119. package/dist/runtime/getAiGatewayConfig.js +16 -0
  120. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  121. package/dist/runtime/getAuthSessionParameters.js +20 -0
  122. package/dist/runtime/index.d.ts +10 -168
  123. package/dist/runtime/index.js +88 -779
  124. package/dist/runtime/persistentStore.d.ts +2 -0
  125. package/dist/runtime/persistentStore.js +37 -0
  126. package/dist/runtime/persistentStore.test.js +101 -0
  127. package/dist/runtime/runInfo.d.ts +2 -0
  128. package/dist/runtime/runInfo.js +21 -0
  129. package/dist/vendor/runtime-interface.d.ts +1 -0
  130. package/dist/vendor/runtime-interface.js +497 -0
  131. package/package.json +21 -75
  132. package/template.tsconfig.json +11 -0
  133. package/tsconfig.eslint.json +5 -0
  134. package/tsconfig.json +25 -0
  135. package/tsup.config.ts +12 -0
  136. package/typedoc.json +49 -0
  137. package/dist/chunk-3AGSY4RT.mjs +0 -1108
  138. package/dist/chunk-3AGSY4RT.mjs.map +0 -1
  139. package/dist/chunk-6ZRJOUQS.mjs +0 -16
  140. package/dist/chunk-6ZRJOUQS.mjs.map +0 -1
  141. package/dist/chunk-7YL2JUTE.mjs +0 -146
  142. package/dist/chunk-7YL2JUTE.mjs.map +0 -1
  143. package/dist/chunk-BF45RZ32.mjs +0 -13
  144. package/dist/chunk-BF45RZ32.mjs.map +0 -1
  145. package/dist/chunk-FGV5T6SI.mjs +0 -27
  146. package/dist/chunk-FGV5T6SI.mjs.map +0 -1
  147. package/dist/chunk-G4PO5RIV.mjs +0 -85
  148. package/dist/chunk-G4PO5RIV.mjs.map +0 -1
  149. package/dist/chunk-LZOMFHX3.mjs +0 -38
  150. package/dist/chunk-LZOMFHX3.mjs.map +0 -1
  151. package/dist/chunk-NDMVGENG.mjs.map +0 -1
  152. package/dist/chunk-UO2E7T7T.mjs +0 -787
  153. package/dist/chunk-UO2E7T7T.mjs.map +0 -1
  154. package/dist/chunk-W4UX6G4X.mjs +0 -17
  155. package/dist/chunk-W4UX6G4X.mjs.map +0 -1
  156. package/dist/chunk-XOAZ2MGA.mjs +0 -59
  157. package/dist/chunk-XOAZ2MGA.mjs.map +0 -1
  158. package/dist/commands/common/tsNodeImport.d.mts +0 -5
  159. package/dist/commands/common/tsNodeImport.js.map +0 -1
  160. package/dist/commands/common/tsNodeImport.mjs +0 -45
  161. package/dist/commands/common/tsNodeImport.mjs.map +0 -1
  162. package/dist/commands/interface/run.d.mts +0 -3
  163. package/dist/commands/interface/run.js.map +0 -1
  164. package/dist/commands/interface/run.mjs +0 -256
  165. package/dist/commands/interface/run.mjs.map +0 -1
  166. package/dist/common/asyncLocalStorage/index.d.mts +0 -17
  167. package/dist/common/asyncLocalStorage/index.js.map +0 -1
  168. package/dist/common/asyncLocalStorage/index.mjs +0 -12
  169. package/dist/common/asyncLocalStorage/index.mjs.map +0 -1
  170. package/dist/common/binStartupScript.d.mts +0 -2
  171. package/dist/common/binStartupScript.js.map +0 -1
  172. package/dist/common/binStartupScript.mjs +0 -135
  173. package/dist/common/binStartupScript.mjs.map +0 -1
  174. package/dist/common/cleanEnvironmentVariables.d.mts +0 -3
  175. package/dist/common/cleanEnvironmentVariables.js.map +0 -1
  176. package/dist/common/cleanEnvironmentVariables.mjs +0 -8
  177. package/dist/common/cleanEnvironmentVariables.mjs.map +0 -1
  178. package/dist/common/constants.d.mts +0 -13
  179. package/dist/common/constants.js.map +0 -1
  180. package/dist/common/constants.mjs +0 -28
  181. package/dist/common/constants.mjs.map +0 -1
  182. package/dist/common/contextStorageStateHelpers.d.mts +0 -24
  183. package/dist/common/contextStorageStateHelpers.js.map +0 -1
  184. package/dist/common/contextStorageStateHelpers.mjs +0 -10
  185. package/dist/common/contextStorageStateHelpers.mjs.map +0 -1
  186. package/dist/common/jwtTokenManager.d.mts +0 -19
  187. package/dist/common/jwtTokenManager.js.map +0 -1
  188. package/dist/common/jwtTokenManager.mjs +0 -11
  189. package/dist/common/jwtTokenManager.mjs.map +0 -1
  190. package/dist/common/runApi/index.d.mts +0 -11
  191. package/dist/common/runApi/index.js.map +0 -1
  192. package/dist/common/runApi/index.mjs +0 -19
  193. package/dist/common/runApi/index.mjs.map +0 -1
  194. package/dist/common/settingsSchema.d.mts +0 -540
  195. package/dist/common/settingsSchema.js.map +0 -1
  196. package/dist/common/settingsSchema.mjs +0 -10
  197. package/dist/common/settingsSchema.mjs.map +0 -1
  198. package/dist/common/telemetry.d.mts +0 -6
  199. package/dist/common/telemetry.js.map +0 -1
  200. package/dist/common/telemetry.mjs +0 -31
  201. package/dist/common/telemetry.mjs.map +0 -1
  202. package/dist/export.d-BAUMB-lG.d.mts +0 -140
  203. package/dist/export.d-BAUMB-lG.d.ts +0 -140
  204. package/dist/index.d.mts +0 -6
  205. package/dist/index.js.map +0 -1
  206. package/dist/index.mjs +0 -48
  207. package/dist/index.mjs.map +0 -1
  208. package/dist/runtime/index.d.mts +0 -168
  209. package/dist/runtime/index.js.map +0 -1
  210. package/dist/runtime/index.mjs +0 -43
  211. package/dist/runtime/index.mjs.map +0 -1
  212. /package/dist/common/assets/{assets/browser_scripts.js → browser_scripts.js} +0 -0
package/.babelrc ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "chrome": 130,
8
+ "node": "20"
9
+ },
10
+ "modules": "commonjs"
11
+ }
12
+ ],
13
+ "@babel/preset-typescript"
14
+ ],
15
+ "plugins": [
16
+ ["module-resolver", {
17
+ "root": ["./src"],
18
+ "alias": {
19
+ "@intuned/runtime-interface": "./src/vendor/runtime-interface"
20
+ }
21
+ }],
22
+ "babel-plugin-macros",
23
+ "@babel/plugin-transform-export-namespace-from"
24
+ ],
25
+ "sourceMaps": false,
26
+ "comments": false
27
+ }
package/.eslintignore ADDED
@@ -0,0 +1,10 @@
1
+ node_modules
2
+ dist
3
+ .eslintrc.js
4
+ *.test.ts
5
+ *.js
6
+ types-package
7
+ vite.config.ts
8
+ reports
9
+ intuned
10
+ **/*.d.ts
package/.eslintrc.js ADDED
@@ -0,0 +1,39 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: "@typescript-eslint/parser",
4
+ parserOptions: {
5
+ project: "./tsconfig.eslint.json",
6
+ tsconfigRootDir: __dirname,
7
+ },
8
+ plugins: ["@typescript-eslint", "deprecation", "prettier"],
9
+ ignorePatterns: ["src/common/browserScripts/rollup.config.mjs"],
10
+ extends: [
11
+ "eslint:recommended",
12
+ "plugin:@typescript-eslint/eslint-recommended",
13
+ "plugin:@typescript-eslint/recommended",
14
+ ],
15
+ rules: {
16
+ "@next/next/no-html-link-for-pages": 0,
17
+ "prettier/prettier": "error",
18
+
19
+ // recommended for safety
20
+ "@typescript-eslint/no-floating-promises": "error", // forgetting to await Activities and Workflow APIs is bad
21
+ "deprecation/deprecation": "warn",
22
+
23
+ // code style preference
24
+ "object-shorthand": ["warn", "always"],
25
+
26
+ // relaxed rules, for convenience
27
+ "@typescript-eslint/no-unused-vars": [
28
+ "warn",
29
+ {
30
+ argsIgnorePattern: "^_",
31
+ varsIgnorePattern: "^_",
32
+ },
33
+ ],
34
+ "@typescript-eslint/no-explicit-any": "off",
35
+ "@typescript-eslint/no-empty-interface": "off",
36
+ "@typescript-eslint/ban-ts-comment": "warn",
37
+ "no-empty": "warn",
38
+ },
39
+ };
package/CHANGELOG.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # UNRELEASED
2
2
 
3
- -
3
+ - Add support for `ignoreHttpErrors` parameter to handle HTTP errors during browser navigation. Can be configured via `IGNORE_HTTP_ERRORS` environment variable or `ignoreHttpErrors` field in Intuned.json config file.
4
+ - Add `timeout` parameter (in seconds, defaults to 30) to `launchBrowser` and `launchChromium` functions
4
5
 
5
6
  # 1.3.11
6
7
 
@@ -0,0 +1,63 @@
1
+ // @ts-ignore
2
+ import type { ImportFunction } from "@intuned/runtime-interface";
3
+
4
+ import { err, ok } from "neverthrow";
5
+
6
+ export const importModule: ImportFunction = async (path: string) => {
7
+ const [folderName, ...functionNameParts] = path.split("/");
8
+ const functionNameDepth = functionNameParts.length;
9
+
10
+ // string literals should be inline
11
+ // currently we support only 5 levels of depth
12
+ // rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
13
+ let imported: any = undefined;
14
+ try {
15
+ switch (functionNameDepth) {
16
+ case 1:
17
+ imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
18
+ break;
19
+ case 2:
20
+ imported = await import(
21
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`
22
+ );
23
+ break;
24
+ case 3:
25
+ imported = await import(
26
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`
27
+ );
28
+ break;
29
+ case 4:
30
+ imported = await import(
31
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`
32
+ );
33
+ break;
34
+ case 5:
35
+ imported = await import(
36
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`
37
+ );
38
+ break;
39
+ default:
40
+ return err({
41
+ type: "other",
42
+ error: new Error(
43
+ `intuned supports maximum 5 levels of depth in the api folder`
44
+ ),
45
+ });
46
+ }
47
+ return ok(imported);
48
+ } catch (e: any) {
49
+ if (
50
+ "message" in e &&
51
+ typeof e.message === "string" &&
52
+ e.message.includes("Unknown variable dynamic import")
53
+ ) {
54
+ return err({
55
+ type: "not_found",
56
+ });
57
+ }
58
+ return err({
59
+ type: "other",
60
+ error: e,
61
+ });
62
+ }
63
+ };
@@ -0,0 +1,6 @@
1
+ require("@intuned/runtime/dist/common/binStartupScript");
2
+ import { runAutomationCLI } from "@intuned/runtime/dist/commands/interface/run";
3
+
4
+ import { importModule } from "./__utils";
5
+
6
+ runAutomationCLI(importModule);
package/bin/intuned CHANGED
@@ -1,4 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require("../dist/common/binStartupScript.js");
4
- require("../dist/commands/intuned-cli/main.js");
3
+ // detect `intunedctl` in PATH and run it with the provided arguments
4
+ const spawn = require("child_process").spawn;
5
+ const which = require("which");
6
+
7
+ const intunedctlPath = which.sync("intunedctl", { nothrow: true });
8
+
9
+ if (!intunedctlPath) {
10
+ console.error(
11
+ "Install Intuned CLI globally with `npm install -g @intuned/cli` to run this command."
12
+ );
13
+ process.exit(1);
14
+ }
15
+
16
+ const child = spawn(intunedctlPath, process.argv.slice(2), {
17
+ stdio: "inherit",
18
+ });
19
+
20
+ child.on("exit", (code) => {
21
+ process.exit(code ?? 0);
22
+ });
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ export declare function executeCLI(apiName: string, mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless", inputData: object | null | undefined, options: {
3
+ cdpAddress: string;
4
+ authSessionPath: undefined | string;
5
+ outputFileId: string | undefined;
6
+ }): Promise<void>;
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.executeCLI = executeCLI;
8
+ var _commander = require("commander");
9
+ var fs = _interopRequireWildcard(require("fs-extra"));
10
+ var _settings = require("../common/utils/settings");
11
+ var _dotenv = _interopRequireDefault(require("dotenv"));
12
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
13
+ var _enums = require("../../runtime/enums");
14
+ var _cleanEnvironmentVariables = require("../../common/cleanEnvironmentVariables");
15
+ var _Logger = require("../../common/Logger");
16
+ var _nanoid = require("nanoid");
17
+ var _chalk = _interopRequireDefault(require("chalk"));
18
+ var _runApi = require("../../common/runApi");
19
+ var _runtimeInterface = require("../../vendor/runtime-interface");
20
+ var _tsNodeImport = require("../common/tsNodeImport");
21
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
22
+ var _constants = require("../../common/constants");
23
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
+ 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); }
25
+ _dotenv.default.config({
26
+ path: `.env`
27
+ });
28
+ async function executeCLI(apiName, mode, inputData, options) {
29
+ (0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
30
+ let authSessionPathToUse = null;
31
+ const settings = await (0, _settings.getSettings)();
32
+ if (settings.authSessions.enabled) {
33
+ if (!options.authSessionPath) {
34
+ throw new Error("AuthSessions are enabled but no AuthSession provided.\n" + "Please provide --auth-session-path option.\n" + "See https://docs.intunedhq.com/docs/cli/auth-sessions for more information.");
35
+ }
36
+ authSessionPathToUse = options.authSessionPath;
37
+ } else {
38
+ if (options.authSessionPath) {
39
+ throw new Error("Authentication is not enabled but AuthSession was provided.\n" + "Enable AuthSessions in Intuned.json to use this feature.\n" + "See https://docs.intunedhq.com/docs/cli/auth-sessions for more information.");
40
+ }
41
+ }
42
+ const runApiResult = await (0, _runApi.runApi)({
43
+ automationFunction: {
44
+ name: `${_constants.API_FOLDER_NAME}/${apiName}`,
45
+ params: inputData
46
+ },
47
+ auth: authSessionPathToUse ? {
48
+ session: {
49
+ type: "file",
50
+ path: authSessionPathToUse
51
+ }
52
+ } : undefined,
53
+ runOptions: {
54
+ environment: "cdp",
55
+ cdpAddress: options.cdpAddress
56
+ },
57
+ importFunction: _tsNodeImport.tsNodeImport
58
+ });
59
+ if (runApiResult.isErr()) {
60
+ if (runApiResult.error instanceof _runtimeInterface.AutomationError) {
61
+ throw runApiResult.error.error;
62
+ }
63
+ console.error(runApiResult.error);
64
+ throw new Error("An error occurred while running the API");
65
+ }
66
+ const {
67
+ result,
68
+ extendedPayloads: payloadToAppend
69
+ } = runApiResult.value;
70
+ const resultsDir = "/tmp/run-results";
71
+ if (options.outputFileId) {
72
+ _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
73
+ fs.ensureDirSync(resultsDir);
74
+ const path = `${resultsDir}/${options.outputFileId}.json`;
75
+ await fs.writeJson(path, {
76
+ input: inputData,
77
+ output: result
78
+ }, {
79
+ spaces: 2
80
+ });
81
+ } else {
82
+ console.log("result:", result);
83
+ }
84
+ const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
85
+ if (hasPayloadToAppend && options.outputFileId) {
86
+ _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
87
+ fs.ensureDirSync(resultsDir);
88
+ const path = `${resultsDir}/${options.outputFileId}-payloads-to-append.json`;
89
+ await fs.writeJson(path, payloadToAppend, {
90
+ spaces: 2
91
+ });
92
+ } else if (hasPayloadToAppend) {
93
+ _Logger.logger.info("payload to append:", payloadToAppend);
94
+ _Logger.logger.info("This will only take an effect if this API run was part of a job.");
95
+ }
96
+ }
97
+ _commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "AuthSession to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").option("--authSessionParameters <authSessionParameters>", "parameters used to create the used AuthSession").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
98
+ let inputData = null;
99
+ if (options.input) {
100
+ inputData = await fs.readJSON(options.input);
101
+ } else if (options.json) {
102
+ inputData = JSON.parse(options.json);
103
+ } else {
104
+ inputData = {};
105
+ }
106
+ let authSessionParametersJson = undefined;
107
+ if (!(0, _isNil.default)(options?.authSessionParameters)) {
108
+ authSessionParametersJson = JSON.parse(options.authSessionParameters);
109
+ }
110
+ await (0, _asyncLocalStorage.runWithContext)({
111
+ runEnvironment: _enums.RunEnvironment.IDE,
112
+ extendedPayloads: [],
113
+ runId: (0, _nanoid.nanoid)(),
114
+ proxy: options.proxy,
115
+ getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
116
+ }, () => executeCLI(apiName, mode, inputData, options));
117
+ process.exit(0);
118
+ });
119
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _playwrightContext = require("../../common/playwrightContext");
6
+ var _settings = require("../common/utils/settings");
7
+ var _dotenv = _interopRequireDefault(require("dotenv"));
8
+ var _neverthrow = require("neverthrow");
9
+ var _launchBrowser = require("../../common/launchBrowser");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ _dotenv.default.config({
12
+ path: `.env`
13
+ });
14
+ _commander.program.description("load AuthSession to browser").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "AuthSession to use when executing the api").allowUnknownOption().action(async ({
15
+ cdpAddress,
16
+ authSessionPath
17
+ }) => {
18
+ const setting = await (0, _settings.getSettings)();
19
+ if (!setting.authSessions.enabled) {
20
+ throw new Error("Authentication required but not configured.\n" + "Enable AuthSessions in Intuned.json to use this feature.\n" + "See https://docs.intunedhq.com/docs/cli/auth-sessions for more information.");
21
+ }
22
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)();
23
+ await (0, _playwrightContext.withPlaywrightContext)({
24
+ cdpAddress,
25
+ ignoreHttpErrors
26
+ }, async context => {
27
+ await (0, _playwrightContext.loadSessionToContext)({
28
+ context,
29
+ session: {
30
+ type: "file",
31
+ path: authSessionPath
32
+ }
33
+ });
34
+ return (0, _neverthrow.ok)({});
35
+ });
36
+ process.exit(0);
37
+ });
38
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var fs = _interopRequireWildcard(require("fs-extra"));
6
+ var _fileUtils = require("../common/utils/fileUtils");
7
+ var _settings = require("../common/utils/settings");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _constants = require("../../common/constants");
10
+ var _runApi = require("../../common/runApi");
11
+ var _runtimeInterface = require("../../vendor/runtime-interface");
12
+ var _tsNodeImport = require("../common/tsNodeImport");
13
+ var _enums = require("../../runtime/enums");
14
+ var _nanoid = require("nanoid");
15
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
16
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
17
+ var _launchBrowser = require("../../common/launchBrowser");
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ 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); }
20
+ _dotenv.default.config({
21
+ path: `.env`
22
+ });
23
+ _commander.program.description("run AuthSession check").option("--cdpAddress <cdpAddress>", "CDP address").option("--authSessionPath <authSession>", "AuthSession to use when executing the check").option("--authSessionParameters <authSessionParameters>", "parameters used to create the used AuthSession").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
24
+ cdpAddress,
25
+ authSessionPath,
26
+ authSessionParameters
27
+ }) => {
28
+ const setting = await (0, _settings.getSettings)();
29
+ if (!setting.authSessions.enabled) {
30
+ throw new Error("Authentication required but not configured.\n" + "Enable AuthSessions in Intuned.json to use this feature.\n" + "See https://docs.intunedhq.com/docs/cli/auth-sessions for more information.");
31
+ }
32
+ const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
33
+ if (!fs.exists(checkFilePath)) {
34
+ throw new Error("AuthSession check file not found");
35
+ }
36
+ let authSessionParametersJson = undefined;
37
+ if (!(0, _isNil.default)(authSessionParameters)) {
38
+ authSessionParametersJson = JSON.parse(authSessionParameters);
39
+ }
40
+ const runApiResult = await (0, _asyncLocalStorage.runWithContext)({
41
+ runEnvironment: _enums.RunEnvironment.IDE,
42
+ extendedPayloads: [],
43
+ runId: (0, _nanoid.nanoid)(),
44
+ getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
45
+ }, async () => {
46
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)();
47
+ return await (0, _runApi.runApi)({
48
+ automationFunction: {
49
+ name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
50
+ },
51
+ runOptions: cdpAddress !== undefined ? {
52
+ environment: "cdp",
53
+ cdpAddress,
54
+ ignoreHttpErrors
55
+ } : {
56
+ environment: "standalone",
57
+ headless: mode !== "playwright",
58
+ ignoreHttpErrors
59
+ },
60
+ auth: {
61
+ session: {
62
+ type: "file",
63
+ path: authSessionPath
64
+ }
65
+ },
66
+ importFunction: _tsNodeImport.tsNodeImport
67
+ });
68
+ });
69
+ if (runApiResult.isErr()) {
70
+ if (runApiResult.error instanceof _runtimeInterface.AutomationError) {
71
+ throw runApiResult.error.error;
72
+ }
73
+ console.error(runApiResult.error);
74
+ throw new Error("Error running AuthSession check");
75
+ }
76
+ const result = runApiResult.value.result;
77
+ console.log("check result", result);
78
+ if (!result) {
79
+ throw new Error("AuthSession check failed");
80
+ }
81
+ process.exit(0);
82
+ });
83
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var fs = _interopRequireWildcard(require("fs-extra"));
6
+ var _fileUtils = require("../common/utils/fileUtils");
7
+ var _settings = require("../common/utils/settings");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _constants = require("../../common/constants");
10
+ var _runApi = require("../../common/runApi");
11
+ var _runtimeInterface = require("../../vendor/runtime-interface");
12
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
13
+ var _nanoid = require("nanoid");
14
+ var _enums = require("../../runtime/enums");
15
+ var _tsNodeImport = require("../common/tsNodeImport");
16
+ var _launchBrowser = require("../../common/launchBrowser");
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ 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); }
19
+ _dotenv.default.config({
20
+ path: `.env`
21
+ });
22
+ _commander.program.description("run AuthSession create").option("--cdpAddress <cdpAddress>", "CDP address").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--authSessionPath <authSession>", "AuthSession to use when executing the api").option("--pathToSave <pathToSave>", "path to save the AuthSession, if not provided, will discard the AuthSession").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
23
+ cdpAddress,
24
+ pathToSave,
25
+ input,
26
+ json
27
+ }) => {
28
+ let inputData = null;
29
+ if (input) {
30
+ inputData = await fs.readJSON(input);
31
+ } else if (json) {
32
+ inputData = JSON.parse(json);
33
+ } else {
34
+ inputData = {};
35
+ }
36
+ const setting = await (0, _settings.getSettings)();
37
+ if (!setting.authSessions.enabled) {
38
+ throw new Error("Authentication required but not configured.\n" + "Enable AuthSessions in Intuned.json to use this feature.\n" + "See https://docs.intunedhq.com/docs/cli/auth-sessions for more information.");
39
+ }
40
+ const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
41
+ if (!fs.exists(createFilePath)) {
42
+ throw new Error("AuthSession create file not found");
43
+ }
44
+ async function runCreate() {
45
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)();
46
+ const result = await (0, _runApi.runApi)({
47
+ automationFunction: {
48
+ name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`,
49
+ params: inputData
50
+ },
51
+ runOptions: cdpAddress !== undefined ? {
52
+ environment: "cdp",
53
+ cdpAddress,
54
+ ignoreHttpErrors
55
+ } : {
56
+ environment: "standalone",
57
+ headless: mode !== "playwright",
58
+ ignoreHttpErrors
59
+ },
60
+ retrieveSession: true,
61
+ importFunction: _tsNodeImport.tsNodeImport
62
+ });
63
+ if (result.isErr()) {
64
+ if (result.error instanceof _runtimeInterface.AutomationError) {
65
+ throw result.error.error;
66
+ }
67
+ console.error(result.error);
68
+ throw new Error("Error while running create");
69
+ }
70
+ const fullState = result.value.session;
71
+ if (pathToSave) {
72
+ const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
73
+ fs.ensureFileSync(fullPath);
74
+ await fs.writeJSON(fullPath, fullState);
75
+ }
76
+ }
77
+ await (0, _asyncLocalStorage.runWithContext)({
78
+ runEnvironment: _enums.RunEnvironment.IDE,
79
+ extendedPayloads: [],
80
+ runId: (0, _nanoid.nanoid)(),
81
+ getAuthSessionParameters: async () => inputData
82
+ }, runCreate);
83
+ process.exit(0);
84
+ });
85
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _browserUtils = require("../common/browserUtils");
6
+ var _dotenv = _interopRequireDefault(require("dotenv"));
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ _dotenv.default.config({
9
+ path: `.env`
10
+ });
11
+ _commander.program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
12
+ path
13
+ }) => {
14
+ await (0, _browserUtils.saveSessionFromOpenedBrowser)(path);
15
+ process.exit(0);
16
+ });
17
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _browserUtils = require("../common/browserUtils");
6
+ var _dotenv = _interopRequireDefault(require("dotenv"));
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ _dotenv.default.config({
9
+ path: `.env`
10
+ });
11
+ _commander.program.description("start browser testing purposes").allowUnknownOption().action(async () => {
12
+ await (0, _browserUtils.startOrRestartBrowser)();
13
+ });
14
+ _commander.program.parse(process.argv);
@@ -0,0 +1 @@
1
+ export {};