@intuned/runtime-dev 0.1.0-test.19 → 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.
|
@@ -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,5 +1,5 @@
|
|
|
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
5
|
import type { RequestMoreInfoDetails } from "@intuned/runtime/runtime";
|
|
@@ -53,7 +53,7 @@ export async function createAuthSession({
|
|
|
53
53
|
unknown
|
|
54
54
|
>({
|
|
55
55
|
automationFunction: {
|
|
56
|
-
|
|
56
|
+
module: await importModule("auth-sessions/create"),
|
|
57
57
|
params: parameters,
|
|
58
58
|
},
|
|
59
59
|
tracing: saveTrace
|
|
@@ -14,6 +14,23 @@ var _jwtTokenManager = require("src/common/jwtTokenManager");
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
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); }
|
|
16
16
|
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; }
|
|
17
|
+
const startRunApiSchema = _zod.default.object({
|
|
18
|
+
type: _zod.default.literal("start"),
|
|
19
|
+
parameters: _runApi.runApiParametersSchema.extend({
|
|
20
|
+
automationFunction: _runApi.runApiParametersSchema.shape.automationFunction.omit({
|
|
21
|
+
module: true
|
|
22
|
+
}).extend({
|
|
23
|
+
name: _zod.default.string()
|
|
24
|
+
}),
|
|
25
|
+
retrieveSession: _zod.default.boolean(),
|
|
26
|
+
context: _zod.default.object({
|
|
27
|
+
jobId: _zod.default.string().optional(),
|
|
28
|
+
jobRunId: _zod.default.string().optional(),
|
|
29
|
+
runId: _zod.default.string().optional(),
|
|
30
|
+
queueId: _zod.default.string().optional()
|
|
31
|
+
}).optional()
|
|
32
|
+
})
|
|
33
|
+
});
|
|
17
34
|
const nextRunApiSchema = _zod.default.object({
|
|
18
35
|
type: _zod.default.literal("next"),
|
|
19
36
|
parameters: _zod.default.object({
|
|
@@ -30,29 +47,12 @@ const tokenUpdateSchema = _zod.default.object({
|
|
|
30
47
|
functionsToken: _zod.default.string()
|
|
31
48
|
})
|
|
32
49
|
});
|
|
50
|
+
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema]);
|
|
33
51
|
_dotenv.default.config({
|
|
34
52
|
path: `.env`
|
|
35
53
|
});
|
|
36
54
|
function main(importFunction) {
|
|
37
55
|
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
|
|
38
|
-
const startRunApiSchema = _zod.default.object({
|
|
39
|
-
type: _zod.default.literal("start"),
|
|
40
|
-
parameters: _runApi.runApiParametersSchema.extend({
|
|
41
|
-
automationFunction: _runApi.runApiParametersSchema.shape.automationFunction.omit({
|
|
42
|
-
module: true
|
|
43
|
-
}).extend({
|
|
44
|
-
name: _zod.default.string()
|
|
45
|
-
}),
|
|
46
|
-
retrieveSession: _zod.default.boolean(),
|
|
47
|
-
context: _zod.default.object({
|
|
48
|
-
jobId: _zod.default.string().optional(),
|
|
49
|
-
jobRunId: _zod.default.string().optional(),
|
|
50
|
-
runId: _zod.default.string().optional(),
|
|
51
|
-
queueId: _zod.default.string().optional()
|
|
52
|
-
}).optional()
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema]);
|
|
56
56
|
let context;
|
|
57
57
|
const throttleTime = 1_000;
|
|
58
58
|
let timeoutTimestamp = Date.now();
|
|
@@ -227,20 +227,20 @@ async function checkAuthSessionWithRetries(page, context, retries = 3) {
|
|
|
227
227
|
}
|
|
228
228
|
return (0, _neverthrow.ok)(false);
|
|
229
229
|
}
|
|
230
|
-
async function validateModule(
|
|
231
|
-
if (!
|
|
230
|
+
async function validateModule(moduleToValidate) {
|
|
231
|
+
if (!moduleToValidate || !moduleToValidate.default || !moduleToValidate.default.constructor) {
|
|
232
232
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default export"));
|
|
233
233
|
}
|
|
234
|
-
if (
|
|
234
|
+
if (moduleToValidate.default.constructor.name === "AsyncGeneratorFunction") {
|
|
235
235
|
return (0, _neverthrow.ok)({
|
|
236
236
|
type: "async-generator",
|
|
237
|
-
generator:
|
|
237
|
+
generator: moduleToValidate.default
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
-
if (
|
|
240
|
+
if (moduleToValidate.default.constructor.name === "AsyncFunction") {
|
|
241
241
|
return (0, _neverthrow.ok)({
|
|
242
242
|
type: "async",
|
|
243
|
-
func:
|
|
243
|
+
func: moduleToValidate.default
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default async function/generator export"));
|