@intuned/runtime-dev 1.3.18-interface.16 → 1.3.18-interface.19
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/dist/commands/intuned-cli/controller/__test__/api.test.js +6 -5
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +6 -5
- package/dist/commands/intuned-cli/helpers/errors.js +1 -1
- package/dist/common/runApi/index.js +5 -6
- package/dist/vendor/runtime-interface.js +6 -1
- package/package.json +1 -1
- package/tsup.config.ts +1 -0
- package/WebTemplate.zip +0 -0
|
@@ -6,6 +6,7 @@ var _authSession = require("../authSession");
|
|
|
6
6
|
var _helpers = require("../../helpers");
|
|
7
7
|
var _neverthrow = require("neverthrow");
|
|
8
8
|
var _runApi = require("../../../../common/runApi");
|
|
9
|
+
var _runtimeInterface = require("../../../../vendor/runtime-interface");
|
|
9
10
|
var _fsExtra = require("fs-extra");
|
|
10
11
|
var _browser = require("../../helpers/browser");
|
|
11
12
|
function getTerminal() {
|
|
@@ -224,7 +225,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
224
225
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
225
226
|
});
|
|
226
227
|
(0, _vitest.it)("stops retrying after max retries", async () => {
|
|
227
|
-
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new
|
|
228
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
|
|
228
229
|
await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
|
|
229
230
|
apiName: "testApi",
|
|
230
231
|
inputData: {},
|
|
@@ -242,7 +243,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
242
243
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
243
244
|
});
|
|
244
245
|
(0, _vitest.it)("stops retrying on success", async () => {
|
|
245
|
-
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new
|
|
246
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
|
|
246
247
|
result: "success"
|
|
247
248
|
}));
|
|
248
249
|
await (0, _api.executeRunApiCLI)({
|
|
@@ -253,7 +254,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
253
254
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
254
255
|
});
|
|
255
256
|
(0, _vitest.it)("validates AuthSession before each attempt if provided", async () => {
|
|
256
|
-
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new
|
|
257
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
|
|
257
258
|
result: "success"
|
|
258
259
|
}));
|
|
259
260
|
await (0, _api.executeRunApiCLI)({
|
|
@@ -364,11 +365,11 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
364
365
|
});
|
|
365
366
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
366
367
|
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
367
|
-
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new
|
|
368
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
|
|
368
369
|
await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
|
|
369
370
|
apiName: "testApi",
|
|
370
371
|
inputData: {}
|
|
371
|
-
})).rejects.toThrow(
|
|
372
|
+
})).rejects.toThrow(_runtimeInterface.AutomationError);
|
|
372
373
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
373
374
|
});
|
|
374
375
|
(0, _vitest.it)("writes result to file if outputFile is provided", async () => {
|
|
@@ -5,6 +5,7 @@ var _authSession = require("../authSession");
|
|
|
5
5
|
var _helpers = require("../../helpers");
|
|
6
6
|
var _neverthrow = require("neverthrow");
|
|
7
7
|
var _runApi = require("../../../../common/runApi");
|
|
8
|
+
var _runtimeInterface = require("../../../../vendor/runtime-interface");
|
|
8
9
|
var _browser = require("../../helpers/browser");
|
|
9
10
|
var _launchBrowser = require("../../../../common/launchBrowser");
|
|
10
11
|
var _promises = require("timers/promises");
|
|
@@ -14,7 +15,7 @@ const _checkPassedResult = (0, _neverthrow.ok)({
|
|
|
14
15
|
const _checkFailedResult = (0, _neverthrow.ok)({
|
|
15
16
|
result: false
|
|
16
17
|
});
|
|
17
|
-
const _errorResult = (0, _neverthrow.err)(new
|
|
18
|
+
const _errorResult = (0, _neverthrow.err)(new _runtimeInterface.AutomationError("failed"));
|
|
18
19
|
function _createSuccessResult(session) {
|
|
19
20
|
return (0, _neverthrow.ok)({
|
|
20
21
|
session
|
|
@@ -559,7 +560,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
559
560
|
(0, _vitest.beforeEach)(() => {
|
|
560
561
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
|
|
561
562
|
});
|
|
562
|
-
afterEach(() => {
|
|
563
|
+
(0, _vitest.afterEach)(() => {
|
|
563
564
|
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
564
565
|
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
565
566
|
});
|
|
@@ -725,7 +726,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
725
726
|
}
|
|
726
727
|
});
|
|
727
728
|
});
|
|
728
|
-
afterEach(() => {
|
|
729
|
+
(0, _vitest.afterEach)(() => {
|
|
729
730
|
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
730
731
|
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
731
732
|
});
|
|
@@ -848,7 +849,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
848
849
|
});
|
|
849
850
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
850
851
|
});
|
|
851
|
-
afterEach(() => {
|
|
852
|
+
(0, _vitest.afterEach)(() => {
|
|
852
853
|
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
853
854
|
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
854
855
|
});
|
|
@@ -963,7 +964,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
963
964
|
}
|
|
964
965
|
});
|
|
965
966
|
});
|
|
966
|
-
afterEach(() => {
|
|
967
|
+
(0, _vitest.afterEach)(() => {
|
|
967
968
|
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
968
969
|
_vitest.vi.mocked(_launchBrowser.launchChromium).mockReset();
|
|
969
970
|
_vitest.vi.useRealTimers();
|
|
@@ -31,7 +31,7 @@ class CLIAssertionError extends CLIError {
|
|
|
31
31
|
exports.CLIAssertionError = CLIAssertionError;
|
|
32
32
|
function logAutomationError(error) {
|
|
33
33
|
(0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
|
|
34
|
-
if (error instanceof _runtimeInterface.AutomationError) {
|
|
34
|
+
if (error instanceof _runtimeInterface.AutomationError && error.error) {
|
|
35
35
|
if (error.error.stack) {
|
|
36
36
|
const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
|
|
37
37
|
(0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
|
|
@@ -109,7 +109,10 @@ async function runApi({
|
|
|
109
109
|
(0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
|
|
110
110
|
const automationFunctionParameters = [...(params !== undefined ? [params] : []), page, context];
|
|
111
111
|
try {
|
|
112
|
-
const
|
|
112
|
+
const automationFunctionResult = await Promise.race([automationFunction(...automationFunctionParameters), abortPromise]);
|
|
113
|
+
if (automationFunctionResult === abortSymbol) {
|
|
114
|
+
return (0, _neverthrow.err)(new _runtimeInterface.AbortedError());
|
|
115
|
+
}
|
|
113
116
|
const MAX_RESULT_SIZE_BYTES = 2 * 1024 * 1024;
|
|
114
117
|
const resultSizeInBytes = getObjectSizeInBytes(automationFunctionResult);
|
|
115
118
|
if (resultSizeInBytes > MAX_RESULT_SIZE_BYTES) {
|
|
@@ -157,11 +160,7 @@ async function runApi({
|
|
|
157
160
|
}, runAutomationWithContext);
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
|
|
161
|
-
if (result === abortSymbol) {
|
|
162
|
-
return (0, _neverthrow.err)(new _runtimeInterface.AbortedError());
|
|
163
|
-
}
|
|
164
|
-
return result;
|
|
163
|
+
return await runAutomation();
|
|
165
164
|
}
|
|
166
165
|
async function checkAuthSessionWithRetries(page, context, checkFn, retries = 3) {
|
|
167
166
|
if (retries === 0) {
|
|
@@ -127,7 +127,12 @@ var require_errors = __commonJS({
|
|
|
127
127
|
constructor(error) {
|
|
128
128
|
super(exports2.automationError, `[${error?.name ?? error}] ${error?.message}`);
|
|
129
129
|
this.details = {
|
|
130
|
-
...error
|
|
130
|
+
...error,
|
|
131
|
+
name: error?.name,
|
|
132
|
+
stack: error?.stack,
|
|
133
|
+
message: error?.message,
|
|
134
|
+
statusCode: error?.statusCode,
|
|
135
|
+
errorCode: error?.code
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
};
|
package/package.json
CHANGED
package/tsup.config.ts
CHANGED
package/WebTemplate.zip
DELETED
|
Binary file
|