@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.
Files changed (163) hide show
  1. package/InterfaceTemplate/index.ts +1 -0
  2. package/Intuned.json +5 -0
  3. package/WebTemplate/api.ts +92 -90
  4. package/WebTemplate/controllers/authSessions/check.ts +23 -29
  5. package/WebTemplate/controllers/authSessions/create.ts +46 -71
  6. package/WebTemplate/controllers/authSessions/index.ts +4 -4
  7. package/WebTemplate/controllers/authSessions/killOperation.ts +1 -1
  8. package/WebTemplate/controllers/authSessions/resumeOperation.ts +28 -52
  9. package/WebTemplate/controllers/authSessions/store.ts +11 -6
  10. package/WebTemplate/controllers/runApi/helpers.ts +47 -146
  11. package/WebTemplate/index.playwright.ts +42 -32
  12. package/WebTemplate/index.vanilla.ts +2 -20
  13. package/WebTemplate/jobs.ts +2 -13
  14. package/WebTemplate/utils.ts +1 -85
  15. package/WebTemplate.zip +0 -0
  16. package/api/authed.ts +12 -0
  17. package/api/test.ts +3 -0
  18. package/api/test2.ts +25 -0
  19. package/auth-sessions/check.ts +9 -0
  20. package/auth-sessions/create.ts +32 -0
  21. package/authSessions +1 -0
  22. package/bin/intuned-api-run +2 -0
  23. package/bin/intuned-auth-session-check +2 -0
  24. package/bin/intuned-auth-session-create +2 -0
  25. package/bin/intuned-auth-session-load +2 -0
  26. package/bin/intuned-auth-session-refresh +2 -0
  27. package/bin/intuned-browser-save-state +2 -0
  28. package/bin/intuned-browser-start +2 -0
  29. package/bin/intuned-build +2 -0
  30. package/bin/intuned-ts-check +2 -0
  31. package/dist/commands/api/run.d.ts +6 -0
  32. package/dist/commands/api/run.js +113 -0
  33. package/dist/commands/auth-sessions/load.d.ts +2 -0
  34. package/dist/commands/auth-sessions/load.js +32 -0
  35. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  36. package/dist/commands/auth-sessions/run-check.js +56 -0
  37. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  38. package/dist/commands/auth-sessions/run-create.js +96 -0
  39. package/dist/commands/browser/save-state.d.ts +2 -0
  40. package/dist/commands/browser/save-state.js +17 -0
  41. package/dist/commands/browser/start-browser.d.ts +2 -0
  42. package/dist/commands/browser/start-browser.js +14 -0
  43. package/dist/commands/build.d.ts +2 -0
  44. package/dist/commands/build.js +83 -0
  45. package/dist/commands/common/browserUtils.d.ts +14 -0
  46. package/dist/commands/common/browserUtils.js +58 -0
  47. package/dist/commands/common/getDefaultExportFromFile.d.ts +1 -0
  48. package/dist/commands/common/getDefaultExportFromFile.js +19 -0
  49. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  50. package/dist/commands/common/getFirstLineNumber.js +103 -0
  51. package/{src/commands/common/getFirstLineNumber.test.ts → dist/commands/common/getFirstLineNumber.test.js} +75 -121
  52. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  53. package/dist/commands/common/sendMessageToClient.js +10 -0
  54. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  55. package/dist/commands/common/utils/fileUtils.js +33 -0
  56. package/dist/commands/common/utils/settings.d.ts +2 -0
  57. package/dist/commands/common/utils/settings.js +28 -0
  58. package/dist/commands/common/utils/unixSocket.d.ts +9 -0
  59. package/dist/commands/common/utils/unixSocket.js +45 -0
  60. package/dist/commands/common/utils/webTemplate.d.ts +1 -0
  61. package/dist/commands/common/utils/webTemplate.js +31 -0
  62. package/dist/commands/interface/run.d.ts +2 -0
  63. package/dist/commands/interface/run.js +161 -0
  64. package/dist/commands/ts-check.d.ts +2 -0
  65. package/dist/commands/ts-check.js +54 -0
  66. package/dist/common/Logger/Logger/index.d.ts +12 -0
  67. package/dist/common/Logger/Logger/index.js +60 -0
  68. package/{src/common/Logger/Logger/types.ts → dist/common/Logger/Logger/types.d.ts} +4 -5
  69. package/dist/common/Logger/Logger/types.js +5 -0
  70. package/dist/common/Logger/index.d.ts +12 -0
  71. package/dist/common/Logger/index.js +60 -0
  72. package/{src/common/Logger/types.ts → dist/common/Logger/types.d.ts} +4 -5
  73. package/dist/common/Logger/types.js +5 -0
  74. package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  75. package/dist/common/asyncLocalStorage/index.js +17 -0
  76. package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  77. package/dist/common/cleanEnvironmentVariables.js +16 -0
  78. package/dist/common/constants.d.ts +1 -0
  79. package/dist/common/constants.js +7 -0
  80. package/dist/common/contextStorageStateHelpers.d.ts +14 -0
  81. package/dist/common/contextStorageStateHelpers.js +50 -0
  82. package/dist/common/getPlaywrightConstructs.d.ts +30 -0
  83. package/dist/common/getPlaywrightConstructs.js +192 -0
  84. package/dist/common/jwtTokenManager.d.ts +16 -0
  85. package/dist/common/jwtTokenManager.js +81 -0
  86. package/dist/common/runApi/errors.d.ts +71 -0
  87. package/dist/common/runApi/errors.js +172 -0
  88. package/dist/common/runApi/index.d.ts +12 -0
  89. package/dist/common/runApi/index.js +288 -0
  90. package/dist/common/runApi/types.d.ts +486 -0
  91. package/dist/common/runApi/types.js +50 -0
  92. package/dist/common/settingsSchema.d.ts +19 -0
  93. package/dist/common/settingsSchema.js +17 -0
  94. package/dist/common/telemetry.d.ts +3 -0
  95. package/dist/common/telemetry.js +32 -0
  96. package/dist/index.d.ts +4 -0
  97. package/dist/index.js +69 -0
  98. package/dist/runtime/RunError.d.ts +5 -0
  99. package/dist/runtime/RunError.js +19 -0
  100. package/dist/runtime/downloadDirectory.d.ts +1 -0
  101. package/dist/runtime/downloadDirectory.js +19 -0
  102. package/dist/runtime/enums.d.js +5 -0
  103. package/dist/runtime/enums.js +18 -0
  104. package/dist/runtime/executionHelpers.test.js +53 -0
  105. package/dist/runtime/export.d.js +5 -0
  106. package/dist/runtime/extendPayload.d.ts +2 -0
  107. package/dist/runtime/extendPayload.js +21 -0
  108. package/dist/runtime/extendTimeout.d.ts +1 -0
  109. package/dist/runtime/extendTimeout.js +30 -0
  110. package/{src/runtime/index.ts → dist/runtime/index.d.ts} +2 -3
  111. package/dist/runtime/index.js +53 -0
  112. package/dist/runtime/requestMoreInfo.d.ts +18 -0
  113. package/dist/runtime/requestMoreInfo.js +25 -0
  114. package/dist/runtime/runInfo.d.ts +2 -0
  115. package/dist/runtime/runInfo.js +21 -0
  116. package/output.txt +39 -0
  117. package/package.json +9 -7
  118. package/testing +0 -0
  119. package/tsconfig.json +2 -1
  120. package/.vite/deps_temp_01af7156/package.json +0 -3
  121. package/.vscode/extensions.json +0 -3
  122. package/.vscode/launch.json +0 -102
  123. package/.vscode/settings.json +0 -12
  124. package/playwright.config.ts +0 -48
  125. package/src/commands/api/run.ts +0 -225
  126. package/src/commands/auth-sessions/load.ts +0 -42
  127. package/src/commands/auth-sessions/run-check.ts +0 -70
  128. package/src/commands/auth-sessions/run-create.ts +0 -124
  129. package/src/commands/browser/save-state.ts +0 -22
  130. package/src/commands/browser/start-browser.ts +0 -17
  131. package/src/commands/build.ts +0 -125
  132. package/src/commands/common/browserUtils.ts +0 -80
  133. package/src/commands/common/getDefaultExportFromFile.ts +0 -13
  134. package/src/commands/common/getFirstLineNumber.ts +0 -146
  135. package/src/commands/common/sendMessageToClient.ts +0 -8
  136. package/src/commands/common/utils/fileUtils.ts +0 -25
  137. package/src/commands/common/utils/settings.ts +0 -23
  138. package/src/commands/common/utils/webTemplate.ts +0 -46
  139. package/src/commands/testing/saveVisibleHtml.ts +0 -29
  140. package/src/commands/ts-check.ts +0 -88
  141. package/src/common/Logger/Logger/index.ts +0 -64
  142. package/src/common/Logger/index.ts +0 -64
  143. package/src/common/asyncLocalStorage/index.ts +0 -29
  144. package/src/common/cleanEnvironmentVariables.ts +0 -13
  145. package/src/common/constants.ts +0 -1
  146. package/src/common/contextStorageStateHelpers.ts +0 -71
  147. package/src/common/getPlaywrightConstructs.ts +0 -283
  148. package/src/common/jwtTokenManager.ts +0 -111
  149. package/src/common/settingsSchema.ts +0 -16
  150. package/src/common/telemetry.ts +0 -49
  151. package/src/index.ts +0 -14
  152. package/src/runtime/RunError.ts +0 -16
  153. package/src/runtime/downloadDirectory.ts +0 -14
  154. package/src/runtime/enums.ts +0 -11
  155. package/src/runtime/executionHelpers.test.ts +0 -70
  156. package/src/runtime/extendPayload.ts +0 -22
  157. package/src/runtime/extendTimeout.ts +0 -32
  158. package/src/runtime/requestMoreInfo.ts +0 -40
  159. package/src/runtime/runInfo.ts +0 -19
  160. package/vite.config.ts +0 -17
  161. /package/{src → dist}/common/assets/browser_scripts.js +0 -0
  162. /package/{src → dist}/runtime/enums.d.ts +0 -0
  163. /package/{src → dist}/runtime/export.d.ts +0 -0
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RunError = void 0;
7
+ class RunError extends Error {
8
+ constructor(message, options) {
9
+ super(message);
10
+ this.message = message;
11
+ this.name = "USER_GENERATED_ERROR";
12
+ this.options = options ?? {
13
+ retryable: false
14
+ };
15
+ Object.setPrototypeOf(this, RunError.prototype);
16
+ }
17
+ }
18
+ exports.RunError = RunError;
19
+ new RunError("", {});
@@ -0,0 +1 @@
1
+ export declare function getDownloadDirectoryPath(): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDownloadDirectoryPath = getDownloadDirectoryPath;
7
+ var _ = require("..");
8
+ var _fsExtra = require("fs-extra");
9
+ function getDownloadDirectoryPath() {
10
+ const context = (0, _.getExecutionContext)();
11
+ if (!context) {
12
+ throw new Error("ExecutionContext not found");
13
+ }
14
+ const path = `/tmp/downloads/${context.runId}`;
15
+ (0, _fsExtra.ensureDirSync)(path, {
16
+ mode: 0o2775
17
+ });
18
+ return path;
19
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RunType = exports.RunEnvironment = void 0;
7
+ let RunEnvironment = exports.RunEnvironment = function (RunEnvironment) {
8
+ RunEnvironment["IDE"] = "IDE";
9
+ RunEnvironment["DEPLOYED"] = "DEPLOYED";
10
+ return RunEnvironment;
11
+ }({});
12
+ let RunType = exports.RunType = function (RunType) {
13
+ RunType["SYNC"] = "SYNC";
14
+ RunType["ASYNC"] = "ASYNC";
15
+ RunType["JOB"] = "JOB";
16
+ RunType["QUEUE"] = "QUEUE";
17
+ return RunType;
18
+ }({});
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
5
+ var _index = require("./index");
6
+ var _enums = require("./enums");
7
+ (0, _vitest.describe)("Execution Helpers", () => {
8
+ (0, _vitest.it)("should be able to get execution info", () => {
9
+ (0, _asyncLocalStorage.runWithContext)({
10
+ runEnvironment: _enums.RunEnvironment.IDE,
11
+ runId: "test-run-id",
12
+ extendedPayloads: []
13
+ }, () => {
14
+ (0, _vitest.expect)((0, _index.runInfo)().runId).toEqual("test-run-id");
15
+ });
16
+ });
17
+ (0, _vitest.it)("should be able to mutate extendedPayloads and get the accmulated value at the end ", () => {
18
+ const context = {
19
+ extendedPayloads: [],
20
+ runId: "test-run-id"
21
+ };
22
+ (0, _asyncLocalStorage.runWithContext)({
23
+ runEnvironment: _enums.RunEnvironment.IDE,
24
+ runId: "test-run-id",
25
+ extendedPayloads: []
26
+ }, () => {
27
+ var _getExecutionContext, _getExecutionContext2;
28
+ (0, _vitest.expect)((_getExecutionContext = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
29
+ (0, _index.extendPayload)({
30
+ api: "test-api",
31
+ parameters: {}
32
+ });
33
+ (0, _vitest.expect)((_getExecutionContext2 = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext2 === void 0 ? void 0 : _getExecutionContext2.extendedPayloads).toEqual([{
34
+ api: "test-api",
35
+ parameters: {}
36
+ }]);
37
+ (0, _index.extendPayload)({
38
+ api: "test-api",
39
+ parameters: {}
40
+ });
41
+ (0, _index.extendPayload)({
42
+ api: "test-api",
43
+ parameters: {}
44
+ });
45
+ (0, _index.extendPayload)({
46
+ api: "test-api",
47
+ parameters: {}
48
+ });
49
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
50
+ (0, _vitest.expect)(context === null || context === void 0 ? void 0 : context.extendedPayloads).toHaveLength(4);
51
+ });
52
+ });
53
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,2 @@
1
+ import { Payload } from "./export";
2
+ export declare function extendPayload(payload: Payload | Payload[]): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extendPayload = extendPayload;
7
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
+ var _extendTimeout = require("./extendTimeout");
9
+ function extendPayload(payload) {
10
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
11
+ if (!context) {
12
+ throw new Error("extendPayload failed due to an internal error.");
13
+ }
14
+ const items = Array.isArray(payload) ? payload : [payload];
15
+ if (!context.extendedPayloads) {
16
+ context.extendedPayloads = [...items];
17
+ return;
18
+ }
19
+ context === null || context === void 0 || context.extendedPayloads.push(...items);
20
+ (0, _extendTimeout.extendTimeout)();
21
+ }
@@ -0,0 +1 @@
1
+ export declare function extendTimeout(): void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extendTimeout = extendTimeout;
7
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
+ const _DEBOUNCE_TIME = 60_000;
9
+ function extendTimeout() {
10
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
11
+ if (!context) {
12
+ throw new Error("extendTimeout failed due to an internal error.");
13
+ }
14
+ const {
15
+ timeoutInfo
16
+ } = context;
17
+ if (!timeoutInfo) {
18
+ return;
19
+ }
20
+ if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
21
+ const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
22
+ if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
23
+ return;
24
+ }
25
+ timeoutInfo.timeoutTimestamp = newTimeoutStamp;
26
+ }
27
+ if (timeoutInfo.extendTimeoutCallback !== undefined) {
28
+ void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
29
+ }
30
+ }
@@ -2,7 +2,6 @@ export { extendPayload } from "./extendPayload";
2
2
  export { extendTimeout } from "./extendTimeout";
3
3
  export { runInfo } from "./runInfo";
4
4
  export { RunError } from "./RunError";
5
-
6
5
  export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
7
-
8
- export {getDownloadDirectoryPath} from "./downloadDirectory";
6
+ export type { RequestMoreInfoDetails } from "./requestMoreInfo";
7
+ export { getDownloadDirectoryPath } from "./downloadDirectory";
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "RunError", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _RunError.RunError;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "extendPayload", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _extendPayload.extendPayload;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "extendTimeout", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _extendTimeout.extendTimeout;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "getDownloadDirectoryPath", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _downloadDirectory.getDownloadDirectoryPath;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "requestMultipleChoice", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _requestMoreInfo.requestMultipleChoice;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "requestOTP", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _requestMoreInfo.requestOTP;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "runInfo", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _runInfo.runInfo;
46
+ }
47
+ });
48
+ var _extendPayload = require("./extendPayload");
49
+ var _extendTimeout = require("./extendTimeout");
50
+ var _runInfo = require("./runInfo");
51
+ var _RunError = require("./RunError");
52
+ var _requestMoreInfo = require("./requestMoreInfo");
53
+ var _downloadDirectory = require("./downloadDirectory");
@@ -0,0 +1,18 @@
1
+ interface RequestMoreInfoReturnTypeBase {
2
+ [REQUEST_MORE_INFO_KEY]: true;
3
+ action: "request_more_info";
4
+ }
5
+ interface RequestMultipleChoiceReturnType extends RequestMoreInfoReturnTypeBase {
6
+ messageToUser: string;
7
+ choices: string[];
8
+ requestType: "multiple_choice";
9
+ }
10
+ interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase {
11
+ messageToUser: string;
12
+ requestType: "otp";
13
+ }
14
+ declare const REQUEST_MORE_INFO_KEY: unique symbol;
15
+ export declare function requestOTP(messageToUser: string): RequestOtpReturnType;
16
+ export declare function requestMultipleChoice(messageToUser: string, choices: string[]): RequestMultipleChoiceReturnType;
17
+ export type RequestMoreInfoDetails = RequestMultipleChoiceReturnType | RequestOtpReturnType;
18
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.requestMultipleChoice = requestMultipleChoice;
7
+ exports.requestOTP = requestOTP;
8
+ const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
9
+ function requestOTP(messageToUser) {
10
+ return {
11
+ [REQUEST_MORE_INFO_KEY]: true,
12
+ action: "request_more_info",
13
+ messageToUser,
14
+ requestType: "otp"
15
+ };
16
+ }
17
+ function requestMultipleChoice(messageToUser, choices) {
18
+ return {
19
+ [REQUEST_MORE_INFO_KEY]: true,
20
+ action: "request_more_info",
21
+ messageToUser,
22
+ requestType: "multiple_choice",
23
+ choices
24
+ };
25
+ }
@@ -0,0 +1,2 @@
1
+ import { RunInfo } from "./export";
2
+ export declare function runInfo(): RunInfo;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runInfo = runInfo;
7
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
+ var _enums = require("./enums");
9
+ function runInfo() {
10
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
11
+ if (!context) {
12
+ return {
13
+ runEnvironment: _enums.RunEnvironment.IDE
14
+ };
15
+ }
16
+ const {
17
+ extendedPayloads: _extendedPayloads,
18
+ ...rest
19
+ } = context;
20
+ return rest;
21
+ }