@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16

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 (114) hide show
  1. package/.babelrc +1 -2
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/authSessions/create.ts +2 -2
  4. package/WebTemplate/controllers/authSessions/store.ts +1 -1
  5. package/WebTemplate/controllers/runApi/helpers.ts +14 -12
  6. package/WebTemplate/index.playwright.ts +32 -42
  7. package/WebTemplate/jobs.ts +13 -2
  8. package/WebTemplate/utils.ts +53 -1
  9. package/api/test2.ts +6 -1
  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 +109 -170
  22. package/dist/commands/auth-sessions/load.js +28 -26
  23. package/dist/commands/auth-sessions/run-check.js +54 -53
  24. package/dist/commands/auth-sessions/run-create.js +93 -96
  25. package/dist/commands/browser/save-state.js +14 -16
  26. package/dist/commands/browser/start-browser.js +11 -11
  27. package/dist/commands/build.js +79 -109
  28. package/dist/commands/common/browserUtils.js +53 -51
  29. package/dist/commands/common/getFirstLineNumber.js +93 -93
  30. package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
  31. package/dist/commands/common/sendMessageToClient.js +9 -4
  32. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  33. package/dist/commands/common/tsNodeImport.js +18 -0
  34. package/dist/commands/common/utils/fileUtils.js +32 -22
  35. package/dist/commands/common/utils/settings.js +27 -19
  36. package/dist/commands/common/utils/unixSocket.js +43 -43
  37. package/dist/commands/common/utils/webTemplate.js +30 -28
  38. package/dist/commands/interface/run.js +162 -139
  39. package/dist/commands/ts-check.js +50 -50
  40. package/dist/common/Logger/Logger/index.js +55 -42
  41. package/dist/common/Logger/Logger/types.js +5 -1
  42. package/dist/common/Logger/index.js +55 -42
  43. package/dist/common/Logger/types.js +5 -1
  44. package/dist/common/asyncLocalStorage/index.js +16 -8
  45. package/dist/common/cleanEnvironmentVariables.js +16 -12
  46. package/dist/common/constants.js +7 -1
  47. package/dist/common/contextStorageStateHelpers.js +47 -38
  48. package/dist/common/getPlaywrightConstructs.js +178 -197
  49. package/dist/common/jwtTokenManager.js +76 -79
  50. package/dist/common/runApi/errors.js +159 -150
  51. package/dist/common/runApi/index.js +240 -232
  52. package/dist/common/runApi/types.d.ts +19 -5
  53. package/dist/common/runApi/types.js +53 -56
  54. package/dist/common/settingsSchema.js +15 -10
  55. package/dist/common/telemetry.js +28 -30
  56. package/dist/index.js +69 -4
  57. package/dist/runtime/RunError.js +18 -11
  58. package/dist/runtime/downloadDirectory.js +19 -13
  59. package/dist/runtime/enums.d.js +5 -0
  60. package/dist/runtime/enums.d.ts +11 -1
  61. package/dist/runtime/enums.js +18 -12
  62. package/dist/runtime/executionHelpers.test.js +53 -0
  63. package/dist/runtime/export.d.js +5 -0
  64. package/dist/runtime/export.d.ts +202 -1
  65. package/dist/runtime/extendPayload.js +21 -15
  66. package/dist/runtime/extendTimeout.js +28 -21
  67. package/dist/runtime/index.js +53 -6
  68. package/dist/runtime/requestMoreInfo.js +23 -16
  69. package/dist/runtime/runInfo.js +21 -14
  70. package/package.json +4 -7
  71. package/dist/commands/api/run.ts +0 -105
  72. package/dist/commands/auth-sessions/load.ts +0 -30
  73. package/dist/commands/auth-sessions/run-check.ts +0 -51
  74. package/dist/commands/auth-sessions/run-create.ts +0 -91
  75. package/dist/commands/browser/save-state.ts +0 -14
  76. package/dist/commands/browser/start-browser.ts +0 -11
  77. package/dist/commands/build.ts +0 -79
  78. package/dist/commands/common/browserUtils.ts +0 -45
  79. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
  80. package/dist/commands/common/getDefaultExportFromFile.js +0 -12
  81. package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
  82. package/dist/commands/common/getFirstLineNumber.ts +0 -96
  83. package/dist/commands/common/sendMessageToClient.ts +0 -3
  84. package/dist/commands/common/utils/fileUtils.ts +0 -23
  85. package/dist/commands/common/utils/settings.ts +0 -22
  86. package/dist/commands/common/utils/unixSocket.ts +0 -38
  87. package/dist/commands/common/utils/webTemplate.ts +0 -23
  88. package/dist/commands/interface/run.ts +0 -156
  89. package/dist/commands/ts-check.ts +0 -51
  90. package/dist/common/Logger/Logger/index.ts +0 -53
  91. package/dist/common/Logger/Logger/types.ts +0 -1
  92. package/dist/common/Logger/index.ts +0 -53
  93. package/dist/common/Logger/types.ts +0 -1
  94. package/dist/common/asyncLocalStorage/index.ts +0 -9
  95. package/dist/common/cleanEnvironmentVariables.ts +0 -10
  96. package/dist/common/constants.ts +0 -1
  97. package/dist/common/contextStorageStateHelpers.ts +0 -43
  98. package/dist/common/getPlaywrightConstructs.ts +0 -182
  99. package/dist/common/jwtTokenManager.ts +0 -71
  100. package/dist/common/runApi/errors.ts +0 -154
  101. package/dist/common/runApi/index.ts +0 -253
  102. package/dist/common/runApi/types.ts +0 -43
  103. package/dist/common/settingsSchema.ts +0 -9
  104. package/dist/common/telemetry.ts +0 -23
  105. package/dist/index.ts +0 -4
  106. package/dist/runtime/RunError.ts +0 -12
  107. package/dist/runtime/downloadDirectory.ts +0 -13
  108. package/dist/runtime/enums.ts +0 -12
  109. package/dist/runtime/executionHelpers.test.ts +0 -51
  110. package/dist/runtime/extendPayload.ts +0 -15
  111. package/dist/runtime/extendTimeout.ts +0 -24
  112. package/dist/runtime/index.ts +0 -6
  113. package/dist/runtime/requestMoreInfo.ts +0 -18
  114. package/dist/runtime/runInfo.ts +0 -15
@@ -1,96 +0,0 @@
1
- import { ts, Project, ModuleKind, ScriptTarget, Node } from "ts-morph";
2
- import { SourceMapConsumer } from "source-map";
3
- function compileTypeScript(apiFilePath) {
4
- const compilerOptions = {
5
- lib: ["dom", "es2020"],
6
- sourceMap: true,
7
- inlineSourceMap: true,
8
- inlineSources: true,
9
- declaration: false,
10
- noEmit: false,
11
- module: ModuleKind.CommonJS,
12
- target: ScriptTarget.ES2020
13
- };
14
- const project = new Project({
15
- compilerOptions
16
- });
17
- const sourceFile = project.addSourceFileAtPath(apiFilePath);
18
- const outputJS = project.emitToMemory({
19
- targetSourceFile: sourceFile
20
- });
21
- const outputJSText = outputJS.getFiles()[0].text;
22
- return {
23
- sourceFile,
24
- outputJSText
25
- };
26
- }
27
- export function findFirstExecutableLine(sourceFile) {
28
- var _defaultExportSymbol$;
29
- let functionBody;
30
- const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
31
- const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
32
- if (defaultExportDeclaration) {
33
- if (defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration) {
34
- functionBody = defaultExportDeclaration.getBody();
35
- } else {
36
- const exportAssignments = sourceFile.getExportAssignments();
37
- for (const exportAssignment of exportAssignments) {
38
- const expression = exportAssignment.getExpression();
39
- if (!expression) continue;
40
- if (expression.getKind() === ts.SyntaxKind.Identifier || expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction) {
41
- var _sourceFile$getVariab;
42
- const identifier = expression.getText();
43
- const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() === ts.SyntaxKind.FunctionExpression || node.getKind() === ts.SyntaxKind.ArrowFunction));
44
- if (possiblyExportedFunction) {
45
- functionBody = possiblyExportedFunction.getBody();
46
- break;
47
- }
48
- }
49
- if (Node.hasBody(expression) && (expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
50
- functionBody = expression.getBody();
51
- break;
52
- }
53
- }
54
- }
55
- }
56
- if (!functionBody || !Node.isStatemented(functionBody)) {
57
- return -1;
58
- }
59
- if (functionBody.getStatements().length === 0) {
60
- return -1;
61
- }
62
- const position = functionBody.getStatements()[0].getStart();
63
- return sourceFile.getLineAndColumnAtPos(position);
64
- }
65
- async function getSourceMap(jsCode) {
66
- const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
67
- const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
68
- const sourceMap = JSON.parse(sourceMapText);
69
- return new SourceMapConsumer(sourceMap);
70
- }
71
- async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
72
- const sourceMap = await getSourceMap(jsCode);
73
- const generatedLineNumber = sourceMap.generatedPositionFor({
74
- source: sourceFileName,
75
- line,
76
- column
77
- }).line;
78
- if (!generatedLineNumber) return -1;
79
- return generatedLineNumber;
80
- }
81
- export default async function getFirstLineNumber(apiFilePath) {
82
- const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
83
- const {
84
- sourceFile,
85
- outputJSText
86
- } = compileTypeScript(apiFilePath);
87
- const result = findFirstExecutableLine(sourceFile);
88
- if (result === -1) return {
89
- sourceFileName,
90
- lineNumber: -1
91
- };
92
- return {
93
- sourceFileName,
94
- lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column)
95
- };
96
- }
@@ -1,3 +0,0 @@
1
- export const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
2
- console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
3
- };
@@ -1,23 +0,0 @@
1
- import * as path from "path";
2
- import * as fs from "fs-extra";
3
- import dotenv from "dotenv";
4
- dotenv.config();
5
- export function getFullPathInProject(...paths) {
6
- return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
7
- }
8
- export async function listProjectFilesAndFolders() {
9
- const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
10
- try {
11
- const files = await fs.readdir(projectPath, {
12
- withFileTypes: true
13
- });
14
- return files.map(file => ({
15
- type: file.isDirectory() ? "Folder" : "File",
16
- fullPath: path.join(projectPath, file.name),
17
- name: file.name
18
- }));
19
- } catch (err) {
20
- console.error("Error reading the directory:", err);
21
- throw err;
22
- }
23
- }
@@ -1,22 +0,0 @@
1
- import { getFullPathInProject } from "./fileUtils.js";
2
- import { settingsSchema } from "../../../common/settingsSchema";
3
- import { readJSON } from "fs-extra";
4
- export async function getSettings() {
5
- const settingsFilePath = getFullPathInProject("Intuned.json");
6
- console.log("loading settings");
7
- const settings = await readJSON(settingsFilePath);
8
- if (settings) {
9
- const parsed = settingsSchema.safeParse(settings);
10
- console.log(parsed);
11
- if (parsed.success) {
12
- return parsed.data;
13
- } else {
14
- throw new Error(parsed.error.message);
15
- }
16
- }
17
- return {
18
- authSessions: {
19
- enabled: false
20
- }
21
- };
22
- }
@@ -1,38 +0,0 @@
1
- export class JSONUnixSocket {
2
- static LENGTH_HEADER_LENGTH = 4;
3
- constructor(socket) {
4
- this.socket = socket;
5
- }
6
- sendJSON(data) {
7
- const dataToSend = JSON.stringify(data);
8
- const length = Buffer.byteLength(dataToSend);
9
- const buffer = Buffer.alloc(JSONUnixSocket.LENGTH_HEADER_LENGTH + length);
10
- buffer.writeUInt32BE(length, 0);
11
- buffer.write(dataToSend, JSONUnixSocket.LENGTH_HEADER_LENGTH);
12
- this.socket.write(buffer);
13
- }
14
- async *receiveJSON() {
15
- let buffer = Buffer.alloc(0);
16
- const endPromise = new Promise((resolve, reject) => {
17
- this.socket.once("end", () => {
18
- console.log("end");
19
- resolve();
20
- });
21
- this.socket.once("error", reject);
22
- });
23
- while (true) {
24
- const chunk = await Promise.race([new Promise(resolve => this.socket.once("data", data => resolve(data))), endPromise]);
25
- if (!(chunk instanceof Buffer)) {
26
- break;
27
- }
28
- buffer = Buffer.concat([buffer, chunk]);
29
- const length = buffer.readUInt32BE(0);
30
- if (buffer.length < length + JSONUnixSocket.LENGTH_HEADER_LENGTH) {
31
- continue;
32
- }
33
- const data = buffer.subarray(JSONUnixSocket.LENGTH_HEADER_LENGTH, length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
34
- buffer = buffer.subarray(length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
35
- yield JSON.parse(data.toString());
36
- }
37
- }
38
- }
@@ -1,23 +0,0 @@
1
- import * as fs from "fs-extra";
2
- import * as path from "path";
3
- import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils.js";
4
- import { fileURLToPath } from "url";
5
- export const moveWebTemplateFiles = async () => {
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;
15
- }
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,156 +0,0 @@
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,51 +0,0 @@
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
- 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();
13
- });
14
- function checkTypes() {
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"));
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
- }
50
- }
51
- program.parse(process.argv);
@@ -1,53 +0,0 @@
1
- import { formatWithOptions } from "node:util";
2
- import chalk from "chalk";
3
- const format = formatWithOptions.bind(undefined, {
4
- colors: true
5
- });
6
- const LOG_LEVEL_COLORS = {
7
- TRACE: chalk.gray,
8
- DEBUG: chalk.blue,
9
- INFO: chalk.green,
10
- WARN: chalk.yellow,
11
- ERROR: chalk.red
12
- };
13
- class Logger {
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`);
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
- }
52
- }
53
- export const logger = new Logger();
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
1
- import { formatWithOptions } from "node:util";
2
- import chalk from "chalk";
3
- const format = formatWithOptions.bind(undefined, {
4
- colors: true
5
- });
6
- const LOG_LEVEL_COLORS = {
7
- TRACE: chalk.gray,
8
- DEBUG: chalk.blue,
9
- INFO: chalk.green,
10
- WARN: chalk.yellow,
11
- ERROR: chalk.red
12
- };
13
- class Logger {
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`);
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
- }
52
- }
53
- export const logger = new Logger();
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { AsyncLocalStorage } from "async_hooks";
2
- export const asyncLocalStorage = new AsyncLocalStorage();
3
- export function runWithContext(contextData, callback, ...args) {
4
- return asyncLocalStorage.run(contextData, callback, ...args);
5
- }
6
- export function getExecutionContext() {
7
- const contextData = asyncLocalStorage.getStore();
8
- return contextData;
9
- }
@@ -1,10 +0,0 @@
1
- export function cleanEnvironmentVariables() {
2
- Object.keys(process.env).filter(i => {
3
- if (i.toLocaleLowerCase().startsWith("npm")) {
4
- return true;
5
- }
6
- if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
7
- return true;
8
- }
9
- }).forEach(i => delete process.env[i]);
10
- }
@@ -1 +0,0 @@
1
- export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
@@ -1,43 +0,0 @@
1
- function sessionStorageToArray(storage) {
2
- const result = [];
3
- for (const key in storage) {
4
- result.push({
5
- name: key,
6
- value: storage[key]
7
- });
8
- }
9
- return result;
10
- }
11
- export async function getContextStorageState(context) {
12
- const cookiesAndLocalStorage = await context.storageState();
13
- const pages = context.pages();
14
- const pagesSessions = [];
15
- for (const page of pages) {
16
- try {
17
- const [origin, session] = await page.evaluate(() => [location.origin, sessionStorage]);
18
- const transformed = sessionStorageToArray(session);
19
- pagesSessions.push({
20
- origin,
21
- sessionStorage: transformed
22
- });
23
- } catch (e) {}
24
- }
25
- return {
26
- ...cookiesAndLocalStorage,
27
- sessionStorage: pagesSessions
28
- };
29
- }
30
- export async function setContextStorageState(context, storage) {
31
- await context.intunedSetStorageState(storage);
32
- const sessionStorage = storage.sessionStorage;
33
- await context.addInitScript(storage => {
34
- for (const {
35
- origin,
36
- sessionStorage
37
- } of storage) {
38
- if (window.location.origin === origin) {
39
- for (const item of sessionStorage) window.sessionStorage.setItem(item.name, item.value);
40
- }
41
- }
42
- }, sessionStorage);
43
- }