@intuned/runtime-dev 1.1.7-dev-52 → 1.2.0-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.
- package/.babelrc +2 -2
- package/CHANGELOG.md +5 -1
- package/WebTemplate.zip +0 -0
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +2 -2
- package/dist/commands/cli-auth-sessions/create.js +1 -1
- package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
- package/dist/commands/cli-auth-sessions/utils.js +2 -3
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/deploy/utils.js +1 -2
- package/dist/commands/init/utils.js +1 -7
- package/dist/commands/interface/run.js +5 -6
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +47 -0
- package/dist/commands/intuned-cli/commands/helpers.d.ts +26 -0
- package/dist/commands/intuned-cli/commands/helpers.js +126 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
- package/dist/commands/intuned-cli/commands/index.js +170 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/init.command.js +14 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/types.js +21 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +19 -0
- package/dist/commands/intuned-cli/controller/api.js +179 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +32 -0
- package/dist/commands/intuned-cli/controller/authSession.js +295 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
- package/dist/commands/intuned-cli/controller/deploy.js +397 -0
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +45 -0
- package/dist/commands/intuned-cli/controller/init.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/init.js +139 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +12 -0
- package/dist/commands/intuned-cli/terminal.d.ts +1 -0
- package/dist/commands/intuned-cli/terminal.js +12 -0
- package/dist/commands/run-api-cli/utils.js +6 -6
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/cli/cliReadme.d.ts +1 -1
- package/dist/common/cli/cliReadme.js +14 -23
- package/dist/common/cli/constants.d.ts +4 -2
- package/dist/common/cli/constants.js +7 -3
- package/dist/common/cli/types.d.ts +1 -1
- package/dist/common/cli/utils.d.ts +5 -2
- package/dist/common/cli/utils.js +6 -2
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.js +2 -10
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +5 -6
- package/dist/common/runApi/index.d.ts +3 -0
- package/dist/common/runApi/index.js +21 -21
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +15 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/package.json +9 -5
package/.babelrc
CHANGED
package/CHANGELOG.md
CHANGED
package/WebTemplate.zip
ADDED
|
Binary file
|
package/bin/intuned
ADDED
package/dist/commands/api/run.js
CHANGED
|
@@ -96,7 +96,7 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
96
96
|
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
_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>", "auth session 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("--
|
|
99
|
+
_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>", "auth session 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 auth session").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) => {
|
|
100
100
|
let inputData = null;
|
|
101
101
|
if (options.input) {
|
|
102
102
|
inputData = await fs.readJSON(options.input);
|
|
@@ -106,7 +106,7 @@ _commander.program.description("run the user function in the cli for testing pur
|
|
|
106
106
|
inputData = {};
|
|
107
107
|
}
|
|
108
108
|
let authSessionParametersJson = undefined;
|
|
109
|
-
if (!(0, _isNil.default)(options
|
|
109
|
+
if (!(0, _isNil.default)(options?.authSessionParameters)) {
|
|
110
110
|
authSessionParametersJson = JSON.parse(options.authSessionParameters);
|
|
111
111
|
}
|
|
112
112
|
await (0, _asyncLocalStorage.runWithContext)({
|
|
@@ -32,7 +32,7 @@ _commander.program.description("Create an auth session").argument("[auth-session
|
|
|
32
32
|
if (!createApiExists) {
|
|
33
33
|
throw new Error("Auth session create API not implemented, please create it in the auth sessions specified directory");
|
|
34
34
|
}
|
|
35
|
-
const authSessionInput = (await (0, _utils2.loadParameters)(options
|
|
35
|
+
const authSessionInput = (await (0, _utils2.loadParameters)(options?.input)) ?? {};
|
|
36
36
|
const session = await (0, _utils.runCreateApi)(authSessionInput);
|
|
37
37
|
if (!session) {
|
|
38
38
|
console.error(_chalk.default.red("Failed to create auth session."));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageState } from "../../common/contextStorageStateHelpers";
|
|
2
2
|
import { AuthSessionMetadata, AuthSessionType } from "../../common/cli/types";
|
|
3
|
-
import * as playwright from "playwright";
|
|
3
|
+
import * as playwright from "playwright-core";
|
|
4
4
|
export declare function isAuthEnabled(): Promise<boolean>;
|
|
5
5
|
export declare function getAuthType(): Promise<AuthSessionType>;
|
|
6
6
|
export declare function ensureRecorderURLs(): Promise<{
|
|
@@ -26,15 +26,14 @@ var _tsNodeImport = require("../common/tsNodeImport");
|
|
|
26
26
|
var _promptly = require("promptly");
|
|
27
27
|
var _utils = require("../../common/cli/utils");
|
|
28
28
|
var _types = require("../../common/cli/types");
|
|
29
|
-
var playwright = _interopRequireWildcard(require("playwright"));
|
|
29
|
+
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
30
30
|
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); }
|
|
31
31
|
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; }
|
|
32
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
33
|
async function isAuthEnabled() {
|
|
34
34
|
try {
|
|
35
|
-
var _intunedJson$authSess;
|
|
36
35
|
const intunedJson = await fs.readJSON(_path.default.join(process.cwd(), "Intuned.json"));
|
|
37
|
-
return Boolean(intunedJson
|
|
36
|
+
return Boolean(intunedJson?.authSessions?.enabled);
|
|
38
37
|
} catch (error) {
|
|
39
38
|
return false;
|
|
40
39
|
}
|
|
@@ -32,10 +32,9 @@ function compileTypeScript(apiFilePath) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function findFirstExecutableLine(sourceFile) {
|
|
35
|
-
var _defaultExportSymbol$;
|
|
36
35
|
let functionBody;
|
|
37
36
|
const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
|
|
38
|
-
const defaultExportDeclaration = defaultExportSymbol
|
|
37
|
+
const defaultExportDeclaration = defaultExportSymbol?.getDeclarations()?.[0];
|
|
39
38
|
if (defaultExportDeclaration) {
|
|
40
39
|
if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
|
|
41
40
|
functionBody = defaultExportDeclaration.getBody();
|
|
@@ -45,9 +44,8 @@ function findFirstExecutableLine(sourceFile) {
|
|
|
45
44
|
const expression = exportAssignment.getExpression();
|
|
46
45
|
if (!expression) continue;
|
|
47
46
|
if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
|
|
48
|
-
var _sourceFile$getVariab;
|
|
49
47
|
const identifier = expression.getText();
|
|
50
|
-
const possiblyExportedFunction = sourceFile.getFunction(identifier) ||
|
|
48
|
+
const possiblyExportedFunction = sourceFile.getFunction(identifier) || sourceFile.getVariableStatement(identifier)?.getDescendants().find(node => node.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction);
|
|
51
49
|
if (possiblyExportedFunction) {
|
|
52
50
|
functionBody = possiblyExportedFunction.getBody();
|
|
53
51
|
break;
|
|
@@ -228,13 +228,12 @@ const validateIntunedProject = async () => {
|
|
|
228
228
|
name: "package.json",
|
|
229
229
|
check: async () => {
|
|
230
230
|
try {
|
|
231
|
-
var _packageJson$dependen;
|
|
232
231
|
const packageJsonPath = path.join(currentDirectoryToDeploy, "package.json");
|
|
233
232
|
await fs.exists(packageJsonPath);
|
|
234
233
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, {
|
|
235
234
|
encoding: "utf-8"
|
|
236
235
|
}));
|
|
237
|
-
const userCodePlaywrightVersion =
|
|
236
|
+
const userCodePlaywrightVersion = packageJson.dependencies?.playwright;
|
|
238
237
|
if (userCodePlaywrightVersion !== _constants.CURRENT_PLAYWRIGHT_VERSION) {
|
|
239
238
|
return {
|
|
240
239
|
isValid: false,
|
|
@@ -15,7 +15,6 @@ var _types = require("../../common/cli/types");
|
|
|
15
15
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
16
|
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
17
17
|
var _path = _interopRequireDefault(require("path"));
|
|
18
|
-
var _boxen = _interopRequireDefault(require("boxen"));
|
|
19
18
|
var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
|
|
20
19
|
var _constants = require("../../common/cli/constants");
|
|
21
20
|
var _cliReadme = require("../../common/cli/cliReadme");
|
|
@@ -139,12 +138,7 @@ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
|
|
|
139
138
|
await prepareCLITemplate(codeTree);
|
|
140
139
|
await mountFiles(cwd, codeTree);
|
|
141
140
|
console.log(_chalk.default.green("✓ Project files created"));
|
|
142
|
-
console.log(
|
|
143
|
-
padding: 1,
|
|
144
|
-
margin: 1,
|
|
145
|
-
borderStyle: "round",
|
|
146
|
-
borderColor: "green"
|
|
147
|
-
}));
|
|
141
|
+
console.log(_chalk.default.cyan(`\n🎉 Project initialized successfully!`), _chalk.default.yellow(`\n\nRun ${_chalk.default.bold("yarn")} to install dependencies and start coding!`));
|
|
148
142
|
}
|
|
149
143
|
async function fetchProjectTemplate(templateId) {
|
|
150
144
|
const baseUrl = (0, _utils.getBaseUrl)();
|
|
@@ -29,7 +29,8 @@ const startRunApiSchema = _zod.default.object({
|
|
|
29
29
|
jobId: _zod.default.string().optional(),
|
|
30
30
|
jobRunId: _zod.default.string().optional(),
|
|
31
31
|
runId: _zod.default.string().optional(),
|
|
32
|
-
queueId: _zod.default.string().optional()
|
|
32
|
+
queueId: _zod.default.string().optional(),
|
|
33
|
+
authSessionId: _zod.default.string().optional()
|
|
33
34
|
}).optional()
|
|
34
35
|
})
|
|
35
36
|
});
|
|
@@ -66,14 +67,12 @@ function runAutomationCLI(importFunction) {
|
|
|
66
67
|
let generator = null;
|
|
67
68
|
const abortController = new AbortController();
|
|
68
69
|
client.on("error", err => {
|
|
69
|
-
|
|
70
|
-
void ((_generator = generator) === null || _generator === void 0 ? void 0 : _generator.throw(err).catch(() => undefined));
|
|
70
|
+
void generator?.throw(err).catch(() => undefined);
|
|
71
71
|
});
|
|
72
72
|
const interruptSignalHandler = async () => {
|
|
73
|
-
var _generator2;
|
|
74
73
|
abortController.abort();
|
|
75
74
|
await (0, _promises.setTimeout)(60_000);
|
|
76
|
-
void
|
|
75
|
+
void generator?.throw(new Error("Interrupted")).catch(() => undefined);
|
|
77
76
|
client.end();
|
|
78
77
|
process.exit(1);
|
|
79
78
|
};
|
|
@@ -214,7 +213,7 @@ function runAutomationCLI(importFunction) {
|
|
|
214
213
|
_commander.program.parse(process.argv);
|
|
215
214
|
}
|
|
216
215
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
217
|
-
if (
|
|
216
|
+
if (runOptions?.environment !== "standalone") return undefined;
|
|
218
217
|
const proxy = runOptions.proxy;
|
|
219
218
|
if (!proxy) return undefined;
|
|
220
219
|
const url = new URL(proxy.server);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptCommand: import("commander").Command;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attemptCommand = void 0;
|
|
7
|
+
var _command = require("./command");
|
|
8
|
+
const attemptCommand = exports.attemptCommand = _command.program.command("attempt").description("Execute an Intuned attempt");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptApiCommand: import("commander").Command;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attemptApiCommand = void 0;
|
|
7
|
+
var _api = require("../controller/api");
|
|
8
|
+
var _controller = require("../controller");
|
|
9
|
+
var _zod = require("zod");
|
|
10
|
+
var _types = require("./types");
|
|
11
|
+
var _helpers = require("./helpers");
|
|
12
|
+
var _attempt = require("./attempt.command");
|
|
13
|
+
const attemptApiCommandInputSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
|
|
14
|
+
authSession: _zod.z.string().optional(),
|
|
15
|
+
outputFile: _zod.z.string().optional()
|
|
16
|
+
})]);
|
|
17
|
+
const attemptApiCommand = exports.attemptApiCommand = _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 auth session to use for the API. This is expected to be in ./auth-session-instances/<id>.json").option("--proxy <url>", "proxy URL to use").option("--timeout <time>", "timeout - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").option("-o, --output-file <path>", "output file path").action((0, _helpers.withErrorLogging)(async (inputApiName, inputParameters, inputOptions) => {
|
|
18
|
+
const parseResult = attemptApiCommandInputSchema.safeParse([inputApiName, inputParameters, inputOptions]);
|
|
19
|
+
if (!parseResult.success) {
|
|
20
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
21
|
+
}
|
|
22
|
+
const [apiName, parameters, {
|
|
23
|
+
headless,
|
|
24
|
+
authSession,
|
|
25
|
+
outputFile,
|
|
26
|
+
timeout,
|
|
27
|
+
proxy
|
|
28
|
+
}] = parseResult.data;
|
|
29
|
+
await (0, _helpers.assertAuthConsistent)(authSession);
|
|
30
|
+
const inputData = await (0, _controller.loadParameters)(parameters);
|
|
31
|
+
await (0, _api.executeAttemptApiCLI)({
|
|
32
|
+
apiName,
|
|
33
|
+
inputData: inputData,
|
|
34
|
+
authSessionId: authSession,
|
|
35
|
+
proxy,
|
|
36
|
+
headless,
|
|
37
|
+
timeout,
|
|
38
|
+
outputFile
|
|
39
|
+
});
|
|
40
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptAuthSessionCommand: import("commander").Command;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attemptAuthSessionCommand = void 0;
|
|
7
|
+
var _attempt = require("./attempt.command");
|
|
8
|
+
const attemptAuthSessionCommand = exports.attemptAuthSessionCommand = _attempt.attemptCommand.command("authsession").description("Manage authentication sessions");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptAuthSessionCheckCommand: import("commander").Command;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attemptAuthSessionCheckCommand = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _authSession = require("../controller/authSession");
|
|
9
|
+
var _attempt_authsession = require("./attempt_authsession.command");
|
|
10
|
+
var _helpers = require("./helpers");
|
|
11
|
+
var _types = require("./types");
|
|
12
|
+
const attemptAuthSessionCheckSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _types.baseCommandOptionsSchema]);
|
|
13
|
+
const attemptAuthSessionCheckCommand = exports.attemptAuthSessionCheckCommand = _attempt_authsession.attemptAuthSessionCommand.command("check").description("Check an existing auth session").argument("<id>", "ID of the auth session to check").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputId, inputOptions) => {
|
|
14
|
+
const parseResult = attemptAuthSessionCheckSchema.safeParse([inputId, inputOptions]);
|
|
15
|
+
if (!parseResult.success) {
|
|
16
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
17
|
+
}
|
|
18
|
+
const [id, options] = parseResult.data;
|
|
19
|
+
await (0, _helpers.assertAuthEnabled)();
|
|
20
|
+
await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
21
|
+
id,
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptAuthSessionCreateCommand: import("commander").Command;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attemptAuthSessionCreateCommand = void 0;
|
|
7
|
+
var _controller = require("../controller");
|
|
8
|
+
var _zod = require("zod");
|
|
9
|
+
var _authSession = require("../controller/authSession");
|
|
10
|
+
var _attempt_authsession = require("./attempt_authsession.command");
|
|
11
|
+
var _helpers = require("./helpers");
|
|
12
|
+
var _types = require("./types");
|
|
13
|
+
const attemptAuthSessionCreateInputSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
|
|
14
|
+
id: _zod.z.string().optional()
|
|
15
|
+
})]);
|
|
16
|
+
const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = _attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to ./auth-session-instances/[current timestamp].json").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputParameters, inputOptions) => {
|
|
17
|
+
const parseResult = attemptAuthSessionCreateInputSchema.safeParse([inputParameters, inputOptions]);
|
|
18
|
+
if (!parseResult.success) {
|
|
19
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
20
|
+
}
|
|
21
|
+
const [parameters, {
|
|
22
|
+
headless,
|
|
23
|
+
id,
|
|
24
|
+
timeout,
|
|
25
|
+
proxy
|
|
26
|
+
}] = parseResult.data;
|
|
27
|
+
await (0, _helpers.assertAuthEnabled)();
|
|
28
|
+
const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
|
|
29
|
+
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
30
|
+
id,
|
|
31
|
+
input: authSessionInput,
|
|
32
|
+
headless,
|
|
33
|
+
timeout,
|
|
34
|
+
proxy
|
|
35
|
+
});
|
|
36
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildCommand: import("commander").Command;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildCommand = void 0;
|
|
7
|
+
var _command = require("./command");
|
|
8
|
+
var _build = require("../controller/build");
|
|
9
|
+
var _helpers = require("./helpers");
|
|
10
|
+
const buildCommand = exports.buildCommand = _command.program.command("build").description("Build Intuned project").action((0, _helpers.withErrorLogging)(async () => {
|
|
11
|
+
await (0, _build.runBuild)();
|
|
12
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.program = void 0;
|
|
7
|
+
var _commander = require("commander");
|
|
8
|
+
const program = exports.program = new _commander.Command();
|
|
9
|
+
program.name("intuned").description("Intuned CLI for creating, developing and deploying Intuned projects").version("1.0.0").enablePositionalOptions(true);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deployCommand: import("commander").Command;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deployCommand = void 0;
|
|
7
|
+
var _command = require("./command");
|
|
8
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
|
+
var _deploy = require("../controller/deploy");
|
|
10
|
+
var _utils = require("../../../common/cli/utils");
|
|
11
|
+
var _zod = require("zod");
|
|
12
|
+
var _helpers = require("./helpers");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
_dotenv.default.config({
|
|
15
|
+
path: `.env`
|
|
16
|
+
});
|
|
17
|
+
const deployCommandSchema = _zod.z.tuple([_zod.z.union([_zod.z.string(), _zod.z.undefined()]), _zod.z.object({
|
|
18
|
+
workspaceId: _zod.z.string().optional(),
|
|
19
|
+
apiKey: _zod.z.string().optional()
|
|
20
|
+
})]);
|
|
21
|
+
const deployCommand = exports.deployCommand = _command.program.command("deploy").description("Deploy an Intuned project to the platform").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action((0, _helpers.withErrorLogging)(async (inputProjectName, inputOptions) => {
|
|
22
|
+
const parseResult = deployCommandSchema.safeParse([inputProjectName, inputOptions]);
|
|
23
|
+
if (!parseResult.success) {
|
|
24
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
25
|
+
}
|
|
26
|
+
const [projectName, options] = parseResult.data;
|
|
27
|
+
const {
|
|
28
|
+
isValid,
|
|
29
|
+
errorMessage
|
|
30
|
+
} = await (0, _deploy.validateIntunedProject)();
|
|
31
|
+
if (!isValid) {
|
|
32
|
+
const message = `^r^+Project to be deployed is not a valid Intuned project:^:^R ${errorMessage}:\n`;
|
|
33
|
+
throw new _helpers.CLIError(message, {
|
|
34
|
+
autoColor: false
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const _projectName = projectName || (await (0, _utils.getSettingIntunedJSON)("projectName"));
|
|
38
|
+
if (!_projectName) {
|
|
39
|
+
throw new _helpers.CLIError("Project name is required");
|
|
40
|
+
}
|
|
41
|
+
const projectNameValidation = (0, _deploy.validateProjectName)(_projectName);
|
|
42
|
+
if (!projectNameValidation.isValid) {
|
|
43
|
+
throw new _helpers.CLIError(projectNameValidation.errorMessage);
|
|
44
|
+
}
|
|
45
|
+
const auth = await (0, _utils.getAuthCredentials)(options);
|
|
46
|
+
await (0, _deploy.runDeployProject)(_projectName, auth);
|
|
47
|
+
}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
|
|
3
|
+
export declare class CLIError extends Error {
|
|
4
|
+
autoColor: boolean;
|
|
5
|
+
constructor(message: string, options?: {
|
|
6
|
+
autoColor?: boolean;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export declare class CLIAssertionError extends CLIError {
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
autoColor?: boolean;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export declare function logInvalidInput(result: z.SafeParseError<unknown>): void;
|
|
15
|
+
export declare function assertAuthEnabled(): Promise<void>;
|
|
16
|
+
export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
|
|
17
|
+
export declare function withErrorLogging<T extends any[]>(fn: (...args: T) => Promise<unknown>): (...args: T) => Promise<never>;
|
|
18
|
+
export declare function parseUrlProxy(proxyUrl: string): {
|
|
19
|
+
password: string;
|
|
20
|
+
username: string;
|
|
21
|
+
server: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export declare function withTimeout<R, P extends any[]>(fn: (...args: P) => Promise<R>, timeout: number): (...args: P) => Promise<R>;
|
|
24
|
+
export declare function withCLIContext<R, P extends any[]>(fn: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
|
|
25
|
+
export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
|
|
26
|
+
export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
class CLIError extends Error {
|
|
24
|
+
constructor(message, options) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "CLIError";
|
|
27
|
+
this.autoColor = options?.autoColor ?? true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.CLIError = CLIError;
|
|
31
|
+
class CLIAssertionError extends CLIError {
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
this.name = "CLIAssertionError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.CLIAssertionError = CLIAssertionError;
|
|
38
|
+
function logInvalidInput(result) {
|
|
39
|
+
(0, _terminal.terminal)("^r^+Invalid input parameters:^: ^R" + result.error.errors.map(({
|
|
40
|
+
message
|
|
41
|
+
}) => `^R${message}^:`).join(", ") + "\n");
|
|
42
|
+
}
|
|
43
|
+
async function assertAuthEnabled() {
|
|
44
|
+
if (!(await (0, _utils.isAuthEnabled)())) {
|
|
45
|
+
throw new CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function assertAuthConsistent(authSession) {
|
|
49
|
+
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
50
|
+
if (_isAuthEnabled && !authSession) {
|
|
51
|
+
throw new CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
|
|
52
|
+
}
|
|
53
|
+
if (!_isAuthEnabled && authSession) {
|
|
54
|
+
throw new CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function withErrorLogging(fn) {
|
|
58
|
+
return async (...args) => {
|
|
59
|
+
try {
|
|
60
|
+
await fn(...args);
|
|
61
|
+
process.exit(0);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error instanceof CLIError) {
|
|
64
|
+
if (error.autoColor) {
|
|
65
|
+
(0, _terminal.terminal)(`^r^+${error.message}^:\n`);
|
|
66
|
+
} else {
|
|
67
|
+
(0, _terminal.terminal)(`${error.message}\n`);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
(0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
|
|
71
|
+
}
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function parseUrlProxy(proxyUrl) {
|
|
77
|
+
try {
|
|
78
|
+
const url = new URL(proxyUrl);
|
|
79
|
+
const username = url.username;
|
|
80
|
+
const password = url.password;
|
|
81
|
+
const proxy = url.hostname;
|
|
82
|
+
const port = url.port ? `:${url.port}` : "";
|
|
83
|
+
const domain = `${url.protocol}//${proxy}${port}`;
|
|
84
|
+
return {
|
|
85
|
+
password,
|
|
86
|
+
username,
|
|
87
|
+
server: domain
|
|
88
|
+
};
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function withTimeout(fn, timeout) {
|
|
94
|
+
let reject;
|
|
95
|
+
const timeoutPromise = new Promise((_, _reject) => {
|
|
96
|
+
reject = _reject;
|
|
97
|
+
});
|
|
98
|
+
const timeoutId = setTimeout(() => {
|
|
99
|
+
reject(new CLIError("Timed out"));
|
|
100
|
+
}, timeout);
|
|
101
|
+
const fnWithWrapper = async (...args) => {
|
|
102
|
+
return Promise.race([fn(...args), timeoutPromise]);
|
|
103
|
+
};
|
|
104
|
+
(0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
|
|
105
|
+
timeoutId.refresh();
|
|
106
|
+
};
|
|
107
|
+
return fnWithWrapper;
|
|
108
|
+
}
|
|
109
|
+
function withCLIContext(fn) {
|
|
110
|
+
const runId = (0, _nanoid.nanoid)();
|
|
111
|
+
return async (...args) => (0, _asyncLocalStorage.runWithContext)({
|
|
112
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
113
|
+
runId,
|
|
114
|
+
extendedPayloads: [],
|
|
115
|
+
timeoutInfo: {}
|
|
116
|
+
}, fn, ...args);
|
|
117
|
+
}
|
|
118
|
+
async function assertApiFileExists(dirname, api) {
|
|
119
|
+
const file = `${dirname}/${api}.ts`;
|
|
120
|
+
const filePath = _path.default.join(process.cwd(), file);
|
|
121
|
+
if (!(await (0, _fsExtra.exists)(filePath))) {
|
|
122
|
+
throw new CLIAssertionError(`^+^r API^ ^+${dirname}/${api}^ ^r^+is not implemented.^:`, {
|
|
123
|
+
autoColor: false
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./command";
|
|
2
|
+
export * from "./build.command";
|
|
3
|
+
export * from "./deploy.command";
|
|
4
|
+
export * from "./init.command";
|
|
5
|
+
export * from "./run.command";
|
|
6
|
+
export * from "./run_api.command";
|
|
7
|
+
export * from "./run_authsession.command";
|
|
8
|
+
export * from "./run_authsession_create.command";
|
|
9
|
+
export * from "./run_authsession_update.command";
|
|
10
|
+
export * from "./run_authsession_validate.command";
|
|
11
|
+
export * from "./attempt.command";
|
|
12
|
+
export * from "./attempt_api.command";
|
|
13
|
+
export * from "./attempt_authsession.command";
|
|
14
|
+
export * from "./attempt_authsession_create.command";
|
|
15
|
+
export * from "./attempt_authsession_check.command";
|