@intuned/runtime-dev 0.1.0-test.10 → 0.1.0-test.12

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 (103) hide show
  1. package/.babelrc +1 -2
  2. package/dist/commands/api/run.js +170 -105
  3. package/dist/commands/api/run.ts +105 -0
  4. package/dist/commands/auth-sessions/load.js +26 -28
  5. package/dist/commands/auth-sessions/load.ts +30 -0
  6. package/dist/commands/auth-sessions/run-check.js +53 -52
  7. package/dist/commands/auth-sessions/run-check.ts +51 -0
  8. package/dist/commands/auth-sessions/run-create.js +96 -91
  9. package/dist/commands/auth-sessions/run-create.ts +91 -0
  10. package/dist/commands/browser/save-state.js +16 -14
  11. package/dist/commands/browser/save-state.ts +14 -0
  12. package/dist/commands/browser/start-browser.js +11 -11
  13. package/dist/commands/browser/start-browser.ts +11 -0
  14. package/dist/commands/build.js +108 -75
  15. package/dist/commands/build.ts +78 -0
  16. package/dist/commands/common/browserUtils.js +51 -53
  17. package/dist/commands/common/browserUtils.ts +45 -0
  18. package/dist/commands/common/getDefaultExportFromFile.js +12 -17
  19. package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
  20. package/dist/commands/common/getFirstLineNumber.js +93 -93
  21. package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
  22. package/dist/commands/common/getFirstLineNumber.ts +96 -0
  23. package/dist/commands/common/sendMessageToClient.js +4 -9
  24. package/dist/commands/common/sendMessageToClient.ts +3 -0
  25. package/dist/commands/common/utils/fileUtils.js +22 -32
  26. package/dist/commands/common/utils/fileUtils.ts +23 -0
  27. package/dist/commands/common/utils/settings.js +19 -27
  28. package/dist/commands/common/utils/settings.ts +22 -0
  29. package/dist/commands/common/utils/unixSocket.js +43 -43
  30. package/dist/commands/common/utils/unixSocket.ts +38 -0
  31. package/dist/commands/common/utils/webTemplate.js +27 -29
  32. package/dist/commands/common/utils/webTemplate.ts +22 -0
  33. package/dist/commands/interface/run.js +151 -150
  34. package/dist/commands/interface/run.ts +156 -0
  35. package/dist/commands/ts-check.js +49 -49
  36. package/dist/commands/ts-check.ts +50 -0
  37. package/dist/common/Logger/Logger/index.d.ts +1 -1
  38. package/dist/common/Logger/Logger/index.js +42 -55
  39. package/dist/common/Logger/Logger/index.ts +53 -0
  40. package/dist/common/Logger/Logger/types.js +1 -5
  41. package/dist/common/Logger/Logger/types.ts +1 -0
  42. package/dist/common/Logger/index.d.ts +1 -1
  43. package/dist/common/Logger/index.js +42 -55
  44. package/dist/common/Logger/index.ts +53 -0
  45. package/dist/common/Logger/types.js +1 -5
  46. package/dist/common/Logger/types.ts +1 -0
  47. package/dist/common/asyncLocalStorage/index.js +8 -16
  48. package/dist/common/asyncLocalStorage/index.ts +9 -0
  49. package/dist/common/cleanEnvironmentVariables.js +12 -16
  50. package/dist/common/cleanEnvironmentVariables.ts +10 -0
  51. package/dist/common/constants.js +1 -7
  52. package/dist/common/constants.ts +1 -0
  53. package/dist/common/contextStorageStateHelpers.js +38 -47
  54. package/dist/common/contextStorageStateHelpers.ts +43 -0
  55. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  56. package/dist/common/getPlaywrightConstructs.js +196 -177
  57. package/dist/common/getPlaywrightConstructs.ts +181 -0
  58. package/dist/common/jwtTokenManager.js +79 -76
  59. package/dist/common/jwtTokenManager.ts +71 -0
  60. package/dist/common/runApi/errors.d.ts +1 -1
  61. package/dist/common/runApi/errors.js +150 -159
  62. package/dist/common/runApi/errors.ts +154 -0
  63. package/dist/common/runApi/index.d.ts +4 -4
  64. package/dist/common/runApi/index.js +220 -269
  65. package/dist/common/runApi/index.ts +253 -0
  66. package/dist/common/runApi/types.d.ts +1 -1
  67. package/dist/common/runApi/types.js +56 -49
  68. package/dist/common/runApi/types.ts +43 -0
  69. package/dist/common/settingsSchema.js +10 -15
  70. package/dist/common/settingsSchema.ts +9 -0
  71. package/dist/common/telemetry.js +30 -28
  72. package/dist/common/telemetry.ts +23 -0
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -69
  75. package/dist/index.ts +4 -0
  76. package/dist/runtime/RunError.d.ts +1 -1
  77. package/dist/runtime/RunError.js +11 -18
  78. package/dist/runtime/RunError.ts +12 -0
  79. package/dist/runtime/downloadDirectory.js +13 -19
  80. package/dist/runtime/downloadDirectory.ts +13 -0
  81. package/dist/runtime/enums.d.ts +1 -11
  82. package/dist/runtime/enums.js +12 -18
  83. package/dist/runtime/enums.ts +12 -0
  84. package/dist/runtime/executionHelpers.test.ts +51 -0
  85. package/dist/runtime/export.d.ts +1 -202
  86. package/dist/runtime/extendPayload.d.ts +1 -1
  87. package/dist/runtime/extendPayload.js +15 -21
  88. package/dist/runtime/extendPayload.ts +15 -0
  89. package/dist/runtime/extendTimeout.js +21 -28
  90. package/dist/runtime/extendTimeout.ts +24 -0
  91. package/dist/runtime/index.d.ts +7 -7
  92. package/dist/runtime/index.js +6 -53
  93. package/dist/runtime/index.ts +6 -0
  94. package/dist/runtime/requestMoreInfo.js +16 -23
  95. package/dist/runtime/requestMoreInfo.ts +18 -0
  96. package/dist/runtime/runInfo.d.ts +1 -1
  97. package/dist/runtime/runInfo.js +14 -21
  98. package/dist/runtime/runInfo.ts +15 -0
  99. package/package.json +3 -2
  100. package/tsconfig.json +1 -1
  101. package/dist/runtime/enums.d.js +0 -5
  102. package/dist/runtime/executionHelpers.test.js +0 -53
  103. package/dist/runtime/export.d.js +0 -5
@@ -0,0 +1,22 @@
1
+ import * as fs from "fs-extra";
2
+ import * as path from "path";
3
+ import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils.js";
4
+ export const moveWebTemplateFiles = async () => {
5
+ await fs.remove("./intuned");
6
+ await fs.ensureDir("./intuned");
7
+ const currentFileLocation = path.resolve(__dirname, "..", "..", "..", "..", "WebTemplate");
8
+ await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
9
+ filter: (src, dest) => {
10
+ if (src.includes(".d.ts")) {
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+ });
16
+ const filesAndFolders = await listProjectFilesAndFolders();
17
+ const pathsIgnoreList = [getFullPathInProject("intuned"), getFullPathInProject("node_modules"), getFullPathInProject("package.json"), getFullPathInProject("yarn.lock"), getFullPathInProject(".env")];
18
+ const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
19
+ for (const file of filesToCopy) {
20
+ await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
21
+ }
22
+ };
@@ -1,161 +1,162 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
7
- var net = _interopRequireWildcard(require("net"));
8
- var _zod = _interopRequireDefault(require("zod"));
9
- var _runApi = require("../../common/runApi");
10
- var _enums = require("src/runtime/enums");
11
- var _unixSocket = require("../common/utils/unixSocket");
12
- var _promises = require("timers/promises");
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); }
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; }
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- const startRunApiSchema = _zod.default.object({
17
- type: _zod.default.literal("start"),
18
- parameters: _runApi.runApiParametersSchema.extend({
19
- retrieveSession: _zod.default.boolean(),
20
- context: _zod.default.object({
21
- jobId: _zod.default.string().optional(),
22
- jobRunId: _zod.default.string().optional(),
23
- runId: _zod.default.string().optional(),
24
- queueId: _zod.default.string().optional()
25
- }).optional()
26
- })
2
+ import { program } from "commander";
3
+ import dotenv from "dotenv";
4
+ import { runWithContext, } from "../../common/asyncLocalStorage";
5
+ import * as net from "net";
6
+ import z from "zod";
7
+ import { runApiGenerator, runApiParametersSchema, } from "../../common/runApi";
8
+ import { RunEnvironment } from "src/runtime/enums";
9
+ import { JSONUnixSocket } from "../common/utils/unixSocket";
10
+ import { setTimeout } from "timers/promises";
11
+ const startRunApiSchema = z.object({
12
+ type: z.literal("start"),
13
+ parameters: runApiParametersSchema.extend({
14
+ retrieveSession: z.boolean(),
15
+ context: z
16
+ .object({
17
+ jobId: z.string().optional(),
18
+ jobRunId: z.string().optional(),
19
+ runId: z.string().optional(),
20
+ queueId: z.string().optional(),
21
+ })
22
+ .optional(),
23
+ }),
27
24
  });
28
- const nextRunApiSchema = _zod.default.object({
29
- type: _zod.default.literal("next"),
30
- parameters: _zod.default.object({
31
- value: _zod.default.string()
32
- })
25
+ const nextRunApiSchema = z.object({
26
+ type: z.literal("next"),
27
+ parameters: z.object({ value: z.string() }),
33
28
  });
34
- const abortRunApiSchema = _zod.default.object({
35
- type: _zod.default.literal("abort"),
36
- parameters: _zod.default.object({}).optional()
29
+ const abortRunApiSchema = z.object({
30
+ type: z.literal("abort"),
31
+ parameters: z.object({}).optional(),
37
32
  });
38
- const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
39
- _dotenv.default.config({
40
- path: `.env`
33
+ const inputSchema = z.union([
34
+ startRunApiSchema,
35
+ nextRunApiSchema,
36
+ abortRunApiSchema,
37
+ ]);
38
+ dotenv.config({
39
+ path: `.env`,
41
40
  });
42
- _commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
43
- let context;
44
- const throttleTime = 1_000;
45
- let timeoutTimestamp = Date.now();
46
- const client = net.createConnection(socketPath, () => {
47
- console.log("connected to server!");
48
- });
49
- let generator = null;
50
- const abortController = new AbortController();
51
- client.on("end", () => {
52
- console.log("Disconnected from socket");
53
- });
54
- client.on("error", err => {
55
- var _generator;
56
- console.error("Child connection error:", err);
57
- void ((_generator = generator) === null || _generator === void 0 ? void 0 : _generator.throw(err).catch(() => undefined));
58
- });
59
- process.on("SIGINT", () => {
60
- var _generator2;
61
- console.log("Received SIGINT");
62
- void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(new Error("Interrupted")).catch(() => undefined));
63
- client.end();
64
- process.exit(1);
65
- });
66
- const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
67
- async function runGeneratorAndSendResult(next) {
68
- if (!generator) return;
69
- const result = await (0, _asyncLocalStorage.runWithContext)(context, () => generator.next(next));
70
- if (result.done) {
71
- const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
72
- const success = result.value.isOk();
73
- jsonUnixSocket.sendJSON({
74
- type: "done",
75
- result: resultToSend,
76
- success
77
- });
78
- return true;
79
- } else {
80
- jsonUnixSocket.sendJSON({
81
- type: "yield",
82
- result: result.value
83
- });
84
- return false;
85
- }
86
- }
87
- for await (const data of jsonUnixSocket.receiveJSON()) {
88
- const inputParseResult = inputSchema.safeParse(data);
89
- if (!inputParseResult.success) {
90
- console.error(inputParseResult.error.errors);
91
- jsonUnixSocket.sendJSON({
92
- type: "done",
93
- result: {
94
- error: "InvalidJSON",
95
- message: "Invalid input",
96
- details: {
97
- errors: inputParseResult.error.errors
98
- }
99
- },
100
- success: false
101
- });
102
- break;
103
- }
104
- const input = inputParseResult.data;
105
- if (input.type === "abort") {
106
- abortController.abort();
107
- await (0, _promises.setTimeout)(10);
108
- jsonUnixSocket.sendJSON({
109
- type: "done",
110
- result: null
111
- });
112
- break;
113
- }
114
- if (input.type === "start") {
115
- const gen = (0, _runApi.runApiGenerator)({
116
- ...input.parameters,
117
- abortSignal: abortController.signal
118
- });
119
- generator = gen;
120
- context = {
121
- extendedPayloads: [],
122
- runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
123
- timeoutInfo: {
124
- extendTimeoutCallback: async () => {
125
- if (Date.now() - timeoutTimestamp < throttleTime) return;
126
- timeoutTimestamp = Date.now();
41
+ program
42
+ .description("run user automation and communicate using unix socket")
43
+ .argument("<socket-path>", "path to unix socket")
44
+ .action(async (socketPath) => {
45
+ let context;
46
+ const throttleTime = 1_000;
47
+ let timeoutTimestamp = Date.now();
48
+ const client = net.createConnection(socketPath, () => {
49
+ console.log("connected to server!");
50
+ });
51
+ let generator = null;
52
+ const abortController = new AbortController();
53
+ client.on("end", () => {
54
+ console.log("Disconnected from socket");
55
+ });
56
+ client.on("error", (err) => {
57
+ console.error("Child connection error:", err);
58
+ void generator?.throw(err).catch(() => undefined);
59
+ });
60
+ process.on("SIGINT", () => {
61
+ console.log("Received SIGINT");
62
+ void generator?.throw(new Error("Interrupted")).catch(() => undefined);
63
+ client.end();
64
+ process.exit(1);
65
+ });
66
+ const jsonUnixSocket = new JSONUnixSocket(client);
67
+ async function runGeneratorAndSendResult(next) {
68
+ if (!generator)
69
+ return;
70
+ const result = await runWithContext(context, () => generator.next(next));
71
+ if (result.done) {
72
+ const resultToSend = result.value.isOk()
73
+ ? result.value.value
74
+ : result.value.error.json;
75
+ const success = result.value.isOk();
127
76
  jsonUnixSocket.sendJSON({
128
- type: "extend"
77
+ type: "done",
78
+ result: resultToSend,
79
+ success,
129
80
  });
130
- }
131
- },
132
- ...(input.parameters.context ?? {}),
133
- proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
134
- };
135
- if (await runGeneratorAndSendResult()) {
136
- break;
137
- }
138
- continue;
81
+ return true;
82
+ }
83
+ else {
84
+ jsonUnixSocket.sendJSON({ type: "yield", result: result.value });
85
+ return false;
86
+ }
139
87
  }
140
- if (input.type === "next") {
141
- if (!generator) {
142
- throw new Error("generator not started");
143
- }
144
- if (await runGeneratorAndSendResult(input.parameters.value)) {
145
- break;
146
- }
147
- continue;
88
+ for await (const data of jsonUnixSocket.receiveJSON()) {
89
+ const inputParseResult = inputSchema.safeParse(data);
90
+ if (!inputParseResult.success) {
91
+ console.error(inputParseResult.error.errors);
92
+ jsonUnixSocket.sendJSON({
93
+ type: "done",
94
+ result: {
95
+ error: "InvalidJSON",
96
+ message: "Invalid input",
97
+ details: {
98
+ errors: inputParseResult.error.errors,
99
+ },
100
+ },
101
+ success: false,
102
+ });
103
+ break;
104
+ }
105
+ const input = inputParseResult.data;
106
+ if (input.type === "abort") {
107
+ abortController.abort();
108
+ await setTimeout(10);
109
+ jsonUnixSocket.sendJSON({ type: "done", result: null });
110
+ break;
111
+ }
112
+ if (input.type === "start") {
113
+ const gen = runApiGenerator({
114
+ ...input.parameters,
115
+ abortSignal: abortController.signal,
116
+ });
117
+ generator = gen;
118
+ context = {
119
+ extendedPayloads: [],
120
+ runEnvironment: input.parameters.runOptions.environment === "deployed"
121
+ ? RunEnvironment.DEPLOYED
122
+ : RunEnvironment.IDE,
123
+ timeoutInfo: {
124
+ extendTimeoutCallback: async () => {
125
+ if (Date.now() - timeoutTimestamp < throttleTime)
126
+ return;
127
+ timeoutTimestamp = Date.now();
128
+ jsonUnixSocket.sendJSON({ type: "extend" });
129
+ },
130
+ },
131
+ ...(input.parameters.context ?? {}),
132
+ proxy: getProxyUrlFromRunOptions(input.parameters.runOptions),
133
+ };
134
+ if (await runGeneratorAndSendResult()) {
135
+ break;
136
+ }
137
+ continue;
138
+ }
139
+ if (input.type === "next") {
140
+ if (!generator) {
141
+ throw new Error("generator not started");
142
+ }
143
+ if (await runGeneratorAndSendResult(input.parameters.value)) {
144
+ break;
145
+ }
146
+ continue;
147
+ }
148
148
  }
149
- }
150
- process.exit(0);
149
+ process.exit(0);
151
150
  });
152
- _commander.program.parse(process.argv);
151
+ program.parse(process.argv);
153
152
  function getProxyUrlFromRunOptions(runOptions) {
154
- if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
155
- const proxy = runOptions.proxy;
156
- if (!proxy) return undefined;
157
- const url = new URL(proxy.server);
158
- url.username = proxy.username;
159
- url.password = proxy.password;
160
- return url.toString();
161
- }
153
+ if (runOptions?.environment !== "deployed")
154
+ return undefined;
155
+ const proxy = runOptions.proxy;
156
+ if (!proxy)
157
+ return undefined;
158
+ const url = new URL(proxy.server);
159
+ url.username = proxy.username;
160
+ url.password = proxy.password;
161
+ return url.toString();
162
+ }
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ import { program } from "commander";
3
+ import dotenv from "dotenv";
4
+ import { runWithContext } from "../../common/asyncLocalStorage";
5
+ import * as net from "net";
6
+ import z from "zod";
7
+ import { runApiGenerator, runApiParametersSchema } from "../../common/runApi";
8
+ import { RunEnvironment } from "src/runtime/enums";
9
+ import { JSONUnixSocket } from "../common/utils/unixSocket";
10
+ import { setTimeout } from "timers/promises";
11
+ const startRunApiSchema = z.object({
12
+ type: z.literal("start"),
13
+ parameters: runApiParametersSchema.extend({
14
+ retrieveSession: z.boolean(),
15
+ context: z.object({
16
+ jobId: z.string().optional(),
17
+ jobRunId: z.string().optional(),
18
+ runId: z.string().optional(),
19
+ queueId: z.string().optional()
20
+ }).optional()
21
+ })
22
+ });
23
+ const nextRunApiSchema = z.object({
24
+ type: z.literal("next"),
25
+ parameters: z.object({
26
+ value: z.string()
27
+ })
28
+ });
29
+ const abortRunApiSchema = z.object({
30
+ type: z.literal("abort"),
31
+ parameters: z.object({}).optional()
32
+ });
33
+ const inputSchema = z.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
34
+ dotenv.config({
35
+ path: `.env`
36
+ });
37
+ program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
38
+ let context;
39
+ const throttleTime = 1_000;
40
+ let timeoutTimestamp = Date.now();
41
+ const client = net.createConnection(socketPath, () => {
42
+ console.log("connected to server!");
43
+ });
44
+ let generator = null;
45
+ const abortController = new AbortController();
46
+ client.on("end", () => {
47
+ console.log("Disconnected from socket");
48
+ });
49
+ client.on("error", err => {
50
+ var _generator;
51
+ console.error("Child connection error:", err);
52
+ void ((_generator = generator) === null || _generator === void 0 ? void 0 : _generator.throw(err).catch(() => undefined));
53
+ });
54
+ process.on("SIGINT", () => {
55
+ var _generator2;
56
+ console.log("Received SIGINT");
57
+ void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(new Error("Interrupted")).catch(() => undefined));
58
+ client.end();
59
+ process.exit(1);
60
+ });
61
+ const jsonUnixSocket = new JSONUnixSocket(client);
62
+ async function runGeneratorAndSendResult(next) {
63
+ if (!generator) return;
64
+ const result = await runWithContext(context, () => generator.next(next));
65
+ if (result.done) {
66
+ const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
67
+ const success = result.value.isOk();
68
+ jsonUnixSocket.sendJSON({
69
+ type: "done",
70
+ result: resultToSend,
71
+ success
72
+ });
73
+ return true;
74
+ } else {
75
+ jsonUnixSocket.sendJSON({
76
+ type: "yield",
77
+ result: result.value
78
+ });
79
+ return false;
80
+ }
81
+ }
82
+ for await (const data of jsonUnixSocket.receiveJSON()) {
83
+ const inputParseResult = inputSchema.safeParse(data);
84
+ if (!inputParseResult.success) {
85
+ console.error(inputParseResult.error.errors);
86
+ jsonUnixSocket.sendJSON({
87
+ type: "done",
88
+ result: {
89
+ error: "InvalidJSON",
90
+ message: "Invalid input",
91
+ details: {
92
+ errors: inputParseResult.error.errors
93
+ }
94
+ },
95
+ success: false
96
+ });
97
+ break;
98
+ }
99
+ const input = inputParseResult.data;
100
+ if (input.type === "abort") {
101
+ abortController.abort();
102
+ await setTimeout(10);
103
+ jsonUnixSocket.sendJSON({
104
+ type: "done",
105
+ result: null
106
+ });
107
+ break;
108
+ }
109
+ if (input.type === "start") {
110
+ const gen = runApiGenerator({
111
+ ...input.parameters,
112
+ abortSignal: abortController.signal
113
+ });
114
+ generator = gen;
115
+ context = {
116
+ extendedPayloads: [],
117
+ runEnvironment: input.parameters.runOptions.environment === "deployed" ? RunEnvironment.DEPLOYED : RunEnvironment.IDE,
118
+ timeoutInfo: {
119
+ extendTimeoutCallback: async () => {
120
+ if (Date.now() - timeoutTimestamp < throttleTime) return;
121
+ timeoutTimestamp = Date.now();
122
+ jsonUnixSocket.sendJSON({
123
+ type: "extend"
124
+ });
125
+ }
126
+ },
127
+ ...(input.parameters.context ?? {}),
128
+ proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
129
+ };
130
+ if (await runGeneratorAndSendResult()) {
131
+ break;
132
+ }
133
+ continue;
134
+ }
135
+ if (input.type === "next") {
136
+ if (!generator) {
137
+ throw new Error("generator not started");
138
+ }
139
+ if (await runGeneratorAndSendResult(input.parameters.value)) {
140
+ break;
141
+ }
142
+ continue;
143
+ }
144
+ }
145
+ process.exit(0);
146
+ });
147
+ program.parse(process.argv);
148
+ function getProxyUrlFromRunOptions(runOptions) {
149
+ if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
150
+ const proxy = runOptions.proxy;
151
+ if (!proxy) return undefined;
152
+ const url = new URL(proxy.server);
153
+ url.username = proxy.username;
154
+ url.password = proxy.password;
155
+ return url.toString();
156
+ }
@@ -1,54 +1,54 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
-
4
- var ts = _interopRequireWildcard(require("typescript"));
5
- var _commander = require("commander");
6
- var fs = _interopRequireWildcard(require("fs-extra"));
7
- var path = _interopRequireWildcard(require("path"));
8
- var _webTemplate = require("./common/utils/webTemplate");
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 && 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; }
11
- _commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
12
- await (0, _webTemplate.moveWebTemplateFiles)();
13
- const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
14
- await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
15
- checkTypes();
2
+ import * as ts from "typescript";
3
+ import { program } from "commander";
4
+ import * as fs from "fs-extra";
5
+ import * as path from "path";
6
+ import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
7
+ program
8
+ .description("Check TypeScript types in the project")
9
+ .allowUnknownOption()
10
+ .action(async () => {
11
+ await moveWebTemplateFiles();
12
+ const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
13
+ await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
14
+ checkTypes();
16
15
  });
17
16
  function checkTypes() {
18
- const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
19
- if (!configPath) {
20
- console.error("Could not find a valid 'tsconfig.json'.");
21
- process.exit(1);
22
- }
23
- const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
24
- const config = readConfigResult.config;
25
- const parseConfigHost = {
26
- useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
27
- readDirectory: ts.sys.readDirectory,
28
- fileExists: ts.sys.fileExists,
29
- readFile: ts.sys.readFile
30
- };
31
- const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
32
- const program = ts.createProgram(parsed.fileNames, parsed.options);
33
- const emitResult = program.emit();
34
- const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
35
- allDiagnostics.forEach(diagnostic => {
36
- if (diagnostic.file) {
37
- const {
38
- line,
39
- character
40
- } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
41
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
42
- console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
43
- } else {
44
- console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
17
+ const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
18
+ if (!configPath) {
19
+ console.error("Could not find a valid 'tsconfig.json'.");
20
+ process.exit(1);
21
+ }
22
+ const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
23
+ const config = readConfigResult.config;
24
+ const parseConfigHost = {
25
+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
26
+ readDirectory: ts.sys.readDirectory,
27
+ fileExists: ts.sys.fileExists,
28
+ readFile: ts.sys.readFile,
29
+ };
30
+ const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
31
+ const program = ts.createProgram(parsed.fileNames, parsed.options);
32
+ const emitResult = program.emit();
33
+ const allDiagnostics = ts
34
+ .getPreEmitDiagnostics(program)
35
+ .concat(emitResult.diagnostics);
36
+ allDiagnostics.forEach((diagnostic) => {
37
+ if (diagnostic.file) {
38
+ const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
39
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
40
+ console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
41
+ }
42
+ else {
43
+ console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
44
+ }
45
+ });
46
+ if (allDiagnostics.length === 0) {
47
+ console.log("✨ TypeScript type checking passed without errors.");
48
+ }
49
+ else {
50
+ console.error("Errors found during TypeScript type checking.");
51
+ process.exit(1);
45
52
  }
46
- });
47
- if (allDiagnostics.length === 0) {
48
- console.log("✨ TypeScript type checking passed without errors.");
49
- } else {
50
- console.error("Errors found during TypeScript type checking.");
51
- process.exit(1);
52
- }
53
53
  }
54
- _commander.program.parse(process.argv);
54
+ program.parse(process.argv);
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import * as ts from "typescript";
3
+ import { program } from "commander";
4
+ import * as fs from "fs-extra";
5
+ import * as path from "path";
6
+ import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
7
+ program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
8
+ await moveWebTemplateFiles();
9
+ const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
10
+ await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
11
+ checkTypes();
12
+ });
13
+ function checkTypes() {
14
+ const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
15
+ if (!configPath) {
16
+ console.error("Could not find a valid 'tsconfig.json'.");
17
+ process.exit(1);
18
+ }
19
+ const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
20
+ const config = readConfigResult.config;
21
+ const parseConfigHost = {
22
+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
23
+ readDirectory: ts.sys.readDirectory,
24
+ fileExists: ts.sys.fileExists,
25
+ readFile: ts.sys.readFile
26
+ };
27
+ const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
28
+ const program = ts.createProgram(parsed.fileNames, parsed.options);
29
+ const emitResult = program.emit();
30
+ const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
31
+ allDiagnostics.forEach(diagnostic => {
32
+ if (diagnostic.file) {
33
+ const {
34
+ line,
35
+ character
36
+ } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
37
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
38
+ console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
39
+ } else {
40
+ console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
41
+ }
42
+ });
43
+ if (allDiagnostics.length === 0) {
44
+ console.log("✨ TypeScript type checking passed without errors.");
45
+ } else {
46
+ console.error("Errors found during TypeScript type checking.");
47
+ process.exit(1);
48
+ }
49
+ }
50
+ program.parse(process.argv);
@@ -1,4 +1,4 @@
1
- import { LogEntry, LogMetadata } from "./types";
1
+ import { LogEntry, LogMetadata } from "./types.js";
2
2
  declare class Logger {
3
3
  logFunction(entry: LogEntry): void;
4
4
  private log;