@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.
Files changed (114) hide show
  1. package/.babelrc +1 -2
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/authSessions/create.ts +2 -2
  4. package/WebTemplate/controllers/authSessions/store.ts +1 -1
  5. package/WebTemplate/controllers/runApi/helpers.ts +14 -12
  6. package/WebTemplate/index.playwright.ts +32 -42
  7. package/WebTemplate/jobs.ts +13 -2
  8. package/WebTemplate/utils.ts +53 -1
  9. package/api/test2.ts +6 -1
  10. package/auth-sessions/check.ts +3 -1
  11. package/auth-sessions/create.ts +10 -10
  12. package/bin/intuned-api-run +1 -1
  13. package/bin/intuned-auth-session-check +1 -1
  14. package/bin/intuned-auth-session-create +1 -1
  15. package/bin/intuned-auth-session-load +1 -1
  16. package/bin/intuned-auth-session-refresh +1 -1
  17. package/bin/intuned-browser-save-state +1 -1
  18. package/bin/intuned-browser-start +1 -1
  19. package/bin/intuned-build +1 -1
  20. package/bin/intuned-ts-check +1 -1
  21. package/dist/commands/api/run.js +109 -170
  22. package/dist/commands/auth-sessions/load.js +28 -26
  23. package/dist/commands/auth-sessions/run-check.js +54 -53
  24. package/dist/commands/auth-sessions/run-create.js +93 -96
  25. package/dist/commands/browser/save-state.js +14 -16
  26. package/dist/commands/browser/start-browser.js +11 -11
  27. package/dist/commands/build.js +79 -109
  28. package/dist/commands/common/browserUtils.js +53 -51
  29. package/dist/commands/common/getFirstLineNumber.js +93 -93
  30. package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
  31. package/dist/commands/common/sendMessageToClient.js +9 -4
  32. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  33. package/dist/commands/common/tsNodeImport.js +18 -0
  34. package/dist/commands/common/utils/fileUtils.js +32 -22
  35. package/dist/commands/common/utils/settings.js +27 -19
  36. package/dist/commands/common/utils/unixSocket.js +43 -43
  37. package/dist/commands/common/utils/webTemplate.js +30 -28
  38. package/dist/commands/interface/run.js +162 -139
  39. package/dist/commands/ts-check.js +50 -50
  40. package/dist/common/Logger/Logger/index.js +55 -42
  41. package/dist/common/Logger/Logger/types.js +5 -1
  42. package/dist/common/Logger/index.js +55 -42
  43. package/dist/common/Logger/types.js +5 -1
  44. package/dist/common/asyncLocalStorage/index.js +16 -8
  45. package/dist/common/cleanEnvironmentVariables.js +16 -12
  46. package/dist/common/constants.js +7 -1
  47. package/dist/common/contextStorageStateHelpers.js +47 -38
  48. package/dist/common/getPlaywrightConstructs.js +178 -197
  49. package/dist/common/jwtTokenManager.js +76 -79
  50. package/dist/common/runApi/errors.js +159 -150
  51. package/dist/common/runApi/index.js +240 -232
  52. package/dist/common/runApi/types.d.ts +19 -5
  53. package/dist/common/runApi/types.js +53 -56
  54. package/dist/common/settingsSchema.js +15 -10
  55. package/dist/common/telemetry.js +28 -30
  56. package/dist/index.js +69 -4
  57. package/dist/runtime/RunError.js +18 -11
  58. package/dist/runtime/downloadDirectory.js +19 -13
  59. package/dist/runtime/enums.d.js +5 -0
  60. package/dist/runtime/enums.d.ts +11 -1
  61. package/dist/runtime/enums.js +18 -12
  62. package/dist/runtime/executionHelpers.test.js +53 -0
  63. package/dist/runtime/export.d.js +5 -0
  64. package/dist/runtime/export.d.ts +202 -1
  65. package/dist/runtime/extendPayload.js +21 -15
  66. package/dist/runtime/extendTimeout.js +28 -21
  67. package/dist/runtime/index.js +53 -6
  68. package/dist/runtime/requestMoreInfo.js +23 -16
  69. package/dist/runtime/runInfo.js +21 -14
  70. package/package.json +4 -7
  71. package/dist/commands/api/run.ts +0 -105
  72. package/dist/commands/auth-sessions/load.ts +0 -30
  73. package/dist/commands/auth-sessions/run-check.ts +0 -51
  74. package/dist/commands/auth-sessions/run-create.ts +0 -91
  75. package/dist/commands/browser/save-state.ts +0 -14
  76. package/dist/commands/browser/start-browser.ts +0 -11
  77. package/dist/commands/build.ts +0 -79
  78. package/dist/commands/common/browserUtils.ts +0 -45
  79. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
  80. package/dist/commands/common/getDefaultExportFromFile.js +0 -12
  81. package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
  82. package/dist/commands/common/getFirstLineNumber.ts +0 -96
  83. package/dist/commands/common/sendMessageToClient.ts +0 -3
  84. package/dist/commands/common/utils/fileUtils.ts +0 -23
  85. package/dist/commands/common/utils/settings.ts +0 -22
  86. package/dist/commands/common/utils/unixSocket.ts +0 -38
  87. package/dist/commands/common/utils/webTemplate.ts +0 -23
  88. package/dist/commands/interface/run.ts +0 -156
  89. package/dist/commands/ts-check.ts +0 -51
  90. package/dist/common/Logger/Logger/index.ts +0 -53
  91. package/dist/common/Logger/Logger/types.ts +0 -1
  92. package/dist/common/Logger/index.ts +0 -53
  93. package/dist/common/Logger/types.ts +0 -1
  94. package/dist/common/asyncLocalStorage/index.ts +0 -9
  95. package/dist/common/cleanEnvironmentVariables.ts +0 -10
  96. package/dist/common/constants.ts +0 -1
  97. package/dist/common/contextStorageStateHelpers.ts +0 -43
  98. package/dist/common/getPlaywrightConstructs.ts +0 -182
  99. package/dist/common/jwtTokenManager.ts +0 -71
  100. package/dist/common/runApi/errors.ts +0 -154
  101. package/dist/common/runApi/index.ts +0 -253
  102. package/dist/common/runApi/types.ts +0 -43
  103. package/dist/common/settingsSchema.ts +0 -9
  104. package/dist/common/telemetry.ts +0 -23
  105. package/dist/index.ts +0 -4
  106. package/dist/runtime/RunError.ts +0 -12
  107. package/dist/runtime/downloadDirectory.ts +0 -13
  108. package/dist/runtime/enums.ts +0 -12
  109. package/dist/runtime/executionHelpers.test.ts +0 -51
  110. package/dist/runtime/extendPayload.ts +0 -15
  111. package/dist/runtime/extendTimeout.ts +0 -24
  112. package/dist/runtime/index.ts +0 -6
  113. package/dist/runtime/requestMoreInfo.ts +0 -18
  114. package/dist/runtime/runInfo.ts +0 -15
@@ -1,9 +0,0 @@
1
- import * as z from "zod";
2
- const authSessionsSchema = z.object({
3
- enabled: z.boolean()
4
- }).optional().default({
5
- enabled: false
6
- });
7
- export const settingsSchema = z.object({
8
- authSessions: authSessionsSchema
9
- });
@@ -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";
@@ -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
- }
@@ -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
- }
@@ -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
- }
@@ -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
- }