@intuned/runtime-dev 0.0.1-split.0 → 0.0.1-split.2

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 (123) hide show
  1. package/WebTemplate/controllers/authSessions/create.ts +1 -1
  2. package/WebTemplate/controllers/runApi/helpers.ts +1 -3
  3. package/dist/commands/api/run.d.ts +6 -0
  4. package/dist/commands/api/run.js +135 -0
  5. package/dist/commands/auth-sessions/load.d.ts +2 -0
  6. package/dist/commands/auth-sessions/load.js +26 -0
  7. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  8. package/dist/commands/auth-sessions/run-check.js +42 -0
  9. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  10. package/dist/commands/auth-sessions/run-create.js +75 -0
  11. package/dist/commands/browser/save-state.d.ts +2 -0
  12. package/dist/commands/browser/save-state.js +17 -0
  13. package/dist/commands/browser/start-browser.d.ts +2 -0
  14. package/dist/commands/browser/start-browser.js +14 -0
  15. package/dist/commands/build.d.ts +2 -0
  16. package/dist/commands/build.js +80 -0
  17. package/dist/commands/common/browserUtils.d.ts +14 -0
  18. package/dist/commands/common/browserUtils.js +58 -0
  19. package/dist/commands/common/getDefaultExportFromFile.d.ts +1 -0
  20. package/dist/commands/common/getDefaultExportFromFile.js +19 -0
  21. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  22. package/dist/commands/common/getFirstLineNumber.js +103 -0
  23. package/{src/commands/common/getFirstLineNumber.test.ts → dist/commands/common/getFirstLineNumber.test.js} +75 -121
  24. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  25. package/dist/commands/common/sendMessageToClient.js +10 -0
  26. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  27. package/dist/commands/common/utils/fileUtils.js +33 -0
  28. package/dist/commands/common/utils/settings.d.ts +2 -0
  29. package/dist/commands/common/utils/settings.js +28 -0
  30. package/dist/commands/common/utils/webTemplate.d.ts +1 -0
  31. package/dist/commands/common/utils/webTemplate.js +31 -0
  32. package/dist/commands/testing/saveVisibleHtml.d.ts +1 -0
  33. package/dist/commands/testing/saveVisibleHtml.js +24 -0
  34. package/dist/commands/ts-check.d.ts +2 -0
  35. package/dist/commands/ts-check.js +54 -0
  36. package/dist/common/Logger/Logger/index.d.ts +12 -0
  37. package/dist/common/Logger/Logger/index.js +60 -0
  38. package/{src/common/Logger/Logger/types.ts → dist/common/Logger/Logger/types.d.ts} +4 -5
  39. package/dist/common/Logger/Logger/types.js +5 -0
  40. package/dist/common/Logger/index.d.ts +12 -0
  41. package/dist/common/Logger/index.js +60 -0
  42. package/{src/common/Logger/types.ts → dist/common/Logger/types.d.ts} +4 -5
  43. package/dist/common/Logger/types.js +5 -0
  44. package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  45. package/dist/common/asyncLocalStorage/index.js +17 -0
  46. package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  47. package/dist/common/cleanEnvironmentVariables.js +16 -0
  48. package/dist/common/constants.d.ts +1 -0
  49. package/dist/common/constants.js +7 -0
  50. package/dist/common/contextStorageStateHelpers.d.ts +15 -0
  51. package/dist/common/contextStorageStateHelpers.js +48 -0
  52. package/dist/common/getPlaywrightConstructs.d.ts +28 -0
  53. package/dist/common/getPlaywrightConstructs.js +175 -0
  54. package/dist/common/jwtTokenManager.d.ts +16 -0
  55. package/dist/common/jwtTokenManager.js +81 -0
  56. package/dist/common/settingsSchema.d.ts +19 -0
  57. package/dist/common/settingsSchema.js +17 -0
  58. package/dist/common/telemetry.d.ts +3 -0
  59. package/dist/common/telemetry.js +32 -0
  60. package/dist/index.d.ts +4 -0
  61. package/dist/index.js +69 -0
  62. package/dist/runtime/RunError.d.ts +5 -0
  63. package/dist/runtime/RunError.js +19 -0
  64. package/dist/runtime/downloadDirectory.d.ts +1 -0
  65. package/dist/runtime/downloadDirectory.js +19 -0
  66. package/dist/runtime/enums.d.js +5 -0
  67. package/dist/runtime/enums.js +18 -0
  68. package/dist/runtime/executionHelpers.test.js +53 -0
  69. package/dist/runtime/export.d.js +5 -0
  70. package/dist/runtime/extendPayload.d.ts +2 -0
  71. package/dist/runtime/extendPayload.js +21 -0
  72. package/dist/runtime/extendTimeout.d.ts +1 -0
  73. package/dist/runtime/extendTimeout.js +26 -0
  74. package/{src/runtime/index.ts → dist/runtime/index.d.ts} +1 -3
  75. package/dist/runtime/index.js +53 -0
  76. package/dist/runtime/requestMoreInfo.d.ts +17 -0
  77. package/dist/runtime/requestMoreInfo.js +25 -0
  78. package/dist/runtime/runInfo.d.ts +2 -0
  79. package/dist/runtime/runInfo.js +21 -0
  80. package/package.json +1 -1
  81. package/.vscode/extensions.json +0 -3
  82. package/.vscode/launch.json +0 -102
  83. package/.vscode/settings.json +0 -12
  84. package/playwright.config.ts +0 -48
  85. package/src/commands/api/run.ts +0 -225
  86. package/src/commands/auth-sessions/load.ts +0 -42
  87. package/src/commands/auth-sessions/run-check.ts +0 -70
  88. package/src/commands/auth-sessions/run-create.ts +0 -124
  89. package/src/commands/browser/save-state.ts +0 -22
  90. package/src/commands/browser/start-browser.ts +0 -17
  91. package/src/commands/build.ts +0 -125
  92. package/src/commands/common/browserUtils.ts +0 -80
  93. package/src/commands/common/getDefaultExportFromFile.ts +0 -13
  94. package/src/commands/common/getFirstLineNumber.ts +0 -146
  95. package/src/commands/common/sendMessageToClient.ts +0 -8
  96. package/src/commands/common/utils/fileUtils.ts +0 -25
  97. package/src/commands/common/utils/settings.ts +0 -23
  98. package/src/commands/common/utils/webTemplate.ts +0 -46
  99. package/src/commands/testing/saveVisibleHtml.ts +0 -29
  100. package/src/commands/ts-check.ts +0 -88
  101. package/src/common/Logger/Logger/index.ts +0 -64
  102. package/src/common/Logger/index.ts +0 -64
  103. package/src/common/asyncLocalStorage/index.ts +0 -29
  104. package/src/common/cleanEnvironmentVariables.ts +0 -13
  105. package/src/common/constants.ts +0 -1
  106. package/src/common/contextStorageStateHelpers.ts +0 -71
  107. package/src/common/getPlaywrightConstructs.ts +0 -283
  108. package/src/common/jwtTokenManager.ts +0 -111
  109. package/src/common/settingsSchema.ts +0 -16
  110. package/src/common/telemetry.ts +0 -49
  111. package/src/index.ts +0 -14
  112. package/src/runtime/RunError.ts +0 -16
  113. package/src/runtime/downloadDirectory.ts +0 -14
  114. package/src/runtime/enums.ts +0 -11
  115. package/src/runtime/executionHelpers.test.ts +0 -70
  116. package/src/runtime/extendPayload.ts +0 -22
  117. package/src/runtime/extendTimeout.ts +0 -32
  118. package/src/runtime/requestMoreInfo.ts +0 -40
  119. package/src/runtime/runInfo.ts +0 -19
  120. package/vite.config.ts +0 -17
  121. /package/{src → dist}/common/assets/browser_scripts.js +0 -0
  122. /package/{src → dist}/runtime/enums.d.ts +0 -0
  123. /package/{src → dist}/runtime/export.d.ts +0 -0
@@ -1,80 +0,0 @@
1
- // this file is to make testing easier only.
2
-
3
- import { spawn } from "child_process";
4
- import * as playwright from "@intuned/playwright-core";
5
- import * as fs from "fs-extra";
6
- import { BrowserContext } from "@intuned/playwright-core";
7
- import { getFullPathInProject } from "./utils/fileUtils";
8
- import { getContextStorageState } from "../../common/contextStorageStateHelpers";
9
-
10
- export const REMOTE_DEBUGGING_PORT = 9222;
11
-
12
- export const getChromiumLaunchArgs = () => [
13
- "--no-sandbox",
14
- `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`,
15
- `--user-data-dir=/tmp/${Date.now()}`,
16
- "--new-window",
17
- "--start-maximized",
18
- "--disable-popup-blocking",
19
- ];
20
-
21
- // this is needed cause we need to keep the same browser instance alive between start recording and stop recording calls.
22
- async function getBrowser() {
23
- let playwrightBrowser: playwright.Browser | null = null;
24
-
25
- try {
26
- playwrightBrowser = await playwright.chromium.connectOverCDP(
27
- `http://localhost:${REMOTE_DEBUGGING_PORT}`
28
- );
29
- } catch (e) {
30
- throw new Error("Browser is not running");
31
- }
32
-
33
- return playwrightBrowser;
34
- }
35
-
36
- export async function startOrRestartBrowser() {
37
- const chromiumPath = await playwright.chromium.executablePath();
38
-
39
- const chromeInstanceProcess = spawn(chromiumPath, getChromiumLaunchArgs());
40
-
41
- chromeInstanceProcess.stdout.on("data", (data) => {
42
- console.log(`Chrome stdout: ${data}`);
43
- });
44
-
45
- chromeInstanceProcess.stderr.on("data", (data) => {
46
- console.error(`Chrome stderr: ${data}`);
47
- });
48
- }
49
-
50
- export interface SessionState {
51
- cookies: any[];
52
- storage: Record<string, { localStorage: any; sessionStorage: any }>;
53
- }
54
-
55
- export async function saveSessionFromOpenedBrowser(path: string) {
56
- const browser = await getBrowser();
57
- const context = await browser.contexts()[0];
58
-
59
- return saveSession(path, context);
60
- }
61
-
62
- export async function loadState(path: string, context: BrowserContext) {
63
- const fullPath = getFullPathInProject(path);
64
- if (!(await fs.pathExists(fullPath))) {
65
- throw new Error("session file does not exist");
66
- }
67
-
68
- const data: SessionState = await fs.readJson(fullPath);
69
-
70
- await context.addCookies(data.cookies);
71
-
72
- // ToDo: logic to load storage without using the page.
73
- }
74
-
75
- export async function saveSession(path: string, context: BrowserContext) {
76
- const fullState = await getContextStorageState(context);
77
- const fullPath = getFullPathInProject(path);
78
- fs.ensureFileSync(fullPath);
79
- await fs.writeJSON(fullPath, fullState);
80
- }
@@ -1,13 +0,0 @@
1
- export async function getDefaultExportFromFile(apiFilePath: string) {
2
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3
- require("ts-node").register({
4
- transpileOnly: true,
5
- compilerOptions: {
6
- lib: ["dom", "es2020"],
7
- },
8
- });
9
-
10
- const imported = await import(apiFilePath);
11
- const defaultExport = imported.default;
12
- return defaultExport;
13
- }
@@ -1,146 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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
- };
@@ -1,25 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,46 +0,0 @@
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
- };
@@ -1,29 +0,0 @@
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();
@@ -1,88 +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";
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);
@@ -1,64 +0,0 @@
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,64 +0,0 @@
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,29 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";