@intuned/runtime-dev 0.0.1-testing.0 → 0.1.0-test.0
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/InterfaceTemplate/index.ts +1 -0
- package/Intuned.json +5 -0
- package/WebTemplate/api.ts +92 -90
- package/WebTemplate/controllers/authSessions/check.ts +23 -29
- package/WebTemplate/controllers/authSessions/create.ts +46 -71
- package/WebTemplate/controllers/authSessions/index.ts +4 -4
- package/WebTemplate/controllers/authSessions/killOperation.ts +1 -1
- package/WebTemplate/controllers/authSessions/resumeOperation.ts +28 -52
- package/WebTemplate/controllers/authSessions/store.ts +11 -6
- package/WebTemplate/controllers/runApi/helpers.ts +47 -144
- package/WebTemplate/index.playwright.ts +42 -32
- package/WebTemplate/index.vanilla.ts +2 -20
- package/WebTemplate/jobs.ts +2 -13
- package/WebTemplate/utils.ts +1 -85
- package/WebTemplate.zip +0 -0
- package/api/authed.ts +12 -0
- package/api/test.ts +3 -0
- package/api/test2.ts +25 -0
- package/auth-sessions/check.ts +9 -0
- package/auth-sessions/create.ts +32 -0
- package/authSessions +1 -0
- package/dist/commands/api/run.d.ts +1 -1
- package/dist/commands/api/run.js +28 -50
- package/dist/commands/auth-sessions/load.js +7 -1
- package/dist/commands/auth-sessions/run-check.js +23 -9
- package/dist/commands/auth-sessions/run-create.js +51 -30
- package/dist/commands/build.js +5 -2
- package/dist/commands/common/utils/settings.js +5 -5
- package/dist/commands/common/utils/unixSocket.d.ts +9 -0
- package/dist/commands/common/utils/unixSocket.js +45 -0
- package/dist/commands/interface/run.d.ts +2 -0
- package/dist/commands/interface/run.js +161 -0
- package/dist/common/asyncLocalStorage/index.d.ts +1 -1
- package/dist/common/contextStorageStateHelpers.d.ts +1 -2
- package/dist/common/contextStorageStateHelpers.js +9 -7
- package/dist/common/getPlaywrightConstructs.d.ts +7 -5
- package/dist/common/getPlaywrightConstructs.js +28 -11
- package/dist/common/runApi/errors.d.ts +71 -0
- package/dist/common/runApi/errors.js +172 -0
- package/dist/common/runApi/index.d.ts +12 -0
- package/dist/common/runApi/index.js +288 -0
- package/dist/common/runApi/types.d.ts +486 -0
- package/dist/common/runApi/types.js +50 -0
- package/dist/runtime/extendTimeout.js +10 -6
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/requestMoreInfo.d.ts +1 -0
- package/output.txt +39 -0
- package/package.json +7 -5
- package/testing +0 -0
- package/tsconfig.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as _ from "@intuned/runtime/dist/commands/interface/run";
|
package/Intuned.json
ADDED
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
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { getDownloadDirectoryPath } from "@intuned/runtime";
|
|
2
|
-
import { getProductionPlaywrightConstructs } from "@intuned/runtime";
|
|
3
|
-
import { checkAuthSessionWithRetries, isHeadless } from "../../utils";
|
|
4
|
-
import * as fs from "fs-extra";
|
|
5
1
|
import { readJSON } from "fs-extra";
|
|
2
|
+
import { isHeadless } from "../../utils";
|
|
3
|
+
import { runApi } from "@intuned/runtime/dist/common/runApi";
|
|
6
4
|
|
|
7
5
|
export async function checkAuthSession({
|
|
8
|
-
mode,
|
|
9
6
|
proxy,
|
|
10
7
|
session,
|
|
11
8
|
}: {
|
|
@@ -33,36 +30,33 @@ export async function checkAuthSession({
|
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const result = await runApi<boolean>({
|
|
34
|
+
automationFunction: {
|
|
35
|
+
name: "auth-sessions/check",
|
|
36
|
+
},
|
|
37
|
+
runOptions: {
|
|
38
|
+
environment: "deployed",
|
|
39
|
+
headless: isHeadless(),
|
|
40
|
+
proxy,
|
|
41
|
+
},
|
|
42
|
+
auth: {
|
|
43
|
+
session: {
|
|
44
|
+
type: "state",
|
|
45
|
+
state: session,
|
|
42
46
|
},
|
|
47
|
+
runCheck: false,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
if (result.isErr()) {
|
|
51
|
+
return {
|
|
52
|
+
status: 500,
|
|
53
|
+
body: result.error,
|
|
43
54
|
};
|
|
44
55
|
}
|
|
45
|
-
|
|
46
|
-
const downloadsPath = getDownloadDirectoryPath();
|
|
47
|
-
const headless = isHeadless();
|
|
48
|
-
const { page, context } = await getProductionPlaywrightConstructs({
|
|
49
|
-
headless,
|
|
50
|
-
proxy,
|
|
51
|
-
downloadsPath,
|
|
52
|
-
storageState: session,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const authSessionCheckResult = await checkAuthSessionWithRetries(
|
|
56
|
-
page,
|
|
57
|
-
context,
|
|
58
|
-
2
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
await fs.remove(downloadsPath);
|
|
62
56
|
return {
|
|
63
57
|
status: 200,
|
|
64
58
|
body: {
|
|
65
|
-
result:
|
|
59
|
+
result: result.value.result,
|
|
66
60
|
},
|
|
67
61
|
};
|
|
68
62
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { authSessionsContextsStore } from "./store";
|
|
2
|
-
import {
|
|
3
|
-
import { getDownloadDirectoryPath } from "@intuned/runtime";
|
|
4
|
-
import { getProductionPlaywrightConstructs } from "@intuned/runtime";
|
|
5
|
-
import { callFunction, getTraceFilePath, isHeadless } from "../../utils";
|
|
2
|
+
import { getTraceFilePath, isHeadless } from "../../utils";
|
|
6
3
|
import * as fs from "fs-extra";
|
|
7
|
-
import {
|
|
4
|
+
import { runApiGenerator } from "@intuned/runtime/dist/common/runApi";
|
|
5
|
+
import type { RequestMoreInfoDetails } from "@intuned/runtime/dist/runtime";
|
|
8
6
|
|
|
9
7
|
export async function createAuthSession({
|
|
10
8
|
parameters,
|
|
11
9
|
operationId,
|
|
12
|
-
mode,
|
|
13
10
|
proxy,
|
|
14
11
|
saveTrace,
|
|
15
12
|
}: {
|
|
@@ -36,16 +33,6 @@ export async function createAuthSession({
|
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
if (mode !== "async") {
|
|
40
|
-
return {
|
|
41
|
-
status: 400,
|
|
42
|
-
body: {
|
|
43
|
-
error: "Invalid Request",
|
|
44
|
-
message: "only async mode is supported",
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
36
|
if (authSessionsContextsStore.has(operationId)) {
|
|
50
37
|
return {
|
|
51
38
|
status: 400,
|
|
@@ -56,73 +43,61 @@ export async function createAuthSession({
|
|
|
56
43
|
},
|
|
57
44
|
};
|
|
58
45
|
}
|
|
59
|
-
const downloadsPath = getDownloadDirectoryPath();
|
|
60
46
|
const headless = isHeadless();
|
|
61
|
-
const { page, context } = await getProductionPlaywrightConstructs({
|
|
62
|
-
headless,
|
|
63
|
-
proxy,
|
|
64
|
-
downloadsPath,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
if (saveTrace) {
|
|
69
|
-
try {
|
|
70
|
-
await context.tracing.start({ screenshots: true, snapshots: true });
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error("Error starting trace", error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
47
|
|
|
76
|
-
|
|
77
|
-
AUTH_SESSIONS_FOLDER_NAME,
|
|
78
|
-
"create",
|
|
79
|
-
[parameters ?? {}, page, context]
|
|
80
|
-
);
|
|
48
|
+
const abortController = new AbortController();
|
|
81
49
|
|
|
82
|
-
|
|
50
|
+
const createGenerator = runApiGenerator<
|
|
51
|
+
void,
|
|
52
|
+
RequestMoreInfoDetails,
|
|
53
|
+
unknown
|
|
54
|
+
>({
|
|
55
|
+
automationFunction: {
|
|
56
|
+
name: "auth-sessions/create",
|
|
57
|
+
params: parameters ?? {},
|
|
58
|
+
},
|
|
59
|
+
tracing: saveTrace
|
|
60
|
+
? {
|
|
61
|
+
enabled: true,
|
|
62
|
+
filePath: getTraceFilePath(operationId),
|
|
63
|
+
}
|
|
64
|
+
: { enabled: false },
|
|
65
|
+
runOptions: {
|
|
66
|
+
environment: "deployed",
|
|
67
|
+
headless,
|
|
68
|
+
proxy,
|
|
69
|
+
},
|
|
70
|
+
abortSignal: abortController.signal,
|
|
71
|
+
retrieveSession: true,
|
|
72
|
+
});
|
|
83
73
|
|
|
84
|
-
|
|
74
|
+
const result = await createGenerator.next();
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const traceFilePath = getTraceFilePath(operationId);
|
|
90
|
-
await context.tracing.stop({ path: traceFilePath });
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error("Error stopping trace", error);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const fullSessionState = await getContextStorageState(context);
|
|
96
|
-
await context.close();
|
|
76
|
+
if (result.done) {
|
|
77
|
+
const r = result.value;
|
|
97
78
|
|
|
79
|
+
if (r.isErr()) {
|
|
98
80
|
return {
|
|
99
|
-
status:
|
|
100
|
-
body:
|
|
81
|
+
status: 500,
|
|
82
|
+
body: r.error,
|
|
101
83
|
};
|
|
102
84
|
}
|
|
103
85
|
|
|
104
|
-
authSessionsContextsStore.set(operationId, {
|
|
105
|
-
done: false,
|
|
106
|
-
generator: operationGenerator,
|
|
107
|
-
context,
|
|
108
|
-
requestInfo: result.value,
|
|
109
|
-
saveTrace,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
86
|
return {
|
|
113
87
|
status: 200,
|
|
114
|
-
body:
|
|
88
|
+
body: { ...r.value.session, status: 200 },
|
|
115
89
|
};
|
|
116
|
-
} catch (e) {
|
|
117
|
-
if (saveTrace) {
|
|
118
|
-
try {
|
|
119
|
-
const traceFilePath = getTraceFilePath(operationId);
|
|
120
|
-
await context.tracing.stop({ path: traceFilePath });
|
|
121
|
-
} catch (error) {
|
|
122
|
-
console.error("Error stopping trace", error);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
throw e;
|
|
127
90
|
}
|
|
91
|
+
|
|
92
|
+
authSessionsContextsStore.set(operationId, {
|
|
93
|
+
done: false,
|
|
94
|
+
generator: createGenerator,
|
|
95
|
+
requestInfo: result.value,
|
|
96
|
+
abortController,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
status: 200,
|
|
101
|
+
body: result.value,
|
|
102
|
+
};
|
|
128
103
|
}
|
|
@@ -10,7 +10,7 @@ export const {
|
|
|
10
10
|
} = makeEndpointControllers({
|
|
11
11
|
requestId: (req) => `createAuthSession ${req.body.operationId}`,
|
|
12
12
|
handler: createAuthSession,
|
|
13
|
-
parameters: (req) => [req.body],
|
|
13
|
+
parameters: (req): [any] => [req.body],
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export const {
|
|
@@ -19,7 +19,7 @@ export const {
|
|
|
19
19
|
} = makeEndpointControllers({
|
|
20
20
|
requestId: "checkAuthSession",
|
|
21
21
|
handler: checkAuthSession,
|
|
22
|
-
parameters: (req) => [req.body],
|
|
22
|
+
parameters: (req): [any] => [req.body],
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
export const {
|
|
@@ -28,7 +28,7 @@ export const {
|
|
|
28
28
|
} = makeEndpointControllers({
|
|
29
29
|
requestId: (req) => `killAuthSessionOperation ${req.body.operationId}`,
|
|
30
30
|
handler: killAuthSessionOperation,
|
|
31
|
-
parameters: (req) => [req.body],
|
|
31
|
+
parameters: (req): [any] => [req.body],
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export const {
|
|
@@ -37,5 +37,5 @@ export const {
|
|
|
37
37
|
} = makeEndpointControllers({
|
|
38
38
|
requestId: (req) => `resumeAuthSessionOperation ${req.body.operationId}`,
|
|
39
39
|
handler: resumeAuthSessionOperation,
|
|
40
|
-
parameters: (req) => [req.body],
|
|
40
|
+
parameters: (req): [any] => [req.body],
|
|
41
41
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { authSessionsContextsStore } from "./store";
|
|
2
|
-
import { getContextStorageState } from "@intuned/runtime/dist/common/contextStorageStateHelpers";
|
|
3
|
-
import { getTraceFilePath } from "../../utils";
|
|
4
2
|
|
|
5
3
|
export async function resumeAuthSessionOperation({
|
|
6
4
|
operationId,
|
|
@@ -20,61 +18,39 @@ export async function resumeAuthSessionOperation({
|
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const result = await operation.generator.next(input);
|
|
21
|
+
if (
|
|
22
|
+
operation.requestInfo.requestType === "multiple_choice" &&
|
|
23
|
+
!operation.requestInfo.choices.includes(input)
|
|
24
|
+
) {
|
|
25
|
+
return {
|
|
26
|
+
status: 400,
|
|
27
|
+
body: {
|
|
28
|
+
error: "Invalid Request",
|
|
29
|
+
message: "input does not match any of the choices",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
done: result.done,
|
|
41
|
-
generator: operation.generator,
|
|
42
|
-
context: operation.context,
|
|
43
|
-
requestInfo: result.value,
|
|
44
|
-
saveTrace: operation.saveTrace,
|
|
45
|
-
});
|
|
34
|
+
const result = await operation.generator.next(input);
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
await operation.context.tracing.stop({ path: traceFilePath });
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error("Error stopping trace", error);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const storageState = await getContextStorageState(operation.context);
|
|
57
|
-
await operation.context.browser()?.close();
|
|
58
|
-
authSessionsContextsStore.delete(operationId);
|
|
59
|
-
return {
|
|
60
|
-
status: 200,
|
|
61
|
-
body: storageState,
|
|
62
|
-
};
|
|
36
|
+
if (result.done) {
|
|
37
|
+
authSessionsContextsStore.delete(operationId);
|
|
38
|
+
if (result.value.isErr()) {
|
|
39
|
+
return result.value.error.apiResponse;
|
|
63
40
|
}
|
|
64
|
-
|
|
65
41
|
return {
|
|
66
42
|
status: 200,
|
|
67
|
-
body: result.value,
|
|
43
|
+
body: result.value.value.session,
|
|
68
44
|
};
|
|
69
|
-
} catch (e) {
|
|
70
|
-
if (operation.saveTrace) {
|
|
71
|
-
try {
|
|
72
|
-
const traceFilePath = getTraceFilePath(operationId);
|
|
73
|
-
await operation.context.tracing.stop({ path: traceFilePath });
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error("Error stopping trace", error);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
throw e;
|
|
79
45
|
}
|
|
46
|
+
|
|
47
|
+
authSessionsContextsStore.set(operationId, {
|
|
48
|
+
...operation,
|
|
49
|
+
requestInfo: result.value,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
status: 200,
|
|
54
|
+
body: result.value,
|
|
55
|
+
};
|
|
80
56
|
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { RequestMoreInfoDetails } from "@intuned/runtime/dist/runtime";
|
|
2
|
+
import type {
|
|
3
|
+
RunApiResult,
|
|
4
|
+
RunApiResultWithSessionOk,
|
|
5
|
+
} from "@intuned/runtime/dist/common/runApi";
|
|
4
6
|
|
|
5
7
|
export const authSessionsContextsStore = new Map<
|
|
6
8
|
string,
|
|
7
9
|
{
|
|
8
10
|
done: boolean | undefined;
|
|
9
|
-
generator: AsyncGenerator<
|
|
10
|
-
|
|
11
|
+
generator: AsyncGenerator<
|
|
12
|
+
RequestMoreInfoDetails,
|
|
13
|
+
RunApiResult<void, RunApiResultWithSessionOk>,
|
|
14
|
+
string
|
|
15
|
+
>;
|
|
11
16
|
requestInfo: RequestMoreInfoDetails;
|
|
12
|
-
|
|
17
|
+
abortController: AbortController;
|
|
13
18
|
}
|
|
14
19
|
>();
|