@intuned/runtime-dev 1.2.0-cli.3 → 1.2.0-cli.4
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.
|
@@ -7,9 +7,6 @@ export declare class CLIError extends Error {
|
|
|
7
7
|
autoColor?: boolean;
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
export declare class AutomationTimeoutError extends AutomationError {
|
|
11
|
-
constructor(message: string);
|
|
12
|
-
}
|
|
13
10
|
export declare class CLIAssertionError extends CLIError {
|
|
14
11
|
constructor(message: string, options?: {
|
|
15
12
|
autoColor?: boolean;
|
|
@@ -25,7 +22,7 @@ export declare function parseUrlProxy(proxyUrl: string): {
|
|
|
25
22
|
username: string;
|
|
26
23
|
server: string;
|
|
27
24
|
} | undefined;
|
|
28
|
-
export declare function withTimeout<R>(fn: () => Promise<R>, timeout: number): Promise<Awaited<R>>;
|
|
25
|
+
export declare function withTimeout<R>(fn: (abortSignal: AbortSignal) => Promise<R>, timeout: number): Promise<Awaited<R>>;
|
|
29
26
|
export declare function withCLIContext<R>(fn: () => Promise<R>): Promise<R>;
|
|
30
27
|
export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
|
|
31
28
|
export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.CLIError = exports.CLIAssertionError =
|
|
6
|
+
exports.CLIError = exports.CLIAssertionError = void 0;
|
|
7
7
|
exports.assertApiFileExists = assertApiFileExists;
|
|
8
8
|
exports.assertAuthConsistent = assertAuthConsistent;
|
|
9
9
|
exports.assertAuthEnabled = assertAuthEnabled;
|
|
@@ -30,12 +30,6 @@ class CLIError extends Error {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.CLIError = CLIError;
|
|
33
|
-
class AutomationTimeoutError extends _runApi.AutomationError {
|
|
34
|
-
constructor(message) {
|
|
35
|
-
super(message);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.AutomationTimeoutError = AutomationTimeoutError;
|
|
39
33
|
class CLIAssertionError extends CLIError {
|
|
40
34
|
constructor(message, options) {
|
|
41
35
|
super(message, options);
|
|
@@ -111,16 +105,18 @@ function parseUrlProxy(proxyUrl) {
|
|
|
111
105
|
}
|
|
112
106
|
function withTimeout(fn, timeout) {
|
|
113
107
|
let reject;
|
|
108
|
+
const abortController = new AbortController();
|
|
114
109
|
const timeoutPromise = new Promise((_, _reject) => {
|
|
115
110
|
reject = _reject;
|
|
116
111
|
});
|
|
117
112
|
const timeoutId = setTimeout(() => {
|
|
118
|
-
|
|
113
|
+
abortController.abort();
|
|
114
|
+
reject(new _runApi.AutomationError(new Error("Timed out")));
|
|
119
115
|
}, timeout);
|
|
120
116
|
(0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
|
|
121
117
|
timeoutId.refresh();
|
|
122
118
|
};
|
|
123
|
-
return Promise.race([fn(), timeoutPromise]);
|
|
119
|
+
return Promise.race([fn(abortController.signal), timeoutPromise]);
|
|
124
120
|
}
|
|
125
121
|
async function withCLIContext(fn) {
|
|
126
122
|
const runId = (0, _nanoid.nanoid)();
|
|
@@ -151,7 +151,7 @@ async function attemptApi({
|
|
|
151
151
|
headless,
|
|
152
152
|
timeout
|
|
153
153
|
}) {
|
|
154
|
-
return await (0, _helpers.withTimeout)(async
|
|
154
|
+
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
155
155
|
const runApiResult = await (0, _runApi.runApi)({
|
|
156
156
|
automationFunction: {
|
|
157
157
|
name: `api/${apiName}`,
|
|
@@ -163,7 +163,8 @@ async function attemptApi({
|
|
|
163
163
|
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
164
164
|
},
|
|
165
165
|
auth,
|
|
166
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
166
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
167
|
+
abortSignal
|
|
167
168
|
});
|
|
168
169
|
if (runApiResult.isErr()) {
|
|
169
170
|
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
@@ -181,7 +181,7 @@ async function runCheck({
|
|
|
181
181
|
headless,
|
|
182
182
|
timeout
|
|
183
183
|
}) {
|
|
184
|
-
return await (0, _helpers.withTimeout)(async
|
|
184
|
+
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
185
185
|
const runApiResult = await (0, _runApi.runApi)({
|
|
186
186
|
automationFunction: {
|
|
187
187
|
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
@@ -198,7 +198,8 @@ async function runCheck({
|
|
|
198
198
|
},
|
|
199
199
|
runCheck: false
|
|
200
200
|
},
|
|
201
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
201
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
202
|
+
abortSignal
|
|
202
203
|
});
|
|
203
204
|
if (runApiResult.isErr()) {
|
|
204
205
|
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
@@ -219,7 +220,7 @@ async function runCreate({
|
|
|
219
220
|
headless,
|
|
220
221
|
timeout
|
|
221
222
|
}) {
|
|
222
|
-
return await (0, _helpers.withTimeout)(async
|
|
223
|
+
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
223
224
|
const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
|
|
224
225
|
const result = await (0, _runApi.runApi)({
|
|
225
226
|
automationFunction: {
|
|
@@ -232,7 +233,8 @@ async function runCreate({
|
|
|
232
233
|
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
233
234
|
},
|
|
234
235
|
retrieveSession: true,
|
|
235
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
236
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
237
|
+
abortSignal
|
|
236
238
|
});
|
|
237
239
|
if (result.isErr()) {
|
|
238
240
|
if (result.error instanceof _runApi.AutomationError) {
|