@intuned/runtime-dev 0.1.0-test.13 → 0.1.0-test.15
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/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +83 -156
- package/dist/commands/auth-sessions/load.js +20 -20
- package/dist/commands/auth-sessions/run-check.js +39 -45
- package/dist/commands/auth-sessions/run-create.js +74 -84
- package/dist/commands/browser/save-state.js +7 -12
- package/dist/commands/browser/start-browser.js +4 -7
- package/dist/commands/build.js +62 -96
- package/dist/commands/common/browserUtils.js +30 -41
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getFirstLineNumber.js +83 -90
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +2 -1
- package/dist/commands/common/sendMessageToClient.js +2 -4
- package/dist/commands/common/utils/fileUtils.js +16 -16
- package/dist/commands/common/utils/settings.js +18 -16
- package/dist/commands/common/utils/unixSocket.js +36 -43
- package/dist/commands/common/utils/webTemplate.js +19 -25
- package/dist/commands/interface/run.js +133 -139
- package/dist/commands/ts-check.js +41 -44
- package/dist/common/Logger/Logger/index.js +46 -40
- package/dist/common/Logger/Logger/types.js +1 -1
- package/dist/common/Logger/index.js +46 -40
- package/dist/common/Logger/types.js +1 -1
- package/dist/common/asyncLocalStorage/index.js +4 -4
- package/dist/common/cleanEnvironmentVariables.js +9 -11
- package/dist/common/constants.js +1 -1
- package/dist/common/contextStorageStateHelpers.js +38 -36
- package/dist/common/getPlaywrightConstructs.js +158 -187
- package/dist/common/jwtTokenManager.js +61 -74
- package/dist/common/runApi/errors.js +121 -130
- package/dist/common/runApi/index.js +231 -217
- package/dist/common/runApi/types.js +41 -55
- package/dist/common/settingsSchema.js +6 -9
- package/dist/common/telemetry.js +16 -27
- package/dist/index.js +3 -3
- package/dist/runtime/RunError.js +10 -10
- package/dist/runtime/downloadDirectory.js +10 -10
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +12 -12
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +12 -12
- package/dist/runtime/extendTimeout.js +20 -19
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/requestMoreInfo.js +14 -14
- package/dist/runtime/runInfo.js +12 -11
- package/package.json +2 -3
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -78
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -22
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -50
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -181
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
- /package/dist/{common/Logger/Logger/types.ts → runtime/enums.d.js} +0 -0
- /package/dist/runtime/{executionHelpers.test.ts → executionHelpers.test.js} +0 -0
- /package/dist/{common/Logger/types.ts → runtime/export.d.js} +0 -0
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
import * as fs from "fs-extra";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { getFullPathInProject, listProjectFilesAndFolders
|
|
3
|
+
import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils.js";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
4
5
|
export const moveWebTemplateFiles = async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return true;
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const filesAndFolders = await listProjectFilesAndFolders();
|
|
18
|
-
const pathsIgnoreList = [
|
|
19
|
-
getFullPathInProject("intuned"),
|
|
20
|
-
getFullPathInProject("node_modules"),
|
|
21
|
-
getFullPathInProject("package.json"),
|
|
22
|
-
getFullPathInProject("yarn.lock"),
|
|
23
|
-
getFullPathInProject(".env"),
|
|
24
|
-
];
|
|
25
|
-
const filesToCopy = filesAndFolders.filter((file) => !pathsIgnoreList.includes(file.fullPath));
|
|
26
|
-
for (const file of filesToCopy) {
|
|
27
|
-
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
6
|
+
await fs.remove("./intuned");
|
|
7
|
+
await fs.ensureDir("./intuned");
|
|
8
|
+
const currentFileLocation = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..", "WebTemplate");
|
|
9
|
+
await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
|
|
10
|
+
filter: (src, dest) => {
|
|
11
|
+
if (src.includes(".d.ts")) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
28
15
|
}
|
|
29
|
-
};
|
|
16
|
+
});
|
|
17
|
+
const filesAndFolders = await listProjectFilesAndFolders();
|
|
18
|
+
const pathsIgnoreList = [getFullPathInProject("intuned"), getFullPathInProject("node_modules"), getFullPathInProject("package.json"), getFullPathInProject("yarn.lock"), getFullPathInProject(".env")];
|
|
19
|
+
const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
|
|
20
|
+
for (const file of filesToCopy) {
|
|
21
|
+
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,162 +1,156 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from "commander";
|
|
3
3
|
import dotenv from "dotenv";
|
|
4
|
-
import { runWithContext
|
|
4
|
+
import { runWithContext } from "../../common/asyncLocalStorage";
|
|
5
5
|
import * as net from "net";
|
|
6
6
|
import z from "zod";
|
|
7
|
-
import { runApiGenerator, runApiParametersSchema
|
|
7
|
+
import { runApiGenerator, runApiParametersSchema } from "../../common/runApi";
|
|
8
8
|
import { RunEnvironment } from "src/runtime/enums";
|
|
9
9
|
import { JSONUnixSocket } from "../common/utils/unixSocket";
|
|
10
10
|
import { setTimeout } from "timers/promises";
|
|
11
11
|
const startRunApiSchema = z.object({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.optional(),
|
|
23
|
-
}),
|
|
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
|
+
})
|
|
24
22
|
});
|
|
25
23
|
const nextRunApiSchema = z.object({
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
type: z.literal("next"),
|
|
25
|
+
parameters: z.object({
|
|
26
|
+
value: z.string()
|
|
27
|
+
})
|
|
28
28
|
});
|
|
29
29
|
const abortRunApiSchema = z.object({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
type: z.literal("abort"),
|
|
31
|
+
parameters: z.object({}).optional()
|
|
32
32
|
});
|
|
33
|
-
const inputSchema = z.union([
|
|
34
|
-
startRunApiSchema,
|
|
35
|
-
nextRunApiSchema,
|
|
36
|
-
abortRunApiSchema,
|
|
37
|
-
]);
|
|
33
|
+
const inputSchema = z.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
|
|
38
34
|
dotenv.config({
|
|
39
|
-
|
|
35
|
+
path: `.env`
|
|
40
36
|
});
|
|
41
|
-
program
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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;
|
|
87
98
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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();
|
|
92
122
|
jsonUnixSocket.sendJSON({
|
|
93
|
-
|
|
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,
|
|
123
|
+
type: "extend"
|
|
116
124
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
}
|
|
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;
|
|
148
143
|
}
|
|
149
|
-
|
|
144
|
+
}
|
|
145
|
+
process.exit(0);
|
|
150
146
|
});
|
|
151
147
|
program.parse(process.argv);
|
|
152
148
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return url.toString();
|
|
162
|
-
}
|
|
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
|
+
}
|
|
@@ -4,51 +4,48 @@ import { program } from "commander";
|
|
|
4
4
|
import * as fs from "fs-extra";
|
|
5
5
|
import * as path from "path";
|
|
6
6
|
import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
14
|
-
checkTypes();
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
|
|
9
|
+
await moveWebTemplateFiles();
|
|
10
|
+
const templateTsConfig = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "template.tsconfig.json");
|
|
11
|
+
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
12
|
+
checkTypes();
|
|
15
13
|
});
|
|
16
14
|
function checkTypes() {
|
|
17
|
-
|
|
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
|
-
}
|
|
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);
|
|
15
|
+
const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
|
|
16
|
+
if (!configPath) {
|
|
17
|
+
console.error("Could not find a valid 'tsconfig.json'.");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
21
|
+
const config = readConfigResult.config;
|
|
22
|
+
const parseConfigHost = {
|
|
23
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
24
|
+
readDirectory: ts.sys.readDirectory,
|
|
25
|
+
fileExists: ts.sys.fileExists,
|
|
26
|
+
readFile: ts.sys.readFile
|
|
27
|
+
};
|
|
28
|
+
const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
|
|
29
|
+
const program = ts.createProgram(parsed.fileNames, parsed.options);
|
|
30
|
+
const emitResult = program.emit();
|
|
31
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
32
|
+
allDiagnostics.forEach(diagnostic => {
|
|
33
|
+
if (diagnostic.file) {
|
|
34
|
+
const {
|
|
35
|
+
line,
|
|
36
|
+
character
|
|
37
|
+
} = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
38
|
+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
39
|
+
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
40
|
+
} else {
|
|
41
|
+
console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
52
42
|
}
|
|
43
|
+
});
|
|
44
|
+
if (allDiagnostics.length === 0) {
|
|
45
|
+
console.log("✨ TypeScript type checking passed without errors.");
|
|
46
|
+
} else {
|
|
47
|
+
console.error("Errors found during TypeScript type checking.");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
53
50
|
}
|
|
54
|
-
program.parse(process.argv);
|
|
51
|
+
program.parse(process.argv);
|
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
import { formatWithOptions } from "node:util";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
const format = formatWithOptions.bind(undefined, {
|
|
3
|
+
const format = formatWithOptions.bind(undefined, {
|
|
4
|
+
colors: true
|
|
5
|
+
});
|
|
4
6
|
const LOG_LEVEL_COLORS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
TRACE: chalk.gray,
|
|
8
|
+
DEBUG: chalk.blue,
|
|
9
|
+
INFO: chalk.green,
|
|
10
|
+
WARN: chalk.yellow,
|
|
11
|
+
ERROR: chalk.red
|
|
10
12
|
};
|
|
11
13
|
class Logger {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
level,
|
|
26
|
-
message,
|
|
27
|
-
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
28
|
-
timestamp: Date.now(),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
trace(message, meta) {
|
|
32
|
-
this.log("TRACE", message, meta);
|
|
33
|
-
}
|
|
34
|
-
debug(message, meta) {
|
|
35
|
-
this.log("DEBUG", message, meta);
|
|
36
|
-
}
|
|
37
|
-
info(message, meta) {
|
|
38
|
-
this.log("INFO", message, meta);
|
|
39
|
-
}
|
|
40
|
-
warn(message, meta) {
|
|
41
|
-
this.log("WARN", message, meta);
|
|
42
|
-
}
|
|
43
|
-
error(message, meta) {
|
|
44
|
-
this.log("ERROR", message, meta);
|
|
14
|
+
logFunction(entry) {
|
|
15
|
+
const {
|
|
16
|
+
level,
|
|
17
|
+
timestamp,
|
|
18
|
+
message,
|
|
19
|
+
meta
|
|
20
|
+
} = entry;
|
|
21
|
+
const date = new Date(timestamp);
|
|
22
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
23
|
+
if (meta === undefined) {
|
|
24
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
|
|
25
|
+
} else {
|
|
26
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
|
|
45
27
|
}
|
|
28
|
+
}
|
|
29
|
+
log(level, message, meta) {
|
|
30
|
+
this.logFunction({
|
|
31
|
+
level,
|
|
32
|
+
message,
|
|
33
|
+
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
34
|
+
timestamp: Date.now()
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
trace(message, meta) {
|
|
38
|
+
this.log("TRACE", message, meta);
|
|
39
|
+
}
|
|
40
|
+
debug(message, meta) {
|
|
41
|
+
this.log("DEBUG", message, meta);
|
|
42
|
+
}
|
|
43
|
+
info(message, meta) {
|
|
44
|
+
this.log("INFO", message, meta);
|
|
45
|
+
}
|
|
46
|
+
warn(message, meta) {
|
|
47
|
+
this.log("WARN", message, meta);
|
|
48
|
+
}
|
|
49
|
+
error(message, meta) {
|
|
50
|
+
this.log("ERROR", message, meta);
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
|
-
export const logger = new Logger();
|
|
53
|
+
export const logger = new Logger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
import { formatWithOptions } from "node:util";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
const format = formatWithOptions.bind(undefined, {
|
|
3
|
+
const format = formatWithOptions.bind(undefined, {
|
|
4
|
+
colors: true
|
|
5
|
+
});
|
|
4
6
|
const LOG_LEVEL_COLORS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
TRACE: chalk.gray,
|
|
8
|
+
DEBUG: chalk.blue,
|
|
9
|
+
INFO: chalk.green,
|
|
10
|
+
WARN: chalk.yellow,
|
|
11
|
+
ERROR: chalk.red
|
|
10
12
|
};
|
|
11
13
|
class Logger {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
level,
|
|
26
|
-
message,
|
|
27
|
-
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
28
|
-
timestamp: Date.now(),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
trace(message, meta) {
|
|
32
|
-
this.log("TRACE", message, meta);
|
|
33
|
-
}
|
|
34
|
-
debug(message, meta) {
|
|
35
|
-
this.log("DEBUG", message, meta);
|
|
36
|
-
}
|
|
37
|
-
info(message, meta) {
|
|
38
|
-
this.log("INFO", message, meta);
|
|
39
|
-
}
|
|
40
|
-
warn(message, meta) {
|
|
41
|
-
this.log("WARN", message, meta);
|
|
42
|
-
}
|
|
43
|
-
error(message, meta) {
|
|
44
|
-
this.log("ERROR", message, meta);
|
|
14
|
+
logFunction(entry) {
|
|
15
|
+
const {
|
|
16
|
+
level,
|
|
17
|
+
timestamp,
|
|
18
|
+
message,
|
|
19
|
+
meta
|
|
20
|
+
} = entry;
|
|
21
|
+
const date = new Date(timestamp);
|
|
22
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
23
|
+
if (meta === undefined) {
|
|
24
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
|
|
25
|
+
} else {
|
|
26
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
|
|
45
27
|
}
|
|
28
|
+
}
|
|
29
|
+
log(level, message, meta) {
|
|
30
|
+
this.logFunction({
|
|
31
|
+
level,
|
|
32
|
+
message,
|
|
33
|
+
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
34
|
+
timestamp: Date.now()
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
trace(message, meta) {
|
|
38
|
+
this.log("TRACE", message, meta);
|
|
39
|
+
}
|
|
40
|
+
debug(message, meta) {
|
|
41
|
+
this.log("DEBUG", message, meta);
|
|
42
|
+
}
|
|
43
|
+
info(message, meta) {
|
|
44
|
+
this.log("INFO", message, meta);
|
|
45
|
+
}
|
|
46
|
+
warn(message, meta) {
|
|
47
|
+
this.log("WARN", message, meta);
|
|
48
|
+
}
|
|
49
|
+
error(message, meta) {
|
|
50
|
+
this.log("ERROR", message, meta);
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
|
-
export const logger = new Logger();
|
|
53
|
+
export const logger = new Logger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2
2
|
export const asyncLocalStorage = new AsyncLocalStorage();
|
|
3
3
|
export function runWithContext(contextData, callback, ...args) {
|
|
4
|
-
|
|
4
|
+
return asyncLocalStorage.run(contextData, callback, ...args);
|
|
5
5
|
}
|
|
6
6
|
export function getExecutionContext() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
const contextData = asyncLocalStorage.getStore();
|
|
8
|
+
return contextData;
|
|
9
|
+
}
|