@intuned/runtime-dev 1.0.6-cli-auth.0.0.5-test → 1.0.6-cli-auth.0.0.6-test
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.
|
@@ -30,5 +30,6 @@ _commander.program.description("Create an auth session").option("-i, --input <in
|
|
|
30
30
|
if (authSessionInstancePath) {
|
|
31
31
|
console.log(_chalk.default.underline.green.white(`🔒 Auth session instance stored at ${authSessionInstancePath}`));
|
|
32
32
|
}
|
|
33
|
+
process.exit(0);
|
|
33
34
|
});
|
|
34
35
|
_commander.program.parse(process.argv);
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
_dotenv.default.config({
|
|
13
13
|
path: `.env`
|
|
14
14
|
});
|
|
15
|
-
_commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-i, --parameters-file <file>", "JSON file containing API parameters").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
|
|
15
|
+
_commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-i, --parameters-file <file>", "JSON file containing API parameters").option("-a, --auth-session <session>", "Auth session path").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
|
|
16
16
|
try {
|
|
17
17
|
if (!apiName) {
|
|
18
18
|
throw new Error("API name is required, please provide it");
|
|
@@ -26,7 +26,9 @@ _commander.program.name("intuned-run").description("Run an Intuned API with para
|
|
|
26
26
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
27
27
|
extendedPayloads: [],
|
|
28
28
|
runId
|
|
29
|
-
}, () => (0, _utils.runApiViaCLI)(apiName, inputData
|
|
29
|
+
}, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
|
|
30
|
+
authSessionPath: options.authSession
|
|
31
|
+
}));
|
|
30
32
|
if (!result) {
|
|
31
33
|
console.log(_chalk.default.yellow("No result returned from the API"));
|
|
32
34
|
return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Payload } from "../../runtime/export";
|
|
2
2
|
export declare function loadParameters(parametersFile: string): Promise<object | null>;
|
|
3
3
|
export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
|
|
4
|
-
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined
|
|
4
|
+
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options?: {
|
|
5
|
+
authSessionPath?: string;
|
|
6
|
+
}): Promise<{
|
|
5
7
|
result: any;
|
|
6
8
|
payloadToAppend: Payload[] | undefined;
|
|
7
9
|
}>;
|
|
@@ -12,6 +12,7 @@ var _Logger = require("../../common/Logger");
|
|
|
12
12
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
13
|
var _runApi = require("../../common/runApi");
|
|
14
14
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
15
|
+
var _utils = require("../../common/cli/utils");
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
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
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -59,7 +60,21 @@ async function writeResultToFile(runId, result, payloadToAppend) {
|
|
|
59
60
|
_Logger.logger.error(`Failed to write result to file: ${error.message}`);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
async function runApiViaCLI(apiName, inputData) {
|
|
63
|
+
async function runApiViaCLI(apiName, inputData, options) {
|
|
64
|
+
let authSessionPathToUse = null;
|
|
65
|
+
if (options !== null && options !== void 0 && options.authSessionPath) {
|
|
66
|
+
const authSessions = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
67
|
+
if (authSessions.enabled) {
|
|
68
|
+
if (!options.authSessionPath) {
|
|
69
|
+
throw new Error("Auth session is enabled but no auth session provided");
|
|
70
|
+
}
|
|
71
|
+
authSessionPathToUse = options.authSessionPath;
|
|
72
|
+
} else {
|
|
73
|
+
if (options.authSessionPath) {
|
|
74
|
+
throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
const runApiResult = await (0, _runApi.runApi)({
|
|
64
79
|
automationFunction: {
|
|
65
80
|
name: `api/${apiName}`,
|
|
@@ -69,6 +84,13 @@ async function runApiViaCLI(apiName, inputData) {
|
|
|
69
84
|
headless: false,
|
|
70
85
|
environment: "standalone"
|
|
71
86
|
},
|
|
87
|
+
auth: authSessionPathToUse ? {
|
|
88
|
+
session: {
|
|
89
|
+
type: "file",
|
|
90
|
+
path: authSessionPathToUse
|
|
91
|
+
},
|
|
92
|
+
runCheck: true
|
|
93
|
+
} : undefined,
|
|
72
94
|
importFunction: _tsNodeImport.tsNodeImport
|
|
73
95
|
});
|
|
74
96
|
if (runApiResult.isErr()) {
|