@intuned/runtime-dev 1.3.8-jsonl.0 → 1.3.9-dev1

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 (208) hide show
  1. package/bin/common.js +23 -0
  2. package/bin/intuned +2 -0
  3. package/bin/intuned-api-run +2 -0
  4. package/dist/commands/common/utils/settings.js +3 -0
  5. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -1
  6. package/dist/commands/intuned-cli/commands/authsession_record.command.js +3 -2
  7. package/dist/commands/intuned-cli/controller/deploy.js +1 -1
  8. package/dist/commands/intuned-cli/controller/save.js +1 -1
  9. package/dist/common/settingsSchema.d.ts +13 -0
  10. package/dist/common/settingsSchema.js +6 -0
  11. package/package/dist/commands/api/run.d.ts +6 -0
  12. package/package/dist/commands/api/run.js +123 -0
  13. package/package/dist/commands/auth-sessions/load.d.ts +2 -0
  14. package/package/dist/commands/auth-sessions/load.js +35 -0
  15. package/package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  16. package/package/dist/commands/auth-sessions/run-check.js +74 -0
  17. package/package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  18. package/package/dist/commands/auth-sessions/run-create.js +78 -0
  19. package/package/dist/commands/browser/save-state.d.ts +2 -0
  20. package/package/dist/commands/browser/save-state.js +17 -0
  21. package/package/dist/commands/browser/start-browser.d.ts +2 -0
  22. package/package/dist/commands/browser/start-browser.js +14 -0
  23. package/package/dist/commands/build.d.ts +1 -0
  24. package/package/dist/commands/build.js +84 -0
  25. package/package/dist/commands/common/browserUtils.d.ts +14 -0
  26. package/package/dist/commands/common/browserUtils.js +58 -0
  27. package/package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  28. package/package/dist/commands/common/getFirstLineNumber.js +101 -0
  29. package/package/dist/commands/common/getFirstLineNumber.test.js +228 -0
  30. package/package/dist/commands/common/projectExclusions.d.ts +2 -0
  31. package/package/dist/commands/common/projectExclusions.js +8 -0
  32. package/package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  33. package/package/dist/commands/common/sendMessageToClient.js +10 -0
  34. package/package/dist/commands/common/tsNodeImport.d.ts +2 -0
  35. package/package/dist/commands/common/tsNodeImport.js +34 -0
  36. package/package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  37. package/package/dist/commands/common/utils/fileUtils.js +33 -0
  38. package/package/dist/commands/common/utils/settings.d.ts +2 -0
  39. package/package/dist/commands/common/utils/settings.js +31 -0
  40. package/package/dist/commands/common/utils/template.d.ts +2 -0
  41. package/package/dist/commands/common/utils/template.js +31 -0
  42. package/package/dist/commands/common/utils/unixSocket.d.ts +9 -0
  43. package/package/dist/commands/common/utils/unixSocket.js +44 -0
  44. package/package/dist/commands/interface/run.d.ts +1 -0
  45. package/package/dist/commands/interface/run.js +216 -0
  46. package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  47. package/package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  48. package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  49. package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
  50. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  51. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  52. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  53. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
  54. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  55. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
  56. package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
  57. package/package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
  58. package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
  59. package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
  60. package/package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  61. package/package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  62. package/package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  63. package/package/dist/commands/intuned-cli/commands/command.js +9 -0
  64. package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  65. package/package/dist/commands/intuned-cli/commands/deploy.command.js +38 -0
  66. package/package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
  67. package/package/dist/commands/intuned-cli/commands/index.js +203 -0
  68. package/package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  69. package/package/dist/commands/intuned-cli/commands/init.command.js +13 -0
  70. package/package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  71. package/package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  72. package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  73. package/package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
  74. package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +28 -0
  75. package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
  76. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  77. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
  78. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  79. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
  80. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  81. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
  82. package/package/dist/commands/intuned-cli/commands/save.command.d.ts +13 -0
  83. package/package/dist/commands/intuned-cli/commands/save.command.js +42 -0
  84. package/package/dist/commands/intuned-cli/commands/types.d.ts +31 -0
  85. package/package/dist/commands/intuned-cli/commands/types.js +29 -0
  86. package/package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  87. package/package/dist/commands/intuned-cli/constants/index.js +25 -0
  88. package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +397 -0
  89. package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1059 -0
  90. package/package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
  91. package/package/dist/commands/intuned-cli/controller/api.js +189 -0
  92. package/package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
  93. package/package/dist/commands/intuned-cli/controller/authSession.js +420 -0
  94. package/package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  95. package/package/dist/commands/intuned-cli/controller/build.js +36 -0
  96. package/package/dist/commands/intuned-cli/controller/deploy.d.ts +4 -0
  97. package/package/dist/commands/intuned-cli/controller/deploy.js +139 -0
  98. package/package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  99. package/package/dist/commands/intuned-cli/controller/index.js +46 -0
  100. package/package/dist/commands/intuned-cli/controller/save.d.ts +14 -0
  101. package/package/dist/commands/intuned-cli/controller/save.js +345 -0
  102. package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
  103. package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
  104. package/package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  105. package/package/dist/commands/intuned-cli/helpers/api.js +19 -0
  106. package/package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
  107. package/package/dist/commands/intuned-cli/helpers/auth.js +144 -0
  108. package/package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  109. package/package/dist/commands/intuned-cli/helpers/backend.js +27 -0
  110. package/package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
  111. package/package/dist/commands/intuned-cli/helpers/browser.js +57 -0
  112. package/package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  113. package/package/dist/commands/intuned-cli/helpers/context.js +33 -0
  114. package/package/dist/commands/intuned-cli/helpers/errors.d.ts +13 -0
  115. package/package/dist/commands/intuned-cli/helpers/errors.js +37 -0
  116. package/package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
  117. package/package/dist/commands/intuned-cli/helpers/index.js +137 -0
  118. package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -0
  119. package/package/dist/commands/intuned-cli/helpers/intunedJson.js +71 -0
  120. package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  121. package/package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  122. package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  123. package/package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  124. package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  125. package/package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  126. package/package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
  127. package/package/dist/commands/intuned-cli/helpers/traces.js +32 -0
  128. package/package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  129. package/package/dist/commands/intuned-cli/helpers/validation.js +14 -0
  130. package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
  131. package/package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
  132. package/package/dist/commands/intuned-cli/index.d.ts +1 -0
  133. package/package/dist/commands/intuned-cli/index.js +16 -0
  134. package/package/dist/commands/intuned-cli/main.d.ts +1 -0
  135. package/package/dist/commands/intuned-cli/main.js +22 -0
  136. package/package/dist/commands/intuned-cli/types.d.ts +41 -0
  137. package/package/dist/commands/intuned-cli/types.js +12 -0
  138. package/package/dist/commands/ts-check.d.ts +2 -0
  139. package/package/dist/commands/ts-check.js +56 -0
  140. package/package/dist/common/Logger/Logger/index.d.ts +12 -0
  141. package/package/dist/common/Logger/Logger/index.js +60 -0
  142. package/package/dist/common/Logger/Logger/types.d.ts +8 -0
  143. package/package/dist/common/Logger/Logger/types.js +5 -0
  144. package/package/dist/common/Logger/index.d.ts +12 -0
  145. package/package/dist/common/Logger/index.js +60 -0
  146. package/package/dist/common/Logger/types.d.ts +8 -0
  147. package/package/dist/common/Logger/types.js +5 -0
  148. package/package/dist/common/assets/browser_scripts.js +2580 -0
  149. package/package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  150. package/package/dist/common/asyncLocalStorage/index.js +17 -0
  151. package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  152. package/package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  153. package/package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  154. package/package/dist/common/cleanEnvironmentVariables.js +16 -0
  155. package/package/dist/common/constants.d.ts +10 -0
  156. package/package/dist/common/constants.js +16 -0
  157. package/package/dist/common/contextStorageStateHelpers.d.ts +21 -0
  158. package/package/dist/common/contextStorageStateHelpers.js +81 -0
  159. package/package/dist/common/extensionsHelpers.d.ts +8 -0
  160. package/package/dist/common/extensionsHelpers.js +80 -0
  161. package/package/dist/common/formatZodError.d.ts +2 -0
  162. package/package/dist/common/formatZodError.js +18 -0
  163. package/package/dist/common/jwtTokenManager.d.ts +17 -0
  164. package/package/dist/common/jwtTokenManager.js +109 -0
  165. package/package/dist/common/launchBrowser.d.ts +25 -0
  166. package/package/dist/common/launchBrowser.js +172 -0
  167. package/package/dist/common/playwrightContext.d.ts +31 -0
  168. package/package/dist/common/playwrightContext.js +144 -0
  169. package/package/dist/common/runApi/errors.d.ts +72 -0
  170. package/package/dist/common/runApi/errors.js +169 -0
  171. package/package/dist/common/runApi/importUsingImportFunction.d.ts +9 -0
  172. package/package/dist/common/runApi/importUsingImportFunction.js +46 -0
  173. package/package/dist/common/runApi/index.d.ts +11 -0
  174. package/package/dist/common/runApi/index.js +199 -0
  175. package/package/dist/common/runApi/types.d.ts +830 -0
  176. package/package/dist/common/runApi/types.js +73 -0
  177. package/package/dist/common/settingsSchema.d.ts +518 -0
  178. package/package/dist/common/settingsSchema.js +57 -0
  179. package/package/dist/common/setupContextHook.d.ts +17 -0
  180. package/package/dist/common/setupContextHook.js +22 -0
  181. package/package/dist/common/telemetry.d.ts +3 -0
  182. package/package/dist/common/telemetry.js +32 -0
  183. package/package/dist/index.d.ts +4 -0
  184. package/package/dist/index.js +69 -0
  185. package/package/dist/runtime/RunError.d.ts +5 -0
  186. package/package/dist/runtime/RunError.js +19 -0
  187. package/package/dist/runtime/attemptStore.d.ts +2 -0
  188. package/package/dist/runtime/attemptStore.js +23 -0
  189. package/package/dist/runtime/downloadDirectory.d.ts +1 -0
  190. package/package/dist/runtime/downloadDirectory.js +19 -0
  191. package/package/dist/runtime/enums.d.js +5 -0
  192. package/package/dist/runtime/enums.d.ts +11 -0
  193. package/package/dist/runtime/enums.js +18 -0
  194. package/package/dist/runtime/executionHelpers.test.js +52 -0
  195. package/package/dist/runtime/export.d.js +5 -0
  196. package/package/dist/runtime/export.d.ts +228 -0
  197. package/package/dist/runtime/extendPayload.d.ts +2 -0
  198. package/package/dist/runtime/extendPayload.js +21 -0
  199. package/package/dist/runtime/extendTimeout.d.ts +1 -0
  200. package/package/dist/runtime/extendTimeout.js +23 -0
  201. package/package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  202. package/package/dist/runtime/getAuthSessionParameters.js +20 -0
  203. package/package/dist/runtime/index.d.ts +7 -0
  204. package/package/dist/runtime/index.js +54 -0
  205. package/package/dist/runtime/runInfo.d.ts +2 -0
  206. package/package/dist/runtime/runInfo.js +21 -0
  207. package/package.json +1 -2
  208. package/WebTemplate.zip +0 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTelemetryClient = getTelemetryClient;
7
+ exports.initializeAppInsights = initializeAppInsights;
8
+ var appInsights = _interopRequireWildcard(require("applicationinsights"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function gracefulShutdown() {
12
+ console.log("Shutting down, so flushing app insights.");
13
+ appInsights.defaultClient.flush();
14
+ process.exit();
15
+ }
16
+ function initializeAppInsights() {
17
+ const appInsightsConnectionString = process.env.APPINSIGHTS_CONNECTION_STRING;
18
+ if (appInsightsConnectionString) {
19
+ console.log("Initializing app insights.");
20
+ 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);
21
+ appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole] = "@intuned/sdk";
22
+ if (process.env.FLY_APP_NAME) {
23
+ appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRoleInstance] = process.env.FLY_APP_NAME;
24
+ }
25
+ process.on("SIGTERM", gracefulShutdown);
26
+ process.on("SIGINT", gracefulShutdown);
27
+ appInsights.start();
28
+ }
29
+ }
30
+ function getTelemetryClient() {
31
+ return appInsights.defaultClient;
32
+ }
@@ -0,0 +1,4 @@
1
+ export { extendPayload, extendTimeout, runInfo, RunError, getAuthSessionParameters, attemptStore, } from "./runtime";
2
+ export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage";
3
+ export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
4
+ export { withPlaywrightContext } from "./common/playwrightContext";
@@ -0,0 +1,69 @@
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 _runtime.RunError;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "attemptStore", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _runtime.attemptStore;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "extendPayload", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _runtime.extendPayload;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "extendTimeout", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _runtime.extendTimeout;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "getAuthSessionParameters", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _runtime.getAuthSessionParameters;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "getDownloadDirectoryPath", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _downloadDirectory.getDownloadDirectoryPath;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "getExecutionContext", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _asyncLocalStorage.getExecutionContext;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "runInfo", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _runtime.runInfo;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "runWithContext", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _asyncLocalStorage.runWithContext;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "withPlaywrightContext", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _playwrightContext.withPlaywrightContext;
64
+ }
65
+ });
66
+ var _runtime = require("./runtime");
67
+ var _asyncLocalStorage = require("./common/asyncLocalStorage");
68
+ var _downloadDirectory = require("./runtime/downloadDirectory");
69
+ var _playwrightContext = require("./common/playwrightContext");
@@ -0,0 +1,5 @@
1
+ import { RunErrorOptions } from "./export";
2
+ export declare class RunError extends Error {
3
+ options: RunErrorOptions;
4
+ constructor(message: string, options?: RunErrorOptions);
5
+ }
@@ -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,2 @@
1
+ import { Store } from "./export";
2
+ export declare const attemptStore: Store;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptStore = void 0;
7
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
+ const attemptStore = exports.attemptStore = Object.freeze({
9
+ get: key => {
10
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
11
+ return context?.store ? context.store[key] : undefined;
12
+ },
13
+ set: (key, value) => {
14
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
15
+ if (!context) {
16
+ throw new Error("store.set failed due to an internal error.");
17
+ }
18
+ if (!context.store) {
19
+ context.store = {};
20
+ }
21
+ context.store[key] = value;
22
+ }
23
+ });
@@ -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,11 @@
1
+ export declare enum RunEnvironment {
2
+ IDE = "IDE",
3
+ DEPLOYED = "DEPLOYED",
4
+ }
5
+
6
+ export declare enum RunType {
7
+ SYNC = "SYNC",
8
+ ASYNC = "ASYNC",
9
+ JOB = "JOB",
10
+ QUEUE = "QUEUE",
11
+ }
@@ -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,52 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
5
+ var _ = require(".");
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, _.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
+ (0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([]);
28
+ (0, _.extendPayload)({
29
+ api: "test-api",
30
+ parameters: {}
31
+ });
32
+ (0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([{
33
+ api: "test-api",
34
+ parameters: {}
35
+ }]);
36
+ (0, _.extendPayload)({
37
+ api: "test-api",
38
+ parameters: {}
39
+ });
40
+ (0, _.extendPayload)({
41
+ api: "test-api",
42
+ parameters: {}
43
+ });
44
+ (0, _.extendPayload)({
45
+ api: "test-api",
46
+ parameters: {}
47
+ });
48
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
49
+ (0, _vitest.expect)(context?.extendedPayloads).toHaveLength(4);
50
+ });
51
+ });
52
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,228 @@
1
+ import { RunEnvironment } from "./enums";
2
+
3
+ /**
4
+ * ## Description
5
+ * In the context of a job, extendTimeout will increase the timeout of the currently executing payload.
6
+ * This is useful when the payload is expected to take a long time. For example, when running pagination code.
7
+ *
8
+ * @example
9
+ * ```typescript Example
10
+ * import { extendTimeout } from "@intuned/sdk/runtime"
11
+ *
12
+ * extendTimeout();
13
+ * ```
14
+ *
15
+ */
16
+ export declare function extendTimeout(): void;
17
+
18
+ /**
19
+ * ## Description
20
+ * In the context of a job or queue execution, extendPayload appends new payloads to the end of the queue of job.
21
+ * Calling extendPayload will also call extendTimeout.
22
+ *
23
+ * @param {Payload | Payload[]} payload - The payload or array of payloads to extend. you can specify the api name and what parameters you want to pass it, the new added apis will use the same proxy and auth-session settings as the api that extended them
24
+ *
25
+ * @example
26
+ * ```typescript Single payload
27
+ * import { extendPayload } from "@intuned/sdk/runtime"
28
+ *
29
+ * // this function will append the exampleApi to the end of the queue or job it's executing in.
30
+ * extendPayload({ api: 'exampleApi', parameters: { key: 'value' } });
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```typescript Array of payloads
35
+ * import { extendPayload } from "@intuned/sdk/runtime"
36
+ *
37
+ * const payloadArray: Payload[] = [
38
+ * { api: 'exampleApi1', parameters: { key1: 'value1' } },
39
+ * { api: 'exampleApi2', parameters: { key2: 'value2' } }
40
+ * ];
41
+ *
42
+ * // this function will append 2 apis to the end of the queue or job it's executing in.
43
+ * extendPayload(payloadArray);
44
+ * ```
45
+ */
46
+ export declare function extendPayload(payload: Payload | Payload[]): void;
47
+
48
+ /**
49
+ * @interface Payload
50
+ * @property {string} api - The API path you want to extend.
51
+ * @property {Record<string, any>} parameters - A record of key-value pairs representing the parameters to be sent to the API
52
+ *
53
+ * @example
54
+ *
55
+ * ```typescript payload
56
+ * import { Payload } from "@intuned/sdk/runtime"
57
+ *
58
+ * const payload: Payload = {
59
+ * api: 'exampleApi',
60
+ * parameters: {
61
+ * key1: 'value1',
62
+ * key2: 'value2'
63
+ * }
64
+ * };
65
+ * ```
66
+ */
67
+ export interface Payload {
68
+ api: string;
69
+ parameters: Record<string, any>;
70
+ }
71
+
72
+ /**
73
+ * Retrieves information about the current run environment.
74
+ *
75
+ * @returns {RunInfo} An object containing details about the run environment and the run ID.
76
+ *
77
+ * @example
78
+ * ```typescript runInfo
79
+ * import { runInfo } from "@intuned/sdk/runtime"
80
+ *
81
+ * const info = runInfo();
82
+ * console.log(info.runEnvironment); // Outputs the run environment, IDE or DEPLOYED
83
+ * console.log(info.runId); // Outputs the run ID, if available, in IDE run id will be undefined
84
+ * ```
85
+ */
86
+ export declare function runInfo(): RunInfo;
87
+
88
+ /**
89
+ * Represents information about the current run.
90
+ *
91
+ * @interface RunInfo
92
+ * @property {RunEnvironment} runEnvironment - the run environment `IDE` or `DEPLOYED`
93
+ * @property {string} [runId] - Optional. The ID of the current run, in IDE environment, run id will be undefined
94
+ */
95
+ export interface RunInfo {
96
+ runEnvironment: RunEnvironment;
97
+ runId?: string;
98
+ jobId?: string;
99
+ jobRunId?: string;
100
+ queueId?: string;
101
+ proxy?: string;
102
+ authSessionId?: string;
103
+ }
104
+
105
+ /**
106
+ * @interface RunErrorOptions
107
+ * @property {boolean} [retryable] - Optional. Indicates whether the error is retryable.
108
+ * @property {number} [status_code] - Optional. The HTTP status code associated with the error.
109
+ * @property {string} [error_code] - Optional. A specific error code to identify the type of error.
110
+ *
111
+ * @example
112
+ * ```typescript RunErrorOptions
113
+ * import { RunErrorOptions } from "@intuned/sdk/runtime"
114
+ *
115
+ * const options: RunErrorOptions = {
116
+ * retryable: true,
117
+ * status_code: 500,
118
+ * error_code: 'SERVER_ERROR'
119
+ * };
120
+ * ```
121
+ */
122
+ export interface RunErrorOptions {
123
+ retryable?: boolean;
124
+ status_code?: number;
125
+ error_code?: string;
126
+ }
127
+
128
+ /**
129
+ * @deprecated This error is deprecated. it will be treated like any normal error
130
+ *
131
+ * Represents an error that occurs during a run.
132
+ *
133
+ * @class
134
+ * @extends Error
135
+ *
136
+ * @param {string} message - The error message.
137
+ * @param {RunErrorOptions} [options] - Optional. Additional options for the error.
138
+ *
139
+ * @property {RunErrorOptions} options - The options associated with the error.
140
+ *
141
+ * @example
142
+ * ```typescript RunError
143
+ * import { RunError } from "@intuned/sdk/runtime"
144
+ *
145
+ * throw new RunError('An error occurred', {
146
+ * retryable: true,
147
+ * status_code: 500,
148
+ * error_code: 'SERVER_ERROR'
149
+ * });
150
+ *
151
+ * ```
152
+ */
153
+ export declare class RunError extends Error {
154
+ constructor(message: string, options?: RunErrorOptions);
155
+ options: RunErrorOptions;
156
+ }
157
+
158
+ /**
159
+ * Retrieves the parameters for the authentication session currently being used.
160
+ *
161
+ * @returns {AuthSessionParameters} An object containing the parameters for the current authentication session.
162
+ *
163
+ * @example
164
+ * ```typescript getAuthSessionParameters
165
+ * import { getAuthSessionParameters } from "@intuned/sdk/runtime"
166
+ *
167
+ * const authSessionParams = getAuthSessionParameters();
168
+ * console.log(authSessionParams);
169
+ * ```
170
+ */
171
+ export declare function getAuthSessionParameters(): Promise<any>;
172
+
173
+ /**
174
+ * @interface Store
175
+ * @property {function} get - Retrieves a value from the store by key
176
+ * @property {function} set - Sets a value in the store by key
177
+ *
178
+ * @example
179
+ * ```typescript Store usage
180
+ * import { store } from "@intuned/sdk/runtime"
181
+ *
182
+ * // Set a value in the store
183
+ * store.set('userPreference', { theme: 'dark' });
184
+ *
185
+ * // Get a value from the store
186
+ * const preference = store.get('userPreference');
187
+ * ```
188
+ */
189
+ export interface Store {
190
+ /**
191
+ * Retrieves a value from the store by key.
192
+ *
193
+ * @param {string} key - The key to retrieve the value for
194
+ * @returns {any} The value associated with the key, or undefined if not found
195
+ */
196
+ get(key: string): any;
197
+
198
+ /**
199
+ * Sets a value in the store by key.
200
+ *
201
+ * @param {string} key - The key to set the value for
202
+ * @param {any} value - The value to store
203
+ * @throws {Error} Throws an error if the store operation fails
204
+ */
205
+ set(key: string, value: any): void;
206
+ }
207
+
208
+ /**
209
+ * ## Description
210
+ * A persistent key-value store that maintains data within the execution context.
211
+ * This store allows you to share data between different parts of your API execution.
212
+ *
213
+ * @example
214
+ * ```typescript Store usage
215
+ * import { store } from "@intuned/sdk/runtime"
216
+ *
217
+ * // Set a value in the store
218
+ * store.set('sessionData', { userId: '123', token: 'abc' });
219
+ *
220
+ * // Get a value from the store
221
+ * const sessionData = store.get('sessionData');
222
+ * console.log(sessionData.userId); // '123'
223
+ *
224
+ * // Handle missing values
225
+ * const missingData = store.get('nonexistent'); // undefined
226
+ * ```
227
+ */
228
+ export declare const attemptStore: Store;
@@ -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?.extendedPayloads.push(...items);
20
+ (0, _extendTimeout.extendTimeout)();
21
+ }
@@ -0,0 +1 @@
1
+ export declare function extendTimeout(): void;
@@ -0,0 +1,23 @@
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.extendTimeoutCallback !== undefined) {
21
+ void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
22
+ }
23
+ }
@@ -0,0 +1 @@
1
+ export declare function getAuthSessionParameters(): Promise<any>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAuthSessionParameters = getAuthSessionParameters;
7
+ var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
+ async function getAuthSessionParameters() {
9
+ const context = (0, _asyncLocalStorage.getExecutionContext)();
10
+ if (!context) {
11
+ throw new Error("getAuthSessionParameters failed due to an internal error (context was not found).");
12
+ }
13
+ const {
14
+ getAuthSessionParameters
15
+ } = context;
16
+ if (!getAuthSessionParameters) {
17
+ throw new Error("getAuthSessionParameters failed due to an internal error (helper was not found on context).");
18
+ }
19
+ return await getAuthSessionParameters();
20
+ }
@@ -0,0 +1,7 @@
1
+ export { extendPayload } from "./extendPayload";
2
+ export { extendTimeout } from "./extendTimeout";
3
+ export { attemptStore } from "./attemptStore";
4
+ export { getAuthSessionParameters } from "./getAuthSessionParameters";
5
+ export { runInfo } from "./runInfo";
6
+ export { RunError } from "./RunError";
7
+ export { getDownloadDirectoryPath } from "./downloadDirectory";
@@ -0,0 +1,54 @@
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, "attemptStore", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _attemptStore.attemptStore;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "extendPayload", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _extendPayload.extendPayload;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "extendTimeout", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _extendTimeout.extendTimeout;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "getAuthSessionParameters", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _getAuthSessionParameters.getAuthSessionParameters;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "getDownloadDirectoryPath", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _downloadDirectory.getDownloadDirectoryPath;
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 _attemptStore = require("./attemptStore");
51
+ var _getAuthSessionParameters = require("./getAuthSessionParameters");
52
+ var _runInfo = require("./runInfo");
53
+ var _RunError = require("./RunError");
54
+ var _downloadDirectory = require("./downloadDirectory");
@@ -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
+ }