@intuned/runtime-dev 1.3.18-interface.10 → 1.3.18-interface.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/api/run.d.ts +8 -0
- package/dist/commands/api/run.js +2094 -0
- package/dist/commands/auth-sessions/load.d.ts +1 -0
- package/dist/commands/auth-sessions/load.js +1559 -0
- package/dist/commands/auth-sessions/run-check.d.ts +1 -0
- package/dist/commands/auth-sessions/run-check.js +1964 -0
- package/dist/commands/auth-sessions/run-create.d.ts +1 -0
- package/dist/commands/auth-sessions/run-create.js +1968 -0
- package/dist/commands/browser/save-state.d.ts +1 -0
- package/dist/commands/browser/save-state.js +108 -0
- package/dist/commands/browser/start-browser.d.ts +1 -0
- package/dist/commands/browser/start-browser.js +67 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +203 -0
- package/dist/commands/get-headless-user-agent.d.ts +2 -0
- package/dist/commands/get-headless-user-agent.js +354 -0
- package/dist/commands/interface/run.js +20 -32
- package/dist/commands/intuned-cli/main.d.ts +2 -0
- package/dist/commands/intuned-cli/main.js +5403 -0
- package/dist/commands/ts-check.d.ts +1 -0
- package/dist/commands/ts-check.js +158 -0
- package/dist/common/runApi/index.js +18 -30
- package/package.json +16 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// src/commands/ts-check.ts
|
|
26
|
+
var ts = __toESM(require("typescript"));
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
var fs3 = __toESM(require("fs-extra"));
|
|
29
|
+
var path3 = __toESM(require("path"));
|
|
30
|
+
|
|
31
|
+
// src/commands/common/utils/template.ts
|
|
32
|
+
var fs2 = __toESM(require("fs-extra"));
|
|
33
|
+
var path2 = __toESM(require("path"));
|
|
34
|
+
|
|
35
|
+
// src/commands/common/utils/fileUtils.ts
|
|
36
|
+
var path = __toESM(require("path"));
|
|
37
|
+
var fs = __toESM(require("fs-extra"));
|
|
38
|
+
var import_dotenv = __toESM(require("dotenv"));
|
|
39
|
+
import_dotenv.default.config();
|
|
40
|
+
function getFullPathInProject(...paths) {
|
|
41
|
+
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
42
|
+
}
|
|
43
|
+
async function listProjectFilesAndFolders() {
|
|
44
|
+
const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
|
|
45
|
+
try {
|
|
46
|
+
const files = await fs.readdir(projectPath, { withFileTypes: true });
|
|
47
|
+
return files.map((file) => ({
|
|
48
|
+
type: file.isDirectory() ? "Folder" : "File",
|
|
49
|
+
fullPath: path.join(projectPath, file.name),
|
|
50
|
+
name: file.name
|
|
51
|
+
}));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error("Error reading the directory:", err);
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/commands/common/utils/template.ts
|
|
59
|
+
var moveTemplateFiles = async (templateName) => {
|
|
60
|
+
await fs2.remove("./intuned");
|
|
61
|
+
await fs2.ensureDir("./intuned");
|
|
62
|
+
const currentFileLocation = path2.resolve(
|
|
63
|
+
__dirname,
|
|
64
|
+
"..",
|
|
65
|
+
"..",
|
|
66
|
+
"..",
|
|
67
|
+
"..",
|
|
68
|
+
templateName
|
|
69
|
+
);
|
|
70
|
+
await fs2.copy(`${currentFileLocation}`, `./intuned/${templateName}`, {
|
|
71
|
+
filter: (src, _) => {
|
|
72
|
+
if (src.includes(".d.ts")) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const filesAndFolders = await listProjectFilesAndFolders();
|
|
79
|
+
const pathsIgnoreList = [
|
|
80
|
+
getFullPathInProject("intuned"),
|
|
81
|
+
getFullPathInProject("node_modules"),
|
|
82
|
+
getFullPathInProject("package.json"),
|
|
83
|
+
getFullPathInProject("yarn.lock"),
|
|
84
|
+
getFullPathInProject(".env")
|
|
85
|
+
];
|
|
86
|
+
const filesToCopy = filesAndFolders.filter(
|
|
87
|
+
(file) => !pathsIgnoreList.includes(file.fullPath)
|
|
88
|
+
);
|
|
89
|
+
for (const file of filesToCopy) {
|
|
90
|
+
await fs2.copy(file.fullPath, `./intuned/${templateName}/${file.name}`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/commands/ts-check.ts
|
|
95
|
+
import_commander.program.description("Check TypeScript types in the project").option("-t, --template <type>", "template to use", "InterfaceTemplate").allowUnknownOption().action(async ({ template }) => {
|
|
96
|
+
await moveTemplateFiles(template);
|
|
97
|
+
const templateTsConfig = path3.resolve(
|
|
98
|
+
__dirname,
|
|
99
|
+
"..",
|
|
100
|
+
"..",
|
|
101
|
+
"template.tsconfig.json"
|
|
102
|
+
);
|
|
103
|
+
await fs3.copy(templateTsConfig, `./intuned/${template}/tsconfig.json`);
|
|
104
|
+
checkTypes(template);
|
|
105
|
+
});
|
|
106
|
+
function checkTypes(template) {
|
|
107
|
+
const configPath = ts.findConfigFile(
|
|
108
|
+
`./intuned/${template}`,
|
|
109
|
+
ts.sys.fileExists,
|
|
110
|
+
"tsconfig.json"
|
|
111
|
+
);
|
|
112
|
+
if (!configPath) {
|
|
113
|
+
console.error("Could not find a valid 'tsconfig.json'.");
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
117
|
+
const config = readConfigResult.config;
|
|
118
|
+
const parseConfigHost = {
|
|
119
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
120
|
+
readDirectory: ts.sys.readDirectory,
|
|
121
|
+
fileExists: ts.sys.fileExists,
|
|
122
|
+
readFile: ts.sys.readFile
|
|
123
|
+
};
|
|
124
|
+
const parsed = ts.parseJsonConfigFileContent(
|
|
125
|
+
config,
|
|
126
|
+
parseConfigHost,
|
|
127
|
+
"./intuned"
|
|
128
|
+
);
|
|
129
|
+
const program2 = ts.createProgram(parsed.fileNames, parsed.options);
|
|
130
|
+
const emitResult = program2.emit();
|
|
131
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program2).concat(emitResult.diagnostics);
|
|
132
|
+
allDiagnostics.forEach((diagnostic) => {
|
|
133
|
+
if (diagnostic.file) {
|
|
134
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(
|
|
135
|
+
diagnostic.file,
|
|
136
|
+
diagnostic.start
|
|
137
|
+
);
|
|
138
|
+
const message = ts.flattenDiagnosticMessageText(
|
|
139
|
+
diagnostic.messageText,
|
|
140
|
+
"\n"
|
|
141
|
+
);
|
|
142
|
+
console.log(
|
|
143
|
+
`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
|
|
144
|
+
);
|
|
145
|
+
} else {
|
|
146
|
+
console.log(
|
|
147
|
+
ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (allDiagnostics.length === 0) {
|
|
152
|
+
console.log("\u2728 TypeScript type checking passed without errors.");
|
|
153
|
+
} else {
|
|
154
|
+
console.error("Errors found during TypeScript type checking.");
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
import_commander.program.parse(process.argv);
|
|
@@ -398,8 +398,8 @@ var require_interfaceClient = __commonJS({
|
|
|
398
398
|
exports2.SocketClient = SocketClient;
|
|
399
399
|
SocketClient.LENGTH_HEADER_LENGTH = 4;
|
|
400
400
|
var UnixSocketClient = class extends SocketClient {
|
|
401
|
-
constructor(
|
|
402
|
-
super(net.createConnection(
|
|
401
|
+
constructor(path3) {
|
|
402
|
+
super(net.createConnection(path3));
|
|
403
403
|
}
|
|
404
404
|
};
|
|
405
405
|
exports2.UnixSocketClient = UnixSocketClient;
|
|
@@ -644,9 +644,9 @@ var backendFunctionsTokenManager = new JwtTokenManager(
|
|
|
644
644
|
`refreshBackendFunctionsToken`
|
|
645
645
|
);
|
|
646
646
|
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
647
|
-
function callBackendFunctionWithToken(
|
|
647
|
+
function callBackendFunctionWithToken(path3, init) {
|
|
648
648
|
return backendFunctionsTokenManager.fetchWithToken(
|
|
649
|
-
`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${
|
|
649
|
+
`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${path3}`,
|
|
650
650
|
init
|
|
651
651
|
);
|
|
652
652
|
}
|
|
@@ -884,8 +884,8 @@ function getIntunedExtensionPath() {
|
|
|
884
884
|
return process.env.INTUNED_EXTENSION_PATH;
|
|
885
885
|
}
|
|
886
886
|
async function isIntunedExtensionEnabled() {
|
|
887
|
-
const
|
|
888
|
-
if (!
|
|
887
|
+
const path3 = getIntunedExtensionPath();
|
|
888
|
+
if (!path3) {
|
|
889
889
|
return false;
|
|
890
890
|
}
|
|
891
891
|
const captchaSolverSettings2 = await getIntunedCaptchaSolverSettings();
|
|
@@ -1141,11 +1141,11 @@ function getDownloadDirectoryPath() {
|
|
|
1141
1141
|
if (!context) {
|
|
1142
1142
|
throw new Error("ExecutionContext not found");
|
|
1143
1143
|
}
|
|
1144
|
-
const
|
|
1145
|
-
(0, import_fs_extra.ensureDirSync)(
|
|
1144
|
+
const path3 = `/tmp/downloads/${context.runId}`;
|
|
1145
|
+
(0, import_fs_extra.ensureDirSync)(path3, {
|
|
1146
1146
|
mode: 1533
|
|
1147
1147
|
});
|
|
1148
|
-
return
|
|
1148
|
+
return path3;
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
1151
|
// src/common/runApi/index.ts
|
|
@@ -1234,7 +1234,6 @@ async function getStorageState(context) {
|
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
1236
|
// src/common/playwrightContext.ts
|
|
1237
|
-
var import_path3 = __toESM(require("path"));
|
|
1238
1237
|
var fs3 = __toESM(require("fs-extra"));
|
|
1239
1238
|
var import_neverthrow5 = require("neverthrow");
|
|
1240
1239
|
|
|
@@ -1245,27 +1244,27 @@ var import_neverthrow3 = require("neverthrow");
|
|
|
1245
1244
|
var import_neverthrow2 = require("neverthrow");
|
|
1246
1245
|
var import_runtime_interface = __toESM(require_dist());
|
|
1247
1246
|
async function importUsingImportFunction({
|
|
1248
|
-
path:
|
|
1247
|
+
path: path3,
|
|
1249
1248
|
allowGenerators = true,
|
|
1250
1249
|
importFunction
|
|
1251
1250
|
}) {
|
|
1252
1251
|
try {
|
|
1253
|
-
const importedResult = await importFunction(
|
|
1252
|
+
const importedResult = await importFunction(path3);
|
|
1254
1253
|
if (importedResult.isErr()) {
|
|
1255
1254
|
if (importedResult.error.type === "not_found") {
|
|
1256
|
-
return (0, import_neverthrow2.err)(new import_runtime_interface.ApiNotFoundError(
|
|
1255
|
+
return (0, import_neverthrow2.err)(new import_runtime_interface.ApiNotFoundError(path3));
|
|
1257
1256
|
}
|
|
1258
1257
|
return (0, import_neverthrow2.err)(new import_runtime_interface.AutomationError(importedResult.error.error));
|
|
1259
1258
|
}
|
|
1260
1259
|
const imported = importedResult.value;
|
|
1261
1260
|
if (!imported || !imported.default || !imported.default.constructor) {
|
|
1262
|
-
return (0, import_neverthrow2.err)(new import_runtime_interface.InvalidApiError(`${
|
|
1261
|
+
return (0, import_neverthrow2.err)(new import_runtime_interface.InvalidApiError(`${path3} does not have a default export`));
|
|
1263
1262
|
}
|
|
1264
1263
|
if (imported.default.constructor.name === "AsyncGeneratorFunction") {
|
|
1265
1264
|
if (!allowGenerators) {
|
|
1266
1265
|
return (0, import_neverthrow2.err)(
|
|
1267
1266
|
new import_runtime_interface.InvalidApiError(
|
|
1268
|
-
`${
|
|
1267
|
+
`${path3} default export must be an async function`
|
|
1269
1268
|
)
|
|
1270
1269
|
);
|
|
1271
1270
|
}
|
|
@@ -1284,7 +1283,7 @@ async function importUsingImportFunction({
|
|
|
1284
1283
|
return (0, import_neverthrow2.ok)(imported.default);
|
|
1285
1284
|
}
|
|
1286
1285
|
return (0, import_neverthrow2.err)(
|
|
1287
|
-
new import_runtime_interface.InvalidApiError(`${
|
|
1286
|
+
new import_runtime_interface.InvalidApiError(`${path3} default export must be an async function`)
|
|
1288
1287
|
);
|
|
1289
1288
|
} catch (error) {
|
|
1290
1289
|
return (0, import_neverthrow2.err)(new import_runtime_interface.AutomationError(error));
|
|
@@ -1557,10 +1556,6 @@ async function getHeadlessUserAgent({
|
|
|
1557
1556
|
|
|
1558
1557
|
// src/common/playwrightContext.ts
|
|
1559
1558
|
var import_runtime_interface3 = __toESM(require_dist());
|
|
1560
|
-
var browserScriptsFile = import_path3.default.join(
|
|
1561
|
-
__dirname,
|
|
1562
|
-
"./assets/browser_scripts.js"
|
|
1563
|
-
);
|
|
1564
1559
|
async function withPlaywrightContext({
|
|
1565
1560
|
cdpAddress,
|
|
1566
1561
|
cdpTargetId,
|
|
@@ -1671,11 +1666,11 @@ async function loadSessionToContext({
|
|
|
1671
1666
|
// src/common/formatZodError.ts
|
|
1672
1667
|
function formatZodError(zodError) {
|
|
1673
1668
|
const formattedErrors = zodError.errors.map((error) => {
|
|
1674
|
-
const
|
|
1669
|
+
const path3 = error.path.map((segment) => {
|
|
1675
1670
|
return typeof segment === "number" ? `[${segment}]` : segment;
|
|
1676
1671
|
}).join(".");
|
|
1677
|
-
if (
|
|
1678
|
-
return `${
|
|
1672
|
+
if (path3) {
|
|
1673
|
+
return `${path3} is invalid - ${error.message}`;
|
|
1679
1674
|
}
|
|
1680
1675
|
return error.message;
|
|
1681
1676
|
});
|
|
@@ -1776,13 +1771,6 @@ async function runApi({
|
|
|
1776
1771
|
intunedContext.getAuthSessionParameters = async () => auth.parameters;
|
|
1777
1772
|
}
|
|
1778
1773
|
}
|
|
1779
|
-
const scriptContent = await fs4.readFile(browserScriptsFile, "utf-8");
|
|
1780
|
-
await context.addInitScript({
|
|
1781
|
-
content: scriptContent
|
|
1782
|
-
});
|
|
1783
|
-
for (const page2 of context.pages()) {
|
|
1784
|
-
await page2.evaluate(scriptContent);
|
|
1785
|
-
}
|
|
1786
1774
|
if (tracing.enabled) {
|
|
1787
1775
|
await context.tracing.start({
|
|
1788
1776
|
screenshots: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.3.18-interface.
|
|
3
|
+
"version": "1.3.18-interface.12",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"packageManager": "yarn@4.12.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
"types": "./dist/commands/interface/run.d.ts",
|
|
51
51
|
"require": "./dist/commands/interface/run.js"
|
|
52
52
|
},
|
|
53
|
+
"./dist/commands/build": {
|
|
54
|
+
"types": "./dist/commands/build.d.ts",
|
|
55
|
+
"require": "./dist/commands/build.js"
|
|
56
|
+
},
|
|
53
57
|
"./dist/common/binStartupScript": {
|
|
54
58
|
"types": "./dist/common/binStartupScript.d.ts",
|
|
55
59
|
"require": "./dist/common/binStartupScript.js"
|
|
@@ -57,7 +61,16 @@
|
|
|
57
61
|
"./dist/commands/common/tsNodeImport": {
|
|
58
62
|
"types": "./dist/commands/common/tsNodeImport.d.ts",
|
|
59
63
|
"require": "./dist/commands/common/tsNodeImport.js"
|
|
60
|
-
}
|
|
64
|
+
},
|
|
65
|
+
"./dist/commands/intuned-cli/main.js": "./dist/commands/intuned-cli/main.js",
|
|
66
|
+
"./dist/commands/api/run.js": "./dist/commands/api/run.js",
|
|
67
|
+
"./dist/commands/auth-sessions/run-check.js": "./dist/commands/auth-sessions/run-check.js",
|
|
68
|
+
"./dist/commands/auth-sessions/run-create.js": "./dist/commands/auth-sessions/run-create.js",
|
|
69
|
+
"./dist/commands/auth-sessions/load.js": "./dist/commands/auth-sessions/load.js",
|
|
70
|
+
"./dist/commands/browser/save-state.js": "./dist/commands/browser/save-state.js",
|
|
71
|
+
"./dist/commands/browser/start-browser.js": "./dist/commands/browser/start-browser.js",
|
|
72
|
+
"./dist/commands/get-headless-user-agent.js": "./dist/commands/get-headless-user-agent.js",
|
|
73
|
+
"./dist/commands/ts-check.js": "./dist/commands/ts-check.js"
|
|
61
74
|
},
|
|
62
75
|
"files": [
|
|
63
76
|
"dist",
|
|
@@ -76,7 +89,7 @@
|
|
|
76
89
|
"intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
|
|
77
90
|
"intuned": "vite-node ./src/commands/intuned-cli/main.ts",
|
|
78
91
|
"intuned-get-headless-user-agent": "vite-node ./src/commands/get-headless-user-agent.ts",
|
|
79
|
-
"build": "tsup && cp -r ./src/common/assets dist/common/assets",
|
|
92
|
+
"build": "rm -rf ./dist && tsup && cp -r ./src/common/assets dist/common/assets",
|
|
80
93
|
"test": "vitest run",
|
|
81
94
|
"test:watch": "vitest",
|
|
82
95
|
"e2e": "yarn playwright test --config ./playwright.config.ts",
|