@intuned/runtime-dev 0.1.0-test.32 → 0.1.0-test.34
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.
|
@@ -15,6 +15,7 @@ var _enums = require("src/runtime/enums");
|
|
|
15
15
|
var _unixSocket = require("../common/utils/unixSocket");
|
|
16
16
|
var _promises = require("timers/promises");
|
|
17
17
|
var _jwtTokenManager = require("src/common/jwtTokenManager");
|
|
18
|
+
var _formatZodError = require("src/common/formatZodError");
|
|
18
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); }
|
|
19
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; }
|
|
20
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -103,16 +104,10 @@ function runAutomationCLI(importFunction) {
|
|
|
103
104
|
for await (const data of jsonUnixSocket.receiveJSON()) {
|
|
104
105
|
const inputParseResult = inputSchema.safeParse(data);
|
|
105
106
|
if (!inputParseResult.success) {
|
|
106
|
-
console.error(inputParseResult.error
|
|
107
|
+
console.error("Validation error:", (0, _formatZodError.formatZodError)(inputParseResult.error));
|
|
107
108
|
jsonUnixSocket.sendJSON({
|
|
108
109
|
type: "done",
|
|
109
|
-
result:
|
|
110
|
-
error: "InternalInvalidInputError",
|
|
111
|
-
message: "Invalid input",
|
|
112
|
-
details: {
|
|
113
|
-
errors: inputParseResult.error.errors
|
|
114
|
-
}
|
|
115
|
-
},
|
|
110
|
+
result: new _runApi.InternalInvalidInputError("Invalid input", (0, _formatZodError.formatZodError)(inputParseResult.error)).json,
|
|
116
111
|
success: false
|
|
117
112
|
});
|
|
118
113
|
break;
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
|
@@ -43,6 +43,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
+
var _formatZodError = require("../formatZodError");
|
|
46
47
|
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); }
|
|
47
48
|
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; }
|
|
48
49
|
async function* runApiGenerator({
|
|
@@ -52,6 +53,10 @@ async function* runApiGenerator({
|
|
|
52
53
|
...input
|
|
53
54
|
}) {
|
|
54
55
|
let traceStarted = false;
|
|
56
|
+
const inputParseResult = _types.runApiParametersSchema.safeParse(input);
|
|
57
|
+
if (!inputParseResult.success) {
|
|
58
|
+
return (0, _neverthrow.err)(new _errors.InternalInvalidInputError("Input validation failed", (0, _formatZodError.formatZodError)(inputParseResult.error)));
|
|
59
|
+
}
|
|
55
60
|
const {
|
|
56
61
|
automationFunction,
|
|
57
62
|
runOptions,
|