@intuned/runtime-dev 1.2.0-cli.3 → 1.2.0-cli.5
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/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_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/commands/intuned-cli/constants/index.d.ts +36 -0
- package/dist/commands/intuned-cli/constants/index.js +63 -0
- package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
- package/dist/commands/intuned-cli/constants/readme.js +81 -0
- package/dist/commands/intuned-cli/controller/api.js +10 -9
- package/dist/commands/intuned-cli/controller/authSession.js +30 -27
- 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 +9 -11
- 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 +17 -0
- package/dist/commands/intuned-cli/helpers/auth.js +105 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- 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/commands/intuned-cli/helpers/intunedJson.js +19 -0
- 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/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/types.d.ts +42 -0
- package/dist/commands/intuned-cli/types.js +13 -0
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +1 -83
- package/dist/common/cli/constants.d.ts +0 -35
- package/dist/common/cli/constants.js +1 -43
- package/dist/common/cli/types.d.ts +0 -74
- package/dist/common/cli/types.js +1 -13
- package/dist/common/cli/utils.d.ts +0 -9
- package/dist/common/cli/utils.js +1 -39
- package/package.json +1 -7
- 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 -31
- package/dist/commands/intuned-cli/commands/helpers.js +0 -142
- 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/commands/intuned-cli/{terminal.d.ts → helpers/terminal.d.ts} +0 -0
- /package/dist/commands/intuned-cli/{terminal.js → helpers/terminal.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileSystemTree, TemplateId } from "
|
|
1
|
+
import { FileSystemTree, TemplateId } from "../types";
|
|
2
2
|
export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
|
|
3
3
|
export declare function checkEmptyDirectory(): Promise<boolean>;
|
|
4
4
|
export declare function selectTemplate(templateName: string): Promise<TemplateId>;
|
|
@@ -8,14 +8,11 @@ exports.mountFiles = mountFiles;
|
|
|
8
8
|
exports.scaffoldProject = scaffoldProject;
|
|
9
9
|
exports.selectTemplate = selectTemplate;
|
|
10
10
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
-
var _types = require("
|
|
11
|
+
var _types = require("../types");
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
13
|
var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
|
|
14
|
-
var _constants = require("
|
|
15
|
-
var
|
|
16
|
-
var _utils = require("../../../common/cli/utils");
|
|
17
|
-
var _helpers = require("../commands/helpers");
|
|
18
|
-
var _terminal = require("../terminal");
|
|
14
|
+
var _constants = require("../constants");
|
|
15
|
+
var _helpers = require("../helpers");
|
|
19
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
17
|
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); }
|
|
21
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; }
|
|
@@ -61,10 +58,10 @@ async function selectTemplate(templateName) {
|
|
|
61
58
|
}
|
|
62
59
|
return templateName;
|
|
63
60
|
}
|
|
64
|
-
(0,
|
|
61
|
+
(0, _helpers.terminal)("^+Select a template (ESC to cancel):^:\n");
|
|
65
62
|
const {
|
|
66
63
|
promise: selectedCommandPromise
|
|
67
|
-
} =
|
|
64
|
+
} = _helpers.terminal.singleColumnMenu(_types.templateIds, {
|
|
68
65
|
cancelable: true
|
|
69
66
|
});
|
|
70
67
|
const selectedTemplateIndex = (await selectedCommandPromise).selectedIndex;
|
|
@@ -77,10 +74,10 @@ async function selectTemplate(templateName) {
|
|
|
77
74
|
}
|
|
78
75
|
async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
|
|
79
76
|
if (!isTargetDirectoryEmpty) {
|
|
80
|
-
(0,
|
|
77
|
+
(0, _helpers.terminal)("^+The current directory is not empty. Do you want to proceed and override files?^: (y/N)");
|
|
81
78
|
const {
|
|
82
79
|
promise
|
|
83
|
-
} =
|
|
80
|
+
} = _helpers.terminal.yesOrNo({
|
|
84
81
|
no: ["n", "ENTER", "ESCAPE"],
|
|
85
82
|
yes: ["y"],
|
|
86
83
|
echoNo: " no\n",
|
|
@@ -94,16 +91,16 @@ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
|
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
93
|
const cwd = process.cwd();
|
|
97
|
-
(0,
|
|
94
|
+
(0, _helpers.terminal)(`^c🚀 Initializing ^:^+${templateId}^:^c project...\n`);
|
|
98
95
|
const template = await fetchProjectTemplate(templateId);
|
|
99
|
-
(0,
|
|
96
|
+
(0, _helpers.terminal)(`^c🔨 Creating project files...^:\n`);
|
|
100
97
|
const codeTree = template;
|
|
101
98
|
await prepareCLITemplate(codeTree);
|
|
102
99
|
await mountFiles(cwd, codeTree);
|
|
103
|
-
(0,
|
|
100
|
+
(0, _helpers.terminal)(`^g^+🎉 Project initialized successfully!^ ^GRun ^:^+yarn^:^G to install dependencies and start coding!\n`);
|
|
104
101
|
}
|
|
105
102
|
async function fetchProjectTemplate(templateId) {
|
|
106
|
-
const baseUrl = (0,
|
|
103
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
107
104
|
const url = `${baseUrl}/api/templates/${templateId}`;
|
|
108
105
|
const response = await fetch(url);
|
|
109
106
|
if (!response.ok) {
|
|
@@ -133,7 +130,7 @@ async function prepareCLITemplate(codeTree) {
|
|
|
133
130
|
}
|
|
134
131
|
codeTree["README.md"] = {
|
|
135
132
|
file: {
|
|
136
|
-
contents:
|
|
133
|
+
contents: _constants.readme
|
|
137
134
|
}
|
|
138
135
|
};
|
|
139
136
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
|
|
2
|
+
export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
|
|
3
|
+
export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertApiFileExists = assertApiFileExists;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _fsExtra = require("fs-extra");
|
|
9
|
+
var _errors = require("./errors");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
async function assertApiFileExists(dirname, api) {
|
|
12
|
+
const file = `${dirname}/${api}.ts`;
|
|
13
|
+
const filePath = _path.default.join(process.cwd(), file);
|
|
14
|
+
if (!(await (0, _fsExtra.exists)(filePath))) {
|
|
15
|
+
throw new _errors.CLIAssertionError(`^+^r API^ ^+${dirname}/${api}^ ^r^+is not implemented.^:`, {
|
|
16
|
+
autoColor: false
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StorageState } from "../../../common/contextStorageStateHelpers";
|
|
2
|
+
import type { AuthSessionMetadata } from "../types";
|
|
3
|
+
export declare function isAuthEnabled(): Promise<boolean>;
|
|
4
|
+
export declare function assertAuthEnabled(): Promise<void>;
|
|
5
|
+
export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
|
|
6
|
+
export declare function retrieveAuthSessionInstance(authSessionId: string, pathsOnly?: boolean): Promise<{
|
|
7
|
+
authSessionInstanceStoragePath: string;
|
|
8
|
+
authSessionInstanceMetadataPath: string;
|
|
9
|
+
authSessionInstance?: undefined;
|
|
10
|
+
metadata?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
authSessionInstance: StorageState;
|
|
13
|
+
metadata: AuthSessionMetadata;
|
|
14
|
+
authSessionInstanceStoragePath?: undefined;
|
|
15
|
+
authSessionInstanceMetadataPath?: undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function storeAuthSessionInstance(authSessionInstance: StorageState, customName?: string, authSessionInput?: Record<string, any>): Promise<string>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertAuthConsistent = assertAuthConsistent;
|
|
7
|
+
exports.assertAuthEnabled = assertAuthEnabled;
|
|
8
|
+
exports.isAuthEnabled = isAuthEnabled;
|
|
9
|
+
exports.retrieveAuthSessionInstance = retrieveAuthSessionInstance;
|
|
10
|
+
exports.storeAuthSessionInstance = storeAuthSessionInstance;
|
|
11
|
+
var _constants = require("../../../common/constants");
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
var _fsExtra = require("fs-extra");
|
|
14
|
+
var _intunedJson = require("./intunedJson");
|
|
15
|
+
var _errors = require("./errors");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
async function isAuthEnabled() {
|
|
18
|
+
try {
|
|
19
|
+
const intunedJson = await (0, _fsExtra.readJSON)(_path.default.join(process.cwd(), "Intuned.json"));
|
|
20
|
+
return Boolean(intunedJson?.authSessions?.enabled);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function assertAuthEnabled() {
|
|
26
|
+
if (!(await isAuthEnabled())) {
|
|
27
|
+
throw new _errors.CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function assertAuthConsistent(authSession) {
|
|
31
|
+
const _isAuthEnabled = await isAuthEnabled();
|
|
32
|
+
if (_isAuthEnabled && !authSession) {
|
|
33
|
+
throw new _errors.CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
|
|
34
|
+
}
|
|
35
|
+
if (!_isAuthEnabled && authSession) {
|
|
36
|
+
throw new _errors.CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function retrieveAuthSessionInstance(authSessionId, pathsOnly = false) {
|
|
40
|
+
try {
|
|
41
|
+
const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
|
|
42
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
43
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
44
|
+
if (!(await (0, _fsExtra.exists)(authSessionInstanceStoragePath))) {
|
|
45
|
+
throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} not found`);
|
|
46
|
+
}
|
|
47
|
+
if (pathsOnly) {
|
|
48
|
+
return {
|
|
49
|
+
authSessionInstanceStoragePath,
|
|
50
|
+
authSessionInstanceMetadataPath
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const authSessionInstance = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
|
|
54
|
+
const metadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
|
|
55
|
+
return {
|
|
56
|
+
authSessionInstance,
|
|
57
|
+
metadata
|
|
58
|
+
};
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw new _errors.CLIError(`Error retrieving auth session instance: ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function storeAuthSessionInstance(authSessionInstance, customName, authSessionInput) {
|
|
64
|
+
try {
|
|
65
|
+
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
66
|
+
await (0, _fsExtra.ensureDir)(authSessionsDirectoryPath);
|
|
67
|
+
const authSessionInstanceId = customName ?? `auth-session-${Date.now()}`;
|
|
68
|
+
const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, authSessionInstanceId);
|
|
69
|
+
const authSessionExists = await (0, _fsExtra.pathExists)(authSessionInstancePath);
|
|
70
|
+
await (0, _fsExtra.ensureDir)(authSessionInstancePath);
|
|
71
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
72
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceStoragePath, authSessionInstance, {
|
|
73
|
+
spaces: 2
|
|
74
|
+
});
|
|
75
|
+
const projectAuthConfig = await (0, _intunedJson.getSettingIntunedJSON)("authSessions");
|
|
76
|
+
let existingMetadata = {};
|
|
77
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
78
|
+
if (authSessionExists) {
|
|
79
|
+
try {
|
|
80
|
+
existingMetadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
|
|
81
|
+
} catch (readError) {
|
|
82
|
+
existingMetadata = {};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const authSessionMetadata = {
|
|
86
|
+
createdAt: existingMetadata.createdAt || new Date().toISOString(),
|
|
87
|
+
updatedAt: new Date().toISOString(),
|
|
88
|
+
...(projectAuthConfig.type === "API" && {
|
|
89
|
+
authSessionInput: authSessionInput || existingMetadata.authSessionInput || {}
|
|
90
|
+
}),
|
|
91
|
+
authSessionId: authSessionInstanceId,
|
|
92
|
+
authSessionType: projectAuthConfig.type ?? existingMetadata.authSessionType ?? "API",
|
|
93
|
+
...(projectAuthConfig.type === "MANUAL" && {
|
|
94
|
+
recorderStartUrl: projectAuthConfig.startUrl,
|
|
95
|
+
recorderEndUrl: projectAuthConfig.endUrl
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceMetadataPath, authSessionMetadata, {
|
|
99
|
+
spaces: 2
|
|
100
|
+
});
|
|
101
|
+
return authSessionInstancePath;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw new _errors.CLIError(`Error storing auth session instance: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAuthCredentials = getAuthCredentials;
|
|
7
|
+
exports.getBaseUrl = getBaseUrl;
|
|
8
|
+
var _errors = require("./errors");
|
|
9
|
+
var _intunedJson = require("./intunedJson");
|
|
10
|
+
async function getAuthCredentials(options) {
|
|
11
|
+
const workspaceId = options.workspaceId || (await (0, _intunedJson.getSettingIntunedJSON)("workspaceId"));
|
|
12
|
+
const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
|
|
13
|
+
if (!workspaceId) {
|
|
14
|
+
throw new _errors.CLIError("Workspace ID is required. Please provide it via command line options or Intuned.json");
|
|
15
|
+
}
|
|
16
|
+
if (!apiKey) {
|
|
17
|
+
throw new _errors.CLIError("API key is required. Please provide it via command line options or INTUNED_API_KEY environment variable.");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
workspaceId,
|
|
21
|
+
apiKey
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getBaseUrl() {
|
|
25
|
+
return process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`;
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withCLIContext = withCLIContext;
|
|
7
|
+
var _nanoid = require("nanoid");
|
|
8
|
+
var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
|
|
9
|
+
var _enums = require("../../../runtime/enums");
|
|
10
|
+
var _auth = require("./auth");
|
|
11
|
+
async function withCLIContext(fn, options) {
|
|
12
|
+
const runId = (0, _nanoid.nanoid)();
|
|
13
|
+
async function getAuthSessionParameters() {
|
|
14
|
+
const id = options?.authSessionId;
|
|
15
|
+
if (!id) {
|
|
16
|
+
throw new Error("getAuthSessionParameters cannot be called without using an auth session");
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
metadata
|
|
20
|
+
} = await (0, _auth.retrieveAuthSessionInstance)(id);
|
|
21
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
22
|
+
throw new Error("Auth session is recorder-based, it does not have parameters.");
|
|
23
|
+
}
|
|
24
|
+
return metadata?.authSessionInput ?? {};
|
|
25
|
+
}
|
|
26
|
+
return await (0, _asyncLocalStorage.runWithContext)({
|
|
27
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
28
|
+
runId,
|
|
29
|
+
extendedPayloads: [],
|
|
30
|
+
timeoutInfo: {},
|
|
31
|
+
getAuthSessionParameters
|
|
32
|
+
}, fn);
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AutomationError } from "../../../common/runApi";
|
|
2
|
+
export declare class CLIError extends Error {
|
|
3
|
+
autoColor: boolean;
|
|
4
|
+
constructor(message: string, options?: {
|
|
5
|
+
autoColor?: boolean;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
export declare class CLIAssertionError extends CLIError {
|
|
9
|
+
constructor(message: string, options?: {
|
|
10
|
+
autoColor?: boolean;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare function logAutomationError(error: AutomationError): void;
|
|
14
|
+
export declare function withErrorLogging<T extends any[]>(fn: (...args: T) => Promise<unknown>): (...args: T) => Promise<never>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CLIError = exports.CLIAssertionError = void 0;
|
|
7
|
+
exports.logAutomationError = logAutomationError;
|
|
8
|
+
exports.withErrorLogging = withErrorLogging;
|
|
9
|
+
var _runApi = require("../../../common/runApi");
|
|
10
|
+
var _terminal = require("./terminal");
|
|
11
|
+
class CLIError extends Error {
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "CLIError";
|
|
15
|
+
this.autoColor = options?.autoColor ?? true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.CLIError = CLIError;
|
|
19
|
+
class CLIAssertionError extends CLIError {
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super(message, options);
|
|
22
|
+
this.name = "CLIAssertionError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CLIAssertionError = CLIAssertionError;
|
|
26
|
+
function logAutomationError(error) {
|
|
27
|
+
(0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
|
|
28
|
+
if (error.error.stack) {
|
|
29
|
+
const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
|
|
30
|
+
(0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
|
|
31
|
+
} else {
|
|
32
|
+
(0, _terminal.terminal)(`^r${error.error.message}^:\n`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function withErrorLogging(fn) {
|
|
36
|
+
return async (...args) => {
|
|
37
|
+
try {
|
|
38
|
+
await fn(...args);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof CLIError) {
|
|
42
|
+
if (error.autoColor) {
|
|
43
|
+
(0, _terminal.terminal)(`^r^+${error.message}^:\n`);
|
|
44
|
+
} else {
|
|
45
|
+
(0, _terminal.terminal)(`${error.message}\n`);
|
|
46
|
+
}
|
|
47
|
+
} else if (error instanceof _runApi.AutomationError) {
|
|
48
|
+
logAutomationError(error);
|
|
49
|
+
} else {
|
|
50
|
+
(0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
|
|
51
|
+
}
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export * from "./auth";
|
|
3
|
+
export * from "./context";
|
|
4
|
+
export * from "./errors";
|
|
5
|
+
export * from "./proxy";
|
|
6
|
+
export * from "./terminal";
|
|
7
|
+
export * from "./timeout";
|
|
8
|
+
export * from "./validation";
|
|
9
|
+
export * from "./intunedJson";
|
|
10
|
+
export * from "./backend";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _api = require("./api");
|
|
7
|
+
Object.keys(_api).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _api[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _api[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _auth = require("./auth");
|
|
18
|
+
Object.keys(_auth).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _auth[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _auth[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _context = require("./context");
|
|
29
|
+
Object.keys(_context).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _context[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _context[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _errors = require("./errors");
|
|
40
|
+
Object.keys(_errors).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _errors[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _errors[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _proxy = require("./proxy");
|
|
51
|
+
Object.keys(_proxy).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _proxy[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _proxy[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _terminal = require("./terminal");
|
|
62
|
+
Object.keys(_terminal).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _terminal[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _terminal[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _timeout = require("./timeout");
|
|
73
|
+
Object.keys(_timeout).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _timeout[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _timeout[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _validation = require("./validation");
|
|
84
|
+
Object.keys(_validation).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _validation[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _validation[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _intunedJson = require("./intunedJson");
|
|
95
|
+
Object.keys(_intunedJson).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _intunedJson[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _intunedJson[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _backend = require("./backend");
|
|
106
|
+
Object.keys(_backend).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _backend[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _backend[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSettingIntunedJSON(key: string): Promise<any>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSettingIntunedJSON = getSettingIntunedJSON;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
|
+
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); }
|
|
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; }
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
async function getSettingIntunedJSON(key) {
|
|
13
|
+
const intunedJsonPath = _path.default.join(process.cwd(), "Intuned.json");
|
|
14
|
+
const intunedJson = await fs.readJSON(intunedJsonPath);
|
|
15
|
+
if (intunedJson && intunedJson[key]) {
|
|
16
|
+
return intunedJson[key];
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseUrlProxy = parseUrlProxy;
|
|
7
|
+
function parseUrlProxy(proxyUrl) {
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(proxyUrl);
|
|
10
|
+
const username = url.username;
|
|
11
|
+
const password = url.password;
|
|
12
|
+
const proxy = url.hostname;
|
|
13
|
+
const port = url.port ? `:${url.port}` : "";
|
|
14
|
+
const domain = `${url.protocol}//${proxy}${port}`;
|
|
15
|
+
return {
|
|
16
|
+
password,
|
|
17
|
+
username,
|
|
18
|
+
server: domain
|
|
19
|
+
};
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withTimeout<R>(fn: (abortSignal: AbortSignal) => Promise<R>, timeout: number): Promise<Awaited<R>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withTimeout = withTimeout;
|
|
7
|
+
var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
|
|
8
|
+
var _runApi = require("../../../common/runApi");
|
|
9
|
+
function withTimeout(fn, timeout) {
|
|
10
|
+
let reject;
|
|
11
|
+
const abortController = new AbortController();
|
|
12
|
+
const timeoutPromise = new Promise((_, _reject) => {
|
|
13
|
+
reject = _reject;
|
|
14
|
+
});
|
|
15
|
+
const timeoutId = setTimeout(() => {
|
|
16
|
+
abortController.abort();
|
|
17
|
+
reject(new _runApi.AutomationError(new Error("Timed out")));
|
|
18
|
+
}, timeout);
|
|
19
|
+
(0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
|
|
20
|
+
timeoutId.refresh();
|
|
21
|
+
};
|
|
22
|
+
return Promise.race([fn(abortController.signal), timeoutPromise]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logInvalidInput = logInvalidInput;
|
|
7
|
+
var _terminal = require("./terminal");
|
|
8
|
+
function logInvalidInput(result) {
|
|
9
|
+
(0, _terminal.terminal)("^r^+Invalid input parameters:^: ^R" + result.error.errors.map(({
|
|
10
|
+
message
|
|
11
|
+
}) => `^R${message}^:`).join(", ") + "\n");
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare const templateIds: readonly ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
2
|
+
export type TemplateId = typeof templateIds[number];
|
|
3
|
+
export interface FileSystemTree {
|
|
4
|
+
[name: string]: DirectoryNode | FileNode;
|
|
5
|
+
}
|
|
6
|
+
export interface DirectoryNode {
|
|
7
|
+
directory: FileSystemTree;
|
|
8
|
+
}
|
|
9
|
+
export interface FileNode {
|
|
10
|
+
file: {
|
|
11
|
+
/**
|
|
12
|
+
* The contents of the file, either as a UTF-8 string or as raw binary.
|
|
13
|
+
*/
|
|
14
|
+
contents: string | Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface AuthCredentials {
|
|
18
|
+
workspaceId: string;
|
|
19
|
+
apiKey: string;
|
|
20
|
+
}
|
|
21
|
+
export declare enum ApiAuthSessionBehavior {
|
|
22
|
+
PERFORM_CHECK_AND_REFRESH = "PERFORM_CHECK_AND_REFRESH",
|
|
23
|
+
SKIP_CHECK_AND_REFRESH = "SKIP_CHECK_AND_REFRESH"
|
|
24
|
+
}
|
|
25
|
+
export declare const CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
|
|
26
|
+
export type AuthSessionType = "API" | "MANUAL";
|
|
27
|
+
export type AuthSessionMetadata = {
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
authSessionId: string;
|
|
31
|
+
authSessionType: AuthSessionType;
|
|
32
|
+
authSessionInput?: Record<string, any>;
|
|
33
|
+
recorderStartUrl?: string;
|
|
34
|
+
recorderEndUrl?: string;
|
|
35
|
+
};
|
|
36
|
+
export interface SessionStorageState {
|
|
37
|
+
origin: string;
|
|
38
|
+
sessionStorage: {
|
|
39
|
+
name: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}[];
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.templateIds = exports.CHECK_FAILED_ERROR_MESSAGE = exports.ApiAuthSessionBehavior = void 0;
|
|
7
|
+
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
8
|
+
let ApiAuthSessionBehavior = exports.ApiAuthSessionBehavior = function (ApiAuthSessionBehavior) {
|
|
9
|
+
ApiAuthSessionBehavior["PERFORM_CHECK_AND_REFRESH"] = "PERFORM_CHECK_AND_REFRESH";
|
|
10
|
+
ApiAuthSessionBehavior["SKIP_CHECK_AND_REFRESH"] = "SKIP_CHECK_AND_REFRESH";
|
|
11
|
+
return ApiAuthSessionBehavior;
|
|
12
|
+
}({});
|
|
13
|
+
const CHECK_FAILED_ERROR_MESSAGE = exports.CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
|