@intuned/runtime-dev 1.3.17-ws.0 → 1.3.18-dev.3
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.
- package/.babelrc +6 -0
- package/CHANGELOG.md +1 -1
- package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
- package/InterfaceTemplate/index.playwright.ts +1 -1
- package/bin/intuned +0 -0
- package/bin/intuned-interface +7 -0
- package/dist/commands/api/run.js +7 -11
- package/dist/commands/auth-sessions/load.js +2 -2
- package/dist/commands/auth-sessions/run-check.js +8 -8
- package/dist/commands/auth-sessions/run-create.js +6 -6
- package/dist/commands/build.js +2 -3
- package/dist/commands/common/browserUtils.d.ts +3 -3
- package/dist/commands/common/browserUtils.js +3 -4
- package/dist/commands/common/getFirstLineNumber.test.js +1 -2
- package/dist/commands/common/projectExclusions.js +1 -1
- package/dist/commands/common/tsNodeImport.d.ts +1 -1
- package/dist/commands/common/tsNodeImport.js +10 -2
- package/dist/commands/common/utils/fileUtils.js +1 -2
- package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
- package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
- package/dist/commands/common/utils/template.js +1 -2
- package/dist/commands/interface/run.js +23 -49
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -2
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/authsession.command.js +1 -1
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +1 -1
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +13 -9
- package/dist/commands/intuned-cli/commands/index.d.ts +2 -2
- package/dist/commands/intuned-cli/commands/index.js +15 -15
- package/dist/commands/intuned-cli/commands/{save.command.d.ts → provision.command.d.ts} +3 -3
- package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +8 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +2 -2
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +2 -2
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +2 -2
- package/dist/commands/intuned-cli/commands/types.d.ts +9 -1
- package/dist/commands/intuned-cli/commands/types.js +9 -5
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +30 -19
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +140 -77
- package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
- package/dist/commands/intuned-cli/controller/api.js +6 -3
- package/dist/commands/intuned-cli/controller/authSession.d.ts +16 -16
- package/dist/commands/intuned-cli/controller/authSession.js +50 -39
- package/dist/commands/intuned-cli/controller/build.js +1 -2
- package/dist/commands/intuned-cli/controller/deploy.js +53 -12
- package/dist/commands/intuned-cli/controller/index.js +2 -3
- package/dist/commands/intuned-cli/controller/{save.d.ts → provision.d.ts} +5 -1
- package/dist/commands/intuned-cli/controller/provision.js +299 -0
- package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +45 -5
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +4 -3
- package/dist/commands/intuned-cli/helpers/api.js +4 -7
- package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
- package/dist/commands/intuned-cli/helpers/auth.js +24 -21
- package/dist/commands/intuned-cli/helpers/backend.js +12 -4
- package/dist/commands/intuned-cli/helpers/browser.d.ts +4 -4
- package/dist/commands/intuned-cli/helpers/browser.js +40 -5
- package/dist/commands/intuned-cli/helpers/context.js +2 -2
- package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/errors.js +2 -2
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
- package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
- package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/wrapper.js +14 -4
- package/dist/commands/intuned-cli/main.js +1 -2
- package/dist/commands/intuned-cli/types.d.ts +41 -12
- package/dist/commands/intuned-cli/types.js +12 -2
- package/dist/commands/ts-check.js +1 -2
- package/dist/common/backendFunctions/getAuthSessionParameters.js +1 -1
- package/dist/common/binStartupScript.js +1 -2
- package/dist/common/browserTabs.d.ts +72 -0
- package/dist/common/browserTabs.js +74 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/contextStorageStateHelpers.d.ts +4 -3
- package/dist/common/contextStorageStateHelpers.js +4 -1
- package/dist/common/env.d.ts +6 -0
- package/dist/common/env.js +17 -0
- package/dist/common/extension/extensionsHelpers.d.ts +1 -1
- package/dist/common/extension/types.d.ts +14 -7
- package/dist/common/formatZodError.d.ts +1 -1
- package/dist/common/intunedJson.d.ts +19 -14
- package/dist/common/intunedJson.js +4 -4
- package/dist/common/jwtTokenManager.js +10 -6
- package/dist/common/launchBrowser.d.ts +10 -0
- package/dist/common/launchBrowser.js +74 -8
- package/dist/common/playwrightContext.d.ts +5 -5
- package/dist/common/playwrightContext.js +24 -14
- package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
- package/dist/common/runApi/importUsingImportFunction.js +7 -7
- package/dist/common/runApi/index.d.ts +3 -6
- package/dist/common/runApi/index.js +28 -52
- package/dist/common/settingsSchema.d.ts +52 -45
- package/dist/common/settingsSchema.js +3 -3
- package/dist/common/setupContextHook.d.ts +1 -2
- package/dist/common/setupContextHook.js +2 -2
- package/dist/common/telemetry.js +1 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -7
- package/dist/runtime/downloadDirectory.js +2 -2
- package/dist/vendor/runtime-interface.d.ts +1 -0
- package/dist/vendor/runtime-interface.js +493 -0
- package/package.json +19 -11
- package/tsup.config.ts +12 -0
- package/WebTemplate.zip +0 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/init.command.js +0 -13
- package/dist/commands/intuned-cli/commands/save.command.js +0 -42
- package/dist/commands/intuned-cli/controller/save.js +0 -357
- package/dist/common/runApi/errors.d.ts +0 -72
- package/dist/common/runApi/errors.js +0 -169
- package/dist/common/runApi/types.d.ts +0 -830
- package/dist/common/runApi/types.js +0 -73
package/.babelrc
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
"@babel/preset-typescript"
|
|
14
14
|
],
|
|
15
15
|
"plugins": [
|
|
16
|
+
["module-resolver", {
|
|
17
|
+
"root": ["./src"],
|
|
18
|
+
"alias": {
|
|
19
|
+
"@intuned/runtime-interface": "./src/vendor/runtime-interface"
|
|
20
|
+
}
|
|
21
|
+
}],
|
|
16
22
|
"babel-plugin-macros",
|
|
17
23
|
"@babel/plugin-transform-export-namespace-from"
|
|
18
24
|
],
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import type { ImportFunction } from "@intuned/runtime-interface";
|
|
3
|
+
|
|
2
4
|
import { err, ok } from "neverthrow";
|
|
3
5
|
|
|
4
6
|
export const importModule: ImportFunction = async (path: string) => {
|
package/bin/intuned
CHANGED
|
File without changes
|
package/dist/commands/api/run.js
CHANGED
|
@@ -16,12 +16,12 @@ var _Logger = require("../../common/Logger");
|
|
|
16
16
|
var _nanoid = require("nanoid");
|
|
17
17
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
18
|
var _runApi = require("../../common/runApi");
|
|
19
|
+
var _runtimeInterface = require("../../vendor/runtime-interface");
|
|
19
20
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
20
21
|
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
21
22
|
var _constants = require("../../common/constants");
|
|
22
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
function
|
|
24
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
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
25
|
_dotenv.default.config({
|
|
26
26
|
path: `.env`
|
|
27
27
|
});
|
|
@@ -31,12 +31,12 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
31
31
|
const settings = await (0, _settings.getSettings)();
|
|
32
32
|
if (settings.authSessions.enabled) {
|
|
33
33
|
if (!options.authSessionPath) {
|
|
34
|
-
throw new Error("
|
|
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
35
|
}
|
|
36
36
|
authSessionPathToUse = options.authSessionPath;
|
|
37
37
|
} else {
|
|
38
38
|
if (options.authSessionPath) {
|
|
39
|
-
throw new Error("
|
|
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
40
|
}
|
|
41
41
|
}
|
|
42
42
|
const runApiResult = await (0, _runApi.runApi)({
|
|
@@ -57,7 +57,7 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
57
57
|
importFunction: _tsNodeImport.tsNodeImport
|
|
58
58
|
});
|
|
59
59
|
if (runApiResult.isErr()) {
|
|
60
|
-
if (runApiResult.error instanceof
|
|
60
|
+
if (runApiResult.error instanceof _runtimeInterface.AutomationError) {
|
|
61
61
|
throw runApiResult.error.error;
|
|
62
62
|
}
|
|
63
63
|
console.error(runApiResult.error);
|
|
@@ -67,12 +67,8 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
67
67
|
result,
|
|
68
68
|
extendedPayloads: payloadToAppend
|
|
69
69
|
} = runApiResult.value;
|
|
70
|
-
const isResponseObject = typeof result === "object" && result !== null;
|
|
71
|
-
const hasMoreThank5Keys = isResponseObject && Object.keys(result).length > 5;
|
|
72
|
-
const hasNestedObjects = isResponseObject && Object.values(result).some(value => typeof value === "object");
|
|
73
|
-
const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
|
|
74
70
|
const resultsDir = "/tmp/run-results";
|
|
75
|
-
if (options.outputFileId
|
|
71
|
+
if (options.outputFileId) {
|
|
76
72
|
_Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
|
|
77
73
|
fs.ensureDirSync(resultsDir);
|
|
78
74
|
const path = `${resultsDir}/${options.outputFileId}.json`;
|
|
@@ -98,7 +94,7 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
98
94
|
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
_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>", "
|
|
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) => {
|
|
102
98
|
let inputData = null;
|
|
103
99
|
if (options.input) {
|
|
104
100
|
inputData = await fs.readJSON(options.input);
|
|
@@ -10,13 +10,13 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
10
10
|
_dotenv.default.config({
|
|
11
11
|
path: `.env`
|
|
12
12
|
});
|
|
13
|
-
_commander.program.description("load
|
|
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
14
|
cdpAddress,
|
|
15
15
|
authSessionPath
|
|
16
16
|
}) => {
|
|
17
17
|
const setting = await (0, _settings.getSettings)();
|
|
18
18
|
if (!setting.authSessions.enabled) {
|
|
19
|
-
throw new Error("
|
|
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
20
|
}
|
|
21
21
|
await (0, _playwrightContext.withPlaywrightContext)({
|
|
22
22
|
cdpAddress
|
|
@@ -8,29 +8,29 @@ var _settings = require("../common/utils/settings");
|
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _constants = require("../../common/constants");
|
|
10
10
|
var _runApi = require("../../common/runApi");
|
|
11
|
+
var _runtimeInterface = require("../../vendor/runtime-interface");
|
|
11
12
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
12
13
|
var _enums = require("../../runtime/enums");
|
|
13
14
|
var _nanoid = require("nanoid");
|
|
14
15
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
15
16
|
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
function
|
|
18
|
-
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; }
|
|
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
19
|
_dotenv.default.config({
|
|
20
20
|
path: `.env`
|
|
21
21
|
});
|
|
22
|
-
_commander.program.description("run
|
|
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
23
|
cdpAddress,
|
|
24
24
|
authSessionPath,
|
|
25
25
|
authSessionParameters
|
|
26
26
|
}) => {
|
|
27
27
|
const setting = await (0, _settings.getSettings)();
|
|
28
28
|
if (!setting.authSessions.enabled) {
|
|
29
|
-
throw new Error("
|
|
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
30
|
}
|
|
31
31
|
const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
32
32
|
if (!fs.exists(checkFilePath)) {
|
|
33
|
-
throw new Error("
|
|
33
|
+
throw new Error("AuthSession check file not found");
|
|
34
34
|
}
|
|
35
35
|
let authSessionParametersJson = undefined;
|
|
36
36
|
if (!(0, _isNil.default)(authSessionParameters)) {
|
|
@@ -58,16 +58,16 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
58
58
|
importFunction: _tsNodeImport.tsNodeImport
|
|
59
59
|
}));
|
|
60
60
|
if (runApiResult.isErr()) {
|
|
61
|
-
if (runApiResult.error instanceof
|
|
61
|
+
if (runApiResult.error instanceof _runtimeInterface.AutomationError) {
|
|
62
62
|
throw runApiResult.error.error;
|
|
63
63
|
}
|
|
64
64
|
console.error(runApiResult.error);
|
|
65
|
-
throw new Error("Error running
|
|
65
|
+
throw new Error("Error running AuthSession check");
|
|
66
66
|
}
|
|
67
67
|
const result = runApiResult.value.result;
|
|
68
68
|
console.log("check result", result);
|
|
69
69
|
if (!result) {
|
|
70
|
-
throw new Error("
|
|
70
|
+
throw new Error("AuthSession check failed");
|
|
71
71
|
}
|
|
72
72
|
process.exit(0);
|
|
73
73
|
});
|
|
@@ -8,17 +8,17 @@ var _settings = require("../common/utils/settings");
|
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _constants = require("../../common/constants");
|
|
10
10
|
var _runApi = require("../../common/runApi");
|
|
11
|
+
var _runtimeInterface = require("../../vendor/runtime-interface");
|
|
11
12
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
12
13
|
var _nanoid = require("nanoid");
|
|
13
14
|
var _enums = require("../../runtime/enums");
|
|
14
15
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
function
|
|
17
|
-
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; }
|
|
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
18
|
_dotenv.default.config({
|
|
19
19
|
path: `.env`
|
|
20
20
|
});
|
|
21
|
-
_commander.program.description("run
|
|
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
22
|
cdpAddress,
|
|
23
23
|
pathToSave,
|
|
24
24
|
input,
|
|
@@ -34,11 +34,11 @@ _commander.program.description("run auth session create").option("--cdpAddress <
|
|
|
34
34
|
}
|
|
35
35
|
const setting = await (0, _settings.getSettings)();
|
|
36
36
|
if (!setting.authSessions.enabled) {
|
|
37
|
-
throw new Error("
|
|
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
38
|
}
|
|
39
39
|
const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
|
|
40
40
|
if (!fs.exists(createFilePath)) {
|
|
41
|
-
throw new Error("
|
|
41
|
+
throw new Error("AuthSession create file not found");
|
|
42
42
|
}
|
|
43
43
|
async function runCreate() {
|
|
44
44
|
const result = await (0, _runApi.runApi)({
|
|
@@ -54,7 +54,7 @@ _commander.program.description("run auth session create").option("--cdpAddress <
|
|
|
54
54
|
importFunction: _tsNodeImport.tsNodeImport
|
|
55
55
|
});
|
|
56
56
|
if (result.isErr()) {
|
|
57
|
-
if (result.error instanceof
|
|
57
|
+
if (result.error instanceof _runtimeInterface.AutomationError) {
|
|
58
58
|
throw result.error.error;
|
|
59
59
|
}
|
|
60
60
|
console.error(result.error);
|
package/dist/commands/build.js
CHANGED
|
@@ -11,8 +11,7 @@ var fs = _interopRequireWildcard(require("fs-extra"));
|
|
|
11
11
|
var path = _interopRequireWildcard(require("path"));
|
|
12
12
|
var _template = require("./common/utils/template");
|
|
13
13
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
14
|
-
function
|
|
15
|
-
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; }
|
|
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); }
|
|
16
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
16
|
function isThirdPartyWarning(warning) {
|
|
18
17
|
if (warning.id && /node_modules/.test(warning.id)) return true;
|
|
@@ -45,7 +44,7 @@ async function build(outfile, mode, template) {
|
|
|
45
44
|
}), (0, _pluginTypescript.default)({
|
|
46
45
|
tsconfig: `./intuned/${template}/tsconfig.json`
|
|
47
46
|
}), (0, _pluginCommonjs.default)({
|
|
48
|
-
include: ["node_modules/**", `intuned/${template}/**`, "dist", "../typescript-
|
|
47
|
+
include: ["node_modules/**", `intuned/${template}/**`, "dist", "../typescript-runtime/**"],
|
|
49
48
|
extensions: [".js"],
|
|
50
49
|
ignoreGlobal: false,
|
|
51
50
|
sourceMap: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as playwright from "playwright";
|
|
2
2
|
export declare const REMOTE_DEBUGGING_PORT = 9222;
|
|
3
3
|
export declare const getChromiumLaunchArgs: () => string[];
|
|
4
4
|
export declare function startOrRestartBrowser(): Promise<void>;
|
|
@@ -10,5 +10,5 @@ export interface SessionState {
|
|
|
10
10
|
}>;
|
|
11
11
|
}
|
|
12
12
|
export declare function saveSessionFromOpenedBrowser(path: string): Promise<void>;
|
|
13
|
-
export declare function loadState(path: string, context: BrowserContext): Promise<void>;
|
|
14
|
-
export declare function saveSession(path: string, context: BrowserContext): Promise<void>;
|
|
13
|
+
export declare function loadState(path: string, context: playwright.BrowserContext): Promise<void>;
|
|
14
|
+
export declare function saveSession(path: string, context: playwright.BrowserContext): Promise<void>;
|
|
@@ -9,12 +9,11 @@ exports.saveSession = saveSession;
|
|
|
9
9
|
exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
|
|
10
10
|
exports.startOrRestartBrowser = startOrRestartBrowser;
|
|
11
11
|
var _child_process = require("child_process");
|
|
12
|
-
var playwright = _interopRequireWildcard(require("playwright"));
|
|
13
12
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
14
13
|
var _fileUtils = require("./utils/fileUtils");
|
|
15
14
|
var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
|
|
16
|
-
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
15
|
+
var playwright = _interopRequireWildcard(require("playwright"));
|
|
16
|
+
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
17
|
const REMOTE_DEBUGGING_PORT = exports.REMOTE_DEBUGGING_PORT = 9222;
|
|
19
18
|
const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
|
|
20
19
|
exports.getChromiumLaunchArgs = getChromiumLaunchArgs;
|
|
@@ -28,7 +27,7 @@ async function getBrowser() {
|
|
|
28
27
|
return playwrightBrowser;
|
|
29
28
|
}
|
|
30
29
|
async function startOrRestartBrowser() {
|
|
31
|
-
const chromiumPath =
|
|
30
|
+
const chromiumPath = playwright.chromium.executablePath();
|
|
32
31
|
const chromeInstanceProcess = (0, _child_process.spawn)(chromiumPath, getChromiumLaunchArgs());
|
|
33
32
|
chromeInstanceProcess.stdout.on("data", data => {
|
|
34
33
|
console.log(`Chrome stdout: ${data}`);
|
|
@@ -4,8 +4,7 @@ var _vitest = require("vitest");
|
|
|
4
4
|
var _getFirstLineNumber = _interopRequireDefault(require("./getFirstLineNumber"));
|
|
5
5
|
var fs = _interopRequireWildcard(require("fs"));
|
|
6
6
|
var path = _interopRequireWildcard(require("path"));
|
|
7
|
-
function
|
|
8
|
-
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; }
|
|
7
|
+
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); }
|
|
9
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
(0, _vitest.describe)("getFirstLineNumber", () => {
|
|
11
10
|
const testFilesDir = path.join(__dirname, "testFiles");
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
const exclusions = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo", "tsconfig.json", "output/**", "auth-sessions-instances/**", "README.md", "traces/**"];
|
|
7
|
+
const exclusions = ["node_modules/**", ".vscode/**", ".idea/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo", "tsconfig.json", "output/**", "auth-sessions-instances/**", "README.md", "traces/**"];
|
|
8
8
|
var _default = exports.default = exclusions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ExtendedRunApiParameters } from "
|
|
1
|
+
import { ExtendedRunApiParameters } from "@intuned/runtime-interface";
|
|
2
2
|
export declare const tsNodeImport: ExtendedRunApiParameters["importFunction"];
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.tsNodeImport = void 0;
|
|
7
7
|
var _neverthrow = require("neverthrow");
|
|
8
8
|
var _fileUtils = require("./utils/fileUtils");
|
|
9
|
-
function
|
|
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
|
const tsNodeImport = async apiName => {
|
|
12
11
|
require("ts-node").register({
|
|
13
12
|
transpileOnly: true,
|
|
@@ -21,6 +20,15 @@ const tsNodeImport = async apiName => {
|
|
|
21
20
|
return (0, _neverthrow.ok)(imported);
|
|
22
21
|
} catch (e) {
|
|
23
22
|
if ("code" in e && e.code.includes("MODULE_NOT_FOUND")) {
|
|
23
|
+
if ("requireStack" in e && Array.isArray(e.requireStack)) {
|
|
24
|
+
const isStackTopThisFile = e.requireStack[0] === __filename;
|
|
25
|
+
if (!isStackTopThisFile) {
|
|
26
|
+
return (0, _neverthrow.err)({
|
|
27
|
+
type: "other",
|
|
28
|
+
error: e
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
return (0, _neverthrow.err)({
|
|
25
33
|
type: "not_found"
|
|
26
34
|
});
|
|
@@ -9,8 +9,7 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
9
9
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
10
10
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
function
|
|
13
|
-
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; }
|
|
12
|
+
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); }
|
|
14
13
|
_dotenv.default.config();
|
|
15
14
|
function getFullPathInProject(...paths) {
|
|
16
15
|
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as net from "net";
|
|
1
3
|
export interface InterfaceClient {
|
|
2
4
|
sendJSON(data: any): void;
|
|
3
5
|
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
@@ -6,13 +8,19 @@ export interface InterfaceClient {
|
|
|
6
8
|
}
|
|
7
9
|
export declare class SocketClient implements InterfaceClient {
|
|
8
10
|
static readonly LENGTH_HEADER_LENGTH = 4;
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
+
protected readonly socket: net.Socket;
|
|
12
|
+
constructor(socket: net.Socket);
|
|
11
13
|
sendJSON(data: any): void;
|
|
12
14
|
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
13
15
|
close(): Promise<void>;
|
|
14
16
|
get closed(): boolean;
|
|
15
17
|
}
|
|
18
|
+
export declare class UnixSocketClient extends SocketClient {
|
|
19
|
+
constructor(path: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class TCPSocketClient extends SocketClient {
|
|
22
|
+
constructor(host: string, port: number);
|
|
23
|
+
}
|
|
16
24
|
export declare class JSONLFileClient implements InterfaceClient {
|
|
17
25
|
private readonly fileStream;
|
|
18
26
|
constructor(filePath: string);
|
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SocketClient = exports.JSONLFileClient = void 0;
|
|
6
|
+
exports.UnixSocketClient = exports.TCPSocketClient = exports.SocketClient = exports.JSONLFileClient = void 0;
|
|
7
7
|
var net = _interopRequireWildcard(require("net"));
|
|
8
8
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
9
|
var _readline = require("readline");
|
|
10
10
|
var _promises = require("timers/promises");
|
|
11
|
-
function
|
|
12
|
-
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; }
|
|
11
|
+
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); }
|
|
13
12
|
class SocketClient {
|
|
14
13
|
static LENGTH_HEADER_LENGTH = 4;
|
|
15
|
-
constructor(
|
|
16
|
-
this.socket =
|
|
14
|
+
constructor(socket) {
|
|
15
|
+
this.socket = socket;
|
|
17
16
|
}
|
|
18
17
|
sendJSON(data) {
|
|
19
18
|
const dataToSend = JSON.stringify(data);
|
|
@@ -55,6 +54,18 @@ class SocketClient {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
exports.SocketClient = SocketClient;
|
|
57
|
+
class UnixSocketClient extends SocketClient {
|
|
58
|
+
constructor(path) {
|
|
59
|
+
super(net.createConnection(path));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.UnixSocketClient = UnixSocketClient;
|
|
63
|
+
class TCPSocketClient extends SocketClient {
|
|
64
|
+
constructor(host, port) {
|
|
65
|
+
super(net.createConnection(port, host));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.TCPSocketClient = TCPSocketClient;
|
|
58
69
|
class JSONLFileClient {
|
|
59
70
|
constructor(filePath) {
|
|
60
71
|
this.fileStream = fs.createReadStream(filePath, {
|
|
@@ -7,8 +7,7 @@ exports.moveTemplateFiles = void 0;
|
|
|
7
7
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
8
|
var path = _interopRequireWildcard(require("path"));
|
|
9
9
|
var _fileUtils = require("./fileUtils");
|
|
10
|
-
function
|
|
11
|
-
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; }
|
|
10
|
+
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); }
|
|
12
11
|
const moveTemplateFiles = async templateName => {
|
|
13
12
|
await fs.remove("./intuned");
|
|
14
13
|
await fs.ensureDir("./intuned");
|
|
@@ -7,64 +7,27 @@ exports.runAutomationCLI = runAutomationCLI;
|
|
|
7
7
|
var _commander = require("commander");
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
10
|
-
var _zod = _interopRequireDefault(require("zod"));
|
|
11
10
|
var _runApi = require("../../common/runApi");
|
|
12
11
|
var _enums = require("../../runtime/enums");
|
|
13
|
-
var _unixSocket = require("../common/utils/unixSocket");
|
|
14
12
|
var _promises = require("timers/promises");
|
|
15
13
|
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
16
14
|
var _formatZodError = require("../../common/formatZodError");
|
|
17
15
|
var _neverthrow = require("neverthrow");
|
|
18
16
|
var _getAuthSessionParameters = require("../../common/backendFunctions/getAuthSessionParameters");
|
|
17
|
+
var _runtimeInterface = require("../../vendor/runtime-interface");
|
|
19
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
-
function
|
|
21
|
-
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; }
|
|
22
|
-
const startRunApiSchema = _zod.default.object({
|
|
23
|
-
type: _zod.default.literal("start"),
|
|
24
|
-
parameters: _runApi.runApiParametersSchema.extend({
|
|
25
|
-
retrieveSession: _zod.default.boolean(),
|
|
26
|
-
functionsToken: _zod.default.string().optional(),
|
|
27
|
-
context: _zod.default.object({
|
|
28
|
-
jobId: _zod.default.string().optional(),
|
|
29
|
-
jobRunId: _zod.default.string().optional(),
|
|
30
|
-
runId: _zod.default.string().optional(),
|
|
31
|
-
queueId: _zod.default.string().optional(),
|
|
32
|
-
authSessionId: _zod.default.string().optional()
|
|
33
|
-
}).optional()
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
const nextRunApiSchema = _zod.default.object({
|
|
37
|
-
type: _zod.default.literal("next"),
|
|
38
|
-
parameters: _zod.default.object({
|
|
39
|
-
value: _zod.default.string()
|
|
40
|
-
})
|
|
41
|
-
});
|
|
42
|
-
const abortRunApiSchema = _zod.default.object({
|
|
43
|
-
type: _zod.default.literal("abort"),
|
|
44
|
-
parameters: _zod.default.object({}).optional()
|
|
45
|
-
});
|
|
46
|
-
const tokenUpdateSchema = _zod.default.object({
|
|
47
|
-
type: _zod.default.literal("tokenUpdate"),
|
|
48
|
-
parameters: _zod.default.object({
|
|
49
|
-
functionsToken: _zod.default.string()
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
const pingSchema = _zod.default.object({
|
|
53
|
-
type: _zod.default.literal("ping"),
|
|
54
|
-
parameters: _zod.default.object({}).optional()
|
|
55
|
-
});
|
|
56
|
-
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema, pingSchema]);
|
|
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); }
|
|
57
20
|
_dotenv.default.config({
|
|
58
21
|
path: `.env`
|
|
59
22
|
});
|
|
60
23
|
function runAutomationCLI(importFunction) {
|
|
61
|
-
_commander.program.description("run user automation and communicate using unix socket").argument("<
|
|
62
|
-
|
|
24
|
+
_commander.program.description("run user automation and communicate using unix socket").argument("<input>", "In unix socket mode: path to the unix socket. In jsonl mode: path to the jsonl file. In tcp socket mode: host:port").option("--mode [mode]", "Communication mode: unix, jsonl, or tcp").action(async (input, {
|
|
25
|
+
mode = "unix"
|
|
63
26
|
}) => {
|
|
64
27
|
let context;
|
|
65
28
|
const throttleTime = 60 * 1000;
|
|
66
29
|
let timeoutTimestamp = Date.now();
|
|
67
|
-
const client =
|
|
30
|
+
const client = createClient(mode, input);
|
|
68
31
|
const abortController = new AbortController();
|
|
69
32
|
const interruptSignalHandler = async () => {
|
|
70
33
|
abortController.abort();
|
|
@@ -80,12 +43,12 @@ function runAutomationCLI(importFunction) {
|
|
|
80
43
|
if (data.done) {
|
|
81
44
|
return;
|
|
82
45
|
}
|
|
83
|
-
const inputParseResult =
|
|
46
|
+
const inputParseResult = _runtimeInterface.runApiInputSchema.safeParse(data.value);
|
|
84
47
|
if (!inputParseResult.success) {
|
|
85
48
|
console.error("Validation error:", (0, _formatZodError.formatZodError)(inputParseResult.error));
|
|
86
49
|
return {
|
|
87
50
|
type: "error",
|
|
88
|
-
error: new
|
|
51
|
+
error: new _runtimeInterface.InternalInvalidInputError("Invalid input", (0, _formatZodError.formatZodError)(inputParseResult.error))
|
|
89
52
|
};
|
|
90
53
|
}
|
|
91
54
|
const input = inputParseResult.data;
|
|
@@ -128,9 +91,6 @@ function runAutomationCLI(importFunction) {
|
|
|
128
91
|
});
|
|
129
92
|
return;
|
|
130
93
|
}
|
|
131
|
-
if (message.type === "next") {
|
|
132
|
-
throw new Error("next not supported anymore");
|
|
133
|
-
}
|
|
134
94
|
}
|
|
135
95
|
let receiveMessagesPromise = receiveMessages();
|
|
136
96
|
while (true) {
|
|
@@ -196,10 +156,10 @@ function getProxyUrlFromRunOptions(runOptions) {
|
|
|
196
156
|
}
|
|
197
157
|
const _defaultImport = async path => {
|
|
198
158
|
try {
|
|
199
|
-
const imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(
|
|
159
|
+
const imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${process.cwd()}/${path}`);
|
|
200
160
|
return (0, _neverthrow.ok)(imported);
|
|
201
161
|
} catch (e) {
|
|
202
|
-
if ("code" in e && e.code === "MODULE_NOT_FOUND") {
|
|
162
|
+
if ("code" in e && e.code === "MODULE_NOT_FOUND" || e.code === "ERR_MODULE_NOT_FOUND") {
|
|
203
163
|
return (0, _neverthrow.err)({
|
|
204
164
|
type: "not_found"
|
|
205
165
|
});
|
|
@@ -210,6 +170,20 @@ const _defaultImport = async path => {
|
|
|
210
170
|
});
|
|
211
171
|
}
|
|
212
172
|
};
|
|
173
|
+
function createClient(mode, input) {
|
|
174
|
+
if (mode === "jsonl") {
|
|
175
|
+
return new _runtimeInterface.JSONLFileClient(input);
|
|
176
|
+
}
|
|
177
|
+
if (mode === "tcp") {
|
|
178
|
+
const [host, portString] = input.split(":");
|
|
179
|
+
const port = Number(portString);
|
|
180
|
+
if (!host || isNaN(port)) {
|
|
181
|
+
throw new Error("Invalid tcp input, expected format host:port");
|
|
182
|
+
}
|
|
183
|
+
return new _runtimeInterface.TCPSocketClient(host, port);
|
|
184
|
+
}
|
|
185
|
+
return new _runtimeInterface.UnixSocketClient(input);
|
|
186
|
+
}
|
|
213
187
|
if (require.main === module) {
|
|
214
188
|
runAutomationCLI();
|
|
215
189
|
}
|
|
@@ -15,7 +15,7 @@ const optionsSchema = _types.baseCommandOptionsSchema.extend({
|
|
|
15
15
|
authSession: _zod.z.string().optional(),
|
|
16
16
|
outputFile: _zod.z.string().optional()
|
|
17
17
|
});
|
|
18
|
-
const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the
|
|
18
|
+
const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the AuthSession to use for the API. This is expected to be in ./auth-sessions-instances/<id>.json").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
|
|
19
19
|
authSession,
|
|
20
20
|
...rest
|
|
21
21
|
}) => {
|