@intuned/runtime-dev 1.2.0-cli.1 → 1.2.0-cli.11
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/dist/commands/api/run.js +2 -1
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/build.command.js +1 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +3 -4
- package/dist/commands/intuned-cli/commands/init.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +1 -1
- package/dist/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +2 -4
- package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +22 -5
- package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
- package/dist/{common/cli/cliReadme.js → commands/intuned-cli/constants/readme.js} +13 -15
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +25 -0
- package/dist/commands/intuned-cli/controller/api.js +35 -36
- package/dist/commands/intuned-cli/controller/authSession.d.ts +176 -10
- package/dist/commands/intuned-cli/controller/authSession.js +125 -125
- package/dist/commands/intuned-cli/controller/build.js +1 -1
- package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/deploy.js +48 -31
- package/dist/commands/intuned-cli/controller/index.js +5 -4
- package/dist/commands/intuned-cli/controller/init.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/init.js +12 -15
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
- package/dist/commands/intuned-cli/helpers/auth.js +129 -0
- package/dist/{common/cli/utils.d.ts → commands/intuned-cli/helpers/backend.d.ts} +0 -1
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -20
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/{terminal.js → helpers/terminal.js} +3 -2
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +12 -0
- package/dist/commands/intuned-cli/main.js +4 -1
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -32
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/package.json +2 -7
- package/tsconfig.json +2 -1
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/deploy +0 -3
- package/bin/init +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -284
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -47
- package/dist/commands/deploy/utils.d.ts +0 -16
- package/dist/commands/deploy/utils.js +0 -407
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -22
- package/dist/commands/init/utils.d.ts +0 -11
- package/dist/commands/init/utils.js +0 -175
- package/dist/commands/intuned-cli/commands/helpers.d.ts +0 -26
- package/dist/commands/intuned-cli/commands/helpers.js +0 -134
- package/dist/commands/intuned-cli/terminal.d.ts +0 -1
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- /package/dist/{common/cli → commands/intuned-cli}/types.js +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CLIError = exports.CLIAssertionError = void 0;
|
|
7
|
-
exports.assertApiFileExists = assertApiFileExists;
|
|
8
|
-
exports.assertAuthConsistent = assertAuthConsistent;
|
|
9
|
-
exports.assertAuthEnabled = assertAuthEnabled;
|
|
10
|
-
exports.logInvalidInput = logInvalidInput;
|
|
11
|
-
exports.parseUrlProxy = parseUrlProxy;
|
|
12
|
-
exports.withCLIContext = withCLIContext;
|
|
13
|
-
exports.withErrorLogging = withErrorLogging;
|
|
14
|
-
exports.withTimeout = withTimeout;
|
|
15
|
-
var _utils = require("../../cli-auth-sessions/utils");
|
|
16
|
-
var _nanoid = require("nanoid");
|
|
17
|
-
var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
|
|
18
|
-
var _enums = require("../../../runtime/enums");
|
|
19
|
-
var _terminal = require("../terminal");
|
|
20
|
-
var _path = _interopRequireDefault(require("path"));
|
|
21
|
-
var _fsExtra = require("fs-extra");
|
|
22
|
-
var _runApi = require("../../../common/runApi");
|
|
23
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
-
class CLIError extends Error {
|
|
25
|
-
constructor(message, options) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = "CLIError";
|
|
28
|
-
this.autoColor = options?.autoColor ?? true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.CLIError = CLIError;
|
|
32
|
-
class CLIAssertionError extends CLIError {
|
|
33
|
-
constructor(message, options) {
|
|
34
|
-
super(message, options);
|
|
35
|
-
this.name = "CLIAssertionError";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.CLIAssertionError = CLIAssertionError;
|
|
39
|
-
function logInvalidInput(result) {
|
|
40
|
-
(0, _terminal.terminal)("^r^+Invalid input parameters:^: ^R" + result.error.errors.map(({
|
|
41
|
-
message
|
|
42
|
-
}) => `^R${message}^:`).join(", ") + "\n");
|
|
43
|
-
}
|
|
44
|
-
async function assertAuthEnabled() {
|
|
45
|
-
if (!(await (0, _utils.isAuthEnabled)())) {
|
|
46
|
-
throw new CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function assertAuthConsistent(authSession) {
|
|
50
|
-
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
51
|
-
if (_isAuthEnabled && !authSession) {
|
|
52
|
-
throw new CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
|
|
53
|
-
}
|
|
54
|
-
if (!_isAuthEnabled && authSession) {
|
|
55
|
-
throw new CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function withErrorLogging(fn) {
|
|
59
|
-
return async (...args) => {
|
|
60
|
-
try {
|
|
61
|
-
await fn(...args);
|
|
62
|
-
process.exit(0);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (error instanceof CLIError) {
|
|
65
|
-
if (error.autoColor) {
|
|
66
|
-
(0, _terminal.terminal)(`^r^+${error.message}^:\n`);
|
|
67
|
-
} else {
|
|
68
|
-
(0, _terminal.terminal)(`${error.message}\n`);
|
|
69
|
-
}
|
|
70
|
-
} else if (error instanceof _runApi.AutomationError) {
|
|
71
|
-
(0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
|
|
72
|
-
(0, _terminal.terminal)(`^r${error.error.message}^:\n`);
|
|
73
|
-
if (error.error.stack) {
|
|
74
|
-
(0, _terminal.terminal)(`^r^+Stack trace:^:\n`);
|
|
75
|
-
(0, _terminal.terminal)(`^r${error.error.stack}^:\n`);
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
(0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
|
|
79
|
-
}
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function parseUrlProxy(proxyUrl) {
|
|
85
|
-
try {
|
|
86
|
-
const url = new URL(proxyUrl);
|
|
87
|
-
const username = url.username;
|
|
88
|
-
const password = url.password;
|
|
89
|
-
const proxy = url.hostname;
|
|
90
|
-
const port = url.port ? `:${url.port}` : "";
|
|
91
|
-
const domain = `${url.protocol}//${proxy}${port}`;
|
|
92
|
-
return {
|
|
93
|
-
password,
|
|
94
|
-
username,
|
|
95
|
-
server: domain
|
|
96
|
-
};
|
|
97
|
-
} catch (error) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function withTimeout(fn, timeout) {
|
|
102
|
-
let reject;
|
|
103
|
-
const timeoutPromise = new Promise((_, _reject) => {
|
|
104
|
-
reject = _reject;
|
|
105
|
-
});
|
|
106
|
-
const timeoutId = setTimeout(() => {
|
|
107
|
-
reject(new CLIError("Timed out"));
|
|
108
|
-
}, timeout);
|
|
109
|
-
const fnWithWrapper = async (...args) => {
|
|
110
|
-
return Promise.race([fn(...args), timeoutPromise]);
|
|
111
|
-
};
|
|
112
|
-
(0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
|
|
113
|
-
timeoutId.refresh();
|
|
114
|
-
};
|
|
115
|
-
return fnWithWrapper;
|
|
116
|
-
}
|
|
117
|
-
function withCLIContext(fn) {
|
|
118
|
-
const runId = (0, _nanoid.nanoid)();
|
|
119
|
-
return async (...args) => (0, _asyncLocalStorage.runWithContext)({
|
|
120
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
121
|
-
runId,
|
|
122
|
-
extendedPayloads: [],
|
|
123
|
-
timeoutInfo: {}
|
|
124
|
-
}, fn, ...args);
|
|
125
|
-
}
|
|
126
|
-
async function assertApiFileExists(dirname, api) {
|
|
127
|
-
const file = `${dirname}/${api}.ts`;
|
|
128
|
-
const filePath = _path.default.join(process.cwd(), file);
|
|
129
|
-
if (!(await (0, _fsExtra.exists)(filePath))) {
|
|
130
|
-
throw new CLIAssertionError(`^+^r API^ ^+${dirname}/${api}^ ^r^+is not implemented.^:`, {
|
|
131
|
-
autoColor: false
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const terminal: import("terminal-kit/Terminal");
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _commander = require("commander");
|
|
5
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
-
var _nanoid = require("nanoid");
|
|
7
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
var _enums = require("../../runtime/enums");
|
|
10
|
-
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
11
|
-
var _utils2 = require("../cli-auth-sessions/utils");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
_dotenv.default.config({
|
|
14
|
-
path: `.env`
|
|
15
|
-
});
|
|
16
|
-
_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>", "Name of the auth session instance to use").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
|
|
17
|
-
try {
|
|
18
|
-
if (!apiName) {
|
|
19
|
-
throw new Error("API name is required, please provide it");
|
|
20
|
-
}
|
|
21
|
-
const _isAuthEnabled = await (0, _utils2.isAuthEnabled)();
|
|
22
|
-
if (!_isAuthEnabled && options.authSession) {
|
|
23
|
-
throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
|
|
24
|
-
}
|
|
25
|
-
if (_isAuthEnabled && !options.authSession) {
|
|
26
|
-
throw new Error("Auth session is enabled but no auth session provided, please provide it");
|
|
27
|
-
}
|
|
28
|
-
const inputData = await (0, _utils.loadParameters)(options.parametersFile);
|
|
29
|
-
const runId = (0, _nanoid.nanoid)();
|
|
30
|
-
const {
|
|
31
|
-
result,
|
|
32
|
-
payloadToAppend
|
|
33
|
-
} = await (0, _asyncLocalStorage.runWithContext)({
|
|
34
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
35
|
-
extendedPayloads: [],
|
|
36
|
-
runId
|
|
37
|
-
}, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
|
|
38
|
-
authSession: options.authSession
|
|
39
|
-
}));
|
|
40
|
-
if (!result) {
|
|
41
|
-
console.log(_chalk.default.yellow("No result returned from the API"));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!options.storeResults) {
|
|
45
|
-
console.log(_chalk.default.green(`✓ API executed successfully`));
|
|
46
|
-
console.log(_chalk.default.green("Result:"));
|
|
47
|
-
console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
await (0, _utils.writeResultToFile)(runId, result, payloadToAppend);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(_chalk.default.red(`\nError: ${error.message}`));
|
|
53
|
-
} finally {
|
|
54
|
-
process.exit(0);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Payload } from "../../runtime/export";
|
|
2
|
-
export declare function loadParameters(parametersFile: string): Promise<object | null>;
|
|
3
|
-
export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
|
|
4
|
-
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options?: {
|
|
5
|
-
authSession?: string;
|
|
6
|
-
}): Promise<{
|
|
7
|
-
result: any;
|
|
8
|
-
payloadToAppend: Payload[] | undefined;
|
|
9
|
-
}>;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadParameters = loadParameters;
|
|
7
|
-
exports.runApiViaCLI = runApiViaCLI;
|
|
8
|
-
exports.writeResultToFile = writeResultToFile;
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
-
var _Logger = require("../../common/Logger");
|
|
12
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
|
-
var _runApi = require("../../common/runApi");
|
|
14
|
-
var _tsNodeImport = require("../common/tsNodeImport");
|
|
15
|
-
var _utils = require("../cli-auth-sessions/utils");
|
|
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); }
|
|
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; }
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
async function loadParameters(parametersFile) {
|
|
20
|
-
if (!parametersFile) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const filePath = _path.default.join(process.cwd(), parametersFile);
|
|
25
|
-
await fs.access(filePath);
|
|
26
|
-
let inputData = null;
|
|
27
|
-
if (parametersFile) {
|
|
28
|
-
inputData = await fs.readJSON(filePath);
|
|
29
|
-
} else {
|
|
30
|
-
inputData = {};
|
|
31
|
-
}
|
|
32
|
-
return inputData;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (error.code === "ENOENT") {
|
|
35
|
-
throw new Error(`Parameters file not found: ${parametersFile}`);
|
|
36
|
-
} else if (error instanceof SyntaxError) {
|
|
37
|
-
throw new Error(`Invalid JSON in parameters file: ${error.message}`);
|
|
38
|
-
}
|
|
39
|
-
throw new Error(`Error reading parameters file: ${error.message}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function writeResultToFile(runId, result, payloadToAppend) {
|
|
43
|
-
const outputDir = _path.default.join(process.cwd(), "output", runId);
|
|
44
|
-
const resultsPath = _path.default.join(outputDir, "results.json");
|
|
45
|
-
const extendedPayloadsPath = _path.default.join(outputDir, "extendedPayloads.json");
|
|
46
|
-
await fs.ensureDir(outputDir);
|
|
47
|
-
try {
|
|
48
|
-
await fs.writeJSON(resultsPath, result, {
|
|
49
|
-
spaces: 2
|
|
50
|
-
});
|
|
51
|
-
if (payloadToAppend && payloadToAppend.length > 0) {
|
|
52
|
-
await fs.writeJSON(extendedPayloadsPath, payloadToAppend, {
|
|
53
|
-
spaces: 2
|
|
54
|
-
});
|
|
55
|
-
_Logger.logger.info(_chalk.default.underline.green.white(`Payloads to append saved into (${extendedPayloadsPath})`));
|
|
56
|
-
}
|
|
57
|
-
console.log(_chalk.default.underline.green.white(`✓ API executed successfully. Results stored in ${outputDir}`));
|
|
58
|
-
console.log(_chalk.default.blue(`Run ID: ${runId}`));
|
|
59
|
-
} catch (error) {
|
|
60
|
-
_Logger.logger.error(`Failed to write result to file: ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function runApiViaCLI(apiName, inputData, options) {
|
|
64
|
-
let authSessionPathToUse = null;
|
|
65
|
-
if (options?.authSession) {
|
|
66
|
-
const {
|
|
67
|
-
authSessionInstanceStoragePath
|
|
68
|
-
} = await (0, _utils.retrieveAuthSessionInstance)(options?.authSession, true);
|
|
69
|
-
authSessionPathToUse = authSessionInstanceStoragePath;
|
|
70
|
-
}
|
|
71
|
-
if (authSessionPathToUse) {
|
|
72
|
-
const checkApiExists = await (0, _utils.ensureAuthApi)("check");
|
|
73
|
-
if (!checkApiExists) {
|
|
74
|
-
throw new Error("Auth session check API not implemented, please create it in the auth sessions specified directory");
|
|
75
|
-
}
|
|
76
|
-
const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
|
|
77
|
-
if (!checkResult) {
|
|
78
|
-
console.log(_chalk.default.yellow("Auth session check failed, trying to refresh it..."));
|
|
79
|
-
const createApiExists = await (0, _utils.ensureAuthApi)("create");
|
|
80
|
-
if (!createApiExists) {
|
|
81
|
-
throw new Error("Auth session creation API not implemented, please create it in the auth sessions specified directory");
|
|
82
|
-
}
|
|
83
|
-
const {
|
|
84
|
-
metadata
|
|
85
|
-
} = await (0, _utils.retrieveAuthSessionInstance)(options?.authSession);
|
|
86
|
-
if (metadata?.authSessionType === "MANUAL") {
|
|
87
|
-
throw new Error("Expired Auth session is recorder-based, please provide a new one or refresh it manually");
|
|
88
|
-
}
|
|
89
|
-
const authSessionInput = metadata?.authSessionInput ?? {};
|
|
90
|
-
try {
|
|
91
|
-
const refresehAuthSessionInstance = await (0, _utils.runCreateApiViaCLI)(authSessionInput);
|
|
92
|
-
if (!refresehAuthSessionInstance) {
|
|
93
|
-
throw new Error("Failed to refresh auth session");
|
|
94
|
-
}
|
|
95
|
-
await (0, _utils.storeAuthSessionInstance)(refresehAuthSessionInstance, options?.authSession, authSessionInput);
|
|
96
|
-
const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
|
|
97
|
-
if (!checkResult) {
|
|
98
|
-
throw new Error("Failed to refresh auth session");
|
|
99
|
-
}
|
|
100
|
-
console.log(_chalk.default.green("✓ Auth session refreshed successfully on this run"));
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw new Error(`Failed to refresh auth session: ${error.message}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const runApiResult = await (0, _runApi.runApi)({
|
|
107
|
-
automationFunction: {
|
|
108
|
-
name: `api/${apiName}`,
|
|
109
|
-
params: inputData
|
|
110
|
-
},
|
|
111
|
-
runOptions: {
|
|
112
|
-
headless: false,
|
|
113
|
-
environment: "standalone"
|
|
114
|
-
},
|
|
115
|
-
auth: authSessionPathToUse ? {
|
|
116
|
-
session: {
|
|
117
|
-
type: "file",
|
|
118
|
-
path: authSessionPathToUse
|
|
119
|
-
},
|
|
120
|
-
runCheck: false
|
|
121
|
-
} : undefined,
|
|
122
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
123
|
-
});
|
|
124
|
-
if (runApiResult.isErr()) {
|
|
125
|
-
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
126
|
-
throw runApiResult.error.error;
|
|
127
|
-
}
|
|
128
|
-
console.error(runApiResult.error);
|
|
129
|
-
throw new Error("An error occurred while running the API");
|
|
130
|
-
}
|
|
131
|
-
const {
|
|
132
|
-
result,
|
|
133
|
-
extendedPayloads: payloadToAppend
|
|
134
|
-
} = runApiResult.value;
|
|
135
|
-
const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
|
|
136
|
-
if (hasPayloadToAppend) {
|
|
137
|
-
_Logger.logger.info("payload to append:", payloadToAppend);
|
|
138
|
-
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
result,
|
|
142
|
-
payloadToAppend
|
|
143
|
-
};
|
|
144
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const cliReadme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a variety of commands to develop your Intuned projects locally\n\n## Development Commands\n\nFor each command, add `--help` to see more details and options.\n\n### Initialize a Project\n`npx -p @intuned/runtime init`\n\n### Run an API\n`yarn intuned run <api-name>`\nor\n`npm run intuned run <api-name>`\n\n\n### Build a Project\n`yarn intuned build`\n\n### Deploy a Project\n`yarn intuned deploy [project-name]`\nor\n`npm run intuned deploy [project-name]`\n\n\n\n### Create an auth session\n`yarn intuned authsession create <parameters>`\nor\n`npm intuned authsession create <parameters>`\n\n\n\n### Validate an auth session\n`yarn intuned authsession validate <auth-session-name>`\nor\n`npm intuned authsession validate <auth-session-name>`\n\n## Configuration\n\n### Environment Variables and Settings\n- `workspaceId`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))\n - Set in `intuned.json` file under the `workspaceId` property\n - Or provide via CLI with `--workspace-id` flag during deployment\n \n- `projectName`: The name of your Intuned project\n - Set in `intuned.json` file under the `projectName` property\n - Or override via command line when deploying with `yarn deploy my-project-name` or `npm run deploy my-project-name`\n \n- `INTUNED_API_KEY`: Your Intuned API key\n - Set as an environment variable: `export INTUNED_API_KEY=your_api_key_here`\n - Or include in your .env file for development\n - Or provide via CLI with `--api-key` flag during deployment\n\n## Project Structure\n\n### Generated Artifacts\n- `./intuned.json`: Project configuration file\n- `./api`: Folder containing API implementation files\n- `./auth-sessions`: Folder containing auth APIs\n- `./parameters`: Folder for API parameters injection\n- `./output`: Folder containing generated output files\n- `./auth-sessions-instances`: Folder containing auth session instances\n\n## Types of auth sessions\n- `MANUAL`: Manual auth session, records the session using a recorder and stores it in the `auth-sessions-instances` folder\n- `API`: Auth session created via create API, stores the session in the `auth-sessions-instances` folder\n\n### Notes\n- You can use either `yarn` or `npm run` to execute commands\n- All commands must be run from the project root directory\n- Verify you're in the correct location by confirming the presence of package.json and intuned.json\n- Running commands from subdirectories may result in errors\n- You can manage your deployed projects through the Intuned platform\n- WARNING: \u26A0\uFE0F Changes to TS Config may break some Intuned functionalities\n";
|
|
File without changes
|