@intuned/runtime-dev 0.1.0-test.2 → 0.1.0-test.21

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 (56) hide show
  1. package/Intuned.json +1 -1
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/authSessions/check.ts +3 -5
  4. package/WebTemplate/controllers/authSessions/create.ts +4 -7
  5. package/WebTemplate/controllers/runApi/helpers.ts +11 -7
  6. package/WebTemplate/index.playwright.ts +32 -42
  7. package/WebTemplate/jobs.ts +13 -2
  8. package/WebTemplate/utils.ts +51 -1
  9. package/api/test2.ts +7 -5
  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 +6 -2
  22. package/dist/commands/auth-sessions/run-check.js +3 -1
  23. package/dist/commands/auth-sessions/run-create.js +4 -2
  24. package/dist/commands/build.js +7 -4
  25. package/dist/commands/common/browserUtils.js +1 -1
  26. package/dist/commands/common/getFirstLineNumber.test.js +2 -2
  27. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  28. package/dist/commands/common/{getDefaultExportFromFile.js → tsNodeImport.js} +3 -4
  29. package/dist/commands/common/utils/settings.js +1 -1
  30. package/dist/commands/common/utils/webTemplate.js +2 -2
  31. package/dist/commands/interface/run.js +131 -107
  32. package/dist/commands/ts-check.js +2 -2
  33. package/dist/common/Logger/Logger/index.d.ts +1 -1
  34. package/dist/common/Logger/index.d.ts +1 -1
  35. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  36. package/dist/common/getPlaywrightConstructs.js +3 -3
  37. package/dist/common/runApi/errors.d.ts +1 -1
  38. package/dist/common/runApi/index.d.ts +4 -4
  39. package/dist/common/runApi/index.js +27 -68
  40. package/dist/common/runApi/types.d.ts +20 -6
  41. package/dist/common/runApi/types.js +5 -1
  42. package/dist/index.d.ts +4 -4
  43. package/dist/index.js +12 -12
  44. package/dist/runtime/RunError.d.ts +1 -1
  45. package/dist/runtime/executionHelpers.test.js +2 -2
  46. package/dist/runtime/export.d.ts +1 -1
  47. package/dist/runtime/extendPayload.d.ts +1 -1
  48. package/dist/runtime/extendPayload.js +1 -1
  49. package/dist/runtime/index.d.ts +7 -7
  50. package/dist/runtime/index.js +6 -6
  51. package/dist/runtime/runInfo.d.ts +1 -1
  52. package/dist/runtime/runInfo.js +1 -1
  53. package/package.json +4 -4
  54. package/preserve-dynamic-imports.js +16 -0
  55. package/tsconfig.json +1 -1
  56. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
package/Intuned.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "authSessions": {
3
- "enabled": true
3
+ "enabled": false
4
4
  }
5
5
  }
@@ -33,109 +33,107 @@ import {
33
33
  } from "./headers";
34
34
  import { FEATURES } from "./features";
35
35
 
36
- export function registerApiEndpoints() {
37
- if (!isJobRunMachine()) {
38
- app.use((req, _, next) => {
39
- const runId = req.headers[RUN_ID_HEADER] as string;
40
- const jobId = req.headers[JOB_ID_HEADER] as string;
41
- const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
42
- const queueId = req.headers[QUEUE_ID_HEADER] as string;
43
- const proxy = req?.body?.proxy
44
- ? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
45
- : undefined;
46
- const contextData = {
47
- runId: runId ?? "",
48
- jobId,
49
- jobRunId,
50
- queueId,
51
- proxy,
52
- ...(req?.body?.executionContext ?? {}),
53
- };
54
- runWithContext(contextData, next);
55
- });
56
-
57
- app.get(
58
- "/api/protected/health",
59
- accessKeyValidatorMiddleware,
60
- async (req, res) => {
61
- res.status(200).json({ status: "ok" });
62
- }
63
- );
36
+ if (!isJobRunMachine()) {
37
+ app.use((req, _, next) => {
38
+ const runId = req.headers[RUN_ID_HEADER] as string;
39
+ const jobId = req.headers[JOB_ID_HEADER] as string;
40
+ const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
41
+ const queueId = req.headers[QUEUE_ID_HEADER] as string;
42
+ const proxy = req?.body?.proxy
43
+ ? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
44
+ : undefined;
45
+ const contextData = {
46
+ runId: runId ?? "",
47
+ jobId,
48
+ jobRunId,
49
+ queueId,
50
+ proxy,
51
+ ...(req?.body?.executionContext ?? {}),
52
+ };
53
+ runWithContext(contextData, next);
54
+ });
64
55
 
65
- app.post(
66
- "/api/auth-session/create",
67
- accessKeyValidatorMiddleware,
68
- errorRetryMiddleware(createAuthSessionController)
69
- );
56
+ app.get(
57
+ "/api/protected/health",
58
+ accessKeyValidatorMiddleware,
59
+ async (req, res) => {
60
+ res.status(200).json({ status: "ok" });
61
+ }
62
+ );
70
63
 
71
- app.post(
72
- "/api/auth-session-async/create",
73
- accessKeyValidatorMiddleware,
74
- errorRetryMiddleware(createAuthSessionAsyncController)
75
- );
64
+ app.post(
65
+ "/api/auth-session/create",
66
+ accessKeyValidatorMiddleware,
67
+ errorRetryMiddleware(createAuthSessionController)
68
+ );
76
69
 
77
- app.post(
78
- "/api/auth-session/check",
79
- accessKeyValidatorMiddleware,
80
- errorRetryMiddleware(checkAuthSessionController)
81
- );
70
+ app.post(
71
+ "/api/auth-session-async/create",
72
+ accessKeyValidatorMiddleware,
73
+ errorRetryMiddleware(createAuthSessionAsyncController)
74
+ );
82
75
 
83
- app.post(
84
- "/api/auth-session-async/check",
85
- accessKeyValidatorMiddleware,
86
- errorRetryMiddleware(checkAuthSessionAsyncController)
87
- );
76
+ app.post(
77
+ "/api/auth-session/check",
78
+ accessKeyValidatorMiddleware,
79
+ errorRetryMiddleware(checkAuthSessionController)
80
+ );
88
81
 
89
- app.post(
90
- "/api/auth-session/kill",
91
- accessKeyValidatorMiddleware,
92
- errorRetryMiddleware(killAuthSessionOperationController)
93
- );
82
+ app.post(
83
+ "/api/auth-session-async/check",
84
+ accessKeyValidatorMiddleware,
85
+ errorRetryMiddleware(checkAuthSessionAsyncController)
86
+ );
94
87
 
95
- app.post(
96
- "/api/auth-session/resume",
97
- accessKeyValidatorMiddleware,
98
- errorRetryMiddleware(resumeAuthSessionOperationController)
99
- );
88
+ app.post(
89
+ "/api/auth-session/kill",
90
+ accessKeyValidatorMiddleware,
91
+ errorRetryMiddleware(killAuthSessionOperationController)
92
+ );
100
93
 
101
- app.post(
102
- "/api/auth-session-async/resume",
103
- accessKeyValidatorMiddleware,
104
- errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
105
- );
94
+ app.post(
95
+ "/api/auth-session/resume",
96
+ accessKeyValidatorMiddleware,
97
+ errorRetryMiddleware(resumeAuthSessionOperationController)
98
+ );
106
99
 
107
- app.post(
108
- "/api/run/*",
109
- accessKeyValidatorMiddleware,
110
- errorRetryMiddleware(runApiController)
111
- );
100
+ app.post(
101
+ "/api/auth-session-async/resume",
102
+ accessKeyValidatorMiddleware,
103
+ errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
104
+ );
112
105
 
113
- app.post(
114
- "/api/run-async/start/*",
115
- accessKeyValidatorMiddleware,
116
- errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
117
- );
106
+ app.post(
107
+ "/api/run/*",
108
+ accessKeyValidatorMiddleware,
109
+ errorRetryMiddleware(runApiController)
110
+ );
118
111
 
119
- app.get(
120
- "/api/run-async/count",
121
- accessKeyValidatorMiddleware,
122
- getActiveAsyncEndpointController
123
- );
112
+ app.post(
113
+ "/api/run-async/start/*",
114
+ accessKeyValidatorMiddleware,
115
+ errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
116
+ );
124
117
 
125
- app.post(
126
- "/api/trace/upload/:runId",
127
- accessKeyValidatorMiddleware,
128
- uploadTraceController
129
- );
118
+ app.get(
119
+ "/api/run-async/count",
120
+ accessKeyValidatorMiddleware,
121
+ getActiveAsyncEndpointController
122
+ );
130
123
 
131
- app.post(
132
- "/api/trace/delete/:runId",
133
- accessKeyValidatorMiddleware,
134
- deleteTraceController
135
- );
136
- }
124
+ app.post(
125
+ "/api/trace/upload/:runId",
126
+ accessKeyValidatorMiddleware,
127
+ uploadTraceController
128
+ );
137
129
 
138
- app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
139
- res.status(200).json({ features: FEATURES });
140
- });
130
+ app.post(
131
+ "/api/trace/delete/:runId",
132
+ accessKeyValidatorMiddleware,
133
+ deleteTraceController
134
+ );
141
135
  }
136
+
137
+ app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
138
+ res.status(200).json({ features: FEATURES });
139
+ });
@@ -1,6 +1,7 @@
1
1
  import { readJSON } from "fs-extra";
2
2
  import { isHeadless } from "../../utils";
3
3
  import { runApi } from "@intuned/runtime/dist/common/runApi";
4
+ import { importModule } from "../../utils";
4
5
 
5
6
  export async function checkAuthSession({
6
7
  proxy,
@@ -32,7 +33,7 @@ export async function checkAuthSession({
32
33
 
33
34
  const result = await runApi<boolean>({
34
35
  automationFunction: {
35
- name: "auth-sessions/check",
36
+ module: await importModule("auth-sessions/check"),
36
37
  },
37
38
  runOptions: {
38
39
  environment: "deployed",
@@ -48,10 +49,7 @@ export async function checkAuthSession({
48
49
  },
49
50
  });
50
51
  if (result.isErr()) {
51
- return {
52
- status: 500,
53
- body: result.error,
54
- };
52
+ return result.error.apiResponse;
55
53
  }
56
54
  return {
57
55
  status: 200,
@@ -1,5 +1,5 @@
1
1
  import { authSessionsContextsStore } from "./store";
2
- import { getTraceFilePath, isHeadless } from "../../utils";
2
+ import { getTraceFilePath, isHeadless, importModule } from "../../utils";
3
3
  import * as fs from "fs-extra";
4
4
  import { runApiGenerator } from "@intuned/runtime/dist/common/runApi";
5
5
  import type { RequestMoreInfoDetails } from "@intuned/runtime/dist/runtime";
@@ -53,8 +53,8 @@ export async function createAuthSession({
53
53
  unknown
54
54
  >({
55
55
  automationFunction: {
56
- name: "auth-sessions/create",
57
- params: parameters ?? {},
56
+ module: await importModule("auth-sessions/create"),
57
+ params: parameters,
58
58
  },
59
59
  tracing: saveTrace
60
60
  ? {
@@ -77,10 +77,7 @@ export async function createAuthSession({
77
77
  const r = result.value;
78
78
 
79
79
  if (r.isErr()) {
80
- return {
81
- status: 500,
82
- body: r.error,
83
- };
80
+ return r.error.apiResponse;
84
81
  }
85
82
 
86
83
  return {
@@ -1,4 +1,8 @@
1
- import { getTraceFilePath, waitWithExtendableTimeout } from "../../utils";
1
+ import {
2
+ getTraceFilePath,
3
+ importModule,
4
+ waitWithExtendableTimeout,
5
+ } from "../../utils";
2
6
  import * as fs from "fs-extra";
3
7
  import { getExecutionContext } from "@intuned/runtime";
4
8
  import { backendFunctionsTokenManager } from "@intuned/runtime/dist/common/jwtTokenManager";
@@ -64,18 +68,18 @@ export async function runApi({
64
68
  const resultWithTimeout = await waitWithExtendableTimeout({
65
69
  promise: runApiInternal({
66
70
  automationFunction: {
67
- name: `api/${functionName}`,
68
- params: params ?? {},
71
+ module: await importModule(`api/${functionName}`),
72
+ params,
69
73
  },
70
- auth: !isAuthSessionEnabled
71
- ? undefined
72
- : {
74
+ auth: isAuthSessionEnabled
75
+ ? {
73
76
  session: {
74
77
  type: "state",
75
78
  state: session,
76
79
  },
77
80
  runCheck: isAuthSessionEnabled,
78
- },
81
+ }
82
+ : undefined,
79
83
  runOptions: {
80
84
  environment: "deployed",
81
85
  headless,
@@ -6,52 +6,42 @@ import { getExecutionContext } from "@intuned/runtime";
6
6
  import { app } from "./app";
7
7
  import { RUN_ID_HEADER } from "./headers";
8
8
  import { ShutdownController } from "./shutdown";
9
- import { registerApiEndpoints } from "./api";
10
- import { runJobsLoop } from "./jobs";
11
- import { isJobRunMachine } from "./utils";
12
9
 
13
- void main();
10
+ const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
14
11
 
15
- async function main() {
16
- const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
12
+ initializeAppInsights();
17
13
 
18
- initializeAppInsights();
19
-
20
- app.use((req, res, next) => {
21
- // Cleanup after the response is sent
22
- res.on("finish", () => {
23
- console.log("finished", req.headers[RUN_ID_HEADER]);
24
- void ShutdownController.instance.checkForShutdown();
25
- });
26
-
27
- next();
28
- });
29
-
30
- registerApiEndpoints();
31
- if (isJobRunMachine()) {
32
- console.log("Running in job v3 mode");
33
- void runJobsLoop();
34
- }
35
-
36
- const server = app.listen(port, () => {
37
- // when deployed on flyio, the server will be turned on and
38
- // will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
39
- ShutdownController.initialize(server);
14
+ app.use((req, res, next) => {
15
+ // Cleanup after the response is sent
16
+ res.on("finish", () => {
17
+ console.log("finished", req.headers[RUN_ID_HEADER]);
40
18
  void ShutdownController.instance.checkForShutdown();
41
- console.log(`Server is running on port ${port}`);
42
19
  });
43
20
 
44
- process.on("unhandledRejection", (reason, promise) => {
45
- const telemetryClient = getTelemetryClient();
46
- console.error("Unhandled Rejection at:", promise, "reason:", reason);
47
- const context = getExecutionContext();
48
- telemetryClient?.trackEvent({
49
- name: "UNHANDLED_REJECTION",
50
- properties: {
51
- runId: context?.runId,
52
- promise,
53
- reason,
54
- },
55
- });
21
+ next();
22
+ });
23
+
24
+ export * from "./api";
25
+ export * from "./jobs";
26
+
27
+ const server = app.listen(port, () => {
28
+ // when deployed on flyio, the server will be turned on and
29
+ // will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
30
+ ShutdownController.initialize(server);
31
+ void ShutdownController.instance.checkForShutdown();
32
+ console.log(`Server is running on port ${port}`);
33
+ });
34
+
35
+ process.on("unhandledRejection", (reason, promise) => {
36
+ const telemetryClient = getTelemetryClient();
37
+ console.error("Unhandled Rejection at:", promise, "reason:", reason);
38
+ const context = getExecutionContext();
39
+ telemetryClient?.trackEvent({
40
+ name: "UNHANDLED_REJECTION",
41
+ properties: {
42
+ runId: context?.runId,
43
+ promise,
44
+ reason,
45
+ },
56
46
  });
57
- }
47
+ });
@@ -6,7 +6,13 @@ import {
6
6
  RUN_ID_HEADER,
7
7
  SHOULD_SHUTDOWN_HEADER,
8
8
  } from "./headers";
9
- import { getErrorResponse, isHeadless, ProxyConfig, proxyToUrl } from "./utils";
9
+ import {
10
+ getErrorResponse,
11
+ isHeadless,
12
+ isJobRunMachine,
13
+ ProxyConfig,
14
+ proxyToUrl,
15
+ } from "./utils";
10
16
  import {
11
17
  callBackendFunctionWithToken,
12
18
  backendFunctionsTokenManager,
@@ -26,6 +32,11 @@ type JobPayload = {
26
32
  traceSignedUrl?: string;
27
33
  };
28
34
 
35
+ if (isJobRunMachine()) {
36
+ console.log("Running in job v3 mode");
37
+ void jobsV3();
38
+ }
39
+
29
40
  async function runApiInContext(
30
41
  jobPayload: JobPayload
31
42
  ): Promise<Awaited<ReturnType<typeof runApi>>> {
@@ -72,7 +83,7 @@ async function runApiInContext(
72
83
  }
73
84
  }
74
85
 
75
- export async function runJobsLoop() {
86
+ async function jobsV3() {
76
87
  await reportReady();
77
88
  const initialDelay = 1000;
78
89
  let delay = initialDelay;
@@ -1,7 +1,7 @@
1
1
  import * as playwright from "@intuned/playwright-core";
2
2
  import { Handler, Response } from "@tinyhttp/app";
3
3
  import * as path from "path";
4
- import { getExecutionContext } from "@intuned/runtime/dist/common/asyncLocalStorage";
4
+ import { getExecutionContext } from "@intuned/runtime";
5
5
  import { setTimeout } from "timers/promises";
6
6
 
7
7
  export class FunctionNotFoundError extends Error {
@@ -208,3 +208,53 @@ export async function waitWithExtendableTimeout<T>({
208
208
  result: await promise,
209
209
  };
210
210
  }
211
+
212
+ export async function importModule(path: string) {
213
+ // cleanup environment variables before running the user code
214
+ // cleanEnvironmentVariables();
215
+
216
+ const [folderName, ...functionNameParts] = path.split("/");
217
+ const functionNameDepth = functionNameParts.length;
218
+
219
+ // string literals should be inline
220
+ // currently we support only 5 levels of depth
221
+ // rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
222
+ try {
223
+ let imported: any = undefined;
224
+ switch (functionNameDepth) {
225
+ case 1:
226
+ imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
227
+ break;
228
+ case 2:
229
+ imported = await import(
230
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`
231
+ );
232
+ break;
233
+ case 3:
234
+ imported = await import(
235
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`
236
+ );
237
+ break;
238
+ case 4:
239
+ imported = await import(
240
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`
241
+ );
242
+ break;
243
+ case 5:
244
+ imported = await import(
245
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`
246
+ );
247
+ break;
248
+ default:
249
+ throw new Error(
250
+ "intuned supports maximum 5 levels of depth in the api folder"
251
+ );
252
+ }
253
+ return imported;
254
+ } catch (error: any) {
255
+ if (error.message.includes("Unknown variable dynamic import")) {
256
+ throw new FunctionNotFoundError("", path);
257
+ }
258
+ throw error;
259
+ }
260
+ }
package/api/test2.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Page, BrowserContext } from "@intuned/playwright-core";
2
- import { extendTimeout } from "../src/runtime/extendTimeout";
3
- import { requestOTP } from "../src/runtime/requestMoreInfo";
2
+ import { extendTimeout, extendPayload } from "../src/runtime";
4
3
 
5
- export default async function* test2(
4
+ export default async function test2(
6
5
  { n }: { n?: number },
7
6
  page: Page,
8
7
  context: BrowserContext
@@ -10,8 +9,6 @@ export default async function* test2(
10
9
  await page.goto("https://wikipedia.org/");
11
10
  await page.waitForTimeout(1000);
12
11
 
13
- yield requestOTP("Please enter the OTP");
14
-
15
12
  const titles: string[] = [];
16
13
 
17
14
  for (let i = 0; i < (n ?? 2); i++) {
@@ -21,5 +18,10 @@ export default async function* test2(
21
18
  extendTimeout();
22
19
  }
23
20
 
21
+ extendPayload({
22
+ api: "test",
23
+ parameters: {},
24
+ });
25
+
24
26
  return { titles };
25
27
  }
@@ -5,5 +5,7 @@ export default async function check(
5
5
  _context: BrowserContext
6
6
  ): Promise<boolean> {
7
7
  await page.goto("https://setcookie.net");
8
- return (await page.locator("ul li code").all()).length > 0;
8
+ const result = (await page.locator("ul li code").all()).length > 0;
9
+ console.log("Check result", result);
10
+ return result;
9
11
  }
@@ -15,16 +15,16 @@ export default async function* create(
15
15
  await page.locator("#value").fill("password");
16
16
  await page.locator("input[type=submit]").click();
17
17
 
18
- console.log("Received", yield requestOTP("Enter useless otp"));
19
- console.log(
20
- "Received",
21
- yield requestMultipleChoice("Choose the correct answer", [
22
- "A",
23
- "B",
24
- "C",
25
- "D",
26
- ])
27
- );
18
+ // console.log("Received", yield requestOTP("Enter useless otp"));
19
+ // console.log(
20
+ // "Received",
21
+ // yield requestMultipleChoice("Choose the correct answer", [
22
+ // "A",
23
+ // "B",
24
+ // "C",
25
+ // "D",
26
+ // ])
27
+ // );
28
28
 
29
29
  await page.goto("http://www.sharonminsuk.com/code/storage-test.html");
30
30
  await page.locator("#local").fill("intuned");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/api/run.js");
2
+ void import("../dist/commands/api/run.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/auth-sessions/run-check.js");
2
+ void import("../dist/commands/auth-sessions/run-check.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/auth-sessions/run-create.js");
2
+ void import("../dist/commands/auth-sessions/run-create.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/auth-sessions/load.js");
2
+ void import("../dist/commands/auth-sessions/load.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/auth-sessions/run-refresh.js");
2
+ void import("../dist/commands/auth-sessions/run-refresh.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/browser/save-state.js");
2
+ void import("../dist/commands/browser/save-state.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/browser/start-browser.js");
2
+ void import("../dist/commands/browser/start-browser.js");
package/bin/intuned-build CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/build.js");
2
+ void import("../dist/commands/build.js");
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../dist/commands/ts-check.js");
2
+ void import("../dist/commands/ts-check.js");
@@ -16,6 +16,8 @@ var _Logger = require("../../common/Logger");
16
16
  var _nanoid = require("nanoid");
17
17
  var _chalk = _interopRequireDefault(require("chalk"));
18
18
  var _runApi = require("../../common/runApi");
19
+ var _tsNodeImport = require("../common/tsNodeImport");
20
+ var _fileUtils = require("../common/utils/fileUtils");
19
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
22
  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); }
21
23
  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 && Object.prototype.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; }
@@ -36,10 +38,12 @@ async function executeCLI(apiName, mode, inputData, options) {
36
38
  throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
37
39
  }
38
40
  }
41
+ const apiFilePath = (0, _fileUtils.getFullPathInProject)("api", `${apiName}.ts`);
42
+ const runApiModule = await (0, _tsNodeImport.tsNodeImport)(apiFilePath);
39
43
  const runApiResult = await (0, _runApi.runApi)({
40
44
  automationFunction: {
41
- name: `api/${apiName}`,
42
- params: inputData ?? {}
45
+ module: runApiModule,
46
+ params: inputData
43
47
  },
44
48
  auth: authSessionPathToUse ? {
45
49
  session: {
@@ -8,6 +8,7 @@ var _settings = require("../common/utils/settings");
8
8
  var _dotenv = _interopRequireDefault(require("dotenv"));
9
9
  var _constants = require("../../common/constants");
10
10
  var _runApi = require("../../common/runApi");
11
+ var _tsNodeImport = require("../common/tsNodeImport");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  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); }
13
14
  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 && Object.prototype.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; }
@@ -26,9 +27,10 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
26
27
  if (!fs.exists(checkFilePath)) {
27
28
  throw new Error("auth session check file not found");
28
29
  }
30
+ const checkModule = await (0, _tsNodeImport.tsNodeImport)(checkFilePath);
29
31
  const runApiResult = await (0, _runApi.runApi)({
30
32
  automationFunction: {
31
- name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
33
+ module: checkModule
32
34
  },
33
35
  runOptions: {
34
36
  environment: "ide",