@intuned/runtime-dev 0.0.1 → 0.1.0-test.0
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/InterfaceTemplate/index.ts +1 -0
- package/Intuned.json +5 -0
- package/WebTemplate/api.ts +92 -90
- package/WebTemplate/controllers/authSessions/check.ts +23 -29
- package/WebTemplate/controllers/authSessions/create.ts +46 -71
- package/WebTemplate/controllers/authSessions/index.ts +4 -4
- package/WebTemplate/controllers/authSessions/killOperation.ts +1 -1
- package/WebTemplate/controllers/authSessions/resumeOperation.ts +28 -52
- package/WebTemplate/controllers/authSessions/store.ts +11 -6
- package/WebTemplate/controllers/runApi/helpers.ts +47 -146
- package/WebTemplate/index.playwright.ts +42 -32
- package/WebTemplate/index.vanilla.ts +2 -20
- package/WebTemplate/jobs.ts +2 -13
- package/WebTemplate/utils.ts +1 -85
- package/WebTemplate.zip +0 -0
- package/api/authed.ts +12 -0
- package/api/test.ts +3 -0
- package/api/test2.ts +25 -0
- package/auth-sessions/check.ts +9 -0
- package/auth-sessions/create.ts +32 -0
- package/authSessions +1 -0
- package/bin/intuned-api-run +2 -0
- package/bin/intuned-auth-session-check +2 -0
- package/bin/intuned-auth-session-create +2 -0
- package/bin/intuned-auth-session-load +2 -0
- package/bin/intuned-auth-session-refresh +2 -0
- package/bin/intuned-browser-save-state +2 -0
- package/bin/intuned-browser-start +2 -0
- package/bin/intuned-build +2 -0
- package/bin/intuned-ts-check +2 -0
- package/dist/commands/api/run.d.ts +6 -0
- package/dist/commands/api/run.js +113 -0
- package/dist/commands/auth-sessions/load.d.ts +2 -0
- package/dist/commands/auth-sessions/load.js +32 -0
- package/dist/commands/auth-sessions/run-check.d.ts +2 -0
- package/dist/commands/auth-sessions/run-check.js +56 -0
- package/dist/commands/auth-sessions/run-create.d.ts +2 -0
- package/dist/commands/auth-sessions/run-create.js +96 -0
- package/dist/commands/browser/save-state.d.ts +2 -0
- package/dist/commands/browser/save-state.js +17 -0
- package/dist/commands/browser/start-browser.d.ts +2 -0
- package/dist/commands/browser/start-browser.js +14 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +83 -0
- package/dist/commands/common/browserUtils.d.ts +14 -0
- package/dist/commands/common/browserUtils.js +58 -0
- package/dist/commands/common/getDefaultExportFromFile.d.ts +1 -0
- package/dist/commands/common/getDefaultExportFromFile.js +19 -0
- package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
- package/dist/commands/common/getFirstLineNumber.js +103 -0
- package/{src/commands/common/getFirstLineNumber.test.ts → dist/commands/common/getFirstLineNumber.test.js} +75 -121
- package/dist/commands/common/sendMessageToClient.d.ts +1 -0
- package/dist/commands/common/sendMessageToClient.js +10 -0
- package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/dist/commands/common/utils/fileUtils.js +33 -0
- package/dist/commands/common/utils/settings.d.ts +2 -0
- package/dist/commands/common/utils/settings.js +28 -0
- package/dist/commands/common/utils/unixSocket.d.ts +9 -0
- package/dist/commands/common/utils/unixSocket.js +45 -0
- package/dist/commands/common/utils/webTemplate.d.ts +1 -0
- package/dist/commands/common/utils/webTemplate.js +31 -0
- package/dist/commands/interface/run.d.ts +2 -0
- package/dist/commands/interface/run.js +161 -0
- package/dist/commands/ts-check.d.ts +2 -0
- package/dist/commands/ts-check.js +54 -0
- package/dist/common/Logger/Logger/index.d.ts +12 -0
- package/dist/common/Logger/Logger/index.js +60 -0
- package/{src/common/Logger/Logger/types.ts → dist/common/Logger/Logger/types.d.ts} +4 -5
- package/dist/common/Logger/Logger/types.js +5 -0
- package/dist/common/Logger/index.d.ts +12 -0
- package/dist/common/Logger/index.js +60 -0
- package/{src/common/Logger/types.ts → dist/common/Logger/types.d.ts} +4 -5
- package/dist/common/Logger/types.js +5 -0
- package/dist/common/asyncLocalStorage/index.d.ts +16 -0
- package/dist/common/asyncLocalStorage/index.js +17 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
- package/dist/common/cleanEnvironmentVariables.js +16 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +7 -0
- package/dist/common/contextStorageStateHelpers.d.ts +14 -0
- package/dist/common/contextStorageStateHelpers.js +50 -0
- package/dist/common/getPlaywrightConstructs.d.ts +30 -0
- package/dist/common/getPlaywrightConstructs.js +192 -0
- package/dist/common/jwtTokenManager.d.ts +16 -0
- package/dist/common/jwtTokenManager.js +81 -0
- package/dist/common/runApi/errors.d.ts +71 -0
- package/dist/common/runApi/errors.js +172 -0
- package/dist/common/runApi/index.d.ts +12 -0
- package/dist/common/runApi/index.js +288 -0
- package/dist/common/runApi/types.d.ts +486 -0
- package/dist/common/runApi/types.js +50 -0
- package/dist/common/settingsSchema.d.ts +19 -0
- package/dist/common/settingsSchema.js +17 -0
- package/dist/common/telemetry.d.ts +3 -0
- package/dist/common/telemetry.js +32 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +69 -0
- package/dist/runtime/RunError.d.ts +5 -0
- package/dist/runtime/RunError.js +19 -0
- package/dist/runtime/downloadDirectory.d.ts +1 -0
- package/dist/runtime/downloadDirectory.js +19 -0
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.js +18 -0
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/extendPayload.d.ts +2 -0
- package/dist/runtime/extendPayload.js +21 -0
- package/dist/runtime/extendTimeout.d.ts +1 -0
- package/dist/runtime/extendTimeout.js +30 -0
- package/{src/runtime/index.ts → dist/runtime/index.d.ts} +2 -3
- package/dist/runtime/index.js +53 -0
- package/dist/runtime/requestMoreInfo.d.ts +18 -0
- package/dist/runtime/requestMoreInfo.js +25 -0
- package/dist/runtime/runInfo.d.ts +2 -0
- package/dist/runtime/runInfo.js +21 -0
- package/output.txt +39 -0
- package/package.json +9 -7
- package/testing +0 -0
- package/tsconfig.json +2 -1
- package/.vite/deps_temp_01af7156/package.json +0 -3
- package/.vscode/extensions.json +0 -3
- package/.vscode/launch.json +0 -102
- package/.vscode/settings.json +0 -12
- package/playwright.config.ts +0 -48
- package/src/commands/api/run.ts +0 -225
- package/src/commands/auth-sessions/load.ts +0 -42
- package/src/commands/auth-sessions/run-check.ts +0 -70
- package/src/commands/auth-sessions/run-create.ts +0 -124
- package/src/commands/browser/save-state.ts +0 -22
- package/src/commands/browser/start-browser.ts +0 -17
- package/src/commands/build.ts +0 -125
- package/src/commands/common/browserUtils.ts +0 -80
- package/src/commands/common/getDefaultExportFromFile.ts +0 -13
- package/src/commands/common/getFirstLineNumber.ts +0 -146
- package/src/commands/common/sendMessageToClient.ts +0 -8
- package/src/commands/common/utils/fileUtils.ts +0 -25
- package/src/commands/common/utils/settings.ts +0 -23
- package/src/commands/common/utils/webTemplate.ts +0 -46
- package/src/commands/testing/saveVisibleHtml.ts +0 -29
- package/src/commands/ts-check.ts +0 -88
- package/src/common/Logger/Logger/index.ts +0 -64
- package/src/common/Logger/index.ts +0 -64
- package/src/common/asyncLocalStorage/index.ts +0 -29
- package/src/common/cleanEnvironmentVariables.ts +0 -13
- package/src/common/constants.ts +0 -1
- package/src/common/contextStorageStateHelpers.ts +0 -71
- package/src/common/getPlaywrightConstructs.ts +0 -283
- package/src/common/jwtTokenManager.ts +0 -111
- package/src/common/settingsSchema.ts +0 -16
- package/src/common/telemetry.ts +0 -49
- package/src/index.ts +0 -14
- package/src/runtime/RunError.ts +0 -16
- package/src/runtime/downloadDirectory.ts +0 -14
- package/src/runtime/enums.ts +0 -11
- package/src/runtime/executionHelpers.test.ts +0 -70
- package/src/runtime/extendPayload.ts +0 -22
- package/src/runtime/extendTimeout.ts +0 -32
- package/src/runtime/requestMoreInfo.ts +0 -40
- package/src/runtime/runInfo.ts +0 -19
- package/vite.config.ts +0 -17
- /package/{src → dist}/common/assets/browser_scripts.js +0 -0
- /package/{src → dist}/runtime/enums.d.ts +0 -0
- /package/{src → dist}/runtime/export.d.ts +0 -0
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import fetch from "cross-fetch";
|
|
2
|
-
import * as jwt from "jsonwebtoken";
|
|
3
|
-
import { err, ResultAsync } from "neverthrow";
|
|
4
|
-
|
|
5
|
-
// Manages JWT token with renewal
|
|
6
|
-
class JwtTokenManager {
|
|
7
|
-
private _token: string | undefined;
|
|
8
|
-
private tokenRefreshTimeout: NodeJS.Timeout | undefined;
|
|
9
|
-
private refreshTokenPath: string;
|
|
10
|
-
|
|
11
|
-
constructor(refreshTokenPath: string) {
|
|
12
|
-
this.refreshTokenPath = refreshTokenPath;
|
|
13
|
-
this._token = undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public get token() {
|
|
17
|
-
return this._token;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// When the token is set, the schedule for renewal is issued automatically
|
|
21
|
-
// This is currently being set it two places:
|
|
22
|
-
// 1. Whenever the runner starts, initializes it from the environment variable (set whenever the api is run from the authoring IDE)
|
|
23
|
-
// 2. Whenever a published api is called to run (/api/run/*), it is set to the token received in the run request.
|
|
24
|
-
public set token(newToken: string | undefined) {
|
|
25
|
-
if (this._token != newToken) {
|
|
26
|
-
this._token = newToken;
|
|
27
|
-
void this.scheduleTokenRefresh();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private get timeToRefresh() {
|
|
32
|
-
if (!this._token) return;
|
|
33
|
-
|
|
34
|
-
const payload = jwt.decode(this._token);
|
|
35
|
-
|
|
36
|
-
if (!payload || typeof payload == "string") return;
|
|
37
|
-
|
|
38
|
-
const expiry = payload.expiry;
|
|
39
|
-
if (!expiry || typeof expiry !== "number") return;
|
|
40
|
-
|
|
41
|
-
const timeWindow = 60 * 1000; // 1 minute
|
|
42
|
-
|
|
43
|
-
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
44
|
-
return Math.max(timeToRefresh, timeWindow);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private async scheduleTokenRefresh() {
|
|
48
|
-
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
49
|
-
const timeToRefresh = this.timeToRefresh;
|
|
50
|
-
if (timeToRefresh === undefined) return;
|
|
51
|
-
|
|
52
|
-
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
53
|
-
|
|
54
|
-
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
55
|
-
const result = await this.refreshToken();
|
|
56
|
-
if (result && result.isErr()) {
|
|
57
|
-
console.error(`[Internal Error] ${result.error}`);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
await this.scheduleTokenRefresh();
|
|
61
|
-
}, timeToRefresh);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private async refreshToken() {
|
|
65
|
-
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
66
|
-
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
67
|
-
method: "GET",
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (res.status === 401) {
|
|
71
|
-
return err("Unauthorized");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const jsonResult = await ResultAsync.fromPromise(
|
|
75
|
-
res.json(),
|
|
76
|
-
() => "not json"
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (jsonResult.isErr()) return;
|
|
80
|
-
|
|
81
|
-
const newToken = jsonResult.value.token;
|
|
82
|
-
if (newToken) this._token = newToken;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public fetchWithToken(...[input, init]: Parameters<typeof fetch>) {
|
|
86
|
-
const headers = new Headers(init?.headers);
|
|
87
|
-
headers.set("Authorization", `Bearer ${this.token}`);
|
|
88
|
-
return fetch(input, {
|
|
89
|
-
...init,
|
|
90
|
-
headers,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const backendFunctionsPath = `${process.env.FUNCTIONS_DOMAIN}/api/${process.env.INTUNED_WORKSPACE_ID}/functions/${process.env.INTUNED_INTEGRATION_ID}`;
|
|
96
|
-
|
|
97
|
-
export const backendFunctionsTokenManager = new JwtTokenManager(
|
|
98
|
-
`${backendFunctionsPath}/refreshBackendFunctionsToken`
|
|
99
|
-
);
|
|
100
|
-
backendFunctionsTokenManager.token =
|
|
101
|
-
process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
102
|
-
|
|
103
|
-
export function callBackendFunctionWithToken(
|
|
104
|
-
path: string,
|
|
105
|
-
init?: Parameters<typeof fetch>[1]
|
|
106
|
-
) {
|
|
107
|
-
return backendFunctionsTokenManager.fetchWithToken(
|
|
108
|
-
`${backendFunctionsPath}/${path}`,
|
|
109
|
-
init
|
|
110
|
-
);
|
|
111
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
const authSessionsSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
enabled: z.boolean(),
|
|
6
|
-
})
|
|
7
|
-
.optional()
|
|
8
|
-
.default({
|
|
9
|
-
enabled: false,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const settingsSchema = z.object({
|
|
13
|
-
authSessions: authSessionsSchema,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export type IntunedSettings = z.infer<typeof settingsSchema>;
|
package/src/common/telemetry.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as appInsights from "applicationinsights";
|
|
2
|
-
|
|
3
|
-
function gracefulShutdown() {
|
|
4
|
-
console.log("Shutting down, so flushing app insights.");
|
|
5
|
-
|
|
6
|
-
appInsights.defaultClient.flush();
|
|
7
|
-
|
|
8
|
-
process.exit();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function initializeAppInsights() {
|
|
12
|
-
const appInsightsConnectionString = process.env.APPINSIGHTS_CONNECTION_STRING;
|
|
13
|
-
|
|
14
|
-
if (appInsightsConnectionString) {
|
|
15
|
-
console.log("Initializing app insights.");
|
|
16
|
-
|
|
17
|
-
appInsights
|
|
18
|
-
.setup(appInsightsConnectionString)
|
|
19
|
-
.setAutoCollectConsole(true, true)
|
|
20
|
-
.setAutoCollectDependencies(true)
|
|
21
|
-
.setAutoCollectExceptions(true)
|
|
22
|
-
.setAutoCollectHeartbeat(true)
|
|
23
|
-
.setAutoCollectPerformance(true, true)
|
|
24
|
-
.setAutoCollectRequests(true)
|
|
25
|
-
.setAutoDependencyCorrelation(true)
|
|
26
|
-
.setDistributedTracingMode(appInsights.DistributedTracingModes.AI_AND_W3C)
|
|
27
|
-
.setSendLiveMetrics(true)
|
|
28
|
-
.setUseDiskRetryCaching(true);
|
|
29
|
-
|
|
30
|
-
appInsights.defaultClient.context.tags[
|
|
31
|
-
appInsights.defaultClient.context.keys.cloudRole
|
|
32
|
-
] = "@intuned/sdk";
|
|
33
|
-
|
|
34
|
-
if (process.env.FLY_APP_NAME) {
|
|
35
|
-
appInsights.defaultClient.context.tags[
|
|
36
|
-
appInsights.defaultClient.context.keys.cloudRoleInstance
|
|
37
|
-
] = process.env.FLY_APP_NAME;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
process.on("SIGTERM", gracefulShutdown);
|
|
41
|
-
process.on("SIGINT", gracefulShutdown);
|
|
42
|
-
|
|
43
|
-
appInsights.start();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getTelemetryClient(): appInsights.TelemetryClient | undefined {
|
|
48
|
-
return appInsights.defaultClient;
|
|
49
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
extendPayload,
|
|
3
|
-
extendTimeout,
|
|
4
|
-
runInfo,
|
|
5
|
-
RunError,
|
|
6
|
-
requestMultipleChoice,
|
|
7
|
-
requestOTP,
|
|
8
|
-
} from "./runtime";
|
|
9
|
-
export {
|
|
10
|
-
runWithContext,
|
|
11
|
-
getExecutionContext,
|
|
12
|
-
} from "./common/asyncLocalStorage";
|
|
13
|
-
export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
|
|
14
|
-
export { getProductionPlaywrightConstructs } from "./common/getPlaywrightConstructs";
|
package/src/runtime/RunError.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RunErrorOptions } from "./export";
|
|
2
|
-
|
|
3
|
-
export class RunError extends Error {
|
|
4
|
-
options: RunErrorOptions;
|
|
5
|
-
constructor(message: string, options?: RunErrorOptions) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.message = message;
|
|
8
|
-
this.name = "USER_GENERATED_ERROR";
|
|
9
|
-
this.options = options ?? {
|
|
10
|
-
retryable: false,
|
|
11
|
-
};
|
|
12
|
-
Object.setPrototypeOf(this, RunError.prototype);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
new RunError("", {});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "..";
|
|
2
|
-
import { ensureDirSync } from "fs-extra";
|
|
3
|
-
|
|
4
|
-
export function getDownloadDirectoryPath() {
|
|
5
|
-
const context = getExecutionContext();
|
|
6
|
-
if (!context) {
|
|
7
|
-
throw new Error("ExecutionContext not found");
|
|
8
|
-
}
|
|
9
|
-
const path = `/tmp/downloads/${context.runId}`;
|
|
10
|
-
ensureDirSync(path, {
|
|
11
|
-
mode: 0o2775,
|
|
12
|
-
});
|
|
13
|
-
return path;
|
|
14
|
-
}
|
package/src/runtime/enums.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
getExecutionContext,
|
|
4
|
-
runWithContext,
|
|
5
|
-
} from "../common/asyncLocalStorage";
|
|
6
|
-
import { RunError, extendPayload, runInfo } from "./index";
|
|
7
|
-
import { RunEnvironment, RunType } from "./enums";
|
|
8
|
-
|
|
9
|
-
describe("Execution Helpers", () => {
|
|
10
|
-
it("should be able to get execution info", () => {
|
|
11
|
-
runWithContext(
|
|
12
|
-
{
|
|
13
|
-
runEnvironment: RunEnvironment.IDE,
|
|
14
|
-
// runType: RunType.SYNC,
|
|
15
|
-
runId: "test-run-id",
|
|
16
|
-
extendedPayloads: [],
|
|
17
|
-
},
|
|
18
|
-
() => {
|
|
19
|
-
expect(runInfo().runId).toEqual("test-run-id");
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("should be able to mutate extendedPayloads and get the accmulated value at the end ", () => {
|
|
25
|
-
const context = {
|
|
26
|
-
extendedPayloads: [],
|
|
27
|
-
runId: "test-run-id",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
runWithContext(
|
|
31
|
-
{
|
|
32
|
-
runEnvironment: RunEnvironment.IDE,
|
|
33
|
-
// runType: RunType.SYNC,
|
|
34
|
-
runId: "test-run-id",
|
|
35
|
-
extendedPayloads: [],
|
|
36
|
-
},
|
|
37
|
-
() => {
|
|
38
|
-
expect(getExecutionContext()?.extendedPayloads).toEqual([]);
|
|
39
|
-
extendPayload({
|
|
40
|
-
api: "test-api",
|
|
41
|
-
parameters: {},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
expect(getExecutionContext()?.extendedPayloads).toEqual([
|
|
45
|
-
{
|
|
46
|
-
api: "test-api",
|
|
47
|
-
parameters: {},
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
extendPayload({
|
|
52
|
-
api: "test-api",
|
|
53
|
-
parameters: {},
|
|
54
|
-
});
|
|
55
|
-
extendPayload({
|
|
56
|
-
api: "test-api",
|
|
57
|
-
parameters: {},
|
|
58
|
-
});
|
|
59
|
-
extendPayload({
|
|
60
|
-
api: "test-api",
|
|
61
|
-
parameters: {},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const context = getExecutionContext();
|
|
65
|
-
|
|
66
|
-
expect(context?.extendedPayloads).toHaveLength(4);
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
import { Payload } from "./export";
|
|
3
|
-
import { extendTimeout } from "./extendTimeout";
|
|
4
|
-
|
|
5
|
-
export function extendPayload(payload: Payload | Payload[]) {
|
|
6
|
-
const context = getExecutionContext();
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("extendPayload failed due to an internal error.");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const items = Array.isArray(payload) ? payload : [payload];
|
|
13
|
-
|
|
14
|
-
if (!context.extendedPayloads) {
|
|
15
|
-
context.extendedPayloads = [...items];
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
context?.extendedPayloads.push(...items);
|
|
20
|
-
|
|
21
|
-
extendTimeout();
|
|
22
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
|
|
3
|
-
const _DEBOUNCE_TIME = 60_000;
|
|
4
|
-
|
|
5
|
-
export function extendTimeout() {
|
|
6
|
-
const context = getExecutionContext();
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("extendTimeout failed due to an internal error.");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { timeoutInfo } = context;
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
!timeoutInfo ||
|
|
16
|
-
timeoutInfo.timeoutTimestamp === undefined ||
|
|
17
|
-
timeoutInfo.timeoutDuration === undefined ||
|
|
18
|
-
timeoutInfo.extendTimeoutCallback === undefined
|
|
19
|
-
) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
|
|
24
|
-
|
|
25
|
-
if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
timeoutInfo.timeoutTimestamp = newTimeoutStamp;
|
|
30
|
-
|
|
31
|
-
void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
|
|
32
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
interface RequestMoreInfoReturnTypeBase {
|
|
2
|
-
[REQUEST_MORE_INFO_KEY]: true;
|
|
3
|
-
action: "request_more_info";
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
interface RequestMultipleChoiceReturnType
|
|
7
|
-
extends RequestMoreInfoReturnTypeBase {
|
|
8
|
-
messageToUser: string;
|
|
9
|
-
choices: string[];
|
|
10
|
-
requestType: "multiple_choice";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase {
|
|
14
|
-
messageToUser: string;
|
|
15
|
-
requestType: "otp";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const REQUEST_MORE_INFO_KEY: unique symbol = Symbol("REQUEST_MORE_INFO");
|
|
19
|
-
|
|
20
|
-
export function requestOTP(messageToUser: string): RequestOtpReturnType {
|
|
21
|
-
return {
|
|
22
|
-
[REQUEST_MORE_INFO_KEY]: true,
|
|
23
|
-
action: "request_more_info",
|
|
24
|
-
messageToUser,
|
|
25
|
-
requestType: "otp",
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function requestMultipleChoice(
|
|
30
|
-
messageToUser: string,
|
|
31
|
-
choices: string[]
|
|
32
|
-
): RequestMultipleChoiceReturnType {
|
|
33
|
-
return {
|
|
34
|
-
[REQUEST_MORE_INFO_KEY]: true,
|
|
35
|
-
action: "request_more_info",
|
|
36
|
-
messageToUser,
|
|
37
|
-
requestType: "multiple_choice",
|
|
38
|
-
choices,
|
|
39
|
-
};
|
|
40
|
-
}
|
package/src/runtime/runInfo.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getExecutionContext } from "../common/asyncLocalStorage";
|
|
2
|
-
import { RunInfo } from "./export";
|
|
3
|
-
import { RunType, RunEnvironment } from "./enums";
|
|
4
|
-
|
|
5
|
-
export function runInfo(): RunInfo {
|
|
6
|
-
const context = getExecutionContext();
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
return {
|
|
10
|
-
runEnvironment: RunEnvironment.IDE,
|
|
11
|
-
// runType: RunType.SYNC,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//remove extendedPayloads from the user exposed data
|
|
16
|
-
const { extendedPayloads: _extendedPayloads, ...rest } = context;
|
|
17
|
-
|
|
18
|
-
return rest;
|
|
19
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import macros from "vite-plugin-babel-macros"
|
|
3
|
-
require('dotenv').config();
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
test: {
|
|
7
|
-
reporters: ['verbose', "html"],
|
|
8
|
-
outputFile: { html: './reports/html/index.html' },
|
|
9
|
-
testTimeout: 30000,
|
|
10
|
-
env: {
|
|
11
|
-
RUN_ENVIRONMENT: "AUTHORING",
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
plugins: [
|
|
15
|
-
macros(),
|
|
16
|
-
],
|
|
17
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|