@intuned/runtime-dev 0.1.0-test.2 → 0.1.0-test.20
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/Intuned.json +1 -1
- package/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/check.ts +2 -1
- package/WebTemplate/controllers/authSessions/create.ts +4 -4
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +11 -7
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +51 -1
- package/api/test2.ts +7 -5
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +6 -2
- package/dist/commands/auth-sessions/run-check.js +3 -1
- package/dist/commands/auth-sessions/run-create.js +4 -2
- package/dist/commands/build.js +7 -4
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.test.js +2 -2
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/{getDefaultExportFromFile.js → tsNodeImport.js} +3 -4
- package/dist/commands/common/utils/settings.js +1 -1
- package/dist/commands/common/utils/webTemplate.js +2 -2
- package/dist/commands/interface/run.js +131 -107
- package/dist/commands/ts-check.js +2 -2
- package/dist/common/Logger/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +3 -3
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +27 -68
- package/dist/common/runApi/types.d.ts +20 -6
- package/dist/common/runApi/types.js +5 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/executionHelpers.test.js +2 -2
- package/dist/runtime/export.d.ts +1 -1
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +1 -1
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +1 -1
- package/package.json +5 -5
- package/preserve-dynamic-imports.js +16 -0
- package/tsconfig.json +1 -1
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
package/Intuned.json
CHANGED
package/WebTemplate/api.ts
CHANGED
|
@@ -33,109 +33,107 @@ import {
|
|
|
33
33
|
} from "./headers";
|
|
34
34
|
import { FEATURES } from "./features";
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
app.get(
|
|
58
|
-
"/api/protected/health",
|
|
59
|
-
accessKeyValidatorMiddleware,
|
|
60
|
-
async (req, res) => {
|
|
61
|
-
res.status(200).json({ status: "ok" });
|
|
62
|
-
}
|
|
63
|
-
);
|
|
36
|
+
if (!isJobRunMachine()) {
|
|
37
|
+
app.use((req, _, next) => {
|
|
38
|
+
const runId = req.headers[RUN_ID_HEADER] as string;
|
|
39
|
+
const jobId = req.headers[JOB_ID_HEADER] as string;
|
|
40
|
+
const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
|
|
41
|
+
const queueId = req.headers[QUEUE_ID_HEADER] as string;
|
|
42
|
+
const proxy = req?.body?.proxy
|
|
43
|
+
? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
|
|
44
|
+
: undefined;
|
|
45
|
+
const contextData = {
|
|
46
|
+
runId: runId ?? "",
|
|
47
|
+
jobId,
|
|
48
|
+
jobRunId,
|
|
49
|
+
queueId,
|
|
50
|
+
proxy,
|
|
51
|
+
...(req?.body?.executionContext ?? {}),
|
|
52
|
+
};
|
|
53
|
+
runWithContext(contextData, next);
|
|
54
|
+
});
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
app.get(
|
|
57
|
+
"/api/protected/health",
|
|
58
|
+
accessKeyValidatorMiddleware,
|
|
59
|
+
async (req, res) => {
|
|
60
|
+
res.status(200).json({ status: "ok" });
|
|
61
|
+
}
|
|
62
|
+
);
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
app.post(
|
|
65
|
+
"/api/auth-session/create",
|
|
66
|
+
accessKeyValidatorMiddleware,
|
|
67
|
+
errorRetryMiddleware(createAuthSessionController)
|
|
68
|
+
);
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
app.post(
|
|
71
|
+
"/api/auth-session-async/create",
|
|
72
|
+
accessKeyValidatorMiddleware,
|
|
73
|
+
errorRetryMiddleware(createAuthSessionAsyncController)
|
|
74
|
+
);
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
app.post(
|
|
77
|
+
"/api/auth-session/check",
|
|
78
|
+
accessKeyValidatorMiddleware,
|
|
79
|
+
errorRetryMiddleware(checkAuthSessionController)
|
|
80
|
+
);
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
app.post(
|
|
83
|
+
"/api/auth-session-async/check",
|
|
84
|
+
accessKeyValidatorMiddleware,
|
|
85
|
+
errorRetryMiddleware(checkAuthSessionAsyncController)
|
|
86
|
+
);
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
app.post(
|
|
89
|
+
"/api/auth-session/kill",
|
|
90
|
+
accessKeyValidatorMiddleware,
|
|
91
|
+
errorRetryMiddleware(killAuthSessionOperationController)
|
|
92
|
+
);
|
|
100
93
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
app.post(
|
|
95
|
+
"/api/auth-session/resume",
|
|
96
|
+
accessKeyValidatorMiddleware,
|
|
97
|
+
errorRetryMiddleware(resumeAuthSessionOperationController)
|
|
98
|
+
);
|
|
106
99
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
app.post(
|
|
101
|
+
"/api/auth-session-async/resume",
|
|
102
|
+
accessKeyValidatorMiddleware,
|
|
103
|
+
errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
|
|
104
|
+
);
|
|
112
105
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
app.post(
|
|
107
|
+
"/api/run/*",
|
|
108
|
+
accessKeyValidatorMiddleware,
|
|
109
|
+
errorRetryMiddleware(runApiController)
|
|
110
|
+
);
|
|
118
111
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
app.post(
|
|
113
|
+
"/api/run-async/start/*",
|
|
114
|
+
accessKeyValidatorMiddleware,
|
|
115
|
+
errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
|
|
116
|
+
);
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
app.get(
|
|
119
|
+
"/api/run-async/count",
|
|
120
|
+
accessKeyValidatorMiddleware,
|
|
121
|
+
getActiveAsyncEndpointController
|
|
122
|
+
);
|
|
130
123
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
124
|
+
app.post(
|
|
125
|
+
"/api/trace/upload/:runId",
|
|
126
|
+
accessKeyValidatorMiddleware,
|
|
127
|
+
uploadTraceController
|
|
128
|
+
);
|
|
137
129
|
|
|
138
|
-
app.
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
app.post(
|
|
131
|
+
"/api/trace/delete/:runId",
|
|
132
|
+
accessKeyValidatorMiddleware,
|
|
133
|
+
deleteTraceController
|
|
134
|
+
);
|
|
141
135
|
}
|
|
136
|
+
|
|
137
|
+
app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
|
|
138
|
+
res.status(200).json({ features: FEATURES });
|
|
139
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readJSON } from "fs-extra";
|
|
2
2
|
import { isHeadless } from "../../utils";
|
|
3
3
|
import { runApi } from "@intuned/runtime/dist/common/runApi";
|
|
4
|
+
import { importModule } from "../../utils";
|
|
4
5
|
|
|
5
6
|
export async function checkAuthSession({
|
|
6
7
|
proxy,
|
|
@@ -32,7 +33,7 @@ export async function checkAuthSession({
|
|
|
32
33
|
|
|
33
34
|
const result = await runApi<boolean>({
|
|
34
35
|
automationFunction: {
|
|
35
|
-
|
|
36
|
+
module: await importModule("auth-sessions/check"),
|
|
36
37
|
},
|
|
37
38
|
runOptions: {
|
|
38
39
|
environment: "deployed",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { authSessionsContextsStore } from "./store";
|
|
2
|
-
import { getTraceFilePath, isHeadless } from "../../utils";
|
|
2
|
+
import { getTraceFilePath, isHeadless, importModule } from "../../utils";
|
|
3
3
|
import * as fs from "fs-extra";
|
|
4
4
|
import { runApiGenerator } from "@intuned/runtime/dist/common/runApi";
|
|
5
|
-
import type { RequestMoreInfoDetails } from "@intuned/runtime/
|
|
5
|
+
import type { RequestMoreInfoDetails } from "@intuned/runtime/runtime";
|
|
6
6
|
|
|
7
7
|
export async function createAuthSession({
|
|
8
8
|
parameters,
|
|
@@ -53,8 +53,8 @@ export async function createAuthSession({
|
|
|
53
53
|
unknown
|
|
54
54
|
>({
|
|
55
55
|
automationFunction: {
|
|
56
|
-
|
|
57
|
-
params: parameters
|
|
56
|
+
module: await importModule("auth-sessions/create"),
|
|
57
|
+
params: parameters,
|
|
58
58
|
},
|
|
59
59
|
tracing: saveTrace
|
|
60
60
|
? {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getTraceFilePath,
|
|
3
|
+
importModule,
|
|
4
|
+
waitWithExtendableTimeout,
|
|
5
|
+
} from "../../utils";
|
|
2
6
|
import * as fs from "fs-extra";
|
|
3
7
|
import { getExecutionContext } from "@intuned/runtime";
|
|
4
8
|
import { backendFunctionsTokenManager } from "@intuned/runtime/dist/common/jwtTokenManager";
|
|
@@ -64,18 +68,18 @@ export async function runApi({
|
|
|
64
68
|
const resultWithTimeout = await waitWithExtendableTimeout({
|
|
65
69
|
promise: runApiInternal({
|
|
66
70
|
automationFunction: {
|
|
67
|
-
|
|
68
|
-
params
|
|
71
|
+
module: await importModule(`api/${functionName}`),
|
|
72
|
+
params,
|
|
69
73
|
},
|
|
70
|
-
auth:
|
|
71
|
-
?
|
|
72
|
-
: {
|
|
74
|
+
auth: isAuthSessionEnabled
|
|
75
|
+
? {
|
|
73
76
|
session: {
|
|
74
77
|
type: "state",
|
|
75
78
|
state: session,
|
|
76
79
|
},
|
|
77
80
|
runCheck: isAuthSessionEnabled,
|
|
78
|
-
}
|
|
81
|
+
}
|
|
82
|
+
: undefined,
|
|
79
83
|
runOptions: {
|
|
80
84
|
environment: "deployed",
|
|
81
85
|
headless,
|
|
@@ -6,52 +6,42 @@ import { getExecutionContext } from "@intuned/runtime";
|
|
|
6
6
|
import { app } from "./app";
|
|
7
7
|
import { RUN_ID_HEADER } from "./headers";
|
|
8
8
|
import { ShutdownController } from "./shutdown";
|
|
9
|
-
import { registerApiEndpoints } from "./api";
|
|
10
|
-
import { runJobsLoop } from "./jobs";
|
|
11
|
-
import { isJobRunMachine } from "./utils";
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
|
12
|
+
initializeAppInsights();
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
res.on("finish", () => {
|
|
23
|
-
console.log("finished", req.headers[RUN_ID_HEADER]);
|
|
24
|
-
void ShutdownController.instance.checkForShutdown();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
next();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
registerApiEndpoints();
|
|
31
|
-
if (isJobRunMachine()) {
|
|
32
|
-
console.log("Running in job v3 mode");
|
|
33
|
-
void runJobsLoop();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const server = app.listen(port, () => {
|
|
37
|
-
// when deployed on flyio, the server will be turned on and
|
|
38
|
-
// will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
|
|
39
|
-
ShutdownController.initialize(server);
|
|
14
|
+
app.use((req, res, next) => {
|
|
15
|
+
// Cleanup after the response is sent
|
|
16
|
+
res.on("finish", () => {
|
|
17
|
+
console.log("finished", req.headers[RUN_ID_HEADER]);
|
|
40
18
|
void ShutdownController.instance.checkForShutdown();
|
|
41
|
-
console.log(`Server is running on port ${port}`);
|
|
42
19
|
});
|
|
43
20
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
next();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export * from "./api";
|
|
25
|
+
export * from "./jobs";
|
|
26
|
+
|
|
27
|
+
const server = app.listen(port, () => {
|
|
28
|
+
// when deployed on flyio, the server will be turned on and
|
|
29
|
+
// will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
|
|
30
|
+
ShutdownController.initialize(server);
|
|
31
|
+
void ShutdownController.instance.checkForShutdown();
|
|
32
|
+
console.log(`Server is running on port ${port}`);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
36
|
+
const telemetryClient = getTelemetryClient();
|
|
37
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
38
|
+
const context = getExecutionContext();
|
|
39
|
+
telemetryClient?.trackEvent({
|
|
40
|
+
name: "UNHANDLED_REJECTION",
|
|
41
|
+
properties: {
|
|
42
|
+
runId: context?.runId,
|
|
43
|
+
promise,
|
|
44
|
+
reason,
|
|
45
|
+
},
|
|
56
46
|
});
|
|
57
|
-
}
|
|
47
|
+
});
|
package/WebTemplate/jobs.ts
CHANGED
|
@@ -6,7 +6,13 @@ import {
|
|
|
6
6
|
RUN_ID_HEADER,
|
|
7
7
|
SHOULD_SHUTDOWN_HEADER,
|
|
8
8
|
} from "./headers";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getErrorResponse,
|
|
11
|
+
isHeadless,
|
|
12
|
+
isJobRunMachine,
|
|
13
|
+
ProxyConfig,
|
|
14
|
+
proxyToUrl,
|
|
15
|
+
} from "./utils";
|
|
10
16
|
import {
|
|
11
17
|
callBackendFunctionWithToken,
|
|
12
18
|
backendFunctionsTokenManager,
|
|
@@ -26,6 +32,11 @@ type JobPayload = {
|
|
|
26
32
|
traceSignedUrl?: string;
|
|
27
33
|
};
|
|
28
34
|
|
|
35
|
+
if (isJobRunMachine()) {
|
|
36
|
+
console.log("Running in job v3 mode");
|
|
37
|
+
void jobsV3();
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
async function runApiInContext(
|
|
30
41
|
jobPayload: JobPayload
|
|
31
42
|
): Promise<Awaited<ReturnType<typeof runApi>>> {
|
|
@@ -72,7 +83,7 @@ async function runApiInContext(
|
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
|
|
75
|
-
|
|
86
|
+
async function jobsV3() {
|
|
76
87
|
await reportReady();
|
|
77
88
|
const initialDelay = 1000;
|
|
78
89
|
let delay = initialDelay;
|
package/WebTemplate/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as playwright from "@intuned/playwright-core";
|
|
2
2
|
import { Handler, Response } from "@tinyhttp/app";
|
|
3
3
|
import * as path from "path";
|
|
4
|
-
import { getExecutionContext } from "@intuned/runtime
|
|
4
|
+
import { getExecutionContext } from "@intuned/runtime";
|
|
5
5
|
import { setTimeout } from "timers/promises";
|
|
6
6
|
|
|
7
7
|
export class FunctionNotFoundError extends Error {
|
|
@@ -208,3 +208,53 @@ export async function waitWithExtendableTimeout<T>({
|
|
|
208
208
|
result: await promise,
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
+
|
|
212
|
+
export async function importModule(path: string) {
|
|
213
|
+
// cleanup environment variables before running the user code
|
|
214
|
+
// cleanEnvironmentVariables();
|
|
215
|
+
|
|
216
|
+
const [folderName, ...functionNameParts] = path.split("/");
|
|
217
|
+
const functionNameDepth = functionNameParts.length;
|
|
218
|
+
|
|
219
|
+
// string literals should be inline
|
|
220
|
+
// currently we support only 5 levels of depth
|
|
221
|
+
// rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
|
|
222
|
+
try {
|
|
223
|
+
let imported: any = undefined;
|
|
224
|
+
switch (functionNameDepth) {
|
|
225
|
+
case 1:
|
|
226
|
+
imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
|
|
227
|
+
break;
|
|
228
|
+
case 2:
|
|
229
|
+
imported = await import(
|
|
230
|
+
`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`
|
|
231
|
+
);
|
|
232
|
+
break;
|
|
233
|
+
case 3:
|
|
234
|
+
imported = await import(
|
|
235
|
+
`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`
|
|
236
|
+
);
|
|
237
|
+
break;
|
|
238
|
+
case 4:
|
|
239
|
+
imported = await import(
|
|
240
|
+
`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`
|
|
241
|
+
);
|
|
242
|
+
break;
|
|
243
|
+
case 5:
|
|
244
|
+
imported = await import(
|
|
245
|
+
`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`
|
|
246
|
+
);
|
|
247
|
+
break;
|
|
248
|
+
default:
|
|
249
|
+
throw new Error(
|
|
250
|
+
"intuned supports maximum 5 levels of depth in the api folder"
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return imported;
|
|
254
|
+
} catch (error: any) {
|
|
255
|
+
if (error.message.includes("Unknown variable dynamic import")) {
|
|
256
|
+
throw new FunctionNotFoundError("", path);
|
|
257
|
+
}
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
}
|
package/api/test2.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
import { extendTimeout } from "../src/runtime
|
|
3
|
-
import { requestOTP } from "../src/runtime/requestMoreInfo";
|
|
2
|
+
import { extendTimeout, extendPayload } from "../src/runtime";
|
|
4
3
|
|
|
5
|
-
export default async function
|
|
4
|
+
export default async function test2(
|
|
6
5
|
{ n }: { n?: number },
|
|
7
6
|
page: Page,
|
|
8
7
|
context: BrowserContext
|
|
@@ -10,8 +9,6 @@ export default async function* test2(
|
|
|
10
9
|
await page.goto("https://wikipedia.org/");
|
|
11
10
|
await page.waitForTimeout(1000);
|
|
12
11
|
|
|
13
|
-
yield requestOTP("Please enter the OTP");
|
|
14
|
-
|
|
15
12
|
const titles: string[] = [];
|
|
16
13
|
|
|
17
14
|
for (let i = 0; i < (n ?? 2); i++) {
|
|
@@ -21,5 +18,10 @@ export default async function* test2(
|
|
|
21
18
|
extendTimeout();
|
|
22
19
|
}
|
|
23
20
|
|
|
21
|
+
extendPayload({
|
|
22
|
+
api: "test",
|
|
23
|
+
parameters: {},
|
|
24
|
+
});
|
|
25
|
+
|
|
24
26
|
return { titles };
|
|
25
27
|
}
|
package/auth-sessions/check.ts
CHANGED
|
@@ -5,5 +5,7 @@ export default async function check(
|
|
|
5
5
|
_context: BrowserContext
|
|
6
6
|
): Promise<boolean> {
|
|
7
7
|
await page.goto("https://setcookie.net");
|
|
8
|
-
|
|
8
|
+
const result = (await page.locator("ul li code").all()).length > 0;
|
|
9
|
+
console.log("Check result", result);
|
|
10
|
+
return result;
|
|
9
11
|
}
|
package/auth-sessions/create.ts
CHANGED
|
@@ -15,16 +15,16 @@ export default async function* create(
|
|
|
15
15
|
await page.locator("#value").fill("password");
|
|
16
16
|
await page.locator("input[type=submit]").click();
|
|
17
17
|
|
|
18
|
-
console.log("Received", yield requestOTP("Enter useless otp"));
|
|
19
|
-
console.log(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
18
|
+
// console.log("Received", yield requestOTP("Enter useless otp"));
|
|
19
|
+
// console.log(
|
|
20
|
+
// "Received",
|
|
21
|
+
// yield requestMultipleChoice("Choose the correct answer", [
|
|
22
|
+
// "A",
|
|
23
|
+
// "B",
|
|
24
|
+
// "C",
|
|
25
|
+
// "D",
|
|
26
|
+
// ])
|
|
27
|
+
// );
|
|
28
28
|
|
|
29
29
|
await page.goto("http://www.sharonminsuk.com/code/storage-test.html");
|
|
30
30
|
await page.locator("#local").fill("intuned");
|
package/bin/intuned-api-run
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/api/run.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/auth-sessions/run-check.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/auth-sessions/run-create.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/auth-sessions/load.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/auth-sessions/run-refresh.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/browser/save-state.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/browser/start-browser.js");
|
package/bin/intuned-build
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/build.js");
|
package/bin/intuned-ts-check
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
void import("../dist/commands/ts-check.js");
|
package/dist/commands/api/run.js
CHANGED
|
@@ -16,6 +16,8 @@ var _Logger = require("../../common/Logger");
|
|
|
16
16
|
var _nanoid = require("nanoid");
|
|
17
17
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
18
|
var _runApi = require("../../common/runApi");
|
|
19
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
20
|
+
var _fileUtils = require("../common/utils/fileUtils");
|
|
19
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
22
|
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); }
|
|
21
23
|
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 && Object.prototype.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; }
|
|
@@ -36,10 +38,12 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
36
38
|
throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
const apiFilePath = (0, _fileUtils.getFullPathInProject)("api", `${apiName}.ts`);
|
|
42
|
+
const runApiModule = await (0, _tsNodeImport.tsNodeImport)(apiFilePath);
|
|
39
43
|
const runApiResult = await (0, _runApi.runApi)({
|
|
40
44
|
automationFunction: {
|
|
41
|
-
|
|
42
|
-
params: inputData
|
|
45
|
+
module: runApiModule,
|
|
46
|
+
params: inputData
|
|
43
47
|
},
|
|
44
48
|
auth: authSessionPathToUse ? {
|
|
45
49
|
session: {
|
|
@@ -8,6 +8,7 @@ var _settings = require("../common/utils/settings");
|
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _constants = require("../../common/constants");
|
|
10
10
|
var _runApi = require("../../common/runApi");
|
|
11
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
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); }
|
|
13
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 && Object.prototype.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; }
|
|
@@ -26,9 +27,10 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
26
27
|
if (!fs.exists(checkFilePath)) {
|
|
27
28
|
throw new Error("auth session check file not found");
|
|
28
29
|
}
|
|
30
|
+
const checkModule = await (0, _tsNodeImport.tsNodeImport)(checkFilePath);
|
|
29
31
|
const runApiResult = await (0, _runApi.runApi)({
|
|
30
32
|
automationFunction: {
|
|
31
|
-
|
|
33
|
+
module: checkModule
|
|
32
34
|
},
|
|
33
35
|
runOptions: {
|
|
34
36
|
environment: "ide",
|