@intuned/runtime-dev 1.3.9-deploy.0 → 1.3.9-dev10
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/InterfaceTemplate/index.playwright.ts +1 -0
- package/bin/intuned +2 -0
- package/bin/intuned-api-run +2 -0
- package/bin/intuned-auth-session-check +2 -0
- package/bin/intuned-auth-session-create +2 -0
- package/bin/intuned-auth-session-load +2 -0
- package/dist/commands/common/utils/settings.js +3 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
- package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/deploy.js +6 -143
- package/dist/commands/intuned-cli/controller/save.d.ts +1 -4
- package/dist/commands/intuned-cli/controller/save.js +2 -8
- package/dist/commands/intuned-cli/helpers/backend.js +1 -1
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/errors.js +1 -8
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +11 -113
- package/dist/commands/intuned-cli/helpers/intunedJson.js +3 -19
- package/dist/commands/intuned-cli/helpers/wrapper.js +0 -5
- package/dist/common/binStartupScript.d.ts +1 -0
- package/dist/common/binStartupScript.js +34 -0
- package/dist/common/settingsSchema.d.ts +13 -0
- package/dist/common/settingsSchema.js +6 -0
- package/package/dist/commands/api/run.d.ts +6 -0
- package/package/dist/commands/api/run.js +123 -0
- package/package/dist/commands/auth-sessions/load.d.ts +2 -0
- package/package/dist/commands/auth-sessions/load.js +35 -0
- package/package/dist/commands/auth-sessions/run-check.d.ts +2 -0
- package/package/dist/commands/auth-sessions/run-check.js +74 -0
- package/package/dist/commands/auth-sessions/run-create.d.ts +2 -0
- package/package/dist/commands/auth-sessions/run-create.js +78 -0
- package/package/dist/commands/browser/save-state.d.ts +2 -0
- package/package/dist/commands/browser/save-state.js +17 -0
- package/package/dist/commands/browser/start-browser.d.ts +2 -0
- package/package/dist/commands/browser/start-browser.js +14 -0
- package/package/dist/commands/build.d.ts +1 -0
- package/package/dist/commands/build.js +84 -0
- package/package/dist/commands/common/browserUtils.d.ts +14 -0
- package/package/dist/commands/common/browserUtils.js +58 -0
- package/package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
- package/package/dist/commands/common/getFirstLineNumber.js +101 -0
- package/package/dist/commands/common/getFirstLineNumber.test.js +228 -0
- package/package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/package/dist/commands/common/projectExclusions.js +8 -0
- package/package/dist/commands/common/sendMessageToClient.d.ts +1 -0
- package/package/dist/commands/common/sendMessageToClient.js +10 -0
- package/package/dist/commands/common/tsNodeImport.d.ts +2 -0
- package/package/dist/commands/common/tsNodeImport.js +34 -0
- package/package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/package/dist/commands/common/utils/fileUtils.js +33 -0
- package/package/dist/commands/common/utils/settings.d.ts +2 -0
- package/package/dist/commands/common/utils/settings.js +31 -0
- package/package/dist/commands/common/utils/template.d.ts +2 -0
- package/package/dist/commands/common/utils/template.js +31 -0
- package/package/dist/commands/common/utils/unixSocket.d.ts +9 -0
- package/package/dist/commands/common/utils/unixSocket.js +44 -0
- package/package/dist/commands/interface/run.d.ts +1 -0
- package/package/dist/commands/interface/run.js +216 -0
- package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
- package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
- package/package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/deploy.command.js +38 -0
- package/package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
- package/package/dist/commands/intuned-cli/commands/index.js +203 -0
- package/package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/init.command.js +13 -0
- package/package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +28 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
- package/package/dist/commands/intuned-cli/commands/save.command.d.ts +13 -0
- package/package/dist/commands/intuned-cli/commands/save.command.js +42 -0
- package/package/dist/commands/intuned-cli/commands/types.d.ts +31 -0
- package/package/dist/commands/intuned-cli/commands/types.js +29 -0
- package/package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +397 -0
- package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1059 -0
- package/package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
- package/package/dist/commands/intuned-cli/controller/api.js +189 -0
- package/package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
- package/package/dist/commands/intuned-cli/controller/authSession.js +420 -0
- package/package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/package/dist/commands/intuned-cli/controller/deploy.d.ts +4 -0
- package/package/dist/commands/intuned-cli/controller/deploy.js +139 -0
- package/package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/package/dist/commands/intuned-cli/controller/save.d.ts +14 -0
- package/package/dist/commands/intuned-cli/controller/save.js +345 -0
- package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
- package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
- package/package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
- package/package/dist/commands/intuned-cli/helpers/auth.js +144 -0
- package/package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/package/dist/commands/intuned-cli/helpers/backend.js +27 -0
- package/package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/package/dist/commands/intuned-cli/helpers/browser.js +57 -0
- package/package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/package/dist/commands/intuned-cli/helpers/errors.d.ts +13 -0
- package/package/dist/commands/intuned-cli/helpers/errors.js +37 -0
- package/package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
- package/package/dist/commands/intuned-cli/helpers/index.js +137 -0
- package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -0
- package/package/dist/commands/intuned-cli/helpers/intunedJson.js +71 -0
- package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/traces.js +32 -0
- package/package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/validation.js +14 -0
- package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
- package/package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/package/dist/commands/intuned-cli/index.js +16 -0
- package/package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/package/dist/commands/intuned-cli/main.js +22 -0
- package/package/dist/commands/intuned-cli/types.d.ts +41 -0
- package/package/dist/commands/intuned-cli/types.js +12 -0
- package/package/dist/commands/ts-check.d.ts +2 -0
- package/package/dist/commands/ts-check.js +56 -0
- package/package/dist/common/Logger/Logger/index.d.ts +12 -0
- package/package/dist/common/Logger/Logger/index.js +60 -0
- package/package/dist/common/Logger/Logger/types.d.ts +8 -0
- package/package/dist/common/Logger/Logger/types.js +5 -0
- package/package/dist/common/Logger/index.d.ts +12 -0
- package/package/dist/common/Logger/index.js +60 -0
- package/package/dist/common/Logger/types.d.ts +8 -0
- package/package/dist/common/Logger/types.js +5 -0
- package/package/dist/common/assets/browser_scripts.js +2580 -0
- package/package/dist/common/asyncLocalStorage/index.d.ts +16 -0
- package/package/dist/common/asyncLocalStorage/index.js +17 -0
- package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
- package/package/dist/common/cleanEnvironmentVariables.js +16 -0
- package/package/dist/common/constants.d.ts +10 -0
- package/package/dist/common/constants.js +16 -0
- package/package/dist/common/contextStorageStateHelpers.d.ts +21 -0
- package/package/dist/common/contextStorageStateHelpers.js +81 -0
- package/package/dist/common/extensionsHelpers.d.ts +8 -0
- package/package/dist/common/extensionsHelpers.js +80 -0
- package/package/dist/common/formatZodError.d.ts +2 -0
- package/package/dist/common/formatZodError.js +18 -0
- package/package/dist/common/jwtTokenManager.d.ts +17 -0
- package/package/dist/common/jwtTokenManager.js +109 -0
- package/package/dist/common/launchBrowser.d.ts +25 -0
- package/package/dist/common/launchBrowser.js +172 -0
- package/package/dist/common/playwrightContext.d.ts +31 -0
- package/package/dist/common/playwrightContext.js +144 -0
- package/package/dist/common/runApi/errors.d.ts +72 -0
- package/package/dist/common/runApi/errors.js +169 -0
- package/package/dist/common/runApi/importUsingImportFunction.d.ts +9 -0
- package/package/dist/common/runApi/importUsingImportFunction.js +46 -0
- package/package/dist/common/runApi/index.d.ts +11 -0
- package/package/dist/common/runApi/index.js +199 -0
- package/package/dist/common/runApi/types.d.ts +830 -0
- package/package/dist/common/runApi/types.js +73 -0
- package/package/dist/common/settingsSchema.d.ts +518 -0
- package/package/dist/common/settingsSchema.js +57 -0
- package/package/dist/common/setupContextHook.d.ts +17 -0
- package/package/dist/common/setupContextHook.js +22 -0
- package/package/dist/common/telemetry.d.ts +3 -0
- package/package/dist/common/telemetry.js +32 -0
- package/package/dist/index.d.ts +4 -0
- package/package/dist/index.js +69 -0
- package/package/dist/runtime/RunError.d.ts +5 -0
- package/package/dist/runtime/RunError.js +19 -0
- package/package/dist/runtime/attemptStore.d.ts +2 -0
- package/package/dist/runtime/attemptStore.js +23 -0
- package/package/dist/runtime/downloadDirectory.d.ts +1 -0
- package/package/dist/runtime/downloadDirectory.js +19 -0
- package/package/dist/runtime/enums.d.js +5 -0
- package/package/dist/runtime/enums.d.ts +11 -0
- package/package/dist/runtime/enums.js +18 -0
- package/package/dist/runtime/executionHelpers.test.js +52 -0
- package/package/dist/runtime/export.d.js +5 -0
- package/package/dist/runtime/export.d.ts +228 -0
- package/package/dist/runtime/extendPayload.d.ts +2 -0
- package/package/dist/runtime/extendPayload.js +21 -0
- package/package/dist/runtime/extendTimeout.d.ts +1 -0
- package/package/dist/runtime/extendTimeout.js +23 -0
- package/package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/package/dist/runtime/index.d.ts +7 -0
- package/package/dist/runtime/index.js +54 -0
- package/package/dist/runtime/runInfo.d.ts +2 -0
- package/package/dist/runtime/runInfo.js +21 -0
- package/package.json +3 -5
- package/WebTemplate.zip +0 -0
- package/bin/intuned-auth-session-refresh +0 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertAuthConsistent = assertAuthConsistent;
|
|
7
|
+
exports.assertAuthEnabled = assertAuthEnabled;
|
|
8
|
+
exports.getAuthSessionRecorderParameters = getAuthSessionRecorderParameters;
|
|
9
|
+
exports.isAuthEnabled = isAuthEnabled;
|
|
10
|
+
exports.loadAuthSessionInstance = loadAuthSessionInstance;
|
|
11
|
+
exports.registerGetAuthSessionParameters = registerGetAuthSessionParameters;
|
|
12
|
+
exports.storeAuthSessionInstance = storeAuthSessionInstance;
|
|
13
|
+
var _constants = require("../../../common/constants");
|
|
14
|
+
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
var _fsExtra = require("fs-extra");
|
|
16
|
+
var _intunedJson = require("./intunedJson");
|
|
17
|
+
var _errors = require("./errors");
|
|
18
|
+
var _runApi = require("../../../common/runApi");
|
|
19
|
+
var _formatZodError = require("../../../common/formatZodError");
|
|
20
|
+
var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
async function isAuthEnabled() {
|
|
23
|
+
try {
|
|
24
|
+
const intunedJson = await (0, _intunedJson.loadIntunedJson)();
|
|
25
|
+
return Boolean(intunedJson?.authSessions?.enabled);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function assertAuthEnabled() {
|
|
31
|
+
if (!(await isAuthEnabled())) {
|
|
32
|
+
throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function assertAuthConsistent(authSession) {
|
|
36
|
+
const _isAuthEnabled = await isAuthEnabled();
|
|
37
|
+
if (_isAuthEnabled && !authSession) {
|
|
38
|
+
throw new _errors.CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
|
|
39
|
+
}
|
|
40
|
+
if (!_isAuthEnabled && authSession) {
|
|
41
|
+
throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function loadAuthSessionInstance(authSessionId) {
|
|
45
|
+
try {
|
|
46
|
+
const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
|
|
47
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
48
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
49
|
+
if (!(await (0, _fsExtra.exists)(authSessionInstanceStoragePath))) {
|
|
50
|
+
throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} not found`);
|
|
51
|
+
}
|
|
52
|
+
const authSessionInstanceJson = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
|
|
53
|
+
const authSessionInstanceParseResult = _runApi.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
|
|
54
|
+
if (!authSessionInstanceParseResult.success) {
|
|
55
|
+
throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
|
|
56
|
+
}
|
|
57
|
+
const metadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
|
|
58
|
+
return {
|
|
59
|
+
storageState: authSessionInstanceParseResult.data,
|
|
60
|
+
metadata
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new _errors.CLIError(`Error retrieving auth session instance: ${error.message}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function storeAuthSessionInstance({
|
|
67
|
+
state,
|
|
68
|
+
id,
|
|
69
|
+
input,
|
|
70
|
+
proxy,
|
|
71
|
+
metadata
|
|
72
|
+
}) {
|
|
73
|
+
try {
|
|
74
|
+
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
75
|
+
await (0, _fsExtra.ensureDir)(authSessionsDirectoryPath);
|
|
76
|
+
const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, id);
|
|
77
|
+
await (0, _fsExtra.ensureDir)(authSessionInstancePath);
|
|
78
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
79
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceStoragePath, state, {
|
|
80
|
+
spaces: 2
|
|
81
|
+
});
|
|
82
|
+
const projectAuthConfig = (await (0, _intunedJson.loadIntunedJson)()).authSessions;
|
|
83
|
+
if (!projectAuthConfig.enabled) {
|
|
84
|
+
throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
85
|
+
}
|
|
86
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
87
|
+
const authSessionMetadata = {
|
|
88
|
+
createdAt: metadata?.createdAt ?? new Date().toISOString(),
|
|
89
|
+
updatedAt: new Date().toISOString(),
|
|
90
|
+
...(projectAuthConfig.type === "API" && {
|
|
91
|
+
authSessionInput: input || metadata?.authSessionInput || {}
|
|
92
|
+
}),
|
|
93
|
+
authSessionId: id,
|
|
94
|
+
authSessionType: projectAuthConfig.type ?? metadata?.authSessionType ?? "API",
|
|
95
|
+
...(projectAuthConfig.type === "MANUAL" && {
|
|
96
|
+
recorderStartUrl: projectAuthConfig.startUrl,
|
|
97
|
+
recorderEndUrl: projectAuthConfig.finishUrl
|
|
98
|
+
}),
|
|
99
|
+
authSessionInput: input || metadata?.authSessionInput || {},
|
|
100
|
+
authSessionProxy: proxy || metadata?.authSessionProxy
|
|
101
|
+
};
|
|
102
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceMetadataPath, authSessionMetadata, {
|
|
103
|
+
spaces: 2
|
|
104
|
+
});
|
|
105
|
+
return authSessionInstancePath;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new _errors.CLIError(`Error storing auth session instance: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function registerGetAuthSessionParameters(authSessionId) {
|
|
111
|
+
async function getAuthSessionParameters() {
|
|
112
|
+
if (!authSessionId) {
|
|
113
|
+
throw new Error("getAuthSessionParameters cannot be called without using an auth session");
|
|
114
|
+
}
|
|
115
|
+
const {
|
|
116
|
+
metadata
|
|
117
|
+
} = await loadAuthSessionInstance(authSessionId);
|
|
118
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
119
|
+
throw new Error("Auth session is recorder-based, it does not have parameters.");
|
|
120
|
+
}
|
|
121
|
+
return metadata?.authSessionInput ?? {};
|
|
122
|
+
}
|
|
123
|
+
(0, _asyncLocalStorage.getExecutionContext)().getAuthSessionParameters = getAuthSessionParameters;
|
|
124
|
+
}
|
|
125
|
+
async function getAuthSessionRecorderParameters() {
|
|
126
|
+
const intunedJson = await (0, _intunedJson.loadIntunedJson)();
|
|
127
|
+
if (!intunedJson.authSessions.enabled) {
|
|
128
|
+
throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
129
|
+
}
|
|
130
|
+
if (intunedJson.authSessions.type !== "MANUAL") {
|
|
131
|
+
throw new _errors.CLIError(`Auth session type is not recorder-based in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
132
|
+
}
|
|
133
|
+
const {
|
|
134
|
+
startUrl,
|
|
135
|
+
finishUrl
|
|
136
|
+
} = intunedJson.authSessions;
|
|
137
|
+
if (startUrl === undefined || finishUrl === undefined) {
|
|
138
|
+
throw new _errors.CLIError(`Auth session type is recorder-based but start_url or finish_url is not set in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
startUrl,
|
|
142
|
+
finishUrl
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAuthCredentials = getAuthCredentials;
|
|
7
|
+
exports.getBaseUrl = getBaseUrl;
|
|
8
|
+
var _constants = require("../../../common/constants");
|
|
9
|
+
var _errors = require("./errors");
|
|
10
|
+
var _intunedJson = require("./intunedJson");
|
|
11
|
+
async function getAuthCredentials(options) {
|
|
12
|
+
const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId;
|
|
13
|
+
const apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
14
|
+
if (!workspaceId) {
|
|
15
|
+
throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
16
|
+
}
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
throw new _errors.CLIError(`API key is required. Please provide it via command line options or ${_constants.API_KEY_ENV_VAR_KEY} environment variable.`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
workspaceId,
|
|
22
|
+
apiKey
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getBaseUrl() {
|
|
26
|
+
return process.env[_constants.API_BASE_URL_ENV_VAR_KEY] || process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BrowserContext } from "playwright";
|
|
2
|
+
import type { runApiParametersSchema } from "../../../common/runApi";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
declare let context: BrowserContext | null;
|
|
5
|
+
export declare function _getContextForTest(): typeof context;
|
|
6
|
+
type RunApiRunOptions = z.infer<typeof runApiParametersSchema>["runOptions"];
|
|
7
|
+
export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, }: {
|
|
8
|
+
headless: boolean;
|
|
9
|
+
proxy?: string;
|
|
10
|
+
keepBrowserOpen: boolean;
|
|
11
|
+
}): Promise<RunApiRunOptions>;
|
|
12
|
+
export declare function isCliBrowserLaunched(): boolean;
|
|
13
|
+
export declare function closeCliBrowser(): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports._getContextForTest = _getContextForTest;
|
|
7
|
+
exports.closeCliBrowser = closeCliBrowser;
|
|
8
|
+
exports.getCLIRunOptions = getCLIRunOptions;
|
|
9
|
+
exports.isCliBrowserLaunched = isCliBrowserLaunched;
|
|
10
|
+
var _launchBrowser = require("../../../common/launchBrowser");
|
|
11
|
+
var _portfinder = require("portfinder");
|
|
12
|
+
var _proxy = require("./proxy");
|
|
13
|
+
let context = null;
|
|
14
|
+
function _getContextForTest() {
|
|
15
|
+
if (process.env.NODE_ENV !== "test") {
|
|
16
|
+
throw new Error("_getContextForTest should only be used in tests");
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
async function getCLIRunOptions({
|
|
21
|
+
headless,
|
|
22
|
+
proxy,
|
|
23
|
+
keepBrowserOpen
|
|
24
|
+
}) {
|
|
25
|
+
if (context) {
|
|
26
|
+
await closeCliBrowser();
|
|
27
|
+
}
|
|
28
|
+
if (!keepBrowserOpen) {
|
|
29
|
+
return {
|
|
30
|
+
environment: "standalone",
|
|
31
|
+
headless,
|
|
32
|
+
proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const port = await (0, _portfinder.getPort)({});
|
|
36
|
+
({
|
|
37
|
+
context
|
|
38
|
+
} = await (0, _launchBrowser.launchChromium)({
|
|
39
|
+
headless,
|
|
40
|
+
proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
|
|
41
|
+
cdpPort: port
|
|
42
|
+
}));
|
|
43
|
+
return {
|
|
44
|
+
environment: "cdp",
|
|
45
|
+
cdpAddress: `http://localhost:${port}`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function isCliBrowserLaunched() {
|
|
49
|
+
return context !== null;
|
|
50
|
+
}
|
|
51
|
+
async function closeCliBrowser() {
|
|
52
|
+
if (!context) return;
|
|
53
|
+
try {
|
|
54
|
+
await context.close();
|
|
55
|
+
context = null;
|
|
56
|
+
} catch (e) {}
|
|
57
|
+
}
|
|
@@ -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.loadAuthSessionInstance)(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,13 @@
|
|
|
1
|
+
import { RunAutomationError } 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: RunAutomationError): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var _runApi = require("../../../common/runApi");
|
|
9
|
+
var _terminal = require("./terminal");
|
|
10
|
+
class CLIError extends Error {
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "CLIError";
|
|
14
|
+
this.autoColor = options?.autoColor ?? true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CLIError = CLIError;
|
|
18
|
+
class CLIAssertionError extends CLIError {
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message, options);
|
|
21
|
+
this.name = "CLIAssertionError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CLIAssertionError = CLIAssertionError;
|
|
25
|
+
function logAutomationError(error) {
|
|
26
|
+
(0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
|
|
27
|
+
if (error instanceof _runApi.AutomationError) {
|
|
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
|
+
} else {
|
|
35
|
+
(0, _terminal.terminal)(`^r${error.message}^:\n`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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";
|
|
11
|
+
export * from "./traces";
|
|
12
|
+
export * from "./wrapper";
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
});
|
|
116
|
+
var _traces = require("./traces");
|
|
117
|
+
Object.keys(_traces).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _traces[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _traces[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _wrapper = require("./wrapper");
|
|
128
|
+
Object.keys(_wrapper).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _wrapper[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _wrapper[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const intunedJsonSchema: z.ZodObject<{
|
|
3
|
+
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
4
|
+
enabled: z.ZodLiteral<false>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
enabled: false;
|
|
7
|
+
}, {
|
|
8
|
+
enabled: false;
|
|
9
|
+
}>, z.ZodObject<{
|
|
10
|
+
enabled: z.ZodLiteral<true>;
|
|
11
|
+
type: z.ZodEnum<["MANUAL", "API"]>;
|
|
12
|
+
startUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
finishUrl: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
type: "API" | "MANUAL";
|
|
16
|
+
enabled: true;
|
|
17
|
+
startUrl?: string | undefined;
|
|
18
|
+
finishUrl?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
type: "API" | "MANUAL";
|
|
21
|
+
enabled: true;
|
|
22
|
+
startUrl?: string | undefined;
|
|
23
|
+
finishUrl?: string | undefined;
|
|
24
|
+
}>]>;
|
|
25
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
26
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
authSessions: {
|
|
29
|
+
enabled: false;
|
|
30
|
+
} | {
|
|
31
|
+
type: "API" | "MANUAL";
|
|
32
|
+
enabled: true;
|
|
33
|
+
startUrl?: string | undefined;
|
|
34
|
+
finishUrl?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
projectName?: string | undefined;
|
|
37
|
+
workspaceId?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
authSessions: {
|
|
40
|
+
enabled: false;
|
|
41
|
+
} | {
|
|
42
|
+
type: "API" | "MANUAL";
|
|
43
|
+
enabled: true;
|
|
44
|
+
startUrl?: string | undefined;
|
|
45
|
+
finishUrl?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
projectName?: string | undefined;
|
|
48
|
+
workspaceId?: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
51
|
+
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
52
|
+
export declare function loadIntunedJson(): Promise<{
|
|
53
|
+
authSessions: {
|
|
54
|
+
enabled: false;
|
|
55
|
+
} | {
|
|
56
|
+
type: "API" | "MANUAL";
|
|
57
|
+
enabled: true;
|
|
58
|
+
startUrl?: string | undefined;
|
|
59
|
+
finishUrl?: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
projectName?: string | undefined;
|
|
62
|
+
workspaceId?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export declare function getIntunedSettingsFile(): Promise<{
|
|
65
|
+
name: typeof intunedSettingsFileNames[number];
|
|
66
|
+
path: string;
|
|
67
|
+
parse: (content: string) => any;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function getIntunedSettingsFileName(): Promise<string>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getIntunedSettingsFile = getIntunedSettingsFile;
|
|
7
|
+
exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
|
|
8
|
+
exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
|
|
9
|
+
exports.loadIntunedJson = loadIntunedJson;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
+
var _zod = require("zod");
|
|
13
|
+
var _errors = require("./errors");
|
|
14
|
+
var JSONC = _interopRequireWildcard(require("jsonc-parser"));
|
|
15
|
+
var YAML = _interopRequireWildcard(require("yaml"));
|
|
16
|
+
var TOML = _interopRequireWildcard(require("smol-toml"));
|
|
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); }
|
|
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; }
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
21
|
+
authSessions: _zod.z.union([_zod.z.object({
|
|
22
|
+
enabled: _zod.z.literal(false)
|
|
23
|
+
}), _zod.z.object({
|
|
24
|
+
enabled: _zod.z.literal(true),
|
|
25
|
+
type: _zod.z.enum(["MANUAL", "API"]),
|
|
26
|
+
startUrl: _zod.z.string().optional(),
|
|
27
|
+
finishUrl: _zod.z.string().optional()
|
|
28
|
+
})]),
|
|
29
|
+
projectName: _zod.z.string().optional(),
|
|
30
|
+
workspaceId: _zod.z.string().optional()
|
|
31
|
+
});
|
|
32
|
+
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
33
|
+
async function loadIntunedJson() {
|
|
34
|
+
const settingsFile = await getIntunedSettingsFile();
|
|
35
|
+
const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
|
|
36
|
+
let intunedJson;
|
|
37
|
+
try {
|
|
38
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throw new _errors.CLIError(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
41
|
+
}
|
|
42
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
43
|
+
if (!parseResult.success) {
|
|
44
|
+
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
45
|
+
throw new _errors.CLIError(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
46
|
+
}
|
|
47
|
+
return parseResult.data;
|
|
48
|
+
}
|
|
49
|
+
const intunedSettingsParsers = {
|
|
50
|
+
"Intuned.json": JSON.parse,
|
|
51
|
+
"Intuned.jsonc": JSONC.parse,
|
|
52
|
+
"Intuned.yaml": YAML.parse,
|
|
53
|
+
"Intuned.yml": YAML.parse,
|
|
54
|
+
"Intuned.toml": TOML.parse
|
|
55
|
+
};
|
|
56
|
+
async function getIntunedSettingsFile() {
|
|
57
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
58
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
59
|
+
if (await fs.exists(filePath)) {
|
|
60
|
+
return {
|
|
61
|
+
name: fileName,
|
|
62
|
+
path: filePath,
|
|
63
|
+
parse: intunedSettingsParsers[fileName]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new _errors.CLIError(`No Intuned settings file found.`);
|
|
68
|
+
}
|
|
69
|
+
async function getIntunedSettingsFileName() {
|
|
70
|
+
return (await getIntunedSettingsFile()).name;
|
|
71
|
+
}
|
|
@@ -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
|
+
}
|