@intuned/runtime-dev 0.1.0-test.19 → 0.1.0-test.2
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 +92 -90
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +7 -11
- package/WebTemplate/index.playwright.ts +42 -32
- package/WebTemplate/jobs.ts +2 -13
- package/WebTemplate/utils.ts +1 -51
- package/api/test2.ts +5 -7
- package/auth-sessions/check.ts +1 -3
- 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 +2 -6
- package/dist/commands/auth-sessions/run-check.js +1 -3
- package/dist/commands/auth-sessions/run-create.js +2 -4
- package/dist/commands/build.js +4 -7
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getDefaultExportFromFile.d.ts +1 -0
- package/dist/commands/common/{tsNodeImport.js → getDefaultExportFromFile.js} +4 -3
- package/dist/commands/common/getFirstLineNumber.test.js +2 -2
- package/dist/commands/common/utils/settings.js +1 -1
- package/dist/commands/common/utils/webTemplate.js +2 -2
- package/dist/commands/interface/run.js +119 -143
- 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 +68 -27
- package/dist/common/runApi/types.d.ts +6 -20
- package/dist/common/runApi/types.js +1 -5
- 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/tsconfig.json +1 -1
- package/dist/commands/common/tsNodeImport.d.ts +0 -1
- package/preserve-dynamic-imports.js +0 -16
package/Intuned.json
CHANGED
package/WebTemplate/api.ts
CHANGED
|
@@ -33,107 +33,109 @@ 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
|
-
|
|
36
|
+
export function registerApiEndpoints() {
|
|
37
|
+
if (!isJobRunMachine()) {
|
|
38
|
+
app.use((req, _, next) => {
|
|
39
|
+
const runId = req.headers[RUN_ID_HEADER] as string;
|
|
40
|
+
const jobId = req.headers[JOB_ID_HEADER] as string;
|
|
41
|
+
const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
|
|
42
|
+
const queueId = req.headers[QUEUE_ID_HEADER] as string;
|
|
43
|
+
const proxy = req?.body?.proxy
|
|
44
|
+
? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
|
|
45
|
+
: undefined;
|
|
46
|
+
const contextData = {
|
|
47
|
+
runId: runId ?? "",
|
|
48
|
+
jobId,
|
|
49
|
+
jobRunId,
|
|
50
|
+
queueId,
|
|
51
|
+
proxy,
|
|
52
|
+
...(req?.body?.executionContext ?? {}),
|
|
53
|
+
};
|
|
54
|
+
runWithContext(contextData, next);
|
|
55
|
+
});
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
app.get(
|
|
58
|
+
"/api/protected/health",
|
|
59
|
+
accessKeyValidatorMiddleware,
|
|
60
|
+
async (req, res) => {
|
|
61
|
+
res.status(200).json({ status: "ok" });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
app.post(
|
|
66
|
+
"/api/auth-session/create",
|
|
67
|
+
accessKeyValidatorMiddleware,
|
|
68
|
+
errorRetryMiddleware(createAuthSessionController)
|
|
69
|
+
);
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
app.post(
|
|
72
|
+
"/api/auth-session-async/create",
|
|
73
|
+
accessKeyValidatorMiddleware,
|
|
74
|
+
errorRetryMiddleware(createAuthSessionAsyncController)
|
|
75
|
+
);
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
app.post(
|
|
78
|
+
"/api/auth-session/check",
|
|
79
|
+
accessKeyValidatorMiddleware,
|
|
80
|
+
errorRetryMiddleware(checkAuthSessionController)
|
|
81
|
+
);
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
app.post(
|
|
84
|
+
"/api/auth-session-async/check",
|
|
85
|
+
accessKeyValidatorMiddleware,
|
|
86
|
+
errorRetryMiddleware(checkAuthSessionAsyncController)
|
|
87
|
+
);
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
app.post(
|
|
90
|
+
"/api/auth-session/kill",
|
|
91
|
+
accessKeyValidatorMiddleware,
|
|
92
|
+
errorRetryMiddleware(killAuthSessionOperationController)
|
|
93
|
+
);
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
app.post(
|
|
96
|
+
"/api/auth-session/resume",
|
|
97
|
+
accessKeyValidatorMiddleware,
|
|
98
|
+
errorRetryMiddleware(resumeAuthSessionOperationController)
|
|
99
|
+
);
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
app.post(
|
|
102
|
+
"/api/auth-session-async/resume",
|
|
103
|
+
accessKeyValidatorMiddleware,
|
|
104
|
+
errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
|
|
105
|
+
);
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
app.post(
|
|
108
|
+
"/api/run/*",
|
|
109
|
+
accessKeyValidatorMiddleware,
|
|
110
|
+
errorRetryMiddleware(runApiController)
|
|
111
|
+
);
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
app.post(
|
|
114
|
+
"/api/run-async/start/*",
|
|
115
|
+
accessKeyValidatorMiddleware,
|
|
116
|
+
errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
|
|
117
|
+
);
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
app.get(
|
|
120
|
+
"/api/run-async/count",
|
|
121
|
+
accessKeyValidatorMiddleware,
|
|
122
|
+
getActiveAsyncEndpointController
|
|
123
|
+
);
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
app.post(
|
|
126
|
+
"/api/trace/upload/:runId",
|
|
127
|
+
accessKeyValidatorMiddleware,
|
|
128
|
+
uploadTraceController
|
|
129
|
+
);
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
131
|
+
app.post(
|
|
132
|
+
"/api/trace/delete/:runId",
|
|
133
|
+
accessKeyValidatorMiddleware,
|
|
134
|
+
deleteTraceController
|
|
135
|
+
);
|
|
136
|
+
}
|
|
136
137
|
|
|
137
|
-
app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
|
|
138
|
-
|
|
139
|
-
});
|
|
138
|
+
app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
|
|
139
|
+
res.status(200).json({ features: FEATURES });
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -2,7 +2,7 @@ import { authSessionsContextsStore } from "./store";
|
|
|
2
2
|
import { getTraceFilePath, isHeadless } 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/runtime";
|
|
5
|
+
import type { RequestMoreInfoDetails } from "@intuned/runtime/dist/runtime";
|
|
6
6
|
|
|
7
7
|
export async function createAuthSession({
|
|
8
8
|
parameters,
|
|
@@ -54,7 +54,7 @@ export async function createAuthSession({
|
|
|
54
54
|
>({
|
|
55
55
|
automationFunction: {
|
|
56
56
|
name: "auth-sessions/create",
|
|
57
|
-
params: parameters,
|
|
57
|
+
params: parameters ?? {},
|
|
58
58
|
},
|
|
59
59
|
tracing: saveTrace
|
|
60
60
|
? {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTraceFilePath,
|
|
3
|
-
importModule,
|
|
4
|
-
waitWithExtendableTimeout,
|
|
5
|
-
} from "../../utils";
|
|
1
|
+
import { getTraceFilePath, waitWithExtendableTimeout } from "../../utils";
|
|
6
2
|
import * as fs from "fs-extra";
|
|
7
3
|
import { getExecutionContext } from "@intuned/runtime";
|
|
8
4
|
import { backendFunctionsTokenManager } from "@intuned/runtime/dist/common/jwtTokenManager";
|
|
@@ -68,18 +64,18 @@ export async function runApi({
|
|
|
68
64
|
const resultWithTimeout = await waitWithExtendableTimeout({
|
|
69
65
|
promise: runApiInternal({
|
|
70
66
|
automationFunction: {
|
|
71
|
-
|
|
72
|
-
params,
|
|
67
|
+
name: `api/${functionName}`,
|
|
68
|
+
params: params ?? {},
|
|
73
69
|
},
|
|
74
|
-
auth: isAuthSessionEnabled
|
|
75
|
-
?
|
|
70
|
+
auth: !isAuthSessionEnabled
|
|
71
|
+
? undefined
|
|
72
|
+
: {
|
|
76
73
|
session: {
|
|
77
74
|
type: "state",
|
|
78
75
|
state: session,
|
|
79
76
|
},
|
|
80
77
|
runCheck: isAuthSessionEnabled,
|
|
81
|
-
}
|
|
82
|
-
: undefined,
|
|
78
|
+
},
|
|
83
79
|
runOptions: {
|
|
84
80
|
environment: "deployed",
|
|
85
81
|
headless,
|
|
@@ -6,42 +6,52 @@ 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";
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
void main();
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
async function main() {
|
|
16
|
+
const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
initializeAppInsights();
|
|
19
|
+
|
|
20
|
+
app.use((req, res, next) => {
|
|
21
|
+
// Cleanup after the response is sent
|
|
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);
|
|
18
40
|
void ShutdownController.instance.checkForShutdown();
|
|
41
|
+
console.log(`Server is running on port ${port}`);
|
|
19
42
|
});
|
|
20
43
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
},
|
|
44
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
45
|
+
const telemetryClient = getTelemetryClient();
|
|
46
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
47
|
+
const context = getExecutionContext();
|
|
48
|
+
telemetryClient?.trackEvent({
|
|
49
|
+
name: "UNHANDLED_REJECTION",
|
|
50
|
+
properties: {
|
|
51
|
+
runId: context?.runId,
|
|
52
|
+
promise,
|
|
53
|
+
reason,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
46
56
|
});
|
|
47
|
-
}
|
|
57
|
+
}
|
package/WebTemplate/jobs.ts
CHANGED
|
@@ -6,13 +6,7 @@ import {
|
|
|
6
6
|
RUN_ID_HEADER,
|
|
7
7
|
SHOULD_SHUTDOWN_HEADER,
|
|
8
8
|
} from "./headers";
|
|
9
|
-
import {
|
|
10
|
-
getErrorResponse,
|
|
11
|
-
isHeadless,
|
|
12
|
-
isJobRunMachine,
|
|
13
|
-
ProxyConfig,
|
|
14
|
-
proxyToUrl,
|
|
15
|
-
} from "./utils";
|
|
9
|
+
import { getErrorResponse, isHeadless, ProxyConfig, proxyToUrl } from "./utils";
|
|
16
10
|
import {
|
|
17
11
|
callBackendFunctionWithToken,
|
|
18
12
|
backendFunctionsTokenManager,
|
|
@@ -32,11 +26,6 @@ type JobPayload = {
|
|
|
32
26
|
traceSignedUrl?: string;
|
|
33
27
|
};
|
|
34
28
|
|
|
35
|
-
if (isJobRunMachine()) {
|
|
36
|
-
console.log("Running in job v3 mode");
|
|
37
|
-
void jobsV3();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
async function runApiInContext(
|
|
41
30
|
jobPayload: JobPayload
|
|
42
31
|
): Promise<Awaited<ReturnType<typeof runApi>>> {
|
|
@@ -83,7 +72,7 @@ async function runApiInContext(
|
|
|
83
72
|
}
|
|
84
73
|
}
|
|
85
74
|
|
|
86
|
-
async function
|
|
75
|
+
export async function runJobsLoop() {
|
|
87
76
|
await reportReady();
|
|
88
77
|
const initialDelay = 1000;
|
|
89
78
|
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/dist/common/asyncLocalStorage";
|
|
5
5
|
import { setTimeout } from "timers/promises";
|
|
6
6
|
|
|
7
7
|
export class FunctionNotFoundError extends Error {
|
|
@@ -208,53 +208,3 @@ 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,7 +1,8 @@
|
|
|
1
1
|
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
import { extendTimeout
|
|
2
|
+
import { extendTimeout } from "../src/runtime/extendTimeout";
|
|
3
|
+
import { requestOTP } from "../src/runtime/requestMoreInfo";
|
|
3
4
|
|
|
4
|
-
export default async function test2(
|
|
5
|
+
export default async function* test2(
|
|
5
6
|
{ n }: { n?: number },
|
|
6
7
|
page: Page,
|
|
7
8
|
context: BrowserContext
|
|
@@ -9,6 +10,8 @@ export default async function test2(
|
|
|
9
10
|
await page.goto("https://wikipedia.org/");
|
|
10
11
|
await page.waitForTimeout(1000);
|
|
11
12
|
|
|
13
|
+
yield requestOTP("Please enter the OTP");
|
|
14
|
+
|
|
12
15
|
const titles: string[] = [];
|
|
13
16
|
|
|
14
17
|
for (let i = 0; i < (n ?? 2); i++) {
|
|
@@ -18,10 +21,5 @@ export default async function test2(
|
|
|
18
21
|
extendTimeout();
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
extendPayload({
|
|
22
|
-
api: "test",
|
|
23
|
-
parameters: {},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
24
|
return { titles };
|
|
27
25
|
}
|
package/auth-sessions/check.ts
CHANGED
|
@@ -5,7 +5,5 @@ export default async function check(
|
|
|
5
5
|
_context: BrowserContext
|
|
6
6
|
): Promise<boolean> {
|
|
7
7
|
await page.goto("https://setcookie.net");
|
|
8
|
-
|
|
9
|
-
console.log("Check result", result);
|
|
10
|
-
return result;
|
|
8
|
+
return (await page.locator("ul li code").all()).length > 0;
|
|
11
9
|
}
|
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
|
-
|
|
19
|
-
|
|
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
|
+
require("../dist/commands/api/run.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/auth-sessions/run-check.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/auth-sessions/run-create.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/auth-sessions/load.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/auth-sessions/run-refresh.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/browser/save-state.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/browser/start-browser.js");
|
package/bin/intuned-build
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/build.js");
|
package/bin/intuned-ts-check
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
require("../dist/commands/ts-check.js");
|
package/dist/commands/api/run.js
CHANGED
|
@@ -16,8 +16,6 @@ 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");
|
|
21
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
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); }
|
|
23
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 && 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; }
|
|
@@ -38,12 +36,10 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
38
36
|
throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
|
-
const apiFilePath = (0, _fileUtils.getFullPathInProject)("api", `${apiName}.ts`);
|
|
42
|
-
const runApiModule = await (0, _tsNodeImport.tsNodeImport)(apiFilePath);
|
|
43
39
|
const runApiResult = await (0, _runApi.runApi)({
|
|
44
40
|
automationFunction: {
|
|
45
|
-
|
|
46
|
-
params: inputData
|
|
41
|
+
name: `api/${apiName}`,
|
|
42
|
+
params: inputData ?? {}
|
|
47
43
|
},
|
|
48
44
|
auth: authSessionPathToUse ? {
|
|
49
45
|
session: {
|
|
@@ -8,7 +8,6 @@ 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");
|
|
12
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
12
|
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); }
|
|
14
13
|
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; }
|
|
@@ -27,10 +26,9 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
27
26
|
if (!fs.exists(checkFilePath)) {
|
|
28
27
|
throw new Error("auth session check file not found");
|
|
29
28
|
}
|
|
30
|
-
const checkModule = await (0, _tsNodeImport.tsNodeImport)(checkFilePath);
|
|
31
29
|
const runApiResult = await (0, _runApi.runApi)({
|
|
32
30
|
automationFunction: {
|
|
33
|
-
|
|
31
|
+
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
34
32
|
},
|
|
35
33
|
runOptions: {
|
|
36
34
|
environment: "ide",
|
|
@@ -12,7 +12,6 @@ var _runApi = require("../../common/runApi");
|
|
|
12
12
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
13
13
|
var _nanoid = require("nanoid");
|
|
14
14
|
var _enums = require("../../runtime/enums");
|
|
15
|
-
var _tsNodeImport = require("../common/tsNodeImport");
|
|
16
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
16
|
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
17
|
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; }
|
|
@@ -41,12 +40,11 @@ _commander.program.description("run auth session create").option("--cdpAddress <
|
|
|
41
40
|
if (!fs.exists(createFilePath)) {
|
|
42
41
|
throw new Error("auth session create file not found");
|
|
43
42
|
}
|
|
44
|
-
const createModule = await (0, _tsNodeImport.tsNodeImport)(createFilePath);
|
|
45
43
|
async function runCreate() {
|
|
46
44
|
const generator = (0, _runApi.runApiGenerator)({
|
|
47
45
|
automationFunction: {
|
|
48
|
-
|
|
49
|
-
params: inputData
|
|
46
|
+
name: "auth-sessions/create",
|
|
47
|
+
params: inputData ?? {}
|
|
50
48
|
},
|
|
51
49
|
runOptions: {
|
|
52
50
|
environment: "ide",
|