@intuned/runtime-dev 0.1.0-test.9 → 1.0.0-udas.1
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/.babelrc +0 -2
- package/InterfaceTemplate/index.playwright.ts +5 -0
- package/InterfaceTemplate/utils.ts +39 -0
- package/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/async.ts +52 -48
- package/WebTemplate/controllers/authSessions/check.ts +4 -5
- package/WebTemplate/controllers/authSessions/create.ts +6 -8
- package/WebTemplate/controllers/authSessions/resumeOperation.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +13 -8
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +48 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +7 -5
- package/dist/commands/auth-sessions/run-check.js +9 -3
- package/dist/commands/auth-sessions/run-create.js +11 -6
- package/dist/commands/build.js +17 -12
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +20 -0
- package/dist/commands/common/utils/settings.js +5 -5
- package/dist/commands/common/utils/template.d.ts +2 -0
- package/dist/commands/common/utils/{webTemplate.js → template.js} +7 -7
- package/dist/commands/interface/run.d.ts +1 -2
- package/dist/commands/interface/run.js +150 -110
- package/dist/commands/ts-check.js +9 -7
- package/dist/common/formatZodError.d.ts +2 -0
- package/dist/common/formatZodError.js +18 -0
- package/dist/common/getPlaywrightConstructs.js +6 -2
- package/dist/common/runApi/errors.d.ts +8 -3
- package/dist/common/runApi/errors.js +26 -3
- package/dist/common/runApi/index.d.ts +1 -1
- package/dist/common/runApi/index.js +37 -65
- package/dist/common/runApi/types.d.ts +287 -71
- package/dist/common/runApi/types.js +29 -5
- package/dist/runtime/executionHelpers.test.js +6 -6
- package/package.json +1 -1
- package/tsconfig.json +1 -2
- package/InterfaceTemplate/index.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -17
- package/dist/commands/common/utils/webTemplate.d.ts +0 -1
- package/preserve-dynamic-imports.js +0 -16
- package/testing +0 -0
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
"use strict";
|
|
3
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAutomationCLI = runAutomationCLI;
|
|
4
7
|
var _commander = require("commander");
|
|
5
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
6
9
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
7
10
|
var net = _interopRequireWildcard(require("net"));
|
|
8
11
|
var _zod = _interopRequireDefault(require("zod"));
|
|
9
12
|
var _runApi = require("../../common/runApi");
|
|
10
|
-
var _enums = require("
|
|
13
|
+
var _enums = require("../../runtime/enums");
|
|
11
14
|
var _unixSocket = require("../common/utils/unixSocket");
|
|
12
15
|
var _promises = require("timers/promises");
|
|
16
|
+
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
17
|
+
var _formatZodError = require("../../common/formatZodError");
|
|
18
|
+
var _stream = require("stream");
|
|
13
19
|
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
20
|
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; }
|
|
15
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -17,6 +23,7 @@ const startRunApiSchema = _zod.default.object({
|
|
|
17
23
|
type: _zod.default.literal("start"),
|
|
18
24
|
parameters: _runApi.runApiParametersSchema.extend({
|
|
19
25
|
retrieveSession: _zod.default.boolean(),
|
|
26
|
+
functionsToken: _zod.default.string().optional(),
|
|
20
27
|
context: _zod.default.object({
|
|
21
28
|
jobId: _zod.default.string().optional(),
|
|
22
29
|
jobRunId: _zod.default.string().optional(),
|
|
@@ -35,127 +42,160 @@ const abortRunApiSchema = _zod.default.object({
|
|
|
35
42
|
type: _zod.default.literal("abort"),
|
|
36
43
|
parameters: _zod.default.object({}).optional()
|
|
37
44
|
});
|
|
38
|
-
const
|
|
45
|
+
const tokenUpdateSchema = _zod.default.object({
|
|
46
|
+
type: _zod.default.literal("tokenUpdate"),
|
|
47
|
+
parameters: _zod.default.object({
|
|
48
|
+
functionsToken: _zod.default.string()
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema]);
|
|
39
52
|
_dotenv.default.config({
|
|
40
53
|
path: `.env`
|
|
41
54
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
|
|
72
|
-
const success = result.value.isOk();
|
|
73
|
-
jsonUnixSocket.sendJSON({
|
|
74
|
-
type: "done",
|
|
75
|
-
result: resultToSend,
|
|
76
|
-
success
|
|
77
|
-
});
|
|
78
|
-
return true;
|
|
79
|
-
} else {
|
|
80
|
-
jsonUnixSocket.sendJSON({
|
|
81
|
-
type: "yield",
|
|
82
|
-
result: result.value
|
|
83
|
-
});
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
for await (const data of jsonUnixSocket.receiveJSON()) {
|
|
88
|
-
const inputParseResult = inputSchema.safeParse(data);
|
|
89
|
-
if (!inputParseResult.success) {
|
|
90
|
-
console.error(inputParseResult.error.errors);
|
|
91
|
-
jsonUnixSocket.sendJSON({
|
|
92
|
-
type: "done",
|
|
93
|
-
result: {
|
|
94
|
-
error: "InvalidJSON",
|
|
95
|
-
message: "Invalid input",
|
|
96
|
-
details: {
|
|
97
|
-
errors: inputParseResult.error.errors
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
success: false
|
|
101
|
-
});
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
const input = inputParseResult.data;
|
|
105
|
-
if (input.type === "abort") {
|
|
106
|
-
abortController.abort();
|
|
107
|
-
await (0, _promises.setTimeout)(10);
|
|
108
|
-
jsonUnixSocket.sendJSON({
|
|
109
|
-
type: "done",
|
|
110
|
-
result: null
|
|
111
|
-
});
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
if (input.type === "start") {
|
|
115
|
-
const gen = (0, _runApi.runApiGenerator)({
|
|
116
|
-
...input.parameters,
|
|
117
|
-
abortSignal: abortController.signal
|
|
118
|
-
});
|
|
119
|
-
generator = gen;
|
|
120
|
-
context = {
|
|
121
|
-
extendedPayloads: [],
|
|
122
|
-
runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
|
|
123
|
-
timeoutInfo: {
|
|
124
|
-
extendTimeoutCallback: async () => {
|
|
125
|
-
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
126
|
-
timeoutTimestamp = Date.now();
|
|
127
|
-
jsonUnixSocket.sendJSON({
|
|
128
|
-
type: "extend"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
...(input.parameters.context ?? {}),
|
|
133
|
-
proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
|
|
55
|
+
function runAutomationCLI(importFunction) {
|
|
56
|
+
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
|
|
57
|
+
let context;
|
|
58
|
+
const throttleTime = 60 * 1000;
|
|
59
|
+
let timeoutTimestamp = Date.now();
|
|
60
|
+
const client = net.createConnection(socketPath);
|
|
61
|
+
let generator = null;
|
|
62
|
+
const abortController = new AbortController();
|
|
63
|
+
client.on("error", err => {
|
|
64
|
+
var _generator2;
|
|
65
|
+
void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(err).catch(() => undefined));
|
|
66
|
+
});
|
|
67
|
+
process.on("SIGINT", () => {
|
|
68
|
+
var _generator3;
|
|
69
|
+
void ((_generator3 = generator) === null || _generator3 === void 0 ? void 0 : _generator3.throw(new Error("Interrupted")).catch(() => undefined));
|
|
70
|
+
client.end();
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|
|
73
|
+
process.on("SIGTERM", () => {
|
|
74
|
+
var _generator4;
|
|
75
|
+
void ((_generator4 = generator) === null || _generator4 === void 0 ? void 0 : _generator4.throw(new Error("Interrupted")).catch(() => undefined));
|
|
76
|
+
client.end();
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
|
79
|
+
const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
|
|
80
|
+
async function runGeneratorAndSendResult(next) {
|
|
81
|
+
const _generator = generator;
|
|
82
|
+
if (_generator == null) return {
|
|
83
|
+
done: true
|
|
134
84
|
};
|
|
135
|
-
|
|
136
|
-
|
|
85
|
+
const result = await (0, _asyncLocalStorage.runWithContext)(context, () => _generator.next(next));
|
|
86
|
+
if (result.done) {
|
|
87
|
+
const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
|
|
88
|
+
const success = result.value.isOk();
|
|
89
|
+
jsonUnixSocket.sendJSON({
|
|
90
|
+
type: "done",
|
|
91
|
+
result: resultToSend,
|
|
92
|
+
success
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
jsonUnixSocket.sendJSON({
|
|
96
|
+
type: "yield",
|
|
97
|
+
result: result.value
|
|
98
|
+
});
|
|
137
99
|
}
|
|
138
|
-
|
|
100
|
+
return {
|
|
101
|
+
done: result.done ?? false
|
|
102
|
+
};
|
|
139
103
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
104
|
+
const stream = new _stream.PassThrough({
|
|
105
|
+
objectMode: true
|
|
106
|
+
});
|
|
107
|
+
async function messagesLoop() {
|
|
108
|
+
for await (const data of jsonUnixSocket.receiveJSON()) {
|
|
109
|
+
console.log("Received message");
|
|
110
|
+
const inputParseResult = inputSchema.safeParse(data);
|
|
111
|
+
if (!inputParseResult.success) {
|
|
112
|
+
console.error("Validation error:", (0, _formatZodError.formatZodError)(inputParseResult.error));
|
|
113
|
+
jsonUnixSocket.sendJSON({
|
|
114
|
+
type: "done",
|
|
115
|
+
result: new _runApi.InternalInvalidInputError("Invalid input", (0, _formatZodError.formatZodError)(inputParseResult.error)).json,
|
|
116
|
+
success: false
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
const input = inputParseResult.data;
|
|
121
|
+
if (input.type === "abort") {
|
|
122
|
+
abortController.abort();
|
|
123
|
+
await (0, _promises.setTimeout)(10);
|
|
124
|
+
jsonUnixSocket.sendJSON({
|
|
125
|
+
type: "done",
|
|
126
|
+
result: null
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
if (input.type === "tokenUpdate") {
|
|
131
|
+
_jwtTokenManager.backendFunctionsTokenManager.token = input.parameters.functionsToken;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (input.type === "start") {
|
|
135
|
+
_jwtTokenManager.backendFunctionsTokenManager.token = input.parameters.functionsToken;
|
|
136
|
+
generator = (0, _runApi.runApiGenerator)({
|
|
137
|
+
...input.parameters,
|
|
138
|
+
abortSignal: abortController.signal,
|
|
139
|
+
importFunction
|
|
140
|
+
});
|
|
141
|
+
context = {
|
|
142
|
+
extendedPayloads: [],
|
|
143
|
+
runEnvironment: input.parameters.runOptions.environment === "standalone" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
|
|
144
|
+
timeoutInfo: {
|
|
145
|
+
extendTimeoutCallback: async () => {
|
|
146
|
+
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
147
|
+
timeoutTimestamp = Date.now();
|
|
148
|
+
jsonUnixSocket.sendJSON({
|
|
149
|
+
type: "extend"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
...(input.parameters.context ?? {}),
|
|
154
|
+
proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
|
|
155
|
+
};
|
|
156
|
+
stream.write({});
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (input.type === "next") {
|
|
160
|
+
if (!generator) {
|
|
161
|
+
throw new Error("generator not started");
|
|
162
|
+
}
|
|
163
|
+
stream.write({
|
|
164
|
+
value: input.parameters.value
|
|
165
|
+
});
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
146
168
|
}
|
|
147
|
-
|
|
169
|
+
stream.end();
|
|
170
|
+
client.end();
|
|
148
171
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
172
|
+
void messagesLoop();
|
|
173
|
+
console.log("Listening for values");
|
|
174
|
+
for await (const {
|
|
175
|
+
value
|
|
176
|
+
} of stream) {
|
|
177
|
+
console.log("Received a value", value);
|
|
178
|
+
const {
|
|
179
|
+
done
|
|
180
|
+
} = await runGeneratorAndSendResult(value);
|
|
181
|
+
if (done) break;
|
|
182
|
+
}
|
|
183
|
+
if (!client.closed) {
|
|
184
|
+
client.end();
|
|
185
|
+
}
|
|
186
|
+
process.exit(0);
|
|
187
|
+
});
|
|
188
|
+
_commander.program.parse(process.argv);
|
|
189
|
+
}
|
|
153
190
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
154
|
-
if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "
|
|
191
|
+
if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "standalone") return undefined;
|
|
155
192
|
const proxy = runOptions.proxy;
|
|
156
193
|
if (!proxy) return undefined;
|
|
157
194
|
const url = new URL(proxy.server);
|
|
158
195
|
url.username = proxy.username;
|
|
159
196
|
url.password = proxy.password;
|
|
160
197
|
return url.toString();
|
|
198
|
+
}
|
|
199
|
+
if (require.main === module) {
|
|
200
|
+
runAutomationCLI();
|
|
161
201
|
}
|
|
@@ -5,17 +5,19 @@ var ts = _interopRequireWildcard(require("typescript"));
|
|
|
5
5
|
var _commander = require("commander");
|
|
6
6
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
7
7
|
var path = _interopRequireWildcard(require("path"));
|
|
8
|
-
var
|
|
8
|
+
var _template = require("./common/utils/template");
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
|
-
_commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async (
|
|
12
|
-
|
|
11
|
+
_commander.program.description("Check TypeScript types in the project").option("-t, --template <type>", "template to use", "WebTemplate").allowUnknownOption().action(async ({
|
|
12
|
+
template
|
|
13
|
+
}) => {
|
|
14
|
+
await (0, _template.moveTemplateFiles)(template);
|
|
13
15
|
const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
|
|
14
|
-
await fs.copy(templateTsConfig,
|
|
15
|
-
checkTypes();
|
|
16
|
+
await fs.copy(templateTsConfig, `./intuned/${template}/tsconfig.json`);
|
|
17
|
+
checkTypes(template);
|
|
16
18
|
});
|
|
17
|
-
function checkTypes() {
|
|
18
|
-
const configPath = ts.findConfigFile(
|
|
19
|
+
function checkTypes(template) {
|
|
20
|
+
const configPath = ts.findConfigFile(`./intuned/${template}`, ts.sys.fileExists, "tsconfig.json");
|
|
19
21
|
if (!configPath) {
|
|
20
22
|
console.error("Could not find a valid 'tsconfig.json'.");
|
|
21
23
|
process.exit(1);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatZodError = formatZodError;
|
|
7
|
+
function formatZodError(zodError) {
|
|
8
|
+
const formattedErrors = zodError.errors.map(error => {
|
|
9
|
+
const path = error.path.map(segment => {
|
|
10
|
+
return typeof segment === "number" ? `[${segment}]` : segment;
|
|
11
|
+
}).join(".");
|
|
12
|
+
if (path) {
|
|
13
|
+
return `${path} is invalid - ${error.message}`;
|
|
14
|
+
}
|
|
15
|
+
return error.message;
|
|
16
|
+
});
|
|
17
|
+
return formattedErrors;
|
|
18
|
+
}
|
|
@@ -151,7 +151,11 @@ async function loadSessionToContext({
|
|
|
151
151
|
}) {
|
|
152
152
|
let sessionToLoad;
|
|
153
153
|
if (session.type === "state") {
|
|
154
|
-
|
|
154
|
+
const state = session.state;
|
|
155
|
+
if (state === undefined || state === null) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
sessionToLoad = state;
|
|
155
159
|
} else {
|
|
156
160
|
const fullPath = (0, _fileUtils.getFullPathInProject)(session.path);
|
|
157
161
|
sessionToLoad = await fs.readJson(fullPath);
|
|
@@ -159,7 +163,7 @@ async function loadSessionToContext({
|
|
|
159
163
|
await (0, _contextStorageStateHelpers.setContextStorageState)(context, sessionToLoad);
|
|
160
164
|
}
|
|
161
165
|
async function getRemotePlaywrightContext(cdpAddress) {
|
|
162
|
-
const playwright = await Promise.resolve(require("@intuned/playwright-core"));
|
|
166
|
+
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("@intuned/playwright-core")));
|
|
163
167
|
let browser = null;
|
|
164
168
|
if (!cdpAddress) {
|
|
165
169
|
throw new Error("cdpAddress is required");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunAutomationResponse } from "./types";
|
|
2
|
-
import { RunErrorOptions } from "
|
|
2
|
+
import { RunErrorOptions } from "../../runtime/export";
|
|
3
3
|
export declare const apiNotFoundErrorCode = "APINotFoundError";
|
|
4
4
|
export declare const invalidApiErrorCode = "InvalidAPIError";
|
|
5
5
|
export declare const invalidCheckErrorCode = "InvalidCheckError";
|
|
@@ -9,7 +9,8 @@ export declare const authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
|
9
9
|
export declare const authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
10
10
|
export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
11
11
|
export declare const automationError = "AutomationError";
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
13
|
+
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError"];
|
|
13
14
|
export type RunAutomationErrorCode = (typeof runAutomationErrorCodes)[number];
|
|
14
15
|
export declare abstract class RunAutomationError<T = any> {
|
|
15
16
|
code: RunAutomationErrorCode;
|
|
@@ -20,7 +21,7 @@ export declare abstract class RunAutomationError<T = any> {
|
|
|
20
21
|
details?: T;
|
|
21
22
|
get apiResponse(): RunAutomationResponse;
|
|
22
23
|
get json(): {
|
|
23
|
-
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError";
|
|
24
|
+
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError";
|
|
24
25
|
details: T | undefined;
|
|
25
26
|
cause: any;
|
|
26
27
|
};
|
|
@@ -69,3 +70,7 @@ export declare class AutomationError extends RunAutomationError<{
|
|
|
69
70
|
error: any;
|
|
70
71
|
constructor(error: any);
|
|
71
72
|
}
|
|
73
|
+
export declare class InternalInvalidInputError extends RunAutomationError {
|
|
74
|
+
constructor(message: string, details?: any);
|
|
75
|
+
get apiResponse(): RunAutomationResponse;
|
|
76
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
6
|
+
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
7
|
var _runtime = require("../../runtime");
|
|
8
8
|
var playwright = _interopRequireWildcard(require("@intuned/playwright-core"));
|
|
9
9
|
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); }
|
|
@@ -17,7 +17,8 @@ const authCheckNotFoundErrorCode = exports.authCheckNotFoundErrorCode = "AuthChe
|
|
|
17
17
|
const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
18
18
|
const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
19
19
|
const automationError = exports.automationError = "AutomationError";
|
|
20
|
-
const
|
|
20
|
+
const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
21
|
+
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode];
|
|
21
22
|
class RunAutomationError {
|
|
22
23
|
wrapped = false;
|
|
23
24
|
get apiResponse() {
|
|
@@ -92,6 +93,7 @@ class AuthRequiredError extends RunAutomationError {
|
|
|
92
93
|
this.code = authRequiredErrorCode;
|
|
93
94
|
this.statusCode = 401;
|
|
94
95
|
this.message = "Authentication is required";
|
|
96
|
+
this.wrapped = true;
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
exports.AuthRequiredError = AuthRequiredError;
|
|
@@ -110,6 +112,7 @@ class AuthCheckFailedError extends RunAutomationError {
|
|
|
110
112
|
this.code = authCheckFailedErrorCode;
|
|
111
113
|
this.statusCode = 401;
|
|
112
114
|
this.message = "auth session check failed";
|
|
115
|
+
this.wrapped = true;
|
|
113
116
|
}
|
|
114
117
|
get apiResponse() {
|
|
115
118
|
return {
|
|
@@ -169,4 +172,24 @@ class AutomationError extends RunAutomationError {
|
|
|
169
172
|
};
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
|
-
exports.AutomationError = AutomationError;
|
|
175
|
+
exports.AutomationError = AutomationError;
|
|
176
|
+
class InternalInvalidInputError extends RunAutomationError {
|
|
177
|
+
constructor(message, details) {
|
|
178
|
+
super();
|
|
179
|
+
this.code = internalInvalidInputErrorCode;
|
|
180
|
+
this.statusCode = 500;
|
|
181
|
+
this.message = message;
|
|
182
|
+
this.details = details;
|
|
183
|
+
}
|
|
184
|
+
get apiResponse() {
|
|
185
|
+
return {
|
|
186
|
+
status: 500,
|
|
187
|
+
body: {
|
|
188
|
+
error: "InternalServerError",
|
|
189
|
+
message: `Internal error: ${this.message}. Please report this issue to the Intuned team.`,
|
|
190
|
+
details: this.details
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
@@ -9,4 +9,4 @@ export declare function runApiGenerator<ResultType = any, _YieldType = any, _Nex
|
|
|
9
9
|
}): AsyncGenerator<_YieldType, RunApiResult<ResultType, RunApiResultWithSessionOk>, _NextType>;
|
|
10
10
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters): AsyncGenerator<_YieldType, RunApiResult<ResultType>, _NextType>;
|
|
11
11
|
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
12
|
-
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
12
|
+
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, importFunction: ExtendedRunApiParameters["importFunction"], retries?: number): Promise<Result<boolean, RunAutomationError>>;
|