@intuned/runtime-dev 0.0.1-testing.0 → 0.0.1
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/.vite/deps_temp_01af7156/package.json +3 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/launch.json +102 -0
- package/.vscode/settings.json +12 -0
- package/WebTemplate/controllers/authSessions/create.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +3 -1
- package/package.json +3 -3
- package/playwright.config.ts +48 -0
- package/src/commands/api/run.ts +225 -0
- package/src/commands/auth-sessions/load.ts +42 -0
- package/src/commands/auth-sessions/run-check.ts +70 -0
- package/src/commands/auth-sessions/run-create.ts +124 -0
- package/src/commands/browser/save-state.ts +22 -0
- package/src/commands/browser/start-browser.ts +17 -0
- package/src/commands/build.ts +125 -0
- package/src/commands/common/browserUtils.ts +80 -0
- package/src/commands/common/getDefaultExportFromFile.ts +13 -0
- package/{dist/commands/common/getFirstLineNumber.test.js → src/commands/common/getFirstLineNumber.test.ts} +121 -75
- package/src/commands/common/getFirstLineNumber.ts +146 -0
- package/src/commands/common/sendMessageToClient.ts +8 -0
- package/src/commands/common/utils/fileUtils.ts +25 -0
- package/src/commands/common/utils/settings.ts +23 -0
- package/src/commands/common/utils/webTemplate.ts +46 -0
- package/src/commands/testing/saveVisibleHtml.ts +29 -0
- package/src/commands/ts-check.ts +88 -0
- package/src/common/Logger/Logger/index.ts +64 -0
- package/{dist/common/Logger/types.d.ts → src/common/Logger/Logger/types.ts} +5 -4
- package/src/common/Logger/index.ts +64 -0
- package/{dist/common/Logger/Logger/types.d.ts → src/common/Logger/types.ts} +5 -4
- package/src/common/asyncLocalStorage/index.ts +29 -0
- package/src/common/cleanEnvironmentVariables.ts +13 -0
- package/src/common/constants.ts +1 -0
- package/src/common/contextStorageStateHelpers.ts +71 -0
- package/src/common/getPlaywrightConstructs.ts +283 -0
- package/src/common/jwtTokenManager.ts +111 -0
- package/src/common/settingsSchema.ts +16 -0
- package/src/common/telemetry.ts +49 -0
- package/src/index.ts +14 -0
- package/src/runtime/RunError.ts +16 -0
- package/src/runtime/downloadDirectory.ts +14 -0
- package/src/runtime/enums.ts +11 -0
- package/src/runtime/executionHelpers.test.ts +70 -0
- package/src/runtime/extendPayload.ts +22 -0
- package/src/runtime/extendTimeout.ts +32 -0
- package/{dist/runtime/index.d.ts → src/runtime/index.ts} +3 -1
- package/src/runtime/requestMoreInfo.ts +40 -0
- package/src/runtime/runInfo.ts +19 -0
- package/vite.config.ts +17 -0
- package/bin/intuned-api-run +0 -2
- package/bin/intuned-auth-session-check +0 -2
- package/bin/intuned-auth-session-create +0 -2
- package/bin/intuned-auth-session-load +0 -2
- package/bin/intuned-auth-session-refresh +0 -2
- package/bin/intuned-browser-save-state +0 -2
- package/bin/intuned-browser-start +0 -2
- package/bin/intuned-build +0 -2
- package/bin/intuned-ts-check +0 -2
- package/dist/commands/api/run.d.ts +0 -6
- package/dist/commands/api/run.js +0 -135
- package/dist/commands/auth-sessions/load.d.ts +0 -2
- package/dist/commands/auth-sessions/load.js +0 -26
- package/dist/commands/auth-sessions/run-check.d.ts +0 -2
- package/dist/commands/auth-sessions/run-check.js +0 -42
- package/dist/commands/auth-sessions/run-create.d.ts +0 -2
- package/dist/commands/auth-sessions/run-create.js +0 -75
- package/dist/commands/browser/save-state.d.ts +0 -2
- package/dist/commands/browser/save-state.js +0 -17
- package/dist/commands/browser/start-browser.d.ts +0 -2
- package/dist/commands/browser/start-browser.js +0 -14
- package/dist/commands/build.d.ts +0 -2
- package/dist/commands/build.js +0 -80
- package/dist/commands/common/browserUtils.d.ts +0 -14
- package/dist/commands/common/browserUtils.js +0 -58
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -19
- package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
- package/dist/commands/common/getFirstLineNumber.js +0 -103
- package/dist/commands/common/sendMessageToClient.d.ts +0 -1
- package/dist/commands/common/sendMessageToClient.js +0 -10
- package/dist/commands/common/utils/fileUtils.d.ts +0 -6
- package/dist/commands/common/utils/fileUtils.js +0 -33
- package/dist/commands/common/utils/settings.d.ts +0 -2
- package/dist/commands/common/utils/settings.js +0 -28
- package/dist/commands/common/utils/webTemplate.d.ts +0 -1
- package/dist/commands/common/utils/webTemplate.js +0 -31
- package/dist/commands/ts-check.d.ts +0 -2
- package/dist/commands/ts-check.js +0 -54
- package/dist/common/Logger/Logger/index.d.ts +0 -12
- package/dist/common/Logger/Logger/index.js +0 -60
- package/dist/common/Logger/Logger/types.js +0 -5
- package/dist/common/Logger/index.d.ts +0 -12
- package/dist/common/Logger/index.js +0 -60
- package/dist/common/Logger/types.js +0 -5
- package/dist/common/asyncLocalStorage/index.d.ts +0 -16
- package/dist/common/asyncLocalStorage/index.js +0 -17
- package/dist/common/cleanEnvironmentVariables.d.ts +0 -1
- package/dist/common/cleanEnvironmentVariables.js +0 -16
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +0 -7
- package/dist/common/contextStorageStateHelpers.d.ts +0 -15
- package/dist/common/contextStorageStateHelpers.js +0 -48
- package/dist/common/getPlaywrightConstructs.d.ts +0 -28
- package/dist/common/getPlaywrightConstructs.js +0 -175
- package/dist/common/jwtTokenManager.d.ts +0 -16
- package/dist/common/jwtTokenManager.js +0 -81
- package/dist/common/settingsSchema.d.ts +0 -19
- package/dist/common/settingsSchema.js +0 -17
- package/dist/common/telemetry.d.ts +0 -3
- package/dist/common/telemetry.js +0 -32
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -69
- package/dist/runtime/RunError.d.ts +0 -5
- package/dist/runtime/RunError.js +0 -19
- package/dist/runtime/downloadDirectory.d.ts +0 -1
- package/dist/runtime/downloadDirectory.js +0 -19
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/enums.js +0 -18
- package/dist/runtime/executionHelpers.test.js +0 -53
- package/dist/runtime/export.d.js +0 -5
- package/dist/runtime/extendPayload.d.ts +0 -2
- package/dist/runtime/extendPayload.js +0 -21
- package/dist/runtime/extendTimeout.d.ts +0 -1
- package/dist/runtime/extendTimeout.js +0 -26
- package/dist/runtime/index.js +0 -53
- package/dist/runtime/requestMoreInfo.d.ts +0 -17
- package/dist/runtime/requestMoreInfo.js +0 -25
- package/dist/runtime/runInfo.d.ts +0 -2
- package/dist/runtime/runInfo.js +0 -21
- /package/{dist → src}/common/assets/browser_scripts.js +0 -0
- /package/{dist → src}/runtime/enums.d.ts +0 -0
- /package/{dist → src}/runtime/export.d.ts +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ts,
|
|
3
|
+
Project,
|
|
4
|
+
CompilerOptions,
|
|
5
|
+
ModuleKind,
|
|
6
|
+
ScriptTarget,
|
|
7
|
+
FunctionDeclaration,
|
|
8
|
+
SourceFile,
|
|
9
|
+
Node,
|
|
10
|
+
} from "ts-morph";
|
|
11
|
+
import { SourceMapConsumer } from "source-map";
|
|
12
|
+
|
|
13
|
+
function compileTypeScript(apiFilePath: string) {
|
|
14
|
+
const compilerOptions: CompilerOptions = {
|
|
15
|
+
lib: ["dom", "es2020"],
|
|
16
|
+
sourceMap: true,
|
|
17
|
+
inlineSourceMap: true,
|
|
18
|
+
inlineSources: true,
|
|
19
|
+
declaration: false,
|
|
20
|
+
noEmit: false,
|
|
21
|
+
module: ModuleKind.CommonJS,
|
|
22
|
+
target: ScriptTarget.ES2020,
|
|
23
|
+
};
|
|
24
|
+
const project = new Project({
|
|
25
|
+
compilerOptions,
|
|
26
|
+
});
|
|
27
|
+
const sourceFile = project.addSourceFileAtPath(apiFilePath);
|
|
28
|
+
const outputJS = project.emitToMemory({ targetSourceFile: sourceFile });
|
|
29
|
+
const outputJSText = outputJS.getFiles()[0].text;
|
|
30
|
+
return { sourceFile, outputJSText };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function findFirstExecutableLine(sourceFile: SourceFile) {
|
|
34
|
+
let functionBody: ReturnType<FunctionDeclaration["getBody"]>;
|
|
35
|
+
|
|
36
|
+
// Directly find the default exported function's body
|
|
37
|
+
const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
|
|
38
|
+
const defaultExportDeclaration = defaultExportSymbol?.getDeclarations()?.[0];
|
|
39
|
+
if (defaultExportDeclaration) {
|
|
40
|
+
// Check if the default export is a function
|
|
41
|
+
if (
|
|
42
|
+
defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration
|
|
43
|
+
) {
|
|
44
|
+
functionBody = (
|
|
45
|
+
defaultExportDeclaration as FunctionDeclaration
|
|
46
|
+
).getBody();
|
|
47
|
+
} else {
|
|
48
|
+
// Handle ExportAssignment specifically for cases like `export default identifier;`
|
|
49
|
+
const exportAssignments = sourceFile.getExportAssignments();
|
|
50
|
+
for (const exportAssignment of exportAssignments) {
|
|
51
|
+
const expression = exportAssignment.getExpression();
|
|
52
|
+
if (!expression) continue;
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
expression.getKind() === ts.SyntaxKind.Identifier ||
|
|
56
|
+
expression.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
57
|
+
expression.getKind() === ts.SyntaxKind.ArrowFunction
|
|
58
|
+
) {
|
|
59
|
+
const identifier = expression.getText();
|
|
60
|
+
const possiblyExportedFunction =
|
|
61
|
+
sourceFile.getFunction(identifier) ||
|
|
62
|
+
(sourceFile
|
|
63
|
+
.getVariableStatement(identifier)
|
|
64
|
+
?.getDescendants()
|
|
65
|
+
.find(
|
|
66
|
+
(node) =>
|
|
67
|
+
node.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
68
|
+
node.getKind() === ts.SyntaxKind.ArrowFunction
|
|
69
|
+
) as FunctionDeclaration);
|
|
70
|
+
if (possiblyExportedFunction) {
|
|
71
|
+
functionBody = possiblyExportedFunction.getBody();
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
Node.hasBody(expression) &&
|
|
77
|
+
(expression.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
78
|
+
expression.getKind() === ts.SyntaxKind.ArrowFunction)
|
|
79
|
+
) {
|
|
80
|
+
// As these are anonymous, we directly access their body
|
|
81
|
+
functionBody = expression.getBody() as ReturnType<
|
|
82
|
+
FunctionDeclaration["getBody"]
|
|
83
|
+
>;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!functionBody || !Node.isStatemented(functionBody)) {
|
|
90
|
+
return -1;
|
|
91
|
+
}
|
|
92
|
+
if (functionBody.getStatements().length === 0) {
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
const position = functionBody.getStatements()[0].getStart();
|
|
96
|
+
return sourceFile.getLineAndColumnAtPos(position);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function getSourceMap(jsCode: string) {
|
|
100
|
+
const sourceMapBase64 = jsCode.substring(
|
|
101
|
+
jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") +
|
|
102
|
+
"//# sourceMappingURL=data:application/json;base64,".length
|
|
103
|
+
);
|
|
104
|
+
const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString(
|
|
105
|
+
"utf-8"
|
|
106
|
+
);
|
|
107
|
+
const sourceMap = JSON.parse(sourceMapText);
|
|
108
|
+
return new SourceMapConsumer(sourceMap);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function mapFirstLineNumberBySourceMap(
|
|
112
|
+
sourceFileName: string,
|
|
113
|
+
jsCode: string,
|
|
114
|
+
line: number,
|
|
115
|
+
column: number
|
|
116
|
+
) {
|
|
117
|
+
const sourceMap = await getSourceMap(jsCode);
|
|
118
|
+
const generatedLineNumber = sourceMap.generatedPositionFor({
|
|
119
|
+
source: sourceFileName,
|
|
120
|
+
line,
|
|
121
|
+
column,
|
|
122
|
+
}).line;
|
|
123
|
+
if (!generatedLineNumber) return -1;
|
|
124
|
+
return generatedLineNumber;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default async function getFirstLineNumber(apiFilePath: string) {
|
|
128
|
+
const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
|
|
129
|
+
|
|
130
|
+
// Compile TypeScript to JavaScript and get the Typescript AST
|
|
131
|
+
const { sourceFile, outputJSText } = compileTypeScript(apiFilePath);
|
|
132
|
+
|
|
133
|
+
// Find the first line of code in the default export ts code
|
|
134
|
+
const result = findFirstExecutableLine(sourceFile);
|
|
135
|
+
if (result === -1) return { sourceFileName, lineNumber: -1 };
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
sourceFileName,
|
|
139
|
+
lineNumber: await mapFirstLineNumberBySourceMap(
|
|
140
|
+
sourceFileName,
|
|
141
|
+
outputJSText,
|
|
142
|
+
result.line,
|
|
143
|
+
result.column
|
|
144
|
+
),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Send information to the parent process where it should continue the debugger
|
|
2
|
+
// This is handled by DebuggingProcessManager
|
|
3
|
+
export const sendBreakPointOnToClient = (
|
|
4
|
+
sourceFileName: string,
|
|
5
|
+
lineNumber: number
|
|
6
|
+
) => {
|
|
7
|
+
console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
|
|
8
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import * as fs from "fs-extra";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
// TODO: todo-identity handle identity instances
|
|
8
|
+
export function getFullPathInProject(...paths: string[]) {
|
|
9
|
+
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function listProjectFilesAndFolders() {
|
|
13
|
+
const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
|
|
14
|
+
try {
|
|
15
|
+
const files = await fs.readdir(projectPath, { withFileTypes: true });
|
|
16
|
+
return files.map((file) => ({
|
|
17
|
+
type: file.isDirectory() ? ("Folder" as const) : ("File" as const),
|
|
18
|
+
fullPath: path.join(projectPath, file.name),
|
|
19
|
+
name: file.name,
|
|
20
|
+
}));
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error("Error reading the directory:", err);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getFullPathInProject } from "./fileUtils";
|
|
2
|
+
import {
|
|
3
|
+
IntunedSettings,
|
|
4
|
+
settingsSchema,
|
|
5
|
+
} from "../../../common/settingsSchema";
|
|
6
|
+
|
|
7
|
+
export async function getSettings(): Promise<IntunedSettings> {
|
|
8
|
+
const settingsFilePath = getFullPathInProject("Intuned.json");
|
|
9
|
+
console.log("loading settings");
|
|
10
|
+
|
|
11
|
+
const settings = await import(settingsFilePath);
|
|
12
|
+
if (settings.default) {
|
|
13
|
+
const parsed = settingsSchema.safeParse(settings.default);
|
|
14
|
+
if (parsed.success) {
|
|
15
|
+
return parsed.data;
|
|
16
|
+
} else {
|
|
17
|
+
// ToDo: why does the type not work here?
|
|
18
|
+
throw new Error((parsed as any).error.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return { authSessions: { enabled: false } };
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as fs from "fs-extra";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils";
|
|
5
|
+
|
|
6
|
+
export const moveWebTemplateFiles = async () => {
|
|
7
|
+
await fs.remove("./intuned");
|
|
8
|
+
await fs.ensureDir("./intuned");
|
|
9
|
+
|
|
10
|
+
const currentFileLocation = path.resolve(
|
|
11
|
+
__dirname,
|
|
12
|
+
"..",
|
|
13
|
+
"..",
|
|
14
|
+
"..",
|
|
15
|
+
"..",
|
|
16
|
+
"WebTemplate"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// copy WebTemplate to ./intuned
|
|
20
|
+
await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
|
|
21
|
+
filter: (src, dest) => {
|
|
22
|
+
if (src.includes(".d.ts")) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const filesAndFolders = await listProjectFilesAndFolders();
|
|
31
|
+
const pathsIgnoreList = [
|
|
32
|
+
getFullPathInProject("intuned"),
|
|
33
|
+
getFullPathInProject("node_modules"),
|
|
34
|
+
getFullPathInProject("package.json"),
|
|
35
|
+
getFullPathInProject("yarn.lock"),
|
|
36
|
+
getFullPathInProject(".env"),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const filesToCopy = filesAndFolders.filter(
|
|
40
|
+
(file) => !pathsIgnoreList.includes(file.fullPath)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
for (const file of filesToCopy) {
|
|
44
|
+
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as fs from "fs-extra";
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
// import { getPageVisiblePageHtml } from "../../common/playwrightPageHelpers";
|
|
4
|
+
import { getPlaywrightConstructsForMode } from "../../common/getPlaywrightConstructs";
|
|
5
|
+
|
|
6
|
+
dotenv.config({
|
|
7
|
+
path: `.env`,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
const { page } = await getPlaywrightConstructsForMode(
|
|
12
|
+
"playwright",
|
|
13
|
+
undefined
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
await page.goto(
|
|
17
|
+
"https://www.marriott.com/search/findHotels.mi?roomTypeCode=&recordsPerPage=20&autoSuggestItemType=&destinationAddress.types=locality,political&destinationAddress.latitude=47.6061389&propertyCode=&destinationAddress.stateProvinceShort=&isInternalSearch=true&destinationAddress.cityPopulation=&vsInitialRequest=false&searchType=InCity&destinationAddress.locality=&showAddressPin=&miniStoreFormSubmit=&destinationAddress.stateProvinceDisplayName=&destinationAddress.destinationPageDestinationAddress=&countryName=&destinationAddress.stateProvince=WA&searchRadius=50.0&singleSearchAutoSuggest=Unmatched&missingcheckInDateMsg=Please+enter+a+check-in+date.&destinationAddress.placeId=ChIJVTPokywQkFQRmtVEaUZlJRA&is-hotelsnearme-clicked=false&destinationAddress.addressline1=&airportName=&for-hotels-nearme=Near&missingcheckOutDateMsg=Please+enter+a+check-out+date.&suggestionsPropertyCode=&pageType=advanced&destinationAddress.country=US&destinationAddress.name=&poiCity=&destinationAddress.countryShort=&marriottBrands=&poiName=&destinationAddress.address=Seattle,+WA,+USA&search-countryRegion=&collapseAccordian=is-hidden&singleSearch=true&destinationAddress.cityPopulationDensity=&destinationAddress.secondaryText=WA,+USA&destinationAddress.postalCode=&destinationAddress.city=Seattle&destinationAddress.mainText=Seattle&airportCode=&isTransient=true&destinationAddress.longitude=-122.3328481&initialRequest=false&destinationAddress.website=https://maps.google.com/?q=Seattle,+WA,+USA&ftid=0x5490102c93e83355:0x102565466944d59a&search-locality=&dimensions=0&roomTypeCode=&propertyCode=&flexibleDateSearchRateDisplay=false&propertyName=&isSearch=true&marriottRewardsNumber=&isRateCalendar=false&incentiveType_Number=&incentiveType=&flexibleDateLowestRateMonth=&flexibleDateLowestRateDate=&marrOfferId=&isMultiRateSearch=&multiRateMaxCount=&multiRateCorpCodes=&useMultiRateRewardsPoints=&multiRateClusterCodes=&multiRateCorpCodesEntered=&lowestRegularRate=&js-location-nearme-values=&destinationAddress.destination=Seattle,+WA,+USA&fromToDate=10/07/2023&fromToDate_submit=10/08/2023&fromDate=10/07/2023&toDate=10/08/2023&toDateDefaultFormat=10/08/2023&fromDateDefaultFormat=10/07/2023&flexibleDateSearch=false&isHideFlexibleDateCalendar=false&t-start=2023-10-07&t-end=2023-10-08&lengthOfStay=1&roomCountBox=1+Room&roomCount=1&guestCountBox=1+Adult+Per+Room&numAdultsPerRoom=1&childrenCountBox=0+Children+Per+Room&childrenCount=0&childrenAges=&clusterCode=none&corporateCode=&useRewardsPoints=true&view=list#/0/",
|
|
18
|
+
{ waitUntil: "load" }
|
|
19
|
+
);
|
|
20
|
+
await page.waitForTimeout(10000);
|
|
21
|
+
|
|
22
|
+
const html = ""; // await getPageVisiblePageHtml(page);
|
|
23
|
+
|
|
24
|
+
await fs.writeFile("./htmlFiles/marriott.html", html);
|
|
25
|
+
|
|
26
|
+
process.exit();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void main();
|
|
@@ -0,0 +1,88 @@
|
|
|
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";
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.description("Check TypeScript types in the project")
|
|
10
|
+
.allowUnknownOption()
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await moveWebTemplateFiles();
|
|
13
|
+
|
|
14
|
+
const templateTsConfig = path.resolve(
|
|
15
|
+
__dirname,
|
|
16
|
+
"..",
|
|
17
|
+
"..",
|
|
18
|
+
"template.tsconfig.json"
|
|
19
|
+
);
|
|
20
|
+
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
21
|
+
|
|
22
|
+
checkTypes();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function checkTypes() {
|
|
26
|
+
const configPath = ts.findConfigFile(
|
|
27
|
+
"./intuned/WebTemplate",
|
|
28
|
+
ts.sys.fileExists,
|
|
29
|
+
"tsconfig.json"
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (!configPath) {
|
|
33
|
+
console.error("Could not find a valid 'tsconfig.json'.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
38
|
+
const config = readConfigResult.config;
|
|
39
|
+
|
|
40
|
+
const parseConfigHost = {
|
|
41
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
42
|
+
readDirectory: ts.sys.readDirectory,
|
|
43
|
+
fileExists: ts.sys.fileExists,
|
|
44
|
+
readFile: ts.sys.readFile,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const parsed = ts.parseJsonConfigFileContent(
|
|
48
|
+
config,
|
|
49
|
+
parseConfigHost,
|
|
50
|
+
"./intuned"
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const program = ts.createProgram(parsed.fileNames, parsed.options);
|
|
54
|
+
const emitResult = program.emit();
|
|
55
|
+
|
|
56
|
+
const allDiagnostics = ts
|
|
57
|
+
.getPreEmitDiagnostics(program)
|
|
58
|
+
.concat(emitResult.diagnostics);
|
|
59
|
+
|
|
60
|
+
allDiagnostics.forEach((diagnostic) => {
|
|
61
|
+
if (diagnostic.file) {
|
|
62
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(
|
|
63
|
+
diagnostic.file,
|
|
64
|
+
diagnostic.start!
|
|
65
|
+
);
|
|
66
|
+
const message = ts.flattenDiagnosticMessageText(
|
|
67
|
+
diagnostic.messageText,
|
|
68
|
+
"\n"
|
|
69
|
+
);
|
|
70
|
+
console.log(
|
|
71
|
+
`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
|
|
72
|
+
);
|
|
73
|
+
} else {
|
|
74
|
+
console.log(
|
|
75
|
+
ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (allDiagnostics.length === 0) {
|
|
81
|
+
console.log("✨ TypeScript type checking passed without errors.");
|
|
82
|
+
} else {
|
|
83
|
+
console.error("Errors found during TypeScript type checking.");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { formatWithOptions } from "node:util";
|
|
2
|
+
import { LogEntry, LogLevel, LogMetadata } from "./types";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
|
|
5
|
+
const format = formatWithOptions.bind(undefined, { colors: true });
|
|
6
|
+
|
|
7
|
+
const LOG_LEVEL_COLORS: Record<LogLevel, chalk.Chalk> = {
|
|
8
|
+
TRACE: chalk.gray,
|
|
9
|
+
DEBUG: chalk.blue,
|
|
10
|
+
INFO: chalk.green,
|
|
11
|
+
WARN: chalk.yellow,
|
|
12
|
+
ERROR: chalk.red,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
class Logger {
|
|
16
|
+
logFunction(entry: LogEntry): void {
|
|
17
|
+
const { level, timestamp, message, meta } = entry;
|
|
18
|
+
const date = new Date(timestamp);
|
|
19
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
20
|
+
|
|
21
|
+
if (meta === undefined) {
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
`${format(date)} [@intuned/sdk][${levelColor(
|
|
28
|
+
level
|
|
29
|
+
)}] ${message} ${format(meta)}\n`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private log(level: LogLevel, message: string, meta?: LogMetadata): void {
|
|
35
|
+
this.logFunction({
|
|
36
|
+
level,
|
|
37
|
+
message,
|
|
38
|
+
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
trace(message: string, meta?: LogMetadata): void {
|
|
44
|
+
this.log("TRACE", message, meta);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
debug(message: string, meta?: LogMetadata): void {
|
|
48
|
+
this.log("DEBUG", message, meta);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
info(message: string, meta?: LogMetadata): void {
|
|
52
|
+
this.log("INFO", message, meta);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
warn(message: string, meta?: LogMetadata): void {
|
|
56
|
+
this.log("WARN", message, meta);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
error(message: string, meta?: LogMetadata): void {
|
|
60
|
+
this.log("ERROR", message, meta);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const logger = new Logger();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type LogLevel = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
2
2
|
export type LogMetadata = Record<string | symbol, any>;
|
|
3
|
+
|
|
3
4
|
export interface LogEntry {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
message: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
meta?: LogMetadata;
|
|
8
9
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { formatWithOptions } from "node:util";
|
|
2
|
+
import { LogEntry, LogLevel, LogMetadata } from "./types";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
|
|
5
|
+
const format = formatWithOptions.bind(undefined, { colors: true });
|
|
6
|
+
|
|
7
|
+
const LOG_LEVEL_COLORS: Record<LogLevel, chalk.Chalk> = {
|
|
8
|
+
TRACE: chalk.gray,
|
|
9
|
+
DEBUG: chalk.blue,
|
|
10
|
+
INFO: chalk.green,
|
|
11
|
+
WARN: chalk.yellow,
|
|
12
|
+
ERROR: chalk.red,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
class Logger {
|
|
16
|
+
logFunction(entry: LogEntry): void {
|
|
17
|
+
const { level, timestamp, message, meta } = entry;
|
|
18
|
+
const date = new Date(timestamp);
|
|
19
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
20
|
+
|
|
21
|
+
if (meta === undefined) {
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
`${format(date)} [@intuned/sdk][${levelColor(
|
|
28
|
+
level
|
|
29
|
+
)}] ${message} ${format(meta)}\n`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private log(level: LogLevel, message: string, meta?: LogMetadata): void {
|
|
35
|
+
this.logFunction({
|
|
36
|
+
level,
|
|
37
|
+
message,
|
|
38
|
+
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
trace(message: string, meta?: LogMetadata): void {
|
|
44
|
+
this.log("TRACE", message, meta);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
debug(message: string, meta?: LogMetadata): void {
|
|
48
|
+
this.log("DEBUG", message, meta);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
info(message: string, meta?: LogMetadata): void {
|
|
52
|
+
this.log("INFO", message, meta);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
warn(message: string, meta?: LogMetadata): void {
|
|
56
|
+
this.log("WARN", message, meta);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
error(message: string, meta?: LogMetadata): void {
|
|
60
|
+
this.log("ERROR", message, meta);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const logger = new Logger();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type LogLevel = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
2
2
|
export type LogMetadata = Record<string | symbol, any>;
|
|
3
|
+
|
|
3
4
|
export interface LogEntry {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
message: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
meta?: LogMetadata;
|
|
8
9
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
+
import { Payload, RunInfo } from "../../runtime/export";
|
|
3
|
+
|
|
4
|
+
export const asyncLocalStorage = new AsyncLocalStorage<InternalRunInfo>();
|
|
5
|
+
|
|
6
|
+
export function runWithContext<R, TArgs extends any[]>(
|
|
7
|
+
contextData: InternalRunInfo,
|
|
8
|
+
callback: (...args: TArgs) => R,
|
|
9
|
+
...args: TArgs
|
|
10
|
+
): R {
|
|
11
|
+
return asyncLocalStorage.run(contextData, callback, ...args);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface TimeoutInfo {
|
|
15
|
+
extendTimeoutCallback?: () => Promise<void>;
|
|
16
|
+
timeoutDuration?: number;
|
|
17
|
+
timeoutTimestamp?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface InternalRunInfo extends RunInfo {
|
|
21
|
+
extendedPayloads: Payload[];
|
|
22
|
+
timeoutInfo?: TimeoutInfo;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getExecutionContext() {
|
|
26
|
+
const contextData = asyncLocalStorage.getStore();
|
|
27
|
+
|
|
28
|
+
return contextData as InternalRunInfo | undefined;
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function cleanEnvironmentVariables() {
|
|
2
|
+
Object.keys(process.env)
|
|
3
|
+
.filter((i) => {
|
|
4
|
+
if (i.toLocaleLowerCase().startsWith("npm")) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
.forEach((i) => delete process.env[i]);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BrowserContext } from "@intuned/playwright";
|
|
2
|
+
import * as playwright from "@intuned/playwright-core";
|
|
3
|
+
|
|
4
|
+
function sessionStorageToArray(
|
|
5
|
+
storage: Record<string, string>
|
|
6
|
+
): { name: string; value: string }[] {
|
|
7
|
+
const result: { name: string; value: string }[] = [];
|
|
8
|
+
|
|
9
|
+
for (const key in storage) {
|
|
10
|
+
result.push({ name: key, value: storage[key] });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface OriginSessionStorage {
|
|
17
|
+
origin: string;
|
|
18
|
+
sessionStorage: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type IntunedStorageState = Exclude<
|
|
25
|
+
playwright.BrowserContextOptions["storageState"],
|
|
26
|
+
string
|
|
27
|
+
> & {
|
|
28
|
+
sessionStorage?: OriginSessionStorage[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export async function getContextStorageState(
|
|
32
|
+
context: BrowserContext
|
|
33
|
+
): Promise<IntunedStorageState> {
|
|
34
|
+
const cookiesAndLocalStorage = await context.storageState();
|
|
35
|
+
const pages = await context.pages();
|
|
36
|
+
|
|
37
|
+
const pagesSessions: OriginSessionStorage[] = [];
|
|
38
|
+
for (const page of pages) {
|
|
39
|
+
const [origin, session] = await page.evaluate(() => [
|
|
40
|
+
location.origin,
|
|
41
|
+
sessionStorage as Record<string, string>,
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const transformed = sessionStorageToArray(session);
|
|
45
|
+
|
|
46
|
+
pagesSessions.push({ origin, sessionStorage: transformed });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...cookiesAndLocalStorage,
|
|
51
|
+
sessionStorage: pagesSessions,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function setContextStorageState(
|
|
56
|
+
context: BrowserContext,
|
|
57
|
+
storage: IntunedStorageState
|
|
58
|
+
) {
|
|
59
|
+
await (context as any).intunedSetStorageState(storage);
|
|
60
|
+
|
|
61
|
+
const sessionStorage = storage.sessionStorage;
|
|
62
|
+
|
|
63
|
+
await context.addInitScript((storage) => {
|
|
64
|
+
for (const { origin, sessionStorage } of storage) {
|
|
65
|
+
if (window.location.origin === origin) {
|
|
66
|
+
for (const item of sessionStorage)
|
|
67
|
+
window.sessionStorage.setItem(item.name, item.value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, sessionStorage);
|
|
71
|
+
}
|