@intuned/runtime-dev 0.1.0-test.11 → 0.1.0-test.13
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 +0 -1
- package/dist/commands/api/run.js +156 -83
- package/dist/commands/api/run.ts +105 -0
- package/dist/commands/auth-sessions/load.js +20 -20
- package/dist/commands/auth-sessions/load.ts +30 -0
- package/dist/commands/auth-sessions/run-check.js +45 -39
- package/dist/commands/auth-sessions/run-check.ts +51 -0
- package/dist/commands/auth-sessions/run-create.js +84 -74
- package/dist/commands/auth-sessions/run-create.ts +91 -0
- package/dist/commands/browser/save-state.js +12 -7
- package/dist/commands/browser/save-state.ts +14 -0
- package/dist/commands/browser/start-browser.js +7 -4
- package/dist/commands/browser/start-browser.ts +11 -0
- package/dist/commands/build.js +97 -61
- package/dist/commands/build.ts +78 -0
- package/dist/commands/common/browserUtils.js +42 -31
- package/dist/commands/common/browserUtils.ts +45 -0
- package/dist/commands/common/getDefaultExportFromFile.js +11 -10
- package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
- package/dist/commands/common/getFirstLineNumber.js +90 -83
- package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +2 -2
- package/dist/commands/common/getFirstLineNumber.ts +96 -0
- package/dist/commands/common/sendMessageToClient.js +4 -2
- package/dist/commands/common/sendMessageToClient.ts +3 -0
- package/dist/commands/common/utils/fileUtils.js +16 -16
- package/dist/commands/common/utils/fileUtils.ts +23 -0
- package/dist/commands/common/utils/settings.js +17 -19
- package/dist/commands/common/utils/settings.ts +22 -0
- package/dist/commands/common/utils/unixSocket.js +43 -36
- package/dist/commands/common/utils/unixSocket.ts +38 -0
- package/dist/commands/common/utils/webTemplate.js +25 -18
- package/dist/commands/common/utils/webTemplate.ts +22 -0
- package/dist/commands/interface/run.js +139 -133
- package/dist/commands/interface/run.ts +156 -0
- package/dist/commands/ts-check.js +45 -41
- 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 +40 -46
- package/dist/common/Logger/Logger/index.ts +53 -0
- package/dist/common/Logger/Logger/types.js +1 -1
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.js +40 -46
- package/dist/common/Logger/index.ts +53 -0
- package/dist/common/Logger/types.js +1 -1
- package/dist/common/asyncLocalStorage/index.js +4 -4
- package/dist/common/asyncLocalStorage/index.ts +9 -0
- package/dist/common/cleanEnvironmentVariables.js +11 -9
- package/dist/common/cleanEnvironmentVariables.ts +10 -0
- package/dist/common/constants.js +1 -1
- package/dist/common/constants.ts +1 -0
- package/dist/common/contextStorageStateHelpers.js +36 -38
- package/dist/common/contextStorageStateHelpers.ts +43 -0
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +187 -157
- package/dist/common/getPlaywrightConstructs.ts +181 -0
- package/dist/common/jwtTokenManager.js +74 -61
- package/dist/common/jwtTokenManager.ts +71 -0
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +130 -121
- package/dist/common/runApi/errors.ts +154 -0
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +219 -233
- package/dist/common/runApi/index.ts +253 -0
- package/dist/common/runApi/types.d.ts +1 -1
- package/dist/common/runApi/types.js +55 -41
- package/dist/common/runApi/types.ts +43 -0
- package/dist/common/settingsSchema.js +9 -6
- package/dist/common/settingsSchema.ts +9 -0
- package/dist/common/telemetry.js +27 -16
- package/dist/common/telemetry.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.ts +4 -0
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/RunError.js +10 -10
- package/dist/runtime/RunError.ts +12 -0
- package/dist/runtime/downloadDirectory.js +10 -10
- package/dist/runtime/downloadDirectory.ts +13 -0
- package/dist/runtime/enums.d.ts +1 -11
- package/dist/runtime/enums.js +12 -12
- package/dist/runtime/enums.ts +12 -0
- package/dist/runtime/{executionHelpers.test.js → executionHelpers.test.ts} +2 -2
- package/dist/runtime/export.d.ts +1 -202
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +13 -13
- package/dist/runtime/extendPayload.ts +15 -0
- package/dist/runtime/extendTimeout.js +19 -20
- package/dist/runtime/extendTimeout.ts +24 -0
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.ts +6 -0
- package/dist/runtime/requestMoreInfo.js +14 -14
- package/dist/runtime/requestMoreInfo.ts +18 -0
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +12 -13
- package/dist/runtime/runInfo.ts +15 -0
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- /package/dist/{runtime/enums.d.js → common/Logger/Logger/types.ts} +0 -0
- /package/dist/{runtime/export.d.js → common/Logger/types.ts} +0 -0
|
@@ -3,48 +3,52 @@ import * as ts from "typescript";
|
|
|
3
3
|
import { program } from "commander";
|
|
4
4
|
import * as fs from "fs-extra";
|
|
5
5
|
import * as path from "path";
|
|
6
|
-
import { moveWebTemplateFiles } from "./common/utils/webTemplate";
|
|
7
|
-
program
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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(path.dirname(import.meta.url), "..", "..", "template.tsconfig.json");
|
|
13
|
+
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
14
|
+
checkTypes();
|
|
12
15
|
});
|
|
13
16
|
function checkTypes() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
41
52
|
}
|
|
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
53
|
}
|
|
50
|
-
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(path.dirname(import.meta.url), "..", "..", "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,53 +1,47 @@
|
|
|
1
1
|
import { formatWithOptions } from "node:util";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
const format = formatWithOptions.bind(undefined, {
|
|
4
|
-
colors: true
|
|
5
|
-
});
|
|
3
|
+
const format = formatWithOptions.bind(undefined, { colors: true });
|
|
6
4
|
const LOG_LEVEL_COLORS = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
TRACE: chalk.gray,
|
|
6
|
+
DEBUG: chalk.blue,
|
|
7
|
+
INFO: chalk.green,
|
|
8
|
+
WARN: chalk.yellow,
|
|
9
|
+
ERROR: chalk.red,
|
|
12
10
|
};
|
|
13
11
|
class Logger {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
logFunction(entry) {
|
|
13
|
+
const { level, timestamp, message, meta } = entry;
|
|
14
|
+
const date = new Date(timestamp);
|
|
15
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
16
|
+
if (meta === undefined) {
|
|
17
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
log(level, message, meta) {
|
|
24
|
+
this.logFunction({
|
|
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);
|
|
27
45
|
}
|
|
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
46
|
}
|
|
53
|
-
export const logger = new Logger();
|
|
47
|
+
export const logger = new Logger();
|
|
@@ -0,0 +1,53 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,53 +1,47 @@
|
|
|
1
1
|
import { formatWithOptions } from "node:util";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
const format = formatWithOptions.bind(undefined, {
|
|
4
|
-
colors: true
|
|
5
|
-
});
|
|
3
|
+
const format = formatWithOptions.bind(undefined, { colors: true });
|
|
6
4
|
const LOG_LEVEL_COLORS = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
TRACE: chalk.gray,
|
|
6
|
+
DEBUG: chalk.blue,
|
|
7
|
+
INFO: chalk.green,
|
|
8
|
+
WARN: chalk.yellow,
|
|
9
|
+
ERROR: chalk.red,
|
|
12
10
|
};
|
|
13
11
|
class Logger {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
logFunction(entry) {
|
|
13
|
+
const { level, timestamp, message, meta } = entry;
|
|
14
|
+
const date = new Date(timestamp);
|
|
15
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
16
|
+
if (meta === undefined) {
|
|
17
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
log(level, message, meta) {
|
|
24
|
+
this.logFunction({
|
|
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);
|
|
27
45
|
}
|
|
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
46
|
}
|
|
53
|
-
export const logger = new Logger();
|
|
47
|
+
export const logger = new Logger();
|
|
@@ -0,0 +1,53 @@
|
|
|
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 +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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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 +1,12 @@
|
|
|
1
1
|
export function cleanEnvironmentVariables() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
2
|
+
Object.keys(process.env)
|
|
3
|
+
.filter((i) => {
|
|
4
|
+
if (i.toLocaleLowerCase().startsWith("npm")) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
.forEach((i) => delete process.env[i]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
package/dist/common/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
1
|
+
export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
function sessionStorageToArray(storage) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
2
|
+
const result = [];
|
|
3
|
+
for (const key in storage) {
|
|
4
|
+
result.push({ name: key, value: storage[key] });
|
|
5
|
+
}
|
|
6
|
+
return result;
|
|
10
7
|
}
|
|
11
8
|
export async function getContextStorageState(context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
const cookiesAndLocalStorage = await context.storageState();
|
|
10
|
+
const pages = context.pages();
|
|
11
|
+
const pagesSessions = [];
|
|
12
|
+
for (const page of pages) {
|
|
13
|
+
try {
|
|
14
|
+
const [origin, session] = await page.evaluate(() => [
|
|
15
|
+
location.origin,
|
|
16
|
+
sessionStorage,
|
|
17
|
+
]);
|
|
18
|
+
const transformed = sessionStorageToArray(session);
|
|
19
|
+
pagesSessions.push({ origin, sessionStorage: transformed });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// ignore
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...cookiesAndLocalStorage,
|
|
27
|
+
sessionStorage: pagesSessions,
|
|
28
|
+
};
|
|
29
29
|
}
|
|
30
30
|
export async function setContextStorageState(context, storage) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, sessionStorage);
|
|
43
|
-
}
|
|
31
|
+
await context.intunedSetStorageState(storage);
|
|
32
|
+
const sessionStorage = storage.sessionStorage;
|
|
33
|
+
await context.addInitScript((storage) => {
|
|
34
|
+
for (const { origin, sessionStorage } of storage) {
|
|
35
|
+
if (window.location.origin === origin) {
|
|
36
|
+
for (const item of sessionStorage)
|
|
37
|
+
window.sessionStorage.setItem(item.name, item.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, sessionStorage);
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|