@intuned/runtime 1.3.16 → 1.3.18-interface.6
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/bin/intuned +0 -0
- package/bin/intuned-interface +7 -0
- package/dist/chunk-6ZRJOUQS.mjs +16 -0
- package/dist/chunk-6ZRJOUQS.mjs.map +1 -0
- package/dist/chunk-7YL2JUTE.mjs +146 -0
- package/dist/chunk-7YL2JUTE.mjs.map +1 -0
- package/dist/chunk-B3T6RXPC.mjs +794 -0
- package/dist/chunk-B3T6RXPC.mjs.map +1 -0
- package/dist/chunk-FGV5T6SI.mjs +27 -0
- package/dist/chunk-FGV5T6SI.mjs.map +1 -0
- package/dist/chunk-G4PO5RIV.mjs +85 -0
- package/dist/chunk-G4PO5RIV.mjs.map +1 -0
- package/dist/chunk-LZOMFHX3.mjs +38 -0
- package/dist/chunk-LZOMFHX3.mjs.map +1 -0
- package/dist/{common/formatZodError.js → chunk-NDMVGENG.mjs} +9 -9
- package/dist/chunk-NDMVGENG.mjs.map +1 -0
- package/dist/chunk-W4UX6G4X.mjs +17 -0
- package/dist/chunk-W4UX6G4X.mjs.map +1 -0
- package/dist/chunk-XC75QGFG.mjs +1106 -0
- package/dist/chunk-XC75QGFG.mjs.map +1 -0
- package/dist/chunk-XOAZ2MGA.mjs +59 -0
- package/dist/chunk-XOAZ2MGA.mjs.map +1 -0
- package/dist/commands/interface/run.d.mts +3 -0
- package/dist/commands/interface/run.d.ts +3 -1
- package/dist/commands/interface/run.js +2060 -178
- package/dist/commands/interface/run.js.map +1 -0
- package/dist/commands/interface/run.mjs +255 -0
- package/dist/commands/interface/run.mjs.map +1 -0
- package/dist/common/asyncLocalStorage/index.d.mts +17 -0
- package/dist/common/asyncLocalStorage/index.d.ts +9 -8
- package/dist/common/asyncLocalStorage/index.js +34 -9
- package/dist/common/asyncLocalStorage/index.js.map +1 -0
- package/dist/common/asyncLocalStorage/index.mjs +12 -0
- package/dist/common/asyncLocalStorage/index.mjs.map +1 -0
- package/dist/common/binStartupScript.d.mts +2 -0
- package/dist/common/binStartupScript.d.ts +2 -1
- package/dist/common/binStartupScript.js +127 -11
- package/dist/common/binStartupScript.js.map +1 -0
- package/dist/common/binStartupScript.mjs +135 -0
- package/dist/common/binStartupScript.mjs.map +1 -0
- package/dist/common/cleanEnvironmentVariables.d.mts +3 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +3 -1
- package/dist/common/cleanEnvironmentVariables.js +30 -7
- package/dist/common/cleanEnvironmentVariables.js.map +1 -0
- package/dist/common/cleanEnvironmentVariables.mjs +8 -0
- package/dist/common/cleanEnvironmentVariables.mjs.map +1 -0
- package/dist/common/constants.d.mts +13 -0
- package/dist/common/constants.d.ts +13 -10
- package/dist/common/constants.js +58 -14
- package/dist/common/constants.js.map +1 -0
- package/dist/common/constants.mjs +28 -0
- package/dist/common/constants.mjs.map +1 -0
- package/dist/common/contextStorageStateHelpers.d.mts +24 -0
- package/dist/common/contextStorageStateHelpers.d.ts +8 -5
- package/dist/common/contextStorageStateHelpers.js +51 -23
- package/dist/common/contextStorageStateHelpers.js.map +1 -0
- package/dist/common/contextStorageStateHelpers.mjs +10 -0
- package/dist/common/contextStorageStateHelpers.mjs.map +1 -0
- package/dist/common/jwtTokenManager.d.mts +19 -0
- package/dist/common/jwtTokenManager.d.ts +6 -4
- package/dist/common/jwtTokenManager.js +112 -40
- package/dist/common/jwtTokenManager.js.map +1 -0
- package/dist/common/jwtTokenManager.mjs +11 -0
- package/dist/common/jwtTokenManager.mjs.map +1 -0
- package/dist/common/runApi/index.d.mts +11 -0
- package/dist/common/runApi/index.d.ts +10 -10
- package/dist/common/runApi/index.js +1776 -93
- package/dist/common/runApi/index.js.map +1 -0
- package/dist/common/runApi/index.mjs +18 -0
- package/dist/common/runApi/index.mjs.map +1 -0
- package/dist/common/settingsSchema.d.mts +536 -0
- package/dist/common/settingsSchema.d.ts +9 -6
- package/dist/common/settingsSchema.js +55 -20
- package/dist/common/settingsSchema.js.map +1 -0
- package/dist/common/settingsSchema.mjs +10 -0
- package/dist/common/settingsSchema.mjs.map +1 -0
- package/dist/common/telemetry.d.mts +6 -0
- package/dist/common/telemetry.d.ts +6 -3
- package/dist/common/telemetry.js +41 -9
- package/dist/common/telemetry.js.map +1 -0
- package/dist/common/telemetry.mjs +31 -0
- package/dist/common/telemetry.mjs.map +1 -0
- package/dist/export.d-BAUMB-lG.d.mts +140 -0
- package/dist/export.d-BAUMB-lG.d.ts +140 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +783 -98
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +47 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +163 -0
- package/dist/runtime/index.d.ts +163 -10
- package/dist/runtime/index.js +779 -88
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +42 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/package.json +80 -23
- package/.babelrc +0 -21
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -39
- package/InterfaceTemplate/index.playwright.ts +0 -6
- package/InterfaceTemplate/utils.ts +0 -61
- package/dist/commands/api/run.d.ts +0 -6
- package/dist/commands/api/run.js +0 -123
- package/dist/commands/auth-sessions/load.d.ts +0 -2
- package/dist/commands/auth-sessions/load.js +0 -35
- package/dist/commands/auth-sessions/run-check.d.ts +0 -2
- package/dist/commands/auth-sessions/run-check.js +0 -74
- package/dist/commands/auth-sessions/run-create.d.ts +0 -2
- package/dist/commands/auth-sessions/run-create.js +0 -78
- package/dist/commands/browser/save-state.d.ts +0 -2
- package/dist/commands/browser/save-state.js +0 -17
- package/dist/commands/browser/start-browser.d.ts +0 -2
- package/dist/commands/browser/start-browser.js +0 -14
- package/dist/commands/build.d.ts +0 -1
- package/dist/commands/build.js +0 -84
- package/dist/commands/common/browserUtils.d.ts +0 -14
- package/dist/commands/common/browserUtils.js +0 -58
- package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
- package/dist/commands/common/getFirstLineNumber.js +0 -101
- package/dist/commands/common/getFirstLineNumber.test.js +0 -228
- package/dist/commands/common/projectExclusions.d.ts +0 -2
- package/dist/commands/common/projectExclusions.js +0 -8
- package/dist/commands/common/sendMessageToClient.d.ts +0 -1
- package/dist/commands/common/sendMessageToClient.js +0 -10
- package/dist/commands/common/tsNodeImport.d.ts +0 -2
- package/dist/commands/common/tsNodeImport.js +0 -34
- package/dist/commands/common/utils/fileUtils.d.ts +0 -6
- package/dist/commands/common/utils/fileUtils.js +0 -33
- package/dist/commands/common/utils/settings.d.ts +0 -2
- package/dist/commands/common/utils/settings.js +0 -31
- package/dist/commands/common/utils/template.d.ts +0 -2
- package/dist/commands/common/utils/template.js +0 -31
- package/dist/commands/common/utils/unixSocket.d.ts +0 -23
- package/dist/commands/common/utils/unixSocket.js +0 -87
- package/dist/commands/get-headless-user-agent.d.ts +0 -1
- package/dist/commands/get-headless-user-agent.js +0 -18
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
- package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/build.command.js +0 -12
- package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
- package/dist/commands/intuned-cli/commands/command.js +0 -9
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
- package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
- package/dist/commands/intuned-cli/commands/index.js +0 -203
- package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/init.command.js +0 -13
- package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run.command.js +0 -8
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
- package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
- package/dist/commands/intuned-cli/commands/save.command.js +0 -42
- package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
- package/dist/commands/intuned-cli/commands/types.js +0 -31
- package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
- package/dist/commands/intuned-cli/constants/index.js +0 -25
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
- package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
- package/dist/commands/intuned-cli/controller/api.js +0 -191
- package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
- package/dist/commands/intuned-cli/controller/authSession.js +0 -424
- package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/build.js +0 -36
- package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
- package/dist/commands/intuned-cli/controller/deploy.js +0 -276
- package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/index.js +0 -46
- package/dist/commands/intuned-cli/controller/save.d.ts +0 -17
- package/dist/commands/intuned-cli/controller/save.js +0 -351
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -114
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
- package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/api.js +0 -19
- package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
- package/dist/commands/intuned-cli/helpers/auth.js +0 -144
- package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
- package/dist/commands/intuned-cli/helpers/backend.js +0 -27
- package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
- package/dist/commands/intuned-cli/helpers/browser.js +0 -64
- package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/context.js +0 -33
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
- package/dist/commands/intuned-cli/helpers/errors.js +0 -44
- package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
- package/dist/commands/intuned-cli/helpers/index.js +0 -137
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
- package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
- package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
- package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/traces.js +0 -32
- package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/validation.js +0 -14
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/wrapper.js +0 -66
- package/dist/commands/intuned-cli/index.d.ts +0 -1
- package/dist/commands/intuned-cli/index.js +0 -16
- package/dist/commands/intuned-cli/main.d.ts +0 -1
- package/dist/commands/intuned-cli/main.js +0 -23
- package/dist/commands/intuned-cli/types.d.ts +0 -41
- package/dist/commands/intuned-cli/types.js +0 -12
- package/dist/commands/ts-check.d.ts +0 -2
- package/dist/commands/ts-check.js +0 -56
- package/dist/common/Logger/Logger/index.d.ts +0 -12
- package/dist/common/Logger/Logger/index.js +0 -60
- package/dist/common/Logger/Logger/types.d.ts +0 -8
- package/dist/common/Logger/Logger/types.js +0 -5
- package/dist/common/Logger/index.d.ts +0 -12
- package/dist/common/Logger/index.js +0 -60
- package/dist/common/Logger/types.d.ts +0 -8
- package/dist/common/Logger/types.js +0 -5
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
- package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
- package/dist/common/extension/extensionsHelpers.d.ts +0 -11
- package/dist/common/extension/extensionsHelpers.js +0 -147
- package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
- package/dist/common/extension/intunedExtensionServer.js +0 -178
- package/dist/common/extension/types.d.ts +0 -212
- package/dist/common/extension/types.js +0 -51
- package/dist/common/formatZodError.d.ts +0 -2
- package/dist/common/intunedJson.d.ts +0 -229
- package/dist/common/intunedJson.js +0 -133
- package/dist/common/launchBrowser.d.ts +0 -31
- package/dist/common/launchBrowser.js +0 -207
- package/dist/common/playwrightContext.d.ts +0 -31
- package/dist/common/playwrightContext.js +0 -144
- package/dist/common/runApi/errors.d.ts +0 -72
- package/dist/common/runApi/errors.js +0 -169
- package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
- package/dist/common/runApi/importUsingImportFunction.js +0 -46
- package/dist/common/runApi/types.d.ts +0 -830
- package/dist/common/runApi/types.js +0 -73
- package/dist/common/setupContextHook.d.ts +0 -17
- package/dist/common/setupContextHook.js +0 -22
- package/dist/runtime/RunError.d.ts +0 -5
- package/dist/runtime/RunError.js +0 -19
- package/dist/runtime/attemptStore.d.ts +0 -2
- package/dist/runtime/attemptStore.js +0 -23
- package/dist/runtime/captcha.d.ts +0 -15
- package/dist/runtime/captcha.js +0 -191
- package/dist/runtime/captcha.test.js +0 -821
- package/dist/runtime/downloadDirectory.d.ts +0 -1
- package/dist/runtime/downloadDirectory.js +0 -19
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/enums.d.ts +0 -11
- package/dist/runtime/enums.js +0 -18
- package/dist/runtime/executionHelpers.test.js +0 -52
- package/dist/runtime/export.d.js +0 -5
- package/dist/runtime/export.d.ts +0 -284
- package/dist/runtime/extendPayload.d.ts +0 -2
- package/dist/runtime/extendPayload.js +0 -21
- package/dist/runtime/extendTimeout.d.ts +0 -1
- package/dist/runtime/extendTimeout.js +0 -23
- package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
- package/dist/runtime/getAiGatewayConfig.js +0 -16
- package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
- package/dist/runtime/getAuthSessionParameters.js +0 -20
- package/dist/runtime/persistentStore.d.ts +0 -2
- package/dist/runtime/persistentStore.js +0 -37
- package/dist/runtime/persistentStore.test.js +0 -101
- package/dist/runtime/runInfo.d.ts +0 -2
- package/dist/runtime/runInfo.js +0 -21
- package/template.tsconfig.json +0 -11
- package/tsconfig.eslint.json +0 -5
- package/tsconfig.json +0 -25
- package/typedoc.json +0 -49
- /package/dist/common/assets/{browser_scripts.js → assets/browser_scripts.js} +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBrowserExecutablePath = getBrowserExecutablePath;
|
|
7
|
-
exports.getHeadlessUserAgent = getHeadlessUserAgent;
|
|
8
|
-
exports.getLocalCdpAddress = getLocalCdpAddress;
|
|
9
|
-
exports.launchBrowser = launchBrowser;
|
|
10
|
-
exports.launchChromium = launchChromium;
|
|
11
|
-
var playwright = _interopRequireWildcard(require("playwright"));
|
|
12
|
-
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
13
|
-
var fs = _fsExtra;
|
|
14
|
-
var _path = require("path");
|
|
15
|
-
var _waitOn = _interopRequireDefault(require("wait-on"));
|
|
16
|
-
var _child_process = require("child_process");
|
|
17
|
-
var _extensionsHelpers = require("./extension/extensionsHelpers");
|
|
18
|
-
var _intunedExtensionServer = require("./extension/intunedExtensionServer");
|
|
19
|
-
var _util = require("util");
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
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); }
|
|
22
|
-
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; }
|
|
23
|
-
const execAsync = (0, _util.promisify)(_child_process.exec);
|
|
24
|
-
async function createUserDirWithPreferences() {
|
|
25
|
-
const playwrightTempDir = await (0, _fsExtra.mkdtemp)("/tmp/pw-");
|
|
26
|
-
const userDir = (0, _path.join)(playwrightTempDir, "userdir");
|
|
27
|
-
const defaultDir = (0, _path.join)(userDir, "Default");
|
|
28
|
-
await (0, _fsExtra.mkdir)(defaultDir, {
|
|
29
|
-
recursive: true
|
|
30
|
-
});
|
|
31
|
-
const preferences = {
|
|
32
|
-
plugins: {
|
|
33
|
-
always_open_pdf_externally: true
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
await (0, _fsExtra.writeFile)((0, _path.join)(defaultDir, "Preferences"), JSON.stringify(preferences));
|
|
37
|
-
return userDir;
|
|
38
|
-
}
|
|
39
|
-
async function launchChromium(options) {
|
|
40
|
-
if ("cdpAddress" in options) {
|
|
41
|
-
if (await (0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
42
|
-
await (0, _intunedExtensionServer.setupIntunedExtensionServer)();
|
|
43
|
-
}
|
|
44
|
-
const browser = await playwright.chromium.connectOverCDP(options.cdpAddress);
|
|
45
|
-
if (browser.contexts().length === 0) {
|
|
46
|
-
throw new Error("No browser contexts found in the connected browser");
|
|
47
|
-
}
|
|
48
|
-
const context = browser.contexts()[0];
|
|
49
|
-
let page = context.pages().at(0);
|
|
50
|
-
if (!page) {
|
|
51
|
-
page = await context.newPage();
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
page,
|
|
55
|
-
context
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const {
|
|
59
|
-
headless,
|
|
60
|
-
appModeInitialUrl,
|
|
61
|
-
cdpPort,
|
|
62
|
-
proxy,
|
|
63
|
-
downloadsPath
|
|
64
|
-
} = options;
|
|
65
|
-
let {
|
|
66
|
-
executablePath
|
|
67
|
-
} = options;
|
|
68
|
-
const defaultArgsToIgnore = ["--disable-extensions", "--disable-component-extensions-with-background-pages", "--disable-background-networking", "--disable-backgrounding-occluded-windows", "--disable-background-timer-throttling"];
|
|
69
|
-
const extraArgs = [];
|
|
70
|
-
const userDataDir = await createUserDirWithPreferences();
|
|
71
|
-
if ((0, _extensionsHelpers.isIntunedExtensionLoaded)()) {
|
|
72
|
-
const extensionsList = (0, _extensionsHelpers.buildExtensionsList)();
|
|
73
|
-
const extensions = extensionsList.join(",");
|
|
74
|
-
extraArgs.push(`--disable-extensions-except=${extensions}`);
|
|
75
|
-
extraArgs.push(`--load-extension=${extensions}`);
|
|
76
|
-
}
|
|
77
|
-
if (await (0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
78
|
-
await (0, _extensionsHelpers.setupIntunedExtension)();
|
|
79
|
-
if (proxy) {
|
|
80
|
-
extraArgs.push('--proxy-bypass-list="<-loopback>"');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (cdpPort) {
|
|
84
|
-
extraArgs.push(`--remote-debugging-port=${cdpPort}`);
|
|
85
|
-
}
|
|
86
|
-
if (headless) {
|
|
87
|
-
defaultArgsToIgnore.push("--headless=old");
|
|
88
|
-
extraArgs.push("--headless=new");
|
|
89
|
-
}
|
|
90
|
-
if (appModeInitialUrl) {
|
|
91
|
-
extraArgs.push(`--app=${appModeInitialUrl}`);
|
|
92
|
-
}
|
|
93
|
-
if (executablePath) {
|
|
94
|
-
executablePath = await fs.realpath(executablePath);
|
|
95
|
-
if (!(await fs.exists(executablePath))) {
|
|
96
|
-
console.log(`Warning: Executable path ${executablePath} does not exist. Falling back to default.`);
|
|
97
|
-
executablePath = undefined;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const viewport = null;
|
|
101
|
-
const userAgent = process.env.__PLAYWRIGHT_USER_AGENT_OVERRIDE ?? (await getHeadlessUserAgent({
|
|
102
|
-
executablePath
|
|
103
|
-
}));
|
|
104
|
-
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
105
|
-
userAgent,
|
|
106
|
-
executablePath,
|
|
107
|
-
headless,
|
|
108
|
-
viewport,
|
|
109
|
-
proxy,
|
|
110
|
-
downloadsPath,
|
|
111
|
-
args: extraArgs,
|
|
112
|
-
ignoreDefaultArgs: defaultArgsToIgnore
|
|
113
|
-
});
|
|
114
|
-
context.once("close", async () => {
|
|
115
|
-
try {
|
|
116
|
-
await (0, _fsExtra.rm)(userDataDir, {
|
|
117
|
-
recursive: true,
|
|
118
|
-
force: true,
|
|
119
|
-
retryDelay: 1000,
|
|
120
|
-
maxRetries: 5
|
|
121
|
-
});
|
|
122
|
-
if (await (0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
123
|
-
await (0, _intunedExtensionServer.cleanIntunedExtensionServer)();
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.error("Failed to remove user data dir", error);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (cdpPort) {
|
|
130
|
-
const createdCdpAddress = getLocalCdpAddress(cdpPort);
|
|
131
|
-
await waitOnCdpAddress(createdCdpAddress);
|
|
132
|
-
}
|
|
133
|
-
const page = context.pages().at(0) ?? (await context.newPage());
|
|
134
|
-
if (await (0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
135
|
-
await (0, _extensionsHelpers.getIntunedExtensionWorker)(context);
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
page,
|
|
139
|
-
context
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async function getBrowserExecutablePath() {
|
|
143
|
-
const browserType = getBrowserType();
|
|
144
|
-
if (browserType === "brave") {
|
|
145
|
-
return await getBraveExecutablePath();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
async function launchBrowser(options) {
|
|
149
|
-
if ("cdpAddress" in options) {
|
|
150
|
-
return launchChromium(options);
|
|
151
|
-
}
|
|
152
|
-
return launchChromium({
|
|
153
|
-
...options,
|
|
154
|
-
executablePath: await getBrowserExecutablePath()
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function getBrowserType() {
|
|
158
|
-
if (process.env.BROWSER_TYPE === "brave") {
|
|
159
|
-
return "brave";
|
|
160
|
-
}
|
|
161
|
-
return "chromium";
|
|
162
|
-
}
|
|
163
|
-
async function getBraveExecutablePath() {
|
|
164
|
-
const {
|
|
165
|
-
stdout
|
|
166
|
-
} = await execAsync("which brave-browser-stable");
|
|
167
|
-
const bravePath = stdout.trim();
|
|
168
|
-
if (bravePath.length === 0) {
|
|
169
|
-
throw new Error("Brave browser not found");
|
|
170
|
-
}
|
|
171
|
-
return bravePath;
|
|
172
|
-
}
|
|
173
|
-
function getLocalCdpAddress(port) {
|
|
174
|
-
return `http://localhost:${port}`;
|
|
175
|
-
}
|
|
176
|
-
async function waitOnCdpAddress(cdpAddress) {
|
|
177
|
-
const cdpAddressWithoutProtocol = cdpAddress.replace("http://", "").replace("https://", "").replace("localhost", "127.0.0.1");
|
|
178
|
-
await (0, _waitOn.default)({
|
|
179
|
-
resources: [`http-get://${cdpAddressWithoutProtocol}/json/version`],
|
|
180
|
-
delay: 100,
|
|
181
|
-
interval: 100,
|
|
182
|
-
timeout: 5000,
|
|
183
|
-
tcpTimeout: 1000,
|
|
184
|
-
window: 1000
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
async function getHeadlessUserAgent({
|
|
188
|
-
executablePath,
|
|
189
|
-
args,
|
|
190
|
-
ignoreDefaultArgs
|
|
191
|
-
}) {
|
|
192
|
-
const browser = await playwright.chromium.launch({
|
|
193
|
-
headless: true,
|
|
194
|
-
executablePath,
|
|
195
|
-
args,
|
|
196
|
-
ignoreDefaultArgs
|
|
197
|
-
});
|
|
198
|
-
const context = await browser.newContext();
|
|
199
|
-
const page = await context.newPage();
|
|
200
|
-
let userAgent = await page.evaluate(() => navigator.userAgent);
|
|
201
|
-
await browser.close();
|
|
202
|
-
if (!userAgent || typeof userAgent !== "string") {
|
|
203
|
-
return undefined;
|
|
204
|
-
}
|
|
205
|
-
userAgent = userAgent.replace("HeadlessChrome", "Chrome");
|
|
206
|
-
return userAgent;
|
|
207
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as playwright from "playwright";
|
|
2
|
-
import { RunAutomationError } from "./runApi/errors";
|
|
3
|
-
import type { RunApiSession } from "./runApi/types";
|
|
4
|
-
import { Err, Ok } from "neverthrow";
|
|
5
|
-
import { type ImportFunction } from "./runApi/importUsingImportFunction";
|
|
6
|
-
import { type Proxy } from "./launchBrowser";
|
|
7
|
-
export declare const browserScriptsFile: string;
|
|
8
|
-
type WithPlaywrightContextParameters = {
|
|
9
|
-
importFunction: ImportFunction;
|
|
10
|
-
apiName: string;
|
|
11
|
-
apiParameters: any;
|
|
12
|
-
} | {
|
|
13
|
-
importFunction?: undefined;
|
|
14
|
-
apiName?: undefined;
|
|
15
|
-
apiParameters?: undefined;
|
|
16
|
-
};
|
|
17
|
-
type WithPlaywrightContextWrappedFunctionReturn<R> = Ok<R, any> | Err<any, RunAutomationError>;
|
|
18
|
-
export type WithPlaywrightContextWrappedFunction<R> = (context: playwright.BrowserContext, page: playwright.Page) => Promise<WithPlaywrightContextWrappedFunctionReturn<R>>;
|
|
19
|
-
export declare function withPlaywrightContext<R>(options: {
|
|
20
|
-
proxy?: Proxy;
|
|
21
|
-
headless: boolean;
|
|
22
|
-
downloadsPath: string;
|
|
23
|
-
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
24
|
-
export declare function withPlaywrightContext<R>(options: {
|
|
25
|
-
cdpAddress: string;
|
|
26
|
-
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
27
|
-
export declare function loadSessionToContext({ context, session, }: {
|
|
28
|
-
context: playwright.BrowserContext;
|
|
29
|
-
session: RunApiSession;
|
|
30
|
-
}): Promise<void>;
|
|
31
|
-
export {};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.browserScriptsFile = void 0;
|
|
7
|
-
exports.loadSessionToContext = loadSessionToContext;
|
|
8
|
-
exports.withPlaywrightContext = withPlaywrightContext;
|
|
9
|
-
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
-
var _fileUtils = require("../commands/common/utils/fileUtils");
|
|
13
|
-
var _errors = require("./runApi/errors");
|
|
14
|
-
var _neverthrow = require("neverthrow");
|
|
15
|
-
var _setupContextHook = require("./setupContextHook");
|
|
16
|
-
var _portfinder = require("portfinder");
|
|
17
|
-
var _launchBrowser = require("./launchBrowser");
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
const browserScriptsFile = exports.browserScriptsFile = _path.default.join(__dirname, "./assets/browser_scripts.js");
|
|
22
|
-
async function withPlaywrightContext({
|
|
23
|
-
cdpAddress,
|
|
24
|
-
proxy,
|
|
25
|
-
headless = true,
|
|
26
|
-
downloadsPath,
|
|
27
|
-
importFunction,
|
|
28
|
-
apiName,
|
|
29
|
-
apiParameters
|
|
30
|
-
}, fn) {
|
|
31
|
-
let context;
|
|
32
|
-
let page;
|
|
33
|
-
try {
|
|
34
|
-
const setupContextHookResult = importFunction ? await (0, _setupContextHook.loadSetupContextHook)({
|
|
35
|
-
importFunction
|
|
36
|
-
}) : (0, _neverthrow.ok)(null);
|
|
37
|
-
if (setupContextHookResult.isErr()) {
|
|
38
|
-
return setupContextHookResult;
|
|
39
|
-
}
|
|
40
|
-
const setupContextHook = setupContextHookResult.value;
|
|
41
|
-
if (setupContextHook === null) {
|
|
42
|
-
if (cdpAddress !== undefined) {
|
|
43
|
-
({
|
|
44
|
-
page,
|
|
45
|
-
context
|
|
46
|
-
} = await (0, _launchBrowser.launchBrowser)({
|
|
47
|
-
cdpAddress
|
|
48
|
-
}));
|
|
49
|
-
} else {
|
|
50
|
-
({
|
|
51
|
-
page,
|
|
52
|
-
context
|
|
53
|
-
} = await (0, _launchBrowser.launchBrowser)({
|
|
54
|
-
proxy,
|
|
55
|
-
headless,
|
|
56
|
-
downloadsPath
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
return await fn(context, page);
|
|
60
|
-
}
|
|
61
|
-
let hookCdpUrl = null;
|
|
62
|
-
if (cdpAddress) {
|
|
63
|
-
hookCdpUrl = cdpAddress;
|
|
64
|
-
({
|
|
65
|
-
context,
|
|
66
|
-
page
|
|
67
|
-
} = await (0, _launchBrowser.launchBrowser)({
|
|
68
|
-
cdpAddress
|
|
69
|
-
}));
|
|
70
|
-
} else {
|
|
71
|
-
const port = await (0, _portfinder.getPort)({
|
|
72
|
-
port: 9222
|
|
73
|
-
});
|
|
74
|
-
hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
|
|
75
|
-
({
|
|
76
|
-
context,
|
|
77
|
-
page
|
|
78
|
-
} = await (0, _launchBrowser.launchBrowser)({
|
|
79
|
-
proxy,
|
|
80
|
-
headless,
|
|
81
|
-
downloadsPath,
|
|
82
|
-
cdpPort: port
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
let hookResult;
|
|
86
|
-
try {
|
|
87
|
-
hookResult = await setupContextHook({
|
|
88
|
-
apiName: apiName,
|
|
89
|
-
apiParameters: apiParameters,
|
|
90
|
-
cdpUrl: hookCdpUrl
|
|
91
|
-
});
|
|
92
|
-
} catch (error) {
|
|
93
|
-
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
94
|
-
}
|
|
95
|
-
if (!hookResult) {
|
|
96
|
-
return await fn(context, page);
|
|
97
|
-
}
|
|
98
|
-
const {
|
|
99
|
-
page: newPage,
|
|
100
|
-
context: newContext,
|
|
101
|
-
cleanup
|
|
102
|
-
} = hookResult;
|
|
103
|
-
let result;
|
|
104
|
-
try {
|
|
105
|
-
result = {
|
|
106
|
-
return: await fn(newContext, newPage ?? page)
|
|
107
|
-
};
|
|
108
|
-
} catch (e) {
|
|
109
|
-
result = {
|
|
110
|
-
throw: e
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
await cleanup?.();
|
|
115
|
-
} catch (e) {
|
|
116
|
-
result = {
|
|
117
|
-
return: (0, _neverthrow.err)(new _errors.AutomationError(e))
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if ("throw" in result) {
|
|
121
|
-
throw result.throw;
|
|
122
|
-
}
|
|
123
|
-
return result.return;
|
|
124
|
-
} finally {
|
|
125
|
-
await context?.close();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function loadSessionToContext({
|
|
129
|
-
context,
|
|
130
|
-
session
|
|
131
|
-
}) {
|
|
132
|
-
let sessionToLoad;
|
|
133
|
-
if (session.type === "state") {
|
|
134
|
-
const state = session.state;
|
|
135
|
-
if (state === undefined || state === null) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
sessionToLoad = state;
|
|
139
|
-
} else {
|
|
140
|
-
const fullPath = (0, _fileUtils.getFullPathInProject)(session.path);
|
|
141
|
-
sessionToLoad = await fs.readJson(fullPath);
|
|
142
|
-
}
|
|
143
|
-
await (0, _contextStorageStateHelpers.setStorageState)(context, sessionToLoad);
|
|
144
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { RunErrorOptions } from "../../runtime/export";
|
|
2
|
-
export declare const apiNotFoundErrorCode = "APINotFoundError";
|
|
3
|
-
export declare const invalidApiErrorCode = "InvalidAPIError";
|
|
4
|
-
export declare const invalidCheckErrorCode = "InvalidCheckError";
|
|
5
|
-
export declare const abortedErrorCode = "AbortedError";
|
|
6
|
-
export declare const authRequiredErrorCode = "AuthRequiredError";
|
|
7
|
-
export declare const authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
8
|
-
export declare const authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
9
|
-
export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
10
|
-
export declare const automationError = "AutomationError";
|
|
11
|
-
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
12
|
-
export declare const resultTooBigErrorCode = "ResultTooBigError";
|
|
13
|
-
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError", "ResultTooBigError"];
|
|
14
|
-
export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
|
|
15
|
-
export declare abstract class RunAutomationError<T = any> {
|
|
16
|
-
code: RunAutomationErrorCode;
|
|
17
|
-
statusCode: number;
|
|
18
|
-
wrapped: boolean;
|
|
19
|
-
message: string;
|
|
20
|
-
cause?: RunAutomationError;
|
|
21
|
-
details?: T;
|
|
22
|
-
get json(): {
|
|
23
|
-
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError" | "ResultTooBigError";
|
|
24
|
-
details: T | undefined;
|
|
25
|
-
cause: any;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export declare class ApiNotFoundError extends RunAutomationError {
|
|
29
|
-
constructor(apiName: string);
|
|
30
|
-
}
|
|
31
|
-
export declare class InvalidApiError extends RunAutomationError {
|
|
32
|
-
constructor(message: string);
|
|
33
|
-
}
|
|
34
|
-
export declare class InvalidCheckError extends RunAutomationError {
|
|
35
|
-
constructor(message: string, cause?: RunAutomationError);
|
|
36
|
-
}
|
|
37
|
-
export declare class AbortedError extends RunAutomationError {
|
|
38
|
-
constructor();
|
|
39
|
-
}
|
|
40
|
-
export declare class AuthRequiredError extends RunAutomationError {
|
|
41
|
-
constructor();
|
|
42
|
-
}
|
|
43
|
-
export declare class AuthCheckNotFoundError extends RunAutomationError {
|
|
44
|
-
constructor();
|
|
45
|
-
}
|
|
46
|
-
export declare class AuthCheckFailedError extends RunAutomationError {
|
|
47
|
-
constructor();
|
|
48
|
-
}
|
|
49
|
-
export declare class MaxLevelsExceededError extends RunAutomationError<{
|
|
50
|
-
levels: number;
|
|
51
|
-
}> {
|
|
52
|
-
constructor(levels: number);
|
|
53
|
-
}
|
|
54
|
-
export declare class AutomationError extends RunAutomationError<{
|
|
55
|
-
name?: string;
|
|
56
|
-
message?: string;
|
|
57
|
-
statusCode?: number;
|
|
58
|
-
errorCode?: string;
|
|
59
|
-
options?: RunErrorOptions;
|
|
60
|
-
}> {
|
|
61
|
-
error: any;
|
|
62
|
-
constructor(error: any);
|
|
63
|
-
}
|
|
64
|
-
export declare class InternalInvalidInputError extends RunAutomationError {
|
|
65
|
-
constructor(message: string, details?: any);
|
|
66
|
-
}
|
|
67
|
-
export declare class ResultTooBigError extends RunAutomationError<{
|
|
68
|
-
sizeInBytes: number;
|
|
69
|
-
maxSizeInBytes: number;
|
|
70
|
-
}> {
|
|
71
|
-
constructor(sizeInBytes: number, maxSizeInBytes: number);
|
|
72
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.runAutomationErrorCodes = exports.resultTooBigErrorCode = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.ResultTooBigError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
|
-
var _runtime = require("../../runtime");
|
|
8
|
-
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
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
|
-
const apiNotFoundErrorCode = exports.apiNotFoundErrorCode = "APINotFoundError";
|
|
12
|
-
const invalidApiErrorCode = exports.invalidApiErrorCode = "InvalidAPIError";
|
|
13
|
-
const invalidCheckErrorCode = exports.invalidCheckErrorCode = "InvalidCheckError";
|
|
14
|
-
const abortedErrorCode = exports.abortedErrorCode = "AbortedError";
|
|
15
|
-
const authRequiredErrorCode = exports.authRequiredErrorCode = "AuthRequiredError";
|
|
16
|
-
const authCheckNotFoundErrorCode = exports.authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
17
|
-
const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
18
|
-
const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
19
|
-
const automationError = exports.automationError = "AutomationError";
|
|
20
|
-
const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
21
|
-
const resultTooBigErrorCode = exports.resultTooBigErrorCode = "ResultTooBigError";
|
|
22
|
-
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode, resultTooBigErrorCode];
|
|
23
|
-
class RunAutomationError {
|
|
24
|
-
wrapped = false;
|
|
25
|
-
get json() {
|
|
26
|
-
return {
|
|
27
|
-
code: this.code,
|
|
28
|
-
details: this.details,
|
|
29
|
-
cause: this.cause?.json
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.RunAutomationError = RunAutomationError;
|
|
34
|
-
class ApiNotFoundError extends RunAutomationError {
|
|
35
|
-
constructor(apiName) {
|
|
36
|
-
super();
|
|
37
|
-
this.code = apiNotFoundErrorCode;
|
|
38
|
-
this.statusCode = 404;
|
|
39
|
-
this.message = `API ${apiName} not found`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.ApiNotFoundError = ApiNotFoundError;
|
|
43
|
-
class InvalidApiError extends RunAutomationError {
|
|
44
|
-
constructor(message) {
|
|
45
|
-
super();
|
|
46
|
-
this.code = invalidApiErrorCode;
|
|
47
|
-
this.statusCode = 400;
|
|
48
|
-
this.message = `API is invalid: ${message}`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.InvalidApiError = InvalidApiError;
|
|
52
|
-
class InvalidCheckError extends RunAutomationError {
|
|
53
|
-
constructor(message, cause) {
|
|
54
|
-
super();
|
|
55
|
-
this.code = invalidCheckErrorCode;
|
|
56
|
-
this.statusCode = 400;
|
|
57
|
-
this.message = message;
|
|
58
|
-
this.cause = cause;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.InvalidCheckError = InvalidCheckError;
|
|
62
|
-
class AbortedError extends RunAutomationError {
|
|
63
|
-
constructor() {
|
|
64
|
-
super();
|
|
65
|
-
this.code = abortedErrorCode;
|
|
66
|
-
this.statusCode = 200;
|
|
67
|
-
this.message = "Operation was aborted";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.AbortedError = AbortedError;
|
|
71
|
-
class AuthRequiredError extends RunAutomationError {
|
|
72
|
-
constructor() {
|
|
73
|
-
super();
|
|
74
|
-
this.code = authRequiredErrorCode;
|
|
75
|
-
this.statusCode = 401;
|
|
76
|
-
this.message = "Authentication is required";
|
|
77
|
-
this.wrapped = true;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.AuthRequiredError = AuthRequiredError;
|
|
81
|
-
class AuthCheckNotFoundError extends RunAutomationError {
|
|
82
|
-
constructor() {
|
|
83
|
-
super();
|
|
84
|
-
this.code = authCheckNotFoundErrorCode;
|
|
85
|
-
this.statusCode = 404;
|
|
86
|
-
this.message = "Auth check not found";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.AuthCheckNotFoundError = AuthCheckNotFoundError;
|
|
90
|
-
class AuthCheckFailedError extends RunAutomationError {
|
|
91
|
-
constructor() {
|
|
92
|
-
super();
|
|
93
|
-
this.code = authCheckFailedErrorCode;
|
|
94
|
-
this.statusCode = 401;
|
|
95
|
-
this.message = "auth session check failed";
|
|
96
|
-
this.wrapped = true;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.AuthCheckFailedError = AuthCheckFailedError;
|
|
100
|
-
class MaxLevelsExceededError extends RunAutomationError {
|
|
101
|
-
constructor(levels) {
|
|
102
|
-
super();
|
|
103
|
-
this.code = maxLevelsExceededErrorCode;
|
|
104
|
-
this.statusCode = 400;
|
|
105
|
-
this.message = `Max levels exceeded. Only ${levels} levels are supported`;
|
|
106
|
-
this.details = {
|
|
107
|
-
levels
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.MaxLevelsExceededError = MaxLevelsExceededError;
|
|
112
|
-
class AutomationError extends RunAutomationError {
|
|
113
|
-
constructor(error) {
|
|
114
|
-
super();
|
|
115
|
-
this.error = error;
|
|
116
|
-
this.code = automationError;
|
|
117
|
-
if (error instanceof playwright.errors.TimeoutError) {
|
|
118
|
-
this.statusCode = 500;
|
|
119
|
-
this.message = `[${error.name}] ${error.message}`;
|
|
120
|
-
this.details = {
|
|
121
|
-
name: error.name,
|
|
122
|
-
message: error.message
|
|
123
|
-
};
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (error instanceof _runtime.RunError) {
|
|
127
|
-
this.wrapped = true;
|
|
128
|
-
this.statusCode = error.options.status_code ?? 500;
|
|
129
|
-
this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
|
|
130
|
-
this.details = {
|
|
131
|
-
name: error.name,
|
|
132
|
-
statusCode: error.options.status_code,
|
|
133
|
-
errorCode: error.options.error_code,
|
|
134
|
-
message: error.message,
|
|
135
|
-
options: error.options
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
this.statusCode = 500;
|
|
139
|
-
this.message = `[${error?.name ?? error}] ${error?.message}`;
|
|
140
|
-
this.details = {
|
|
141
|
-
name: error?.name,
|
|
142
|
-
message: error?.message
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.AutomationError = AutomationError;
|
|
147
|
-
class InternalInvalidInputError extends RunAutomationError {
|
|
148
|
-
constructor(message, details) {
|
|
149
|
-
super();
|
|
150
|
-
this.code = internalInvalidInputErrorCode;
|
|
151
|
-
this.statusCode = 500;
|
|
152
|
-
this.message = message;
|
|
153
|
-
this.details = details;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
157
|
-
class ResultTooBigError extends RunAutomationError {
|
|
158
|
-
constructor(sizeInBytes, maxSizeInBytes) {
|
|
159
|
-
super();
|
|
160
|
-
this.code = resultTooBigErrorCode;
|
|
161
|
-
this.statusCode = 413;
|
|
162
|
-
this.message = `Automation result is too big. Size: ${Math.round(sizeInBytes / 1024 / 1024 * 100) / 100}MB, Max allowed: ${Math.round(maxSizeInBytes / 1024 / 1024 * 100) / 100}MB`;
|
|
163
|
-
this.details = {
|
|
164
|
-
sizeInBytes,
|
|
165
|
-
maxSizeInBytes
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.ResultTooBigError = ResultTooBigError;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Result } from "neverthrow";
|
|
2
|
-
import { RunAutomationError } from "./errors";
|
|
3
|
-
import { ExtendedRunApiParameters } from "./types";
|
|
4
|
-
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
5
|
-
export declare function importUsingImportFunction<_ReturnType = any>({ path, allowGenerators, importFunction, }: {
|
|
6
|
-
path: string;
|
|
7
|
-
importFunction: ImportFunction;
|
|
8
|
-
allowGenerators?: boolean;
|
|
9
|
-
}): Promise<Result<(..._: any) => Promise<_ReturnType>, RunAutomationError>>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.importUsingImportFunction = importUsingImportFunction;
|
|
7
|
-
var _neverthrow = require("neverthrow");
|
|
8
|
-
var _errors = require("./errors");
|
|
9
|
-
async function importUsingImportFunction({
|
|
10
|
-
path,
|
|
11
|
-
allowGenerators = true,
|
|
12
|
-
importFunction
|
|
13
|
-
}) {
|
|
14
|
-
try {
|
|
15
|
-
const importedResult = await importFunction(path);
|
|
16
|
-
if (importedResult.isErr()) {
|
|
17
|
-
if (importedResult.error.type === "not_found") {
|
|
18
|
-
return (0, _neverthrow.err)(new _errors.ApiNotFoundError(path));
|
|
19
|
-
}
|
|
20
|
-
return (0, _neverthrow.err)(new _errors.AutomationError(importedResult.error.error));
|
|
21
|
-
}
|
|
22
|
-
const imported = importedResult.value;
|
|
23
|
-
if (!imported || !imported.default || !imported.default.constructor) {
|
|
24
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} does not have a default export`));
|
|
25
|
-
}
|
|
26
|
-
if (imported.default.constructor.name === "AsyncGeneratorFunction") {
|
|
27
|
-
if (!allowGenerators) {
|
|
28
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} default export must be an async function`));
|
|
29
|
-
}
|
|
30
|
-
return (0, _neverthrow.ok)(async (...args) => {
|
|
31
|
-
const generator = imported.default(...args);
|
|
32
|
-
const result = await generator.next();
|
|
33
|
-
if (!result.done) {
|
|
34
|
-
throw new Error("Yield is not supported");
|
|
35
|
-
}
|
|
36
|
-
return result.value;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (imported.default.constructor.name === "AsyncFunction") {
|
|
40
|
-
return (0, _neverthrow.ok)(imported.default);
|
|
41
|
-
}
|
|
42
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} default export must be an async function`));
|
|
43
|
-
} catch (error) {
|
|
44
|
-
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
45
|
-
}
|
|
46
|
-
}
|