@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16
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 +1 -2
- package/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +14 -12
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +53 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +109 -170
- package/dist/commands/auth-sessions/load.js +28 -26
- package/dist/commands/auth-sessions/run-check.js +54 -53
- package/dist/commands/auth-sessions/run-create.js +93 -96
- package/dist/commands/browser/save-state.js +14 -16
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/build.js +79 -109
- package/dist/commands/common/browserUtils.js +53 -51
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
- package/dist/commands/common/sendMessageToClient.js +9 -4
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +18 -0
- package/dist/commands/common/utils/fileUtils.js +32 -22
- package/dist/commands/common/utils/settings.js +27 -19
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/webTemplate.js +30 -28
- package/dist/commands/interface/run.js +162 -139
- package/dist/commands/ts-check.js +50 -50
- package/dist/common/Logger/Logger/index.js +55 -42
- package/dist/common/Logger/Logger/types.js +5 -1
- package/dist/common/Logger/index.js +55 -42
- package/dist/common/Logger/types.js +5 -1
- package/dist/common/asyncLocalStorage/index.js +16 -8
- package/dist/common/cleanEnvironmentVariables.js +16 -12
- package/dist/common/constants.js +7 -1
- package/dist/common/contextStorageStateHelpers.js +47 -38
- package/dist/common/getPlaywrightConstructs.js +178 -197
- package/dist/common/jwtTokenManager.js +76 -79
- package/dist/common/runApi/errors.js +159 -150
- package/dist/common/runApi/index.js +240 -232
- package/dist/common/runApi/types.d.ts +19 -5
- package/dist/common/runApi/types.js +53 -56
- package/dist/common/settingsSchema.js +15 -10
- package/dist/common/telemetry.js +28 -30
- package/dist/index.js +69 -4
- package/dist/runtime/RunError.js +18 -11
- package/dist/runtime/downloadDirectory.js +19 -13
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +18 -12
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +21 -15
- package/dist/runtime/extendTimeout.js +28 -21
- package/dist/runtime/index.js +53 -6
- package/dist/runtime/requestMoreInfo.js +23 -16
- package/dist/runtime/runInfo.js +21 -14
- package/package.json +4 -7
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -79
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -23
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -51
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/Logger/types.ts +0 -1
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/Logger/types.ts +0 -1
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -182
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/executionHelpers.test.ts +0 -51
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
package/dist/common/telemetry.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as appInsights from "applicationinsights";
|
|
2
|
-
function gracefulShutdown() {
|
|
3
|
-
console.log("Shutting down, so flushing app insights.");
|
|
4
|
-
appInsights.defaultClient.flush();
|
|
5
|
-
process.exit();
|
|
6
|
-
}
|
|
7
|
-
export function initializeAppInsights() {
|
|
8
|
-
const appInsightsConnectionString = process.env.APPINSIGHTS_CONNECTION_STRING;
|
|
9
|
-
if (appInsightsConnectionString) {
|
|
10
|
-
console.log("Initializing app insights.");
|
|
11
|
-
appInsights.setup(appInsightsConnectionString).setAutoCollectConsole(true, true).setAutoCollectDependencies(true).setAutoCollectExceptions(true).setAutoCollectHeartbeat(true).setAutoCollectPerformance(true, true).setAutoCollectRequests(true).setAutoDependencyCorrelation(true).setDistributedTracingMode(appInsights.DistributedTracingModes.AI_AND_W3C).setSendLiveMetrics(true).setUseDiskRetryCaching(true);
|
|
12
|
-
appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole] = "@intuned/sdk";
|
|
13
|
-
if (process.env.FLY_APP_NAME) {
|
|
14
|
-
appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRoleInstance] = process.env.FLY_APP_NAME;
|
|
15
|
-
}
|
|
16
|
-
process.on("SIGTERM", gracefulShutdown);
|
|
17
|
-
process.on("SIGINT", gracefulShutdown);
|
|
18
|
-
appInsights.start();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function getTelemetryClient() {
|
|
22
|
-
return appInsights.defaultClient;
|
|
23
|
-
}
|
package/dist/index.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP } from "./runtime/index.js";
|
|
2
|
-
export { runWithContext, getExecutionContext } from "./common/asyncLocalStorage/index.js";
|
|
3
|
-
export { getDownloadDirectoryPath } from "./runtime/downloadDirectory.js";
|
|
4
|
-
export { getProductionPlaywrightConstructs } from "./common/getPlaywrightConstructs.js";
|
package/dist/runtime/RunError.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class RunError extends Error {
|
|
2
|
-
constructor(message, options) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.message = message;
|
|
5
|
-
this.name = "USER_GENERATED_ERROR";
|
|
6
|
-
this.options = options ?? {
|
|
7
|
-
retryable: false
|
|
8
|
-
};
|
|
9
|
-
Object.setPrototypeOf(this, RunError.prototype);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
new RunError("", {});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "..";
|
|
2
|
-
import { ensureDirSync } from "fs-extra";
|
|
3
|
-
export function getDownloadDirectoryPath() {
|
|
4
|
-
const context = getExecutionContext();
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error("ExecutionContext not found");
|
|
7
|
-
}
|
|
8
|
-
const path = `/tmp/downloads/${context.runId}`;
|
|
9
|
-
ensureDirSync(path, {
|
|
10
|
-
mode: 0o2775
|
|
11
|
-
});
|
|
12
|
-
return path;
|
|
13
|
-
}
|
package/dist/runtime/enums.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export let RunEnvironment = function (RunEnvironment) {
|
|
2
|
-
RunEnvironment["IDE"] = "IDE";
|
|
3
|
-
RunEnvironment["DEPLOYED"] = "DEPLOYED";
|
|
4
|
-
return RunEnvironment;
|
|
5
|
-
}({});
|
|
6
|
-
export let RunType = function (RunType) {
|
|
7
|
-
RunType["SYNC"] = "SYNC";
|
|
8
|
-
RunType["ASYNC"] = "ASYNC";
|
|
9
|
-
RunType["JOB"] = "JOB";
|
|
10
|
-
RunType["QUEUE"] = "QUEUE";
|
|
11
|
-
return RunType;
|
|
12
|
-
}({});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getExecutionContext, runWithContext } from "../common/asyncLocalStorage";
|
|
3
|
-
import { extendPayload, runInfo } from "./index.js";
|
|
4
|
-
import { RunEnvironment } from "./enums.js";
|
|
5
|
-
describe("Execution Helpers", () => {
|
|
6
|
-
it("should be able to get execution info", () => {
|
|
7
|
-
runWithContext({
|
|
8
|
-
runEnvironment: RunEnvironment.IDE,
|
|
9
|
-
runId: "test-run-id",
|
|
10
|
-
extendedPayloads: []
|
|
11
|
-
}, () => {
|
|
12
|
-
expect(runInfo().runId).toEqual("test-run-id");
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
it("should be able to mutate extendedPayloads and get the accmulated value at the end ", () => {
|
|
16
|
-
const context = {
|
|
17
|
-
extendedPayloads: [],
|
|
18
|
-
runId: "test-run-id"
|
|
19
|
-
};
|
|
20
|
-
runWithContext({
|
|
21
|
-
runEnvironment: RunEnvironment.IDE,
|
|
22
|
-
runId: "test-run-id",
|
|
23
|
-
extendedPayloads: []
|
|
24
|
-
}, () => {
|
|
25
|
-
var _getExecutionContext, _getExecutionContext2;
|
|
26
|
-
expect((_getExecutionContext = getExecutionContext()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
|
|
27
|
-
extendPayload({
|
|
28
|
-
api: "test-api",
|
|
29
|
-
parameters: {}
|
|
30
|
-
});
|
|
31
|
-
expect((_getExecutionContext2 = getExecutionContext()) === null || _getExecutionContext2 === void 0 ? void 0 : _getExecutionContext2.extendedPayloads).toEqual([{
|
|
32
|
-
api: "test-api",
|
|
33
|
-
parameters: {}
|
|
34
|
-
}]);
|
|
35
|
-
extendPayload({
|
|
36
|
-
api: "test-api",
|
|
37
|
-
parameters: {}
|
|
38
|
-
});
|
|
39
|
-
extendPayload({
|
|
40
|
-
api: "test-api",
|
|
41
|
-
parameters: {}
|
|
42
|
-
});
|
|
43
|
-
extendPayload({
|
|
44
|
-
api: "test-api",
|
|
45
|
-
parameters: {}
|
|
46
|
-
});
|
|
47
|
-
const context = getExecutionContext();
|
|
48
|
-
expect(context === null || context === void 0 ? void 0 : context.extendedPayloads).toHaveLength(4);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
import { extendTimeout } from "./extendTimeout.js";
|
|
3
|
-
export function extendPayload(payload) {
|
|
4
|
-
const context = getExecutionContext();
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error("extendPayload failed due to an internal error.");
|
|
7
|
-
}
|
|
8
|
-
const items = Array.isArray(payload) ? payload : [payload];
|
|
9
|
-
if (!context.extendedPayloads) {
|
|
10
|
-
context.extendedPayloads = [...items];
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
context === null || context === void 0 || context.extendedPayloads.push(...items);
|
|
14
|
-
extendTimeout();
|
|
15
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
const _DEBOUNCE_TIME = 60_000;
|
|
3
|
-
export function extendTimeout() {
|
|
4
|
-
const context = getExecutionContext();
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error("extendTimeout failed due to an internal error.");
|
|
7
|
-
}
|
|
8
|
-
const {
|
|
9
|
-
timeoutInfo
|
|
10
|
-
} = context;
|
|
11
|
-
if (!timeoutInfo) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
|
|
15
|
-
const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
|
|
16
|
-
if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
timeoutInfo.timeoutTimestamp = newTimeoutStamp;
|
|
20
|
-
}
|
|
21
|
-
if (timeoutInfo.extendTimeoutCallback !== undefined) {
|
|
22
|
-
void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
|
|
23
|
-
}
|
|
24
|
-
}
|
package/dist/runtime/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { extendPayload } from "./extendPayload.js";
|
|
2
|
-
export { extendTimeout } from "./extendTimeout.js";
|
|
3
|
-
export { runInfo } from "./runInfo.js";
|
|
4
|
-
export { RunError } from "./RunError.js";
|
|
5
|
-
export { requestMultipleChoice, requestOTP } from "./requestMoreInfo.js";
|
|
6
|
-
export { getDownloadDirectoryPath } from "./downloadDirectory.js";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
|
|
2
|
-
export function requestOTP(messageToUser) {
|
|
3
|
-
return {
|
|
4
|
-
[REQUEST_MORE_INFO_KEY]: true,
|
|
5
|
-
action: "request_more_info",
|
|
6
|
-
messageToUser,
|
|
7
|
-
requestType: "otp"
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function requestMultipleChoice(messageToUser, choices) {
|
|
11
|
-
return {
|
|
12
|
-
[REQUEST_MORE_INFO_KEY]: true,
|
|
13
|
-
action: "request_more_info",
|
|
14
|
-
messageToUser,
|
|
15
|
-
requestType: "multiple_choice",
|
|
16
|
-
choices
|
|
17
|
-
};
|
|
18
|
-
}
|
package/dist/runtime/runInfo.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
import { RunEnvironment } from "./enums.js";
|
|
3
|
-
export function runInfo() {
|
|
4
|
-
const context = getExecutionContext();
|
|
5
|
-
if (!context) {
|
|
6
|
-
return {
|
|
7
|
-
runEnvironment: RunEnvironment.IDE
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
const {
|
|
11
|
-
extendedPayloads: _extendedPayloads,
|
|
12
|
-
...rest
|
|
13
|
-
} = context;
|
|
14
|
-
return rest;
|
|
15
|
-
}
|