@intuned/runtime-dev 1.3.18-interface.9 → 1.3.19-new-cli.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/.babelrc +27 -0
  2. package/.claude/settings.local.json +7 -0
  3. package/.eslintignore +10 -0
  4. package/.eslintrc.js +39 -0
  5. package/CHANGELOG.md +1 -1
  6. package/InterfaceTemplate/__utils.ts +63 -0
  7. package/InterfaceTemplate/index.playwright.ts +6 -0
  8. package/bin/intuned +20 -2
  9. package/dist/commands/api/run.d.ts +6 -0
  10. package/dist/commands/api/run.js +119 -0
  11. package/dist/commands/auth-sessions/load.d.ts +2 -0
  12. package/dist/commands/auth-sessions/load.js +35 -0
  13. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  14. package/dist/commands/auth-sessions/run-check.js +74 -0
  15. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  16. package/dist/commands/auth-sessions/run-create.js +78 -0
  17. package/dist/commands/browser/save-state.d.ts +2 -0
  18. package/dist/commands/browser/save-state.js +17 -0
  19. package/dist/commands/browser/start-browser.d.ts +2 -0
  20. package/dist/commands/browser/start-browser.js +14 -0
  21. package/dist/commands/build.d.ts +1 -0
  22. package/dist/commands/build.js +83 -0
  23. package/dist/commands/common/browserUtils.d.ts +14 -0
  24. package/dist/commands/common/browserUtils.js +57 -0
  25. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  26. package/dist/commands/common/getFirstLineNumber.js +101 -0
  27. package/dist/commands/common/getFirstLineNumber.test.js +227 -0
  28. package/dist/commands/common/projectExclusions.d.ts +2 -0
  29. package/dist/commands/common/projectExclusions.js +8 -0
  30. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  31. package/dist/commands/common/sendMessageToClient.js +10 -0
  32. package/dist/commands/common/tsNodeImport.d.ts +2 -5
  33. package/dist/commands/common/tsNodeImport.js +15 -56
  34. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  35. package/dist/commands/common/utils/fileUtils.js +32 -0
  36. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  37. package/dist/commands/common/utils/interfaceClient.js +98 -0
  38. package/dist/commands/common/utils/settings.d.ts +2 -0
  39. package/dist/commands/common/utils/settings.js +31 -0
  40. package/dist/commands/common/utils/template.d.ts +2 -0
  41. package/dist/commands/common/utils/template.js +30 -0
  42. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  43. package/dist/commands/get-headless-user-agent.js +18 -0
  44. package/dist/commands/interface/run.d.ts +1 -3
  45. package/dist/commands/interface/run.js +139 -2047
  46. package/dist/commands/ts-check.d.ts +2 -0
  47. package/dist/commands/ts-check.js +55 -0
  48. package/dist/common/Logger/Logger/index.d.ts +12 -0
  49. package/dist/common/Logger/Logger/index.js +60 -0
  50. package/dist/common/Logger/Logger/types.d.ts +8 -0
  51. package/dist/common/Logger/Logger/types.js +5 -0
  52. package/dist/common/Logger/index.d.ts +12 -0
  53. package/dist/common/Logger/index.js +60 -0
  54. package/dist/common/Logger/types.d.ts +8 -0
  55. package/dist/common/Logger/types.js +5 -0
  56. package/dist/common/asyncLocalStorage/index.d.ts +8 -9
  57. package/dist/common/asyncLocalStorage/index.js +9 -34
  58. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  59. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  60. package/dist/common/binStartupScript.d.ts +1 -2
  61. package/dist/common/binStartupScript.js +25 -132
  62. package/dist/common/browserTabs.d.ts +72 -0
  63. package/dist/common/browserTabs.js +74 -0
  64. package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
  65. package/dist/common/cleanEnvironmentVariables.js +7 -30
  66. package/dist/common/constants.d.ts +11 -13
  67. package/dist/common/constants.js +15 -58
  68. package/dist/common/contextStorageStateHelpers.d.ts +6 -8
  69. package/dist/common/contextStorageStateHelpers.js +26 -48
  70. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  71. package/dist/common/extension/extensionsHelpers.js +147 -0
  72. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  73. package/dist/common/extension/intunedExtensionServer.js +178 -0
  74. package/dist/common/extension/types.d.ts +219 -0
  75. package/dist/common/extension/types.js +51 -0
  76. package/dist/common/formatZodError.d.ts +2 -0
  77. package/dist/{chunk-NDMVGENG.mjs → common/formatZodError.js} +9 -9
  78. package/dist/common/intunedJson.d.ts +244 -0
  79. package/dist/common/intunedJson.js +154 -0
  80. package/dist/common/jwtTokenManager.d.ts +4 -6
  81. package/dist/common/jwtTokenManager.js +40 -108
  82. package/dist/common/launchBrowser.d.ts +36 -0
  83. package/dist/common/launchBrowser.js +269 -0
  84. package/dist/common/playwrightContext.d.ts +29 -0
  85. package/dist/common/playwrightContext.js +148 -0
  86. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  87. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  88. package/dist/common/runApi/index.d.ts +6 -9
  89. package/dist/common/runApi/index.js +73 -1782
  90. package/dist/common/settingsSchema.d.ts +6 -9
  91. package/dist/common/settingsSchema.js +18 -54
  92. package/dist/common/setupContextHook.d.ts +16 -0
  93. package/dist/common/setupContextHook.js +22 -0
  94. package/dist/common/telemetry.d.ts +3 -6
  95. package/dist/common/telemetry.js +8 -41
  96. package/dist/index.d.ts +4 -6
  97. package/dist/index.js +92 -784
  98. package/dist/runtime/RunError.d.ts +5 -0
  99. package/dist/runtime/RunError.js +19 -0
  100. package/dist/runtime/attemptStore.d.ts +2 -0
  101. package/dist/runtime/attemptStore.js +23 -0
  102. package/dist/runtime/captcha.d.ts +15 -0
  103. package/dist/runtime/captcha.js +191 -0
  104. package/dist/runtime/captcha.test.js +821 -0
  105. package/dist/runtime/downloadDirectory.d.ts +1 -0
  106. package/dist/runtime/downloadDirectory.js +19 -0
  107. package/dist/runtime/enums.d.js +5 -0
  108. package/dist/runtime/enums.d.ts +11 -0
  109. package/dist/runtime/enums.js +18 -0
  110. package/dist/runtime/executionHelpers.test.js +52 -0
  111. package/dist/runtime/export.d.js +5 -0
  112. package/dist/runtime/export.d.ts +284 -0
  113. package/dist/runtime/extendPayload.d.ts +2 -0
  114. package/dist/runtime/extendPayload.js +21 -0
  115. package/dist/runtime/extendTimeout.d.ts +1 -0
  116. package/dist/runtime/extendTimeout.js +23 -0
  117. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  118. package/dist/runtime/getAiGatewayConfig.js +16 -0
  119. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  120. package/dist/runtime/getAuthSessionParameters.js +20 -0
  121. package/dist/runtime/index.d.ts +10 -168
  122. package/dist/runtime/index.js +88 -779
  123. package/dist/runtime/persistentStore.d.ts +2 -0
  124. package/dist/runtime/persistentStore.js +37 -0
  125. package/dist/runtime/persistentStore.test.js +101 -0
  126. package/dist/runtime/runInfo.d.ts +2 -0
  127. package/dist/runtime/runInfo.js +21 -0
  128. package/dist/vendor/runtime-interface.d.ts +1 -0
  129. package/dist/vendor/runtime-interface.js +479 -0
  130. package/package.json +20 -74
  131. package/template.tsconfig.json +11 -0
  132. package/tsconfig.eslint.json +5 -0
  133. package/tsconfig.json +25 -0
  134. package/tsup.config.ts +12 -0
  135. package/typedoc.json +49 -0
  136. package/dist/chunk-3AGSY4RT.mjs +0 -1108
  137. package/dist/chunk-3AGSY4RT.mjs.map +0 -1
  138. package/dist/chunk-6ZRJOUQS.mjs +0 -16
  139. package/dist/chunk-6ZRJOUQS.mjs.map +0 -1
  140. package/dist/chunk-7YL2JUTE.mjs +0 -146
  141. package/dist/chunk-7YL2JUTE.mjs.map +0 -1
  142. package/dist/chunk-BF45RZ32.mjs +0 -13
  143. package/dist/chunk-BF45RZ32.mjs.map +0 -1
  144. package/dist/chunk-FGV5T6SI.mjs +0 -27
  145. package/dist/chunk-FGV5T6SI.mjs.map +0 -1
  146. package/dist/chunk-G4PO5RIV.mjs +0 -85
  147. package/dist/chunk-G4PO5RIV.mjs.map +0 -1
  148. package/dist/chunk-LZOMFHX3.mjs +0 -38
  149. package/dist/chunk-LZOMFHX3.mjs.map +0 -1
  150. package/dist/chunk-NDMVGENG.mjs.map +0 -1
  151. package/dist/chunk-UO2E7T7T.mjs +0 -787
  152. package/dist/chunk-UO2E7T7T.mjs.map +0 -1
  153. package/dist/chunk-W4UX6G4X.mjs +0 -17
  154. package/dist/chunk-W4UX6G4X.mjs.map +0 -1
  155. package/dist/chunk-XOAZ2MGA.mjs +0 -59
  156. package/dist/chunk-XOAZ2MGA.mjs.map +0 -1
  157. package/dist/commands/common/tsNodeImport.d.mts +0 -5
  158. package/dist/commands/common/tsNodeImport.js.map +0 -1
  159. package/dist/commands/common/tsNodeImport.mjs +0 -45
  160. package/dist/commands/common/tsNodeImport.mjs.map +0 -1
  161. package/dist/commands/interface/run.d.mts +0 -3
  162. package/dist/commands/interface/run.js.map +0 -1
  163. package/dist/commands/interface/run.mjs +0 -256
  164. package/dist/commands/interface/run.mjs.map +0 -1
  165. package/dist/common/asyncLocalStorage/index.d.mts +0 -17
  166. package/dist/common/asyncLocalStorage/index.js.map +0 -1
  167. package/dist/common/asyncLocalStorage/index.mjs +0 -12
  168. package/dist/common/asyncLocalStorage/index.mjs.map +0 -1
  169. package/dist/common/binStartupScript.d.mts +0 -2
  170. package/dist/common/binStartupScript.js.map +0 -1
  171. package/dist/common/binStartupScript.mjs +0 -135
  172. package/dist/common/binStartupScript.mjs.map +0 -1
  173. package/dist/common/cleanEnvironmentVariables.d.mts +0 -3
  174. package/dist/common/cleanEnvironmentVariables.js.map +0 -1
  175. package/dist/common/cleanEnvironmentVariables.mjs +0 -8
  176. package/dist/common/cleanEnvironmentVariables.mjs.map +0 -1
  177. package/dist/common/constants.d.mts +0 -13
  178. package/dist/common/constants.js.map +0 -1
  179. package/dist/common/constants.mjs +0 -28
  180. package/dist/common/constants.mjs.map +0 -1
  181. package/dist/common/contextStorageStateHelpers.d.mts +0 -24
  182. package/dist/common/contextStorageStateHelpers.js.map +0 -1
  183. package/dist/common/contextStorageStateHelpers.mjs +0 -10
  184. package/dist/common/contextStorageStateHelpers.mjs.map +0 -1
  185. package/dist/common/jwtTokenManager.d.mts +0 -19
  186. package/dist/common/jwtTokenManager.js.map +0 -1
  187. package/dist/common/jwtTokenManager.mjs +0 -11
  188. package/dist/common/jwtTokenManager.mjs.map +0 -1
  189. package/dist/common/runApi/index.d.mts +0 -11
  190. package/dist/common/runApi/index.js.map +0 -1
  191. package/dist/common/runApi/index.mjs +0 -19
  192. package/dist/common/runApi/index.mjs.map +0 -1
  193. package/dist/common/settingsSchema.d.mts +0 -540
  194. package/dist/common/settingsSchema.js.map +0 -1
  195. package/dist/common/settingsSchema.mjs +0 -10
  196. package/dist/common/settingsSchema.mjs.map +0 -1
  197. package/dist/common/telemetry.d.mts +0 -6
  198. package/dist/common/telemetry.js.map +0 -1
  199. package/dist/common/telemetry.mjs +0 -31
  200. package/dist/common/telemetry.mjs.map +0 -1
  201. package/dist/export.d-BAUMB-lG.d.mts +0 -140
  202. package/dist/export.d-BAUMB-lG.d.ts +0 -140
  203. package/dist/index.d.mts +0 -6
  204. package/dist/index.js.map +0 -1
  205. package/dist/index.mjs +0 -48
  206. package/dist/index.mjs.map +0 -1
  207. package/dist/runtime/index.d.mts +0 -168
  208. package/dist/runtime/index.js.map +0 -1
  209. package/dist/runtime/index.mjs +0 -43
  210. package/dist/runtime/index.mjs.map +0 -1
  211. /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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm info:*)"
5
+ ]
6
+ }
7
+ }
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,6 @@
1
1
  # UNRELEASED
2
2
 
3
- -
3
+ - Add `timeout` parameter (in seconds, defaults to 30) to `launchBrowser` and `launchChromium` functions
4
4
 
5
5
  # 1.3.11
6
6
 
@@ -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,35 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ _dotenv.default.config({
11
+ path: `.env`
12
+ });
13
+ _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 ({
14
+ cdpAddress,
15
+ authSessionPath
16
+ }) => {
17
+ const setting = await (0, _settings.getSettings)();
18
+ if (!setting.authSessions.enabled) {
19
+ 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.");
20
+ }
21
+ await (0, _playwrightContext.withPlaywrightContext)({
22
+ cdpAddress
23
+ }, async context => {
24
+ await (0, _playwrightContext.loadSessionToContext)({
25
+ context,
26
+ session: {
27
+ type: "file",
28
+ path: authSessionPath
29
+ }
30
+ });
31
+ return (0, _neverthrow.ok)({});
32
+ });
33
+ process.exit(0);
34
+ });
35
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,74 @@
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
+ 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 check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").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, {
23
+ cdpAddress,
24
+ authSessionPath,
25
+ authSessionParameters
26
+ }) => {
27
+ const setting = await (0, _settings.getSettings)();
28
+ if (!setting.authSessions.enabled) {
29
+ 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.");
30
+ }
31
+ const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
32
+ if (!fs.exists(checkFilePath)) {
33
+ throw new Error("AuthSession check file not found");
34
+ }
35
+ let authSessionParametersJson = undefined;
36
+ if (!(0, _isNil.default)(authSessionParameters)) {
37
+ authSessionParametersJson = JSON.parse(authSessionParameters);
38
+ }
39
+ const runApiResult = await (0, _asyncLocalStorage.runWithContext)({
40
+ runEnvironment: _enums.RunEnvironment.IDE,
41
+ extendedPayloads: [],
42
+ runId: (0, _nanoid.nanoid)(),
43
+ getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
44
+ }, async () => await (0, _runApi.runApi)({
45
+ automationFunction: {
46
+ name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
47
+ },
48
+ runOptions: {
49
+ environment: "cdp",
50
+ cdpAddress
51
+ },
52
+ auth: {
53
+ session: {
54
+ type: "file",
55
+ path: authSessionPath
56
+ }
57
+ },
58
+ importFunction: _tsNodeImport.tsNodeImport
59
+ }));
60
+ if (runApiResult.isErr()) {
61
+ if (runApiResult.error instanceof _runtimeInterface.AutomationError) {
62
+ throw runApiResult.error.error;
63
+ }
64
+ console.error(runApiResult.error);
65
+ throw new Error("Error running AuthSession check");
66
+ }
67
+ const result = runApiResult.value.result;
68
+ console.log("check result", result);
69
+ if (!result) {
70
+ throw new Error("AuthSession check failed");
71
+ }
72
+ process.exit(0);
73
+ });
74
+ _commander.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,78 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ 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); }
18
+ _dotenv.default.config({
19
+ path: `.env`
20
+ });
21
+ _commander.program.description("run AuthSession create").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").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, {
22
+ cdpAddress,
23
+ pathToSave,
24
+ input,
25
+ json
26
+ }) => {
27
+ let inputData = null;
28
+ if (input) {
29
+ inputData = await fs.readJSON(input);
30
+ } else if (json) {
31
+ inputData = JSON.parse(json);
32
+ } else {
33
+ inputData = {};
34
+ }
35
+ const setting = await (0, _settings.getSettings)();
36
+ if (!setting.authSessions.enabled) {
37
+ 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.");
38
+ }
39
+ const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
40
+ if (!fs.exists(createFilePath)) {
41
+ throw new Error("AuthSession create file not found");
42
+ }
43
+ async function runCreate() {
44
+ const result = await (0, _runApi.runApi)({
45
+ automationFunction: {
46
+ name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`,
47
+ params: inputData
48
+ },
49
+ runOptions: {
50
+ environment: "cdp",
51
+ cdpAddress
52
+ },
53
+ retrieveSession: true,
54
+ importFunction: _tsNodeImport.tsNodeImport
55
+ });
56
+ if (result.isErr()) {
57
+ if (result.error instanceof _runtimeInterface.AutomationError) {
58
+ throw result.error.error;
59
+ }
60
+ console.error(result.error);
61
+ throw new Error("Error while running create");
62
+ }
63
+ const fullState = result.value.session;
64
+ if (pathToSave) {
65
+ const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
66
+ fs.ensureFileSync(fullPath);
67
+ await fs.writeJSON(fullPath, fullState);
68
+ }
69
+ }
70
+ await (0, _asyncLocalStorage.runWithContext)({
71
+ runEnvironment: _enums.RunEnvironment.IDE,
72
+ extendedPayloads: [],
73
+ runId: (0, _nanoid.nanoid)(),
74
+ getAuthSessionParameters: async () => inputData
75
+ }, runCreate);
76
+ process.exit(0);
77
+ });
78
+ _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 {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _commander = require("commander");
4
+ var _rollup = require("rollup");
5
+ var _pluginTypescript = _interopRequireDefault(require("@rollup/plugin-typescript"));
6
+ var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
7
+ var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
8
+ var _pluginDynamicImportVars = _interopRequireDefault(require("@rollup/plugin-dynamic-import-vars"));
9
+ var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
10
+ var fs = _interopRequireWildcard(require("fs-extra"));
11
+ var path = _interopRequireWildcard(require("path"));
12
+ var _template = require("./common/utils/template");
13
+ var _dotenv = _interopRequireDefault(require("dotenv"));
14
+ 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); }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function isThirdPartyWarning(warning) {
17
+ if (warning.id && /node_modules/.test(warning.id)) return true;
18
+ if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
19
+ return false;
20
+ }
21
+ _dotenv.default.config();
22
+ _commander.program.description("build the intuned server").option("-t, --template <type>", "template to use", "InterfaceTemplate").addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright"]).default("playwright").argOptional()).argument("[outfile]", "output bundle", "./output/bundle_v2.js").allowUnknownOption().action(async (mode, outfile, {
23
+ template
24
+ }) => {
25
+ await (0, _template.moveTemplateFiles)(template);
26
+ const currentTemplateTsConfig = path.resolve(path.dirname(__filename), "..", "..", "template.tsconfig.json");
27
+ await fs.copy(currentTemplateTsConfig, `./intuned/${template}/tsconfig.json`);
28
+ await build(outfile, mode, template);
29
+ });
30
+ async function build(outfile, mode, template) {
31
+ let bundle = null;
32
+ let buildFailed = false;
33
+ try {
34
+ bundle = await (0, _rollup.rollup)({
35
+ input: `./intuned/${template}/index.${mode}.ts`,
36
+ output: {
37
+ globals: {
38
+ crypto: "crypto"
39
+ }
40
+ },
41
+ plugins: [(0, _pluginJson.default)(), (0, _pluginNodeResolve.nodeResolve)({
42
+ exportConditions: ["node"],
43
+ preferBuiltins: true
44
+ }), (0, _pluginTypescript.default)({
45
+ tsconfig: `./intuned/${template}/tsconfig.json`
46
+ }), (0, _pluginCommonjs.default)({
47
+ include: ["node_modules/**", `intuned/${template}/**`, "dist", "../typescript-runtime/**"],
48
+ extensions: [".js"],
49
+ ignoreGlobal: false,
50
+ sourceMap: false,
51
+ dynamicRequireTargets: ["api/**/*.js", "auth-sessions/**/*.js"],
52
+ requireReturnsDefault: "auto",
53
+ transformMixedEsModules: true
54
+ }), (0, _pluginDynamicImportVars.default)({
55
+ include: ["**/*.js", "**/*.ts"],
56
+ exclude: ["**/*.d.ts", "**/*.js.map"]
57
+ })],
58
+ onwarn: (warning, warn) => {
59
+ if (isThirdPartyWarning(warning)) return;
60
+ warn(warning);
61
+ },
62
+ external: ["playwright", "playwright-core", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector", "node-fetch"]
63
+ });
64
+ console.log(`📦 Building ${outfile}`);
65
+ const outfileFolder = path.dirname(outfile);
66
+ const assetsDir = path.resolve(path.dirname(__filename), "..", "common", "assets");
67
+ await fs.copy(assetsDir, `${outfileFolder}/assets`);
68
+ await bundle.write({
69
+ format: "cjs",
70
+ file: outfile,
71
+ inlineDynamicImports: true
72
+ });
73
+ console.log(`✨ Build succeeded: ${outfile}`);
74
+ } catch (error) {
75
+ buildFailed = true;
76
+ console.error("error", error);
77
+ }
78
+ if (buildFailed) {
79
+ console.error("build failed");
80
+ process.exit(1);
81
+ }
82
+ }
83
+ _commander.program.parse(process.argv);