@intuned/runtime 1.3.17 → 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 +78 -23
- package/.babelrc +0 -21
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -39
- package/InterfaceTemplate/__utils.ts +0 -61
- package/InterfaceTemplate/index.playwright.ts +0 -6
- package/WebTemplate.zip +0 -0
- package/dist/commands/api/run.d.ts +0 -6
- package/dist/commands/api/run.js +0 -119
- 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 -43
- 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/authsession_scaffold.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +0 -16
- 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 -42
- 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/provision.command.d.ts +0 -13
- package/dist/commands/intuned-cli/commands/provision.command.js +0 -50
- 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/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 -398
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1060
- package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
- package/dist/commands/intuned-cli/controller/api.js +0 -194
- 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 -318
- 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/provision.d.ts +0 -21
- package/dist/commands/intuned-cli/controller/provision.js +0 -300
- package/dist/commands/intuned-cli/controller/scaffold.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/scaffold.js +0 -77
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -115
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -41
- package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/api.js +0 -16
- package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
- package/dist/commands/intuned-cli/helpers/auth.js +0 -147
- package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
- package/dist/commands/intuned-cli/helpers/backend.js +0 -35
- 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/prompts.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/prompts.js +0 -71
- 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 -76
- 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 -36
- package/dist/commands/intuned-cli/types.d.ts +0 -70
- package/dist/commands/intuned-cli/types.js +0 -22
- 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 -33
- package/dist/common/launchBrowser.js +0 -235
- package/dist/common/playwrightContext.d.ts +0 -31
- package/dist/common/playwrightContext.js +0 -150
- 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
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildExtensionsList,
|
|
3
|
+
cleanIntunedExtensionServer,
|
|
4
|
+
getDownloadDirectoryPath,
|
|
5
|
+
getFullPathInProject,
|
|
6
|
+
getIntunedExtensionWorker,
|
|
7
|
+
isIntunedExtensionEnabled,
|
|
8
|
+
isIntunedExtensionLoaded,
|
|
9
|
+
setupIntunedExtension,
|
|
10
|
+
setupIntunedExtensionServer
|
|
11
|
+
} from "./chunk-B3T6RXPC.mjs";
|
|
12
|
+
import {
|
|
13
|
+
getExecutionContext
|
|
14
|
+
} from "./chunk-W4UX6G4X.mjs";
|
|
15
|
+
import {
|
|
16
|
+
formatZodError
|
|
17
|
+
} from "./chunk-NDMVGENG.mjs";
|
|
18
|
+
import {
|
|
19
|
+
cleanEnvironmentVariables
|
|
20
|
+
} from "./chunk-6ZRJOUQS.mjs";
|
|
21
|
+
import {
|
|
22
|
+
getStorageState,
|
|
23
|
+
setStorageState
|
|
24
|
+
} from "./chunk-G4PO5RIV.mjs";
|
|
25
|
+
import {
|
|
26
|
+
AUTH_SESSIONS_FOLDER_NAME
|
|
27
|
+
} from "./chunk-FGV5T6SI.mjs";
|
|
28
|
+
import {
|
|
29
|
+
__commonJS,
|
|
30
|
+
__require,
|
|
31
|
+
__toESM
|
|
32
|
+
} from "./chunk-LZOMFHX3.mjs";
|
|
33
|
+
|
|
34
|
+
// ../packages/runtime-interface/dist/errors.js
|
|
35
|
+
var require_errors = __commonJS({
|
|
36
|
+
"../packages/runtime-interface/dist/errors.js"(exports) {
|
|
37
|
+
"use strict";
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ResultTooBigError = exports.InternalInvalidInputError = exports.AutomationError = exports.MaxLevelsExceededError = exports.AuthCheckFailedError = exports.AuthCheckNotFoundError = exports.AuthRequiredError = exports.AbortedError = exports.InvalidCheckError = exports.InvalidApiError = exports.ApiNotFoundError = exports.RunAutomationError = exports.runAutomationErrorCodes = exports.resultTooBigErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.maxLevelsExceededErrorCode = exports.authCheckFailedErrorCode = exports.authCheckNotFoundErrorCode = exports.authRequiredErrorCode = exports.abortedErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.apiNotFoundErrorCode = void 0;
|
|
40
|
+
exports.apiNotFoundErrorCode = "APINotFoundError";
|
|
41
|
+
exports.invalidApiErrorCode = "InvalidAPIError";
|
|
42
|
+
exports.invalidCheckErrorCode = "InvalidCheckError";
|
|
43
|
+
exports.abortedErrorCode = "AbortedError";
|
|
44
|
+
exports.authRequiredErrorCode = "AuthRequiredError";
|
|
45
|
+
exports.authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
46
|
+
exports.authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
47
|
+
exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
48
|
+
exports.automationError = "AutomationError";
|
|
49
|
+
exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
50
|
+
exports.resultTooBigErrorCode = "ResultTooBigError";
|
|
51
|
+
exports.runAutomationErrorCodes = [
|
|
52
|
+
exports.apiNotFoundErrorCode,
|
|
53
|
+
exports.invalidApiErrorCode,
|
|
54
|
+
exports.invalidCheckErrorCode,
|
|
55
|
+
exports.abortedErrorCode,
|
|
56
|
+
exports.authRequiredErrorCode,
|
|
57
|
+
exports.authCheckNotFoundErrorCode,
|
|
58
|
+
exports.authCheckFailedErrorCode,
|
|
59
|
+
exports.maxLevelsExceededErrorCode,
|
|
60
|
+
exports.automationError,
|
|
61
|
+
exports.internalInvalidInputErrorCode,
|
|
62
|
+
exports.resultTooBigErrorCode
|
|
63
|
+
];
|
|
64
|
+
var RunAutomationError4 = class {
|
|
65
|
+
constructor(code, message) {
|
|
66
|
+
this.code = code;
|
|
67
|
+
this.message = message;
|
|
68
|
+
}
|
|
69
|
+
get json() {
|
|
70
|
+
return {
|
|
71
|
+
code: this.code,
|
|
72
|
+
details: this.details,
|
|
73
|
+
cause: this.cause?.json
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.RunAutomationError = RunAutomationError4;
|
|
78
|
+
var ApiNotFoundError3 = class extends RunAutomationError4 {
|
|
79
|
+
constructor(apiName) {
|
|
80
|
+
super(exports.apiNotFoundErrorCode, `API ${apiName} not found`);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.ApiNotFoundError = ApiNotFoundError3;
|
|
84
|
+
var InvalidApiError2 = class extends RunAutomationError4 {
|
|
85
|
+
constructor(message) {
|
|
86
|
+
super(exports.invalidApiErrorCode, `API is invalid: ${message}`);
|
|
87
|
+
this.details = {
|
|
88
|
+
message
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.InvalidApiError = InvalidApiError2;
|
|
93
|
+
var InvalidCheckError = class extends RunAutomationError4 {
|
|
94
|
+
constructor(message, cause) {
|
|
95
|
+
super(exports.invalidCheckErrorCode, message);
|
|
96
|
+
this.cause = cause;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.InvalidCheckError = InvalidCheckError;
|
|
100
|
+
var AbortedError2 = class extends RunAutomationError4 {
|
|
101
|
+
constructor() {
|
|
102
|
+
super(exports.abortedErrorCode, "Operation was aborted");
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.AbortedError = AbortedError2;
|
|
106
|
+
var AuthRequiredError2 = class extends RunAutomationError4 {
|
|
107
|
+
constructor() {
|
|
108
|
+
super(exports.authRequiredErrorCode, "AuthSessions are required");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.AuthRequiredError = AuthRequiredError2;
|
|
112
|
+
var AuthCheckNotFoundError = class extends RunAutomationError4 {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(exports.authCheckNotFoundErrorCode, "AuthSession check not found");
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
exports.AuthCheckNotFoundError = AuthCheckNotFoundError;
|
|
118
|
+
var AuthCheckFailedError = class extends RunAutomationError4 {
|
|
119
|
+
constructor() {
|
|
120
|
+
super(exports.authCheckFailedErrorCode, "AuthSession check failed");
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
exports.AuthCheckFailedError = AuthCheckFailedError;
|
|
124
|
+
var MaxLevelsExceededError = class extends RunAutomationError4 {
|
|
125
|
+
constructor(levels) {
|
|
126
|
+
super(exports.maxLevelsExceededErrorCode, `Max levels exceeded. Only ${levels} levels are supported`);
|
|
127
|
+
this.details = { levels };
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.MaxLevelsExceededError = MaxLevelsExceededError;
|
|
131
|
+
var AutomationError4 = class extends RunAutomationError4 {
|
|
132
|
+
constructor(error) {
|
|
133
|
+
super(exports.automationError, `[${error?.name ?? error}] ${error?.message}`);
|
|
134
|
+
this.details = {
|
|
135
|
+
...error
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
exports.AutomationError = AutomationError4;
|
|
140
|
+
var InternalInvalidInputError2 = class extends RunAutomationError4 {
|
|
141
|
+
constructor(message, details) {
|
|
142
|
+
super(exports.internalInvalidInputErrorCode, message);
|
|
143
|
+
this.details = details;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
exports.InternalInvalidInputError = InternalInvalidInputError2;
|
|
147
|
+
var ResultTooBigError2 = class extends RunAutomationError4 {
|
|
148
|
+
constructor(sizeInBytes, maxSizeInBytes) {
|
|
149
|
+
super(exports.resultTooBigErrorCode, `Automation result is too big. Size: ${Math.round(sizeInBytes / 1024 / 1024 * 100) / 100}MB, Max allowed: ${Math.round(maxSizeInBytes / 1024 / 1024 * 100) / 100}MB`);
|
|
150
|
+
this.details = { sizeInBytes, maxSizeInBytes };
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
exports.ResultTooBigError = ResultTooBigError2;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ../packages/runtime-interface/dist/types.js
|
|
158
|
+
var require_types = __commonJS({
|
|
159
|
+
"../packages/runtime-interface/dist/types.js"(exports) {
|
|
160
|
+
"use strict";
|
|
161
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
162
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
163
|
+
};
|
|
164
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
165
|
+
exports.outputRunApiSchema = exports.pongMessageSchema = exports.doneMessageSchema = exports.extendMessageSchema = exports.runApiInputSchema = exports.pingSchema = exports.tokenUpdateSchema = exports.abortRunApiSchema = exports.startRunApiSchema = exports.startRunApiParametersSchema = exports.runApiParametersSchema = exports.runApiRunOptionsSchema = exports.runApiCdpRunOptionsSchema = exports.runApiStandaloneRunOptionsSchema = exports.runApiAuthSchema = exports.runApiTracingSchema = exports.runApiAutomationFunctionSchema = exports.runApiSessionSchema = exports.runApiStorageStateSchema = void 0;
|
|
166
|
+
exports.runApiResultOkSchema = runApiResultOkSchema;
|
|
167
|
+
exports.runApiResultWithSessionOkSchema = runApiResultWithSessionOkSchema;
|
|
168
|
+
var zod_1 = __importDefault(__require("zod"));
|
|
169
|
+
exports.runApiStorageStateSchema = zod_1.default.object({
|
|
170
|
+
cookies: zod_1.default.array(zod_1.default.object({
|
|
171
|
+
name: zod_1.default.string(),
|
|
172
|
+
value: zod_1.default.string(),
|
|
173
|
+
domain: zod_1.default.string(),
|
|
174
|
+
path: zod_1.default.string(),
|
|
175
|
+
expires: zod_1.default.number(),
|
|
176
|
+
httpOnly: zod_1.default.boolean(),
|
|
177
|
+
secure: zod_1.default.boolean(),
|
|
178
|
+
sameSite: zod_1.default.enum(["Strict", "Lax", "None"])
|
|
179
|
+
})),
|
|
180
|
+
origins: zod_1.default.array(zod_1.default.object({
|
|
181
|
+
origin: zod_1.default.string(),
|
|
182
|
+
localStorage: zod_1.default.array(zod_1.default.object({
|
|
183
|
+
name: zod_1.default.string(),
|
|
184
|
+
value: zod_1.default.string()
|
|
185
|
+
}))
|
|
186
|
+
})),
|
|
187
|
+
sessionStorage: zod_1.default.array(zod_1.default.object({
|
|
188
|
+
origin: zod_1.default.string(),
|
|
189
|
+
sessionStorage: zod_1.default.array(zod_1.default.object({
|
|
190
|
+
name: zod_1.default.string(),
|
|
191
|
+
value: zod_1.default.string()
|
|
192
|
+
}))
|
|
193
|
+
})).optional()
|
|
194
|
+
});
|
|
195
|
+
exports.runApiSessionSchema = zod_1.default.discriminatedUnion("type", [
|
|
196
|
+
zod_1.default.object({
|
|
197
|
+
type: zod_1.default.literal("file"),
|
|
198
|
+
path: zod_1.default.string()
|
|
199
|
+
}),
|
|
200
|
+
zod_1.default.object({
|
|
201
|
+
type: zod_1.default.literal("state"),
|
|
202
|
+
state: exports.runApiStorageStateSchema.nullable().optional()
|
|
203
|
+
})
|
|
204
|
+
]);
|
|
205
|
+
exports.runApiAutomationFunctionSchema = zod_1.default.object({
|
|
206
|
+
name: zod_1.default.string(),
|
|
207
|
+
params: zod_1.default.any().optional()
|
|
208
|
+
});
|
|
209
|
+
exports.runApiTracingSchema = zod_1.default.discriminatedUnion("enabled", [
|
|
210
|
+
zod_1.default.object({ enabled: zod_1.default.literal(false) }),
|
|
211
|
+
zod_1.default.object({ enabled: zod_1.default.literal(true), filePath: zod_1.default.string() })
|
|
212
|
+
]).optional().default({ enabled: false });
|
|
213
|
+
exports.runApiAuthSchema = zod_1.default.object({
|
|
214
|
+
session: exports.runApiSessionSchema,
|
|
215
|
+
parameters: zod_1.default.record(zod_1.default.any()).optional()
|
|
216
|
+
}).optional();
|
|
217
|
+
exports.runApiStandaloneRunOptionsSchema = zod_1.default.object({
|
|
218
|
+
environment: zod_1.default.literal("standalone"),
|
|
219
|
+
headless: zod_1.default.boolean().default(true),
|
|
220
|
+
proxy: zod_1.default.object({
|
|
221
|
+
server: zod_1.default.string(),
|
|
222
|
+
username: zod_1.default.string(),
|
|
223
|
+
password: zod_1.default.string()
|
|
224
|
+
}).optional()
|
|
225
|
+
});
|
|
226
|
+
exports.runApiCdpRunOptionsSchema = zod_1.default.object({
|
|
227
|
+
environment: zod_1.default.literal("cdp"),
|
|
228
|
+
cdpAddress: zod_1.default.string(),
|
|
229
|
+
cdpTargetId: zod_1.default.string().optional()
|
|
230
|
+
});
|
|
231
|
+
exports.runApiRunOptionsSchema = zod_1.default.discriminatedUnion("environment", [
|
|
232
|
+
exports.runApiStandaloneRunOptionsSchema,
|
|
233
|
+
exports.runApiCdpRunOptionsSchema
|
|
234
|
+
]).default({ environment: "standalone", headless: true });
|
|
235
|
+
exports.runApiParametersSchema = zod_1.default.object({
|
|
236
|
+
automationFunction: exports.runApiAutomationFunctionSchema,
|
|
237
|
+
tracing: exports.runApiTracingSchema,
|
|
238
|
+
auth: exports.runApiAuthSchema,
|
|
239
|
+
runOptions: exports.runApiRunOptionsSchema,
|
|
240
|
+
retrieveSession: zod_1.default.boolean().default(false)
|
|
241
|
+
});
|
|
242
|
+
function runApiResultOkSchema(resultSchema) {
|
|
243
|
+
return zod_1.default.object({
|
|
244
|
+
result: resultSchema,
|
|
245
|
+
extendedPayloads: zod_1.default.array(zod_1.default.object({
|
|
246
|
+
api: zod_1.default.string(),
|
|
247
|
+
parameters: zod_1.default.record(zod_1.default.any())
|
|
248
|
+
})).optional()
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function runApiResultWithSessionOkSchema(resultSchema) {
|
|
252
|
+
return runApiResultOkSchema(resultSchema).extend({
|
|
253
|
+
session: exports.runApiStorageStateSchema
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
exports.startRunApiParametersSchema = exports.runApiParametersSchema.extend({
|
|
257
|
+
retrieveSession: zod_1.default.boolean(),
|
|
258
|
+
functionsToken: zod_1.default.string().optional(),
|
|
259
|
+
context: zod_1.default.object({
|
|
260
|
+
jobId: zod_1.default.string().optional(),
|
|
261
|
+
jobRunId: zod_1.default.string().optional(),
|
|
262
|
+
runId: zod_1.default.string().optional(),
|
|
263
|
+
queueId: zod_1.default.string().optional(),
|
|
264
|
+
authSessionId: zod_1.default.string().optional()
|
|
265
|
+
}).optional()
|
|
266
|
+
});
|
|
267
|
+
exports.startRunApiSchema = zod_1.default.object({
|
|
268
|
+
type: zod_1.default.literal("start"),
|
|
269
|
+
parameters: exports.startRunApiParametersSchema
|
|
270
|
+
});
|
|
271
|
+
exports.abortRunApiSchema = zod_1.default.object({
|
|
272
|
+
type: zod_1.default.literal("abort"),
|
|
273
|
+
parameters: zod_1.default.object({}).optional()
|
|
274
|
+
});
|
|
275
|
+
exports.tokenUpdateSchema = zod_1.default.object({
|
|
276
|
+
type: zod_1.default.literal("tokenUpdate"),
|
|
277
|
+
parameters: zod_1.default.object({
|
|
278
|
+
functionsToken: zod_1.default.string()
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
exports.pingSchema = zod_1.default.object({
|
|
282
|
+
type: zod_1.default.literal("ping"),
|
|
283
|
+
parameters: zod_1.default.object({}).optional()
|
|
284
|
+
});
|
|
285
|
+
exports.runApiInputSchema = zod_1.default.union([
|
|
286
|
+
exports.startRunApiSchema,
|
|
287
|
+
exports.abortRunApiSchema,
|
|
288
|
+
exports.tokenUpdateSchema,
|
|
289
|
+
exports.pingSchema
|
|
290
|
+
]);
|
|
291
|
+
exports.extendMessageSchema = zod_1.default.object({ type: zod_1.default.literal("extend") });
|
|
292
|
+
exports.doneMessageSchema = zod_1.default.object({
|
|
293
|
+
type: zod_1.default.literal("done"),
|
|
294
|
+
result: zod_1.default.any(),
|
|
295
|
+
success: zod_1.default.boolean()
|
|
296
|
+
});
|
|
297
|
+
exports.pongMessageSchema = zod_1.default.object({
|
|
298
|
+
type: zod_1.default.literal("pong")
|
|
299
|
+
});
|
|
300
|
+
exports.outputRunApiSchema = zod_1.default.union([
|
|
301
|
+
exports.extendMessageSchema,
|
|
302
|
+
exports.doneMessageSchema,
|
|
303
|
+
exports.pongMessageSchema
|
|
304
|
+
]);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// ../packages/runtime-interface/dist/interfaceClient.js
|
|
309
|
+
var require_interfaceClient = __commonJS({
|
|
310
|
+
"../packages/runtime-interface/dist/interfaceClient.js"(exports) {
|
|
311
|
+
"use strict";
|
|
312
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
313
|
+
if (k2 === void 0) k2 = k;
|
|
314
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
315
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
316
|
+
desc = { enumerable: true, get: function() {
|
|
317
|
+
return m[k];
|
|
318
|
+
} };
|
|
319
|
+
}
|
|
320
|
+
Object.defineProperty(o, k2, desc);
|
|
321
|
+
}) : (function(o, m, k, k2) {
|
|
322
|
+
if (k2 === void 0) k2 = k;
|
|
323
|
+
o[k2] = m[k];
|
|
324
|
+
}));
|
|
325
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
326
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
327
|
+
}) : function(o, v) {
|
|
328
|
+
o["default"] = v;
|
|
329
|
+
});
|
|
330
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
331
|
+
if (mod && mod.__esModule) return mod;
|
|
332
|
+
var result = {};
|
|
333
|
+
if (mod != null) {
|
|
334
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
335
|
+
}
|
|
336
|
+
__setModuleDefault(result, mod);
|
|
337
|
+
return result;
|
|
338
|
+
};
|
|
339
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
340
|
+
exports.JSONLFileClient = exports.TCPSocketClient = exports.UnixSocketClient = exports.SocketClient = void 0;
|
|
341
|
+
var net = __importStar(__require("net"));
|
|
342
|
+
var fs4 = __importStar(__require("fs-extra"));
|
|
343
|
+
var readline_1 = __require("readline");
|
|
344
|
+
var promises_1 = __require("timers/promises");
|
|
345
|
+
var SocketClient = class _SocketClient {
|
|
346
|
+
constructor(socket) {
|
|
347
|
+
this.socket = socket;
|
|
348
|
+
}
|
|
349
|
+
sendJSON(data) {
|
|
350
|
+
const dataToSend = JSON.stringify(data);
|
|
351
|
+
const length = Buffer.byteLength(dataToSend);
|
|
352
|
+
const buffer = Buffer.alloc(_SocketClient.LENGTH_HEADER_LENGTH + length);
|
|
353
|
+
buffer.writeUInt32BE(length, 0);
|
|
354
|
+
buffer.write(dataToSend, _SocketClient.LENGTH_HEADER_LENGTH);
|
|
355
|
+
this.socket.write(buffer);
|
|
356
|
+
}
|
|
357
|
+
async *receiveJSON() {
|
|
358
|
+
let buffer = Buffer.alloc(0);
|
|
359
|
+
const endPromise = new Promise((resolve, reject) => {
|
|
360
|
+
this.socket.once("end", () => {
|
|
361
|
+
resolve();
|
|
362
|
+
});
|
|
363
|
+
this.socket.once("error", reject);
|
|
364
|
+
});
|
|
365
|
+
while (true) {
|
|
366
|
+
const chunk = await Promise.race([
|
|
367
|
+
new Promise((resolve) => this.socket.once("data", (data2) => {
|
|
368
|
+
if (typeof data2 === "string") {
|
|
369
|
+
return resolve(Buffer.from(data2));
|
|
370
|
+
}
|
|
371
|
+
resolve(data2);
|
|
372
|
+
})),
|
|
373
|
+
endPromise
|
|
374
|
+
]);
|
|
375
|
+
if (!(chunk instanceof Buffer)) {
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
379
|
+
const length = buffer.readUInt32BE(0);
|
|
380
|
+
if (buffer.length < length + _SocketClient.LENGTH_HEADER_LENGTH) {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
const data = buffer.subarray(_SocketClient.LENGTH_HEADER_LENGTH, length + _SocketClient.LENGTH_HEADER_LENGTH);
|
|
384
|
+
buffer = buffer.subarray(length + _SocketClient.LENGTH_HEADER_LENGTH);
|
|
385
|
+
yield JSON.parse(data.toString());
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
async close() {
|
|
389
|
+
this.socket.end();
|
|
390
|
+
await Promise.race([
|
|
391
|
+
new Promise((resolve) => this.socket.once("close", resolve)),
|
|
392
|
+
new Promise((resolve) => this.socket.once("error", resolve)),
|
|
393
|
+
(0, promises_1.setTimeout)(3e3)
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
get closed() {
|
|
397
|
+
return this.socket.closed;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
exports.SocketClient = SocketClient;
|
|
401
|
+
SocketClient.LENGTH_HEADER_LENGTH = 4;
|
|
402
|
+
var UnixSocketClient = class extends SocketClient {
|
|
403
|
+
constructor(path2) {
|
|
404
|
+
super(net.createConnection(path2));
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
exports.UnixSocketClient = UnixSocketClient;
|
|
408
|
+
var TCPSocketClient = class extends SocketClient {
|
|
409
|
+
constructor(host, port) {
|
|
410
|
+
super(net.createConnection(port, host));
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
exports.TCPSocketClient = TCPSocketClient;
|
|
414
|
+
var JSONLFileClient = class {
|
|
415
|
+
constructor(filePath) {
|
|
416
|
+
this.fileStream = fs4.createReadStream(filePath, { encoding: "utf-8" });
|
|
417
|
+
}
|
|
418
|
+
sendJSON(data) {
|
|
419
|
+
console.log("Sending message", data);
|
|
420
|
+
}
|
|
421
|
+
async *receiveJSON() {
|
|
422
|
+
const rl = (0, readline_1.createInterface)({
|
|
423
|
+
input: this.fileStream,
|
|
424
|
+
crlfDelay: Infinity
|
|
425
|
+
});
|
|
426
|
+
for await (const line of rl) {
|
|
427
|
+
if (line.trim() === "") {
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
yield JSON.parse(line);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async close() {
|
|
434
|
+
this.fileStream.close();
|
|
435
|
+
await Promise.race([
|
|
436
|
+
new Promise((resolve) => this.fileStream.once("close", resolve)),
|
|
437
|
+
new Promise((resolve) => this.fileStream.once("error", resolve)),
|
|
438
|
+
(0, promises_1.setTimeout)(3e3)
|
|
439
|
+
]);
|
|
440
|
+
}
|
|
441
|
+
get closed() {
|
|
442
|
+
return this.fileStream.closed;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
exports.JSONLFileClient = JSONLFileClient;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
// ../packages/runtime-interface/dist/index.js
|
|
450
|
+
var require_dist = __commonJS({
|
|
451
|
+
"../packages/runtime-interface/dist/index.js"(exports) {
|
|
452
|
+
"use strict";
|
|
453
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
454
|
+
if (k2 === void 0) k2 = k;
|
|
455
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
456
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
457
|
+
desc = { enumerable: true, get: function() {
|
|
458
|
+
return m[k];
|
|
459
|
+
} };
|
|
460
|
+
}
|
|
461
|
+
Object.defineProperty(o, k2, desc);
|
|
462
|
+
}) : (function(o, m, k, k2) {
|
|
463
|
+
if (k2 === void 0) k2 = k;
|
|
464
|
+
o[k2] = m[k];
|
|
465
|
+
}));
|
|
466
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
467
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
468
|
+
};
|
|
469
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
470
|
+
__exportStar(require_errors(), exports);
|
|
471
|
+
__exportStar(require_types(), exports);
|
|
472
|
+
__exportStar(require_interfaceClient(), exports);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// src/common/runApi/index.ts
|
|
477
|
+
import * as fs3 from "fs-extra";
|
|
478
|
+
import { remove as remove2 } from "fs-extra";
|
|
479
|
+
import { ok as ok5, err as err4 } from "neverthrow";
|
|
480
|
+
|
|
481
|
+
// src/common/playwrightContext.ts
|
|
482
|
+
import path from "path";
|
|
483
|
+
import * as fs2 from "fs-extra";
|
|
484
|
+
import { err as err3, ok as ok4 } from "neverthrow";
|
|
485
|
+
|
|
486
|
+
// src/common/setupContextHook.ts
|
|
487
|
+
import { ok as ok2 } from "neverthrow";
|
|
488
|
+
|
|
489
|
+
// src/common/runApi/importUsingImportFunction.ts
|
|
490
|
+
var import_runtime_interface = __toESM(require_dist());
|
|
491
|
+
import { ok, err } from "neverthrow";
|
|
492
|
+
async function importUsingImportFunction({
|
|
493
|
+
path: path2,
|
|
494
|
+
allowGenerators = true,
|
|
495
|
+
importFunction
|
|
496
|
+
}) {
|
|
497
|
+
try {
|
|
498
|
+
const importedResult = await importFunction(path2);
|
|
499
|
+
if (importedResult.isErr()) {
|
|
500
|
+
if (importedResult.error.type === "not_found") {
|
|
501
|
+
return err(new import_runtime_interface.ApiNotFoundError(path2));
|
|
502
|
+
}
|
|
503
|
+
return err(new import_runtime_interface.AutomationError(importedResult.error.error));
|
|
504
|
+
}
|
|
505
|
+
const imported = importedResult.value;
|
|
506
|
+
if (!imported || !imported.default || !imported.default.constructor) {
|
|
507
|
+
return err(new import_runtime_interface.InvalidApiError(`${path2} does not have a default export`));
|
|
508
|
+
}
|
|
509
|
+
if (imported.default.constructor.name === "AsyncGeneratorFunction") {
|
|
510
|
+
if (!allowGenerators) {
|
|
511
|
+
return err(
|
|
512
|
+
new import_runtime_interface.InvalidApiError(
|
|
513
|
+
`${path2} default export must be an async function`
|
|
514
|
+
)
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
return ok(async (...args) => {
|
|
518
|
+
const generator = imported.default(
|
|
519
|
+
...args
|
|
520
|
+
);
|
|
521
|
+
const result = await generator.next();
|
|
522
|
+
if (!result.done) {
|
|
523
|
+
throw new Error("Yield is not supported");
|
|
524
|
+
}
|
|
525
|
+
return result.value;
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
if (imported.default.constructor.name === "AsyncFunction") {
|
|
529
|
+
return ok(imported.default);
|
|
530
|
+
}
|
|
531
|
+
return err(
|
|
532
|
+
new import_runtime_interface.InvalidApiError(`${path2} default export must be an async function`)
|
|
533
|
+
);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
return err(new import_runtime_interface.AutomationError(error));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/common/setupContextHook.ts
|
|
540
|
+
var import_runtime_interface2 = __toESM(require_dist());
|
|
541
|
+
var setupContextHookPath = "hooks/setupContext";
|
|
542
|
+
async function loadSetupContextHook({
|
|
543
|
+
importFunction
|
|
544
|
+
}) {
|
|
545
|
+
const importedFunctionResult = await importUsingImportFunction({
|
|
546
|
+
path: setupContextHookPath,
|
|
547
|
+
importFunction
|
|
548
|
+
});
|
|
549
|
+
if (importedFunctionResult.isErr() && importedFunctionResult.error instanceof import_runtime_interface2.ApiNotFoundError) {
|
|
550
|
+
return ok2(null);
|
|
551
|
+
}
|
|
552
|
+
return importedFunctionResult;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// src/common/playwrightContext.ts
|
|
556
|
+
import { getPort } from "portfinder";
|
|
557
|
+
|
|
558
|
+
// src/common/launchBrowser.ts
|
|
559
|
+
import * as playwright from "playwright";
|
|
560
|
+
import { mkdir, mkdtemp, rm, writeFile } from "fs-extra";
|
|
561
|
+
import { join } from "path";
|
|
562
|
+
import * as fs from "fs-extra";
|
|
563
|
+
import waitOn from "wait-on";
|
|
564
|
+
import { exec } from "child_process";
|
|
565
|
+
import { promisify } from "util";
|
|
566
|
+
import { err as err2, ok as ok3 } from "neverthrow";
|
|
567
|
+
import { z } from "zod";
|
|
568
|
+
var execAsync = promisify(exec);
|
|
569
|
+
async function createUserDirWithPreferences() {
|
|
570
|
+
const playwrightTempDir = await mkdtemp("/tmp/pw-");
|
|
571
|
+
const userDir = join(playwrightTempDir, "userdir");
|
|
572
|
+
const defaultDir = join(userDir, "Default");
|
|
573
|
+
await mkdir(defaultDir, {
|
|
574
|
+
recursive: true
|
|
575
|
+
});
|
|
576
|
+
const preferences = {
|
|
577
|
+
plugins: {
|
|
578
|
+
always_open_pdf_externally: true
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
await writeFile(join(defaultDir, "Preferences"), JSON.stringify(preferences));
|
|
582
|
+
return userDir;
|
|
583
|
+
}
|
|
584
|
+
async function launchChromium(options) {
|
|
585
|
+
if ("cdpAddress" in options) {
|
|
586
|
+
if (await isIntunedExtensionEnabled()) {
|
|
587
|
+
await setupIntunedExtensionServer();
|
|
588
|
+
}
|
|
589
|
+
const browser = await playwright.chromium.connectOverCDP(
|
|
590
|
+
options.cdpAddress
|
|
591
|
+
);
|
|
592
|
+
if (browser.contexts().length === 0) {
|
|
593
|
+
throw new Error("No browser contexts found in the connected browser");
|
|
594
|
+
}
|
|
595
|
+
const context2 = browser.contexts()[0];
|
|
596
|
+
let page2 = context2.pages().at(0) ?? await context2.newPage();
|
|
597
|
+
const targetId = options.cdpTargetId;
|
|
598
|
+
if (targetId) {
|
|
599
|
+
for (const p of context2.pages()) {
|
|
600
|
+
let cdp = null;
|
|
601
|
+
try {
|
|
602
|
+
cdp = await context2.newCDPSession(p);
|
|
603
|
+
const result = await cdp.send("Target.getTargetInfo");
|
|
604
|
+
if (result.targetInfo.targetId === targetId) {
|
|
605
|
+
page2 = p;
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
} catch (error) {
|
|
609
|
+
} finally {
|
|
610
|
+
await cdp?.detach();
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return { page: page2, context: context2 };
|
|
615
|
+
}
|
|
616
|
+
const { headless, appModeInitialUrl, cdpPort, proxy, downloadsPath } = options;
|
|
617
|
+
let { executablePath } = options;
|
|
618
|
+
const defaultArgsToIgnore = [
|
|
619
|
+
"--disable-extensions",
|
|
620
|
+
"--disable-component-extensions-with-background-pages",
|
|
621
|
+
"--disable-background-networking",
|
|
622
|
+
"--disable-backgrounding-occluded-windows",
|
|
623
|
+
"--disable-background-timer-throttling"
|
|
624
|
+
];
|
|
625
|
+
const extraArgs = [];
|
|
626
|
+
const userDataDir = await createUserDirWithPreferences();
|
|
627
|
+
if (isIntunedExtensionLoaded()) {
|
|
628
|
+
const extensionsList = buildExtensionsList();
|
|
629
|
+
const extensions = extensionsList.join(",");
|
|
630
|
+
extraArgs.push(`--disable-extensions-except=${extensions}`);
|
|
631
|
+
extraArgs.push(`--load-extension=${extensions}`);
|
|
632
|
+
}
|
|
633
|
+
if (await isIntunedExtensionEnabled()) {
|
|
634
|
+
await setupIntunedExtension();
|
|
635
|
+
if (proxy) {
|
|
636
|
+
extraArgs.push('--proxy-bypass-list="<-loopback>"');
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (cdpPort) {
|
|
640
|
+
extraArgs.push(`--remote-debugging-port=${cdpPort}`);
|
|
641
|
+
}
|
|
642
|
+
if (headless) {
|
|
643
|
+
defaultArgsToIgnore.push("--headless=old");
|
|
644
|
+
extraArgs.push("--headless=new");
|
|
645
|
+
}
|
|
646
|
+
if (appModeInitialUrl) {
|
|
647
|
+
extraArgs.push(`--app=${appModeInitialUrl}`);
|
|
648
|
+
}
|
|
649
|
+
if (executablePath) {
|
|
650
|
+
executablePath = await fs.realpath(executablePath);
|
|
651
|
+
if (!await fs.exists(executablePath)) {
|
|
652
|
+
console.log(
|
|
653
|
+
`Warning: Executable path ${executablePath} does not exist. Falling back to default.`
|
|
654
|
+
);
|
|
655
|
+
executablePath = void 0;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const viewport = null;
|
|
659
|
+
const userAgent = process.env.__PLAYWRIGHT_USER_AGENT_OVERRIDE ?? await getHeadlessUserAgent({
|
|
660
|
+
executablePath
|
|
661
|
+
});
|
|
662
|
+
const context = await playwright.chromium.launchPersistentContext(
|
|
663
|
+
userDataDir,
|
|
664
|
+
{
|
|
665
|
+
userAgent,
|
|
666
|
+
executablePath,
|
|
667
|
+
headless,
|
|
668
|
+
viewport,
|
|
669
|
+
proxy,
|
|
670
|
+
downloadsPath,
|
|
671
|
+
args: extraArgs,
|
|
672
|
+
ignoreDefaultArgs: defaultArgsToIgnore
|
|
673
|
+
}
|
|
674
|
+
);
|
|
675
|
+
context.once("close", async () => {
|
|
676
|
+
try {
|
|
677
|
+
await rm(userDataDir, {
|
|
678
|
+
recursive: true,
|
|
679
|
+
force: true,
|
|
680
|
+
retryDelay: 1e3,
|
|
681
|
+
maxRetries: 5
|
|
682
|
+
});
|
|
683
|
+
if (await isIntunedExtensionEnabled()) {
|
|
684
|
+
await cleanIntunedExtensionServer();
|
|
685
|
+
}
|
|
686
|
+
} catch (error) {
|
|
687
|
+
console.error("Failed to remove user data dir", error);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
if (cdpPort) {
|
|
691
|
+
const createdCdpAddress = getLocalCdpAddress(cdpPort);
|
|
692
|
+
await waitOnCdpAddress(createdCdpAddress);
|
|
693
|
+
}
|
|
694
|
+
const page = context.pages().at(0) ?? await context.newPage();
|
|
695
|
+
if (await isIntunedExtensionEnabled()) {
|
|
696
|
+
await getIntunedExtensionWorker(context);
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
page,
|
|
700
|
+
context
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
async function getBrowserExecutablePath() {
|
|
704
|
+
const browserType = getBrowserType();
|
|
705
|
+
if (browserType === "brave") {
|
|
706
|
+
return await getBraveExecutablePath();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
async function launchBrowser(options) {
|
|
710
|
+
if ("cdpAddress" in options) {
|
|
711
|
+
return launchChromium(options);
|
|
712
|
+
}
|
|
713
|
+
return launchChromium({
|
|
714
|
+
...options,
|
|
715
|
+
executablePath: await getBrowserExecutablePath()
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function getBrowserType() {
|
|
719
|
+
if (process.env.BROWSER_TYPE === "brave") {
|
|
720
|
+
return "brave";
|
|
721
|
+
}
|
|
722
|
+
return "chromium";
|
|
723
|
+
}
|
|
724
|
+
async function getBraveExecutablePath() {
|
|
725
|
+
const { stdout } = await execAsync("which brave-browser-stable");
|
|
726
|
+
const bravePath = stdout.trim();
|
|
727
|
+
if (bravePath.length === 0) {
|
|
728
|
+
throw new Error("Brave browser not found");
|
|
729
|
+
}
|
|
730
|
+
return bravePath;
|
|
731
|
+
}
|
|
732
|
+
function getLocalCdpAddress(port) {
|
|
733
|
+
return `http://localhost:${port}`;
|
|
734
|
+
}
|
|
735
|
+
async function getCdpWebSocketUrl(cdpAddress) {
|
|
736
|
+
let response;
|
|
737
|
+
try {
|
|
738
|
+
response = await fetch(`${cdpAddress}/json/version`);
|
|
739
|
+
} catch (error) {
|
|
740
|
+
return err2(
|
|
741
|
+
`Failed to fetch CDP version from ${cdpAddress}: ${error instanceof Error ? error.message : String(error)}`
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
if (!response.ok) {
|
|
745
|
+
return err2(
|
|
746
|
+
`Failed to get CDP WebSocket URL from ${cdpAddress}: ${response.status} ${response.statusText}`
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
let data;
|
|
750
|
+
try {
|
|
751
|
+
data = await response.json();
|
|
752
|
+
} catch (error) {
|
|
753
|
+
return err2(
|
|
754
|
+
`Invalid CDP version response from ${cdpAddress}: ${error instanceof Error ? error.message : String(error)}`
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
const cdpJsonVersionResponseSchema = z.object({
|
|
758
|
+
webSocketDebuggerUrl: z.string().url()
|
|
759
|
+
});
|
|
760
|
+
const parseResult = cdpJsonVersionResponseSchema.safeParse(data);
|
|
761
|
+
if (!parseResult.success) {
|
|
762
|
+
return err2(
|
|
763
|
+
`Invalid CDP version response from ${cdpAddress}: ${JSON.stringify(
|
|
764
|
+
parseResult.error.format()
|
|
765
|
+
)}`
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
return ok3(parseResult.data.webSocketDebuggerUrl);
|
|
769
|
+
}
|
|
770
|
+
async function waitOnCdpAddress(cdpAddress) {
|
|
771
|
+
const cdpAddressWithoutProtocol = cdpAddress.replace("http://", "").replace("https://", "").replace("localhost", "127.0.0.1");
|
|
772
|
+
await waitOn({
|
|
773
|
+
resources: [`http-get://${cdpAddressWithoutProtocol}/json/version`],
|
|
774
|
+
delay: 100,
|
|
775
|
+
interval: 100,
|
|
776
|
+
timeout: 5e3,
|
|
777
|
+
tcpTimeout: 1e3,
|
|
778
|
+
window: 1e3
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
async function getHeadlessUserAgent({
|
|
782
|
+
executablePath,
|
|
783
|
+
args,
|
|
784
|
+
ignoreDefaultArgs
|
|
785
|
+
}) {
|
|
786
|
+
const browser = await playwright.chromium.launch({
|
|
787
|
+
headless: true,
|
|
788
|
+
executablePath,
|
|
789
|
+
args,
|
|
790
|
+
ignoreDefaultArgs
|
|
791
|
+
});
|
|
792
|
+
const context = await browser.newContext();
|
|
793
|
+
const page = await context.newPage();
|
|
794
|
+
let userAgent = await page.evaluate(() => navigator.userAgent);
|
|
795
|
+
await browser.close();
|
|
796
|
+
if (!userAgent || typeof userAgent !== "string") {
|
|
797
|
+
return void 0;
|
|
798
|
+
}
|
|
799
|
+
userAgent = userAgent.replace("HeadlessChrome", "Chrome");
|
|
800
|
+
return userAgent;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// src/common/playwrightContext.ts
|
|
804
|
+
var import_runtime_interface3 = __toESM(require_dist());
|
|
805
|
+
var browserScriptsFile = path.join(
|
|
806
|
+
__dirname,
|
|
807
|
+
"./assets/browser_scripts.js"
|
|
808
|
+
);
|
|
809
|
+
async function withPlaywrightContext({
|
|
810
|
+
cdpAddress,
|
|
811
|
+
cdpTargetId,
|
|
812
|
+
proxy,
|
|
813
|
+
headless = true,
|
|
814
|
+
downloadsPath,
|
|
815
|
+
importFunction,
|
|
816
|
+
apiName,
|
|
817
|
+
apiParameters
|
|
818
|
+
}, fn) {
|
|
819
|
+
let context;
|
|
820
|
+
let page;
|
|
821
|
+
try {
|
|
822
|
+
const setupContextHookResult = importFunction ? await loadSetupContextHook({
|
|
823
|
+
importFunction
|
|
824
|
+
}) : ok4(null);
|
|
825
|
+
if (setupContextHookResult.isErr()) {
|
|
826
|
+
return setupContextHookResult;
|
|
827
|
+
}
|
|
828
|
+
const setupContextHook = setupContextHookResult.value;
|
|
829
|
+
if (setupContextHook === null) {
|
|
830
|
+
if (cdpAddress !== void 0) {
|
|
831
|
+
({ page, context } = await launchBrowser({ cdpAddress, cdpTargetId }));
|
|
832
|
+
} else {
|
|
833
|
+
({ page, context } = await launchBrowser({
|
|
834
|
+
proxy,
|
|
835
|
+
headless,
|
|
836
|
+
downloadsPath
|
|
837
|
+
}));
|
|
838
|
+
}
|
|
839
|
+
return await fn(context, page);
|
|
840
|
+
}
|
|
841
|
+
let hookCdpUrl = null;
|
|
842
|
+
if (cdpAddress) {
|
|
843
|
+
hookCdpUrl = cdpAddress;
|
|
844
|
+
({ context, page } = await launchBrowser({ cdpAddress, cdpTargetId }));
|
|
845
|
+
} else {
|
|
846
|
+
const port = await getPort({
|
|
847
|
+
port: 9222
|
|
848
|
+
});
|
|
849
|
+
({ context, page } = await launchBrowser({
|
|
850
|
+
proxy,
|
|
851
|
+
headless,
|
|
852
|
+
downloadsPath,
|
|
853
|
+
cdpPort: port
|
|
854
|
+
}));
|
|
855
|
+
hookCdpUrl = getLocalCdpAddress(port);
|
|
856
|
+
}
|
|
857
|
+
let hookResult;
|
|
858
|
+
try {
|
|
859
|
+
const wsUrlResult = await getCdpWebSocketUrl(hookCdpUrl);
|
|
860
|
+
if (wsUrlResult.isOk()) {
|
|
861
|
+
hookCdpUrl = wsUrlResult.value;
|
|
862
|
+
} else {
|
|
863
|
+
throw new Error(wsUrlResult.error);
|
|
864
|
+
}
|
|
865
|
+
hookResult = await setupContextHook({
|
|
866
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
867
|
+
apiName,
|
|
868
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
869
|
+
apiParameters,
|
|
870
|
+
cdpUrl: hookCdpUrl
|
|
871
|
+
});
|
|
872
|
+
} catch (error) {
|
|
873
|
+
return err3(new import_runtime_interface3.AutomationError(error));
|
|
874
|
+
}
|
|
875
|
+
if (!hookResult) {
|
|
876
|
+
return await fn(context, page);
|
|
877
|
+
}
|
|
878
|
+
const { page: newPage, context: newContext, cleanup } = hookResult;
|
|
879
|
+
let result;
|
|
880
|
+
try {
|
|
881
|
+
result = { return: await fn(newContext, newPage ?? page) };
|
|
882
|
+
} catch (e) {
|
|
883
|
+
result = { throw: e };
|
|
884
|
+
}
|
|
885
|
+
try {
|
|
886
|
+
await cleanup?.();
|
|
887
|
+
} catch (e) {
|
|
888
|
+
result = { return: err3(new import_runtime_interface3.AutomationError(e)) };
|
|
889
|
+
}
|
|
890
|
+
if ("throw" in result) {
|
|
891
|
+
throw result.throw;
|
|
892
|
+
}
|
|
893
|
+
return result.return;
|
|
894
|
+
} finally {
|
|
895
|
+
await context?.close();
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
async function loadSessionToContext({
|
|
899
|
+
context,
|
|
900
|
+
session
|
|
901
|
+
}) {
|
|
902
|
+
let sessionToLoad;
|
|
903
|
+
if (session.type === "state") {
|
|
904
|
+
const state = session.state;
|
|
905
|
+
if (state === void 0 || state === null) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
sessionToLoad = state;
|
|
909
|
+
} else {
|
|
910
|
+
const fullPath = getFullPathInProject(session.path);
|
|
911
|
+
sessionToLoad = await fs2.readJson(fullPath);
|
|
912
|
+
}
|
|
913
|
+
await setStorageState(context, sessionToLoad);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// src/common/runApi/index.ts
|
|
917
|
+
var import_runtime_interface4 = __toESM(require_dist());
|
|
918
|
+
function getObjectSizeInBytes(obj) {
|
|
919
|
+
try {
|
|
920
|
+
return new TextEncoder().encode(JSON.stringify(obj)).length;
|
|
921
|
+
} catch (error) {
|
|
922
|
+
return new TextEncoder().encode(String(obj)).length;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
async function runApi({
|
|
926
|
+
abortSignal,
|
|
927
|
+
importFunction,
|
|
928
|
+
retrieveSession = false,
|
|
929
|
+
...input
|
|
930
|
+
}) {
|
|
931
|
+
let traceStarted = false;
|
|
932
|
+
const inputParseResult = import_runtime_interface4.runApiParametersSchema.safeParse(input);
|
|
933
|
+
if (!inputParseResult.success) {
|
|
934
|
+
return err4(
|
|
935
|
+
new import_runtime_interface4.InternalInvalidInputError(
|
|
936
|
+
"Input validation failed",
|
|
937
|
+
formatZodError(inputParseResult.error)
|
|
938
|
+
)
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
const {
|
|
942
|
+
automationFunction: { name, params },
|
|
943
|
+
runOptions,
|
|
944
|
+
tracing,
|
|
945
|
+
auth
|
|
946
|
+
} = inputParseResult.data;
|
|
947
|
+
const abortSymbol = /* @__PURE__ */ Symbol("abort");
|
|
948
|
+
const abortPromise = new Promise((resolve) => {
|
|
949
|
+
if (!abortSignal) return;
|
|
950
|
+
abortSignal.addEventListener("abort", () => {
|
|
951
|
+
resolve(abortSymbol);
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
async function runAutomation() {
|
|
955
|
+
const validatedModuleResult = await importUsingImportFunction({
|
|
956
|
+
path: name,
|
|
957
|
+
importFunction
|
|
958
|
+
});
|
|
959
|
+
if (validatedModuleResult.isErr()) {
|
|
960
|
+
return err4(validatedModuleResult.error);
|
|
961
|
+
}
|
|
962
|
+
const automationFunction = validatedModuleResult.value;
|
|
963
|
+
if (auth && auth.session.type === "state") {
|
|
964
|
+
const state = auth.session.state;
|
|
965
|
+
if (state === void 0 || state === null) {
|
|
966
|
+
return err4(new import_runtime_interface4.AuthRequiredError());
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
const playwrightContextParameters = {
|
|
970
|
+
apiName: name,
|
|
971
|
+
apiParameters: params,
|
|
972
|
+
importFunction
|
|
973
|
+
};
|
|
974
|
+
const intunedContext = getExecutionContext();
|
|
975
|
+
const runAutomationWithContext = async (context, page) => {
|
|
976
|
+
async function saveTraceIfNeeded({
|
|
977
|
+
errorMessage
|
|
978
|
+
}) {
|
|
979
|
+
if (!tracing.enabled || !traceStarted) {
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
try {
|
|
983
|
+
await context?.tracing.stop({ path: tracing.filePath });
|
|
984
|
+
} catch (error) {
|
|
985
|
+
console.log(errorMessage, error?.message);
|
|
986
|
+
await remove2(tracing.filePath);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (auth) {
|
|
990
|
+
await loadSessionToContext({
|
|
991
|
+
context,
|
|
992
|
+
session: auth.session
|
|
993
|
+
});
|
|
994
|
+
if (intunedContext && auth.parameters) {
|
|
995
|
+
intunedContext.getAuthSessionParameters = async () => auth.parameters;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
const scriptContent = await fs3.readFile(browserScriptsFile, "utf-8");
|
|
999
|
+
await context.addInitScript({
|
|
1000
|
+
content: scriptContent
|
|
1001
|
+
});
|
|
1002
|
+
for (const page2 of context.pages()) {
|
|
1003
|
+
await page2.evaluate(scriptContent);
|
|
1004
|
+
}
|
|
1005
|
+
if (tracing.enabled) {
|
|
1006
|
+
await context.tracing.start({
|
|
1007
|
+
screenshots: true,
|
|
1008
|
+
snapshots: true,
|
|
1009
|
+
sources: true
|
|
1010
|
+
});
|
|
1011
|
+
traceStarted = true;
|
|
1012
|
+
}
|
|
1013
|
+
cleanEnvironmentVariables();
|
|
1014
|
+
const automationFunctionParameters = [
|
|
1015
|
+
...params !== void 0 ? [params] : [],
|
|
1016
|
+
page,
|
|
1017
|
+
context
|
|
1018
|
+
];
|
|
1019
|
+
try {
|
|
1020
|
+
const [automationFunctionResult] = await Promise.all([
|
|
1021
|
+
automationFunction(...automationFunctionParameters)
|
|
1022
|
+
]);
|
|
1023
|
+
const MAX_RESULT_SIZE_BYTES = 2 * 1024 * 1024;
|
|
1024
|
+
const resultSizeInBytes = getObjectSizeInBytes(
|
|
1025
|
+
automationFunctionResult
|
|
1026
|
+
);
|
|
1027
|
+
if (resultSizeInBytes > MAX_RESULT_SIZE_BYTES) {
|
|
1028
|
+
return err4(
|
|
1029
|
+
new import_runtime_interface4.ResultTooBigError(resultSizeInBytes, MAX_RESULT_SIZE_BYTES)
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
if (retrieveSession) {
|
|
1033
|
+
return ok5({
|
|
1034
|
+
result: automationFunctionResult,
|
|
1035
|
+
extendedPayloads: intunedContext?.extendedPayloads,
|
|
1036
|
+
session: await getStorageState(context)
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
return ok5({
|
|
1040
|
+
result: automationFunctionResult,
|
|
1041
|
+
extendedPayloads: intunedContext?.extendedPayloads
|
|
1042
|
+
});
|
|
1043
|
+
} catch (error) {
|
|
1044
|
+
return err4(new import_runtime_interface4.AutomationError(error));
|
|
1045
|
+
} finally {
|
|
1046
|
+
await saveTraceIfNeeded({ errorMessage: "failed to save trace" });
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
if (intunedContext?.store) {
|
|
1050
|
+
intunedContext.store = {};
|
|
1051
|
+
}
|
|
1052
|
+
if (runOptions.environment === "standalone") {
|
|
1053
|
+
const downloadsPath = getDownloadDirectoryPath();
|
|
1054
|
+
try {
|
|
1055
|
+
return await withPlaywrightContext(
|
|
1056
|
+
{
|
|
1057
|
+
headless: runOptions.headless,
|
|
1058
|
+
proxy: runOptions.proxy,
|
|
1059
|
+
downloadsPath,
|
|
1060
|
+
...playwrightContextParameters
|
|
1061
|
+
},
|
|
1062
|
+
runAutomationWithContext
|
|
1063
|
+
);
|
|
1064
|
+
} finally {
|
|
1065
|
+
await fs3.remove(downloadsPath);
|
|
1066
|
+
}
|
|
1067
|
+
} else {
|
|
1068
|
+
return await withPlaywrightContext(
|
|
1069
|
+
{
|
|
1070
|
+
cdpAddress: runOptions.cdpAddress,
|
|
1071
|
+
cdpTargetId: runOptions.cdpTargetId,
|
|
1072
|
+
...playwrightContextParameters
|
|
1073
|
+
},
|
|
1074
|
+
runAutomationWithContext
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
const result = await Promise.race([await runAutomation(), abortPromise]);
|
|
1079
|
+
if (result === abortSymbol) {
|
|
1080
|
+
return err4(new import_runtime_interface4.AbortedError());
|
|
1081
|
+
}
|
|
1082
|
+
return result;
|
|
1083
|
+
}
|
|
1084
|
+
async function checkAuthSessionWithRetries(page, context, checkFn, retries = 3) {
|
|
1085
|
+
if (retries === 0) {
|
|
1086
|
+
return ok5(false);
|
|
1087
|
+
}
|
|
1088
|
+
let tryNumber = 0;
|
|
1089
|
+
console.log(
|
|
1090
|
+
"Checking AuthSession with retries",
|
|
1091
|
+
`${AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
1092
|
+
);
|
|
1093
|
+
while (retries > tryNumber) {
|
|
1094
|
+
const result = await checkFn(page, context);
|
|
1095
|
+
if (result) return ok5(true);
|
|
1096
|
+
tryNumber++;
|
|
1097
|
+
}
|
|
1098
|
+
return ok5(false);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export {
|
|
1102
|
+
require_dist,
|
|
1103
|
+
runApi,
|
|
1104
|
+
checkAuthSessionWithRetries
|
|
1105
|
+
};
|
|
1106
|
+
//# sourceMappingURL=chunk-XC75QGFG.mjs.map
|