@intuned/runtime-dev 1.1.3-release-test-04 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -2
- package/dist/commands/api/run.js +2 -8
- package/dist/commands/auth-sessions/run-check.js +4 -18
- package/dist/commands/auth-sessions/run-create.js +1 -2
- package/dist/commands/cli-auth-sessions/create.js +1 -1
- package/dist/commands/cli-auth-sessions/utils.js +2 -1
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +4 -2
- package/dist/commands/deploy/utils.js +2 -1
- package/dist/commands/interface/run.js +6 -7
- package/dist/commands/run-api-cli/utils.js +6 -6
- package/dist/common/assets/browser_scripts.js +2143 -2509
- package/dist/common/asyncLocalStorage/index.d.ts +2 -1
- package/dist/common/cli/types.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +12 -6
- package/dist/common/jwtTokenManager.js +5 -3
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +5 -4
- package/dist/common/runApi/index.d.ts +1 -1
- package/dist/common/runApi/index.js +11 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -6
- package/dist/runtime/executionHelpers.test.js +4 -3
- package/dist/runtime/export.d.ts +0 -16
- package/dist/runtime/extendPayload.js +1 -1
- package/dist/runtime/extendTimeout.js +7 -0
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.js +0 -7
- package/package.json +3 -2
- package/template.tsconfig.json +0 -1
- package/dist/common/assets/nopecha-extension/_metadata/computed_hashes.json +0 -1
- package/dist/common/assets/nopecha-extension/_metadata/verified_contents.json +0 -1
- package/dist/common/assets/nopecha-extension/background.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/awscaptcha.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/funcaptcha.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/geetest.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/lemincaptcha.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/perimeterx.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/recaptcha.js +0 -2
- package/dist/common/assets/nopecha-extension/captcha/textcaptcha.js +0 -1
- package/dist/common/assets/nopecha-extension/captcha/turnstile.js +0 -1
- package/dist/common/assets/nopecha-extension/eventhook/loader.js +0 -1
- package/dist/common/assets/nopecha-extension/eventhook.js +0 -1
- package/dist/common/assets/nopecha-extension/icon/128.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/128g.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/16.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/16g.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/32.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/32g.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/48.png +0 -0
- package/dist/common/assets/nopecha-extension/icon/48g.png +0 -0
- package/dist/common/assets/nopecha-extension/lib/selector.js +0 -1
- package/dist/common/assets/nopecha-extension/locate.js +0 -76
- package/dist/common/assets/nopecha-extension/manifest.json +0 -59
- package/dist/common/assets/nopecha-extension/pages/funcaptcha-demo.js +0 -1
- package/dist/common/assets/nopecha-extension/pages/integrate.js +0 -1
- package/dist/common/assets/nopecha-extension/pages/setup.js +0 -1
- package/dist/common/assets/nopecha-extension/popup.css +0 -1
- package/dist/common/assets/nopecha-extension/popup.html +0 -19
- package/dist/common/assets/nopecha-extension/popup.js +0 -2
- package/dist/common/assets/nopecha-extension/setup.html +0 -18
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
- package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
- package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
- package/dist/runtime/getAuthSessionParameters.js +0 -20
package/.babelrc
CHANGED
package/dist/commands/api/run.js
CHANGED
|
@@ -17,7 +17,6 @@ var _nanoid = require("nanoid");
|
|
|
17
17
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
18
|
var _runApi = require("../../common/runApi");
|
|
19
19
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
20
|
-
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
21
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
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); }
|
|
23
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; }
|
|
@@ -96,7 +95,7 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
96
95
|
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
_commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").
|
|
98
|
+
_commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
|
|
100
99
|
let inputData = null;
|
|
101
100
|
if (options.input) {
|
|
102
101
|
inputData = await fs.readJSON(options.input);
|
|
@@ -105,16 +104,11 @@ _commander.program.description("run the user function in the cli for testing pur
|
|
|
105
104
|
} else {
|
|
106
105
|
inputData = {};
|
|
107
106
|
}
|
|
108
|
-
let authSessionParametersJson = undefined;
|
|
109
|
-
if (!(0, _isNil.default)(options?.authSessionParameters)) {
|
|
110
|
-
authSessionParametersJson = JSON.parse(options.authSessionParameters);
|
|
111
|
-
}
|
|
112
107
|
await (0, _asyncLocalStorage.runWithContext)({
|
|
113
108
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
114
109
|
extendedPayloads: [],
|
|
115
110
|
runId: (0, _nanoid.nanoid)(),
|
|
116
|
-
proxy: options.proxy
|
|
117
|
-
getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
|
|
111
|
+
proxy: options.proxy
|
|
118
112
|
}, () => executeCLI(apiName, mode, inputData, options));
|
|
119
113
|
process.exit(0);
|
|
120
114
|
});
|
|
@@ -9,20 +9,15 @@ var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
|
9
9
|
var _constants = require("../../common/constants");
|
|
10
10
|
var _runApi = require("../../common/runApi");
|
|
11
11
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
12
|
-
var _enums = require("../../runtime/enums");
|
|
13
|
-
var _nanoid = require("nanoid");
|
|
14
|
-
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
15
|
-
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
16
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
15
|
_dotenv.default.config({
|
|
20
16
|
path: `.env`
|
|
21
17
|
});
|
|
22
|
-
_commander.program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").
|
|
18
|
+
_commander.program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
23
19
|
cdpAddress,
|
|
24
|
-
authSessionPath
|
|
25
|
-
authSessionParameters
|
|
20
|
+
authSessionPath
|
|
26
21
|
}) => {
|
|
27
22
|
const setting = await (0, _settings.getSettings)();
|
|
28
23
|
if (!setting.authSessions.enabled) {
|
|
@@ -32,16 +27,7 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
32
27
|
if (!fs.exists(checkFilePath)) {
|
|
33
28
|
throw new Error("auth session check file not found");
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
if (!(0, _isNil.default)(authSessionParameters)) {
|
|
37
|
-
authSessionParametersJson = JSON.parse(authSessionParameters);
|
|
38
|
-
}
|
|
39
|
-
const runApiResult = await (0, _asyncLocalStorage.runWithContext)({
|
|
40
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
41
|
-
extendedPayloads: [],
|
|
42
|
-
runId: (0, _nanoid.nanoid)(),
|
|
43
|
-
getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
|
|
44
|
-
}, async () => await (0, _runApi.runApi)({
|
|
30
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
45
31
|
automationFunction: {
|
|
46
32
|
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
47
33
|
},
|
|
@@ -58,7 +44,7 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
58
44
|
runCheck: false
|
|
59
45
|
},
|
|
60
46
|
importFunction: _tsNodeImport.tsNodeImport
|
|
61
|
-
})
|
|
47
|
+
});
|
|
62
48
|
if (runApiResult.isErr()) {
|
|
63
49
|
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
64
50
|
throw runApiResult.error.error;
|
|
@@ -94,8 +94,7 @@ _commander.program.description("run auth session create").option("--cdpAddress <
|
|
|
94
94
|
await (0, _asyncLocalStorage.runWithContext)({
|
|
95
95
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
96
96
|
extendedPayloads: [],
|
|
97
|
-
runId: (0, _nanoid.nanoid)()
|
|
98
|
-
getAuthSessionParameters: async () => inputData
|
|
97
|
+
runId: (0, _nanoid.nanoid)()
|
|
99
98
|
}, runCreate);
|
|
100
99
|
process.exit(0);
|
|
101
100
|
});
|
|
@@ -32,7 +32,7 @@ _commander.program.description("Create an auth session").argument("[auth-session
|
|
|
32
32
|
if (!createApiExists) {
|
|
33
33
|
throw new Error("Auth session create API not implemented, please create it in the auth sessions specified directory");
|
|
34
34
|
}
|
|
35
|
-
const authSessionInput = (await (0, _utils2.loadParameters)(options
|
|
35
|
+
const authSessionInput = (await (0, _utils2.loadParameters)(options === null || options === void 0 ? void 0 : options.input)) ?? {};
|
|
36
36
|
const session = await (0, _utils.runCreateApi)(authSessionInput);
|
|
37
37
|
if (!session) {
|
|
38
38
|
console.error(_chalk.default.red("Failed to create auth session."));
|
|
@@ -32,8 +32,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
32
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
33
|
async function isAuthEnabled() {
|
|
34
34
|
try {
|
|
35
|
+
var _intunedJson$authSess;
|
|
35
36
|
const intunedJson = await fs.readJSON(_path.default.join(process.cwd(), "Intuned.json"));
|
|
36
|
-
return Boolean(intunedJson
|
|
37
|
+
return Boolean(intunedJson === null || intunedJson === void 0 || (_intunedJson$authSess = intunedJson.authSessions) === null || _intunedJson$authSess === void 0 ? void 0 : _intunedJson$authSess.enabled);
|
|
37
38
|
} catch (error) {
|
|
38
39
|
return false;
|
|
39
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserContext } from "playwright";
|
|
1
|
+
import { BrowserContext } from "playwright-core";
|
|
2
2
|
export declare const REMOTE_DEBUGGING_PORT = 9222;
|
|
3
3
|
export declare const getChromiumLaunchArgs: () => string[];
|
|
4
4
|
export declare function startOrRestartBrowser(): Promise<void>;
|
|
@@ -9,7 +9,7 @@ exports.saveSession = saveSession;
|
|
|
9
9
|
exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
|
|
10
10
|
exports.startOrRestartBrowser = startOrRestartBrowser;
|
|
11
11
|
var _child_process = require("child_process");
|
|
12
|
-
var playwright = _interopRequireWildcard(require("playwright"));
|
|
12
|
+
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
13
13
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
14
14
|
var _fileUtils = require("./utils/fileUtils");
|
|
15
15
|
var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
|
|
@@ -32,9 +32,10 @@ function compileTypeScript(apiFilePath) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function findFirstExecutableLine(sourceFile) {
|
|
35
|
+
var _defaultExportSymbol$;
|
|
35
36
|
let functionBody;
|
|
36
37
|
const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
|
|
37
|
-
const defaultExportDeclaration = defaultExportSymbol
|
|
38
|
+
const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
|
|
38
39
|
if (defaultExportDeclaration) {
|
|
39
40
|
if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
|
|
40
41
|
functionBody = defaultExportDeclaration.getBody();
|
|
@@ -44,8 +45,9 @@ function findFirstExecutableLine(sourceFile) {
|
|
|
44
45
|
const expression = exportAssignment.getExpression();
|
|
45
46
|
if (!expression) continue;
|
|
46
47
|
if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
|
|
48
|
+
var _sourceFile$getVariab;
|
|
47
49
|
const identifier = expression.getText();
|
|
48
|
-
const possiblyExportedFunction = sourceFile.getFunction(identifier) || sourceFile.getVariableStatement(identifier)
|
|
50
|
+
const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction));
|
|
49
51
|
if (possiblyExportedFunction) {
|
|
50
52
|
functionBody = possiblyExportedFunction.getBody();
|
|
51
53
|
break;
|
|
@@ -228,12 +228,13 @@ const validateIntunedProject = async () => {
|
|
|
228
228
|
name: "package.json",
|
|
229
229
|
check: async () => {
|
|
230
230
|
try {
|
|
231
|
+
var _packageJson$dependen;
|
|
231
232
|
const packageJsonPath = path.join(currentDirectoryToDeploy, "package.json");
|
|
232
233
|
await fs.exists(packageJsonPath);
|
|
233
234
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, {
|
|
234
235
|
encoding: "utf-8"
|
|
235
236
|
}));
|
|
236
|
-
const userCodePlaywrightVersion = packageJson.dependencies
|
|
237
|
+
const userCodePlaywrightVersion = (_packageJson$dependen = packageJson.dependencies) === null || _packageJson$dependen === void 0 ? void 0 : _packageJson$dependen.playwright;
|
|
237
238
|
if (userCodePlaywrightVersion !== _constants.CURRENT_PLAYWRIGHT_VERSION) {
|
|
238
239
|
return {
|
|
239
240
|
isValid: false,
|
|
@@ -16,7 +16,6 @@ var _promises = require("timers/promises");
|
|
|
16
16
|
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
17
17
|
var _formatZodError = require("../../common/formatZodError");
|
|
18
18
|
var _neverthrow = require("neverthrow");
|
|
19
|
-
var _getAuthSessionParameters = require("../../common/backendFunctions/getAuthSessionParameters");
|
|
20
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
20
|
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
21
|
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; }
|
|
@@ -29,8 +28,7 @@ const startRunApiSchema = _zod.default.object({
|
|
|
29
28
|
jobId: _zod.default.string().optional(),
|
|
30
29
|
jobRunId: _zod.default.string().optional(),
|
|
31
30
|
runId: _zod.default.string().optional(),
|
|
32
|
-
queueId: _zod.default.string().optional()
|
|
33
|
-
authSessionId: _zod.default.string().optional()
|
|
31
|
+
queueId: _zod.default.string().optional()
|
|
34
32
|
}).optional()
|
|
35
33
|
})
|
|
36
34
|
});
|
|
@@ -67,12 +65,14 @@ function runAutomationCLI(importFunction) {
|
|
|
67
65
|
let generator = null;
|
|
68
66
|
const abortController = new AbortController();
|
|
69
67
|
client.on("error", err => {
|
|
70
|
-
|
|
68
|
+
var _generator;
|
|
69
|
+
void ((_generator = generator) === null || _generator === void 0 ? void 0 : _generator.throw(err).catch(() => undefined));
|
|
71
70
|
});
|
|
72
71
|
const interruptSignalHandler = async () => {
|
|
72
|
+
var _generator2;
|
|
73
73
|
abortController.abort();
|
|
74
74
|
await (0, _promises.setTimeout)(60_000);
|
|
75
|
-
void generator
|
|
75
|
+
void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(new Error("Interrupted")).catch(() => undefined));
|
|
76
76
|
client.end();
|
|
77
77
|
process.exit(1);
|
|
78
78
|
};
|
|
@@ -124,7 +124,6 @@ function runAutomationCLI(importFunction) {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
getAuthSessionParameters: _getAuthSessionParameters.getAuthSessionParameters,
|
|
128
127
|
...(message.parameters.context ?? {}),
|
|
129
128
|
proxy: getProxyUrlFromRunOptions(message.parameters.runOptions)
|
|
130
129
|
};
|
|
@@ -213,7 +212,7 @@ function runAutomationCLI(importFunction) {
|
|
|
213
212
|
_commander.program.parse(process.argv);
|
|
214
213
|
}
|
|
215
214
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
216
|
-
if (runOptions
|
|
215
|
+
if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "standalone") return undefined;
|
|
217
216
|
const proxy = runOptions.proxy;
|
|
218
217
|
if (!proxy) return undefined;
|
|
219
218
|
const url = new URL(proxy.server);
|
|
@@ -62,10 +62,10 @@ async function writeResultToFile(runId, result, payloadToAppend) {
|
|
|
62
62
|
}
|
|
63
63
|
async function runApiViaCLI(apiName, inputData, options) {
|
|
64
64
|
let authSessionPathToUse = null;
|
|
65
|
-
if (options
|
|
65
|
+
if (options !== null && options !== void 0 && options.authSession) {
|
|
66
66
|
const {
|
|
67
67
|
authSessionInstanceStoragePath
|
|
68
|
-
} = await (0, _utils.retrieveAuthSessionInstance)(options
|
|
68
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession, true);
|
|
69
69
|
authSessionPathToUse = authSessionInstanceStoragePath;
|
|
70
70
|
}
|
|
71
71
|
if (authSessionPathToUse) {
|
|
@@ -82,17 +82,17 @@ async function runApiViaCLI(apiName, inputData, options) {
|
|
|
82
82
|
}
|
|
83
83
|
const {
|
|
84
84
|
metadata
|
|
85
|
-
} = await (0, _utils.retrieveAuthSessionInstance)(options
|
|
86
|
-
if (metadata
|
|
85
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession);
|
|
86
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.authSessionType) === "MANUAL") {
|
|
87
87
|
throw new Error("Expired Auth session is recorder-based, please provide a new one or refresh it manually");
|
|
88
88
|
}
|
|
89
|
-
const authSessionInput = metadata
|
|
89
|
+
const authSessionInput = (metadata === null || metadata === void 0 ? void 0 : metadata.authSessionInput) ?? {};
|
|
90
90
|
try {
|
|
91
91
|
const refresehAuthSessionInstance = await (0, _utils.runCreateApiViaCLI)(authSessionInput);
|
|
92
92
|
if (!refresehAuthSessionInstance) {
|
|
93
93
|
throw new Error("Failed to refresh auth session");
|
|
94
94
|
}
|
|
95
|
-
await (0, _utils.storeAuthSessionInstance)(refresehAuthSessionInstance, options
|
|
95
|
+
await (0, _utils.storeAuthSessionInstance)(refresehAuthSessionInstance, options === null || options === void 0 ? void 0 : options.authSession, authSessionInput);
|
|
96
96
|
const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
|
|
97
97
|
if (!checkResult) {
|
|
98
98
|
throw new Error("Failed to refresh auth session");
|