@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.
- package/.babelrc +1 -2
- package/dist/commands/api/run.js +170 -105
- package/dist/commands/api/run.ts +105 -0
- package/dist/commands/auth-sessions/load.js +26 -28
- package/dist/commands/auth-sessions/load.ts +30 -0
- package/dist/commands/auth-sessions/run-check.js +53 -52
- package/dist/commands/auth-sessions/run-check.ts +51 -0
- package/dist/commands/auth-sessions/run-create.js +96 -91
- package/dist/commands/auth-sessions/run-create.ts +91 -0
- package/dist/commands/browser/save-state.js +16 -14
- package/dist/commands/browser/save-state.ts +14 -0
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/browser/start-browser.ts +11 -0
- package/dist/commands/build.js +108 -75
- package/dist/commands/build.ts +78 -0
- package/dist/commands/common/browserUtils.js +51 -53
- package/dist/commands/common/browserUtils.ts +45 -0
- package/dist/commands/common/getDefaultExportFromFile.js +12 -17
- package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
- package/dist/commands/common/getFirstLineNumber.ts +96 -0
- package/dist/commands/common/sendMessageToClient.js +4 -9
- package/dist/commands/common/sendMessageToClient.ts +3 -0
- package/dist/commands/common/utils/fileUtils.js +22 -32
- package/dist/commands/common/utils/fileUtils.ts +23 -0
- package/dist/commands/common/utils/settings.js +19 -27
- package/dist/commands/common/utils/settings.ts +22 -0
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/unixSocket.ts +38 -0
- package/dist/commands/common/utils/webTemplate.js +27 -29
- package/dist/commands/common/utils/webTemplate.ts +22 -0
- package/dist/commands/interface/run.js +151 -150
- package/dist/commands/interface/run.ts +156 -0
- package/dist/commands/ts-check.js +49 -49
- package/dist/commands/ts-check.ts +50 -0
- package/dist/common/Logger/Logger/index.d.ts +1 -1
- package/dist/common/Logger/Logger/index.js +42 -55
- package/dist/common/Logger/Logger/index.ts +53 -0
- package/dist/common/Logger/Logger/types.js +1 -5
- package/dist/common/Logger/Logger/types.ts +1 -0
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.js +42 -55
- package/dist/common/Logger/index.ts +53 -0
- package/dist/common/Logger/types.js +1 -5
- package/dist/common/Logger/types.ts +1 -0
- package/dist/common/asyncLocalStorage/index.js +8 -16
- package/dist/common/asyncLocalStorage/index.ts +9 -0
- package/dist/common/cleanEnvironmentVariables.js +12 -16
- package/dist/common/cleanEnvironmentVariables.ts +10 -0
- package/dist/common/constants.js +1 -7
- package/dist/common/constants.ts +1 -0
- package/dist/common/contextStorageStateHelpers.js +38 -47
- package/dist/common/contextStorageStateHelpers.ts +43 -0
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +196 -177
- package/dist/common/getPlaywrightConstructs.ts +181 -0
- package/dist/common/jwtTokenManager.js +79 -76
- package/dist/common/jwtTokenManager.ts +71 -0
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +150 -159
- package/dist/common/runApi/errors.ts +154 -0
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +220 -269
- package/dist/common/runApi/index.ts +253 -0
- package/dist/common/runApi/types.d.ts +1 -1
- package/dist/common/runApi/types.js +56 -49
- package/dist/common/runApi/types.ts +43 -0
- package/dist/common/settingsSchema.js +10 -15
- package/dist/common/settingsSchema.ts +9 -0
- package/dist/common/telemetry.js +30 -28
- package/dist/common/telemetry.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -69
- package/dist/index.ts +4 -0
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/RunError.js +11 -18
- package/dist/runtime/RunError.ts +12 -0
- package/dist/runtime/downloadDirectory.js +13 -19
- package/dist/runtime/downloadDirectory.ts +13 -0
- package/dist/runtime/enums.d.ts +1 -11
- package/dist/runtime/enums.js +12 -18
- package/dist/runtime/enums.ts +12 -0
- package/dist/runtime/executionHelpers.test.ts +51 -0
- package/dist/runtime/export.d.ts +1 -202
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +15 -21
- package/dist/runtime/extendPayload.ts +15 -0
- package/dist/runtime/extendTimeout.js +21 -28
- package/dist/runtime/extendTimeout.ts +24 -0
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -53
- package/dist/runtime/index.ts +6 -0
- package/dist/runtime/requestMoreInfo.js +16 -23
- package/dist/runtime/requestMoreInfo.ts +18 -0
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +14 -21
- package/dist/runtime/runInfo.ts +15 -0
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/executionHelpers.test.js +0 -53
- 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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 =
|
|
29
|
-
|
|
30
|
-
|
|
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 =
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const abortRunApiSchema = z.object({
|
|
30
|
+
type: z.literal("abort"),
|
|
31
|
+
parameters: z.object({}).optional(),
|
|
37
32
|
});
|
|
38
|
-
const inputSchema =
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const inputSchema = z.union([
|
|
34
|
+
startRunApiSchema,
|
|
35
|
+
nextRunApiSchema,
|
|
36
|
+
abortRunApiSchema,
|
|
37
|
+
]);
|
|
38
|
+
dotenv.config({
|
|
39
|
+
path: `.env`,
|
|
41
40
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
77
|
+
type: "done",
|
|
78
|
+
result: resultToSend,
|
|
79
|
+
success,
|
|
129
80
|
});
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
151
|
+
program.parse(process.argv);
|
|
153
152
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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);
|