@intuned/runtime 1.2.0 → 1.3.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/commands/api/run.js +5 -3
  3. package/dist/commands/auth-sessions/load.js +3 -3
  4. package/dist/commands/auth-sessions/run-check.js +1 -2
  5. package/dist/commands/auth-sessions/run-create.js +12 -35
  6. package/dist/commands/interface/run.d.ts +1 -1
  7. package/dist/commands/interface/run.js +14 -40
  8. package/dist/commands/intuned-cli/commands/deploy.command.js +6 -9
  9. package/dist/commands/intuned-cli/commands/index.d.ts +1 -0
  10. package/dist/commands/intuned-cli/commands/index.js +11 -0
  11. package/dist/commands/intuned-cli/commands/init.command.js +4 -5
  12. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +2 -1
  13. package/dist/commands/intuned-cli/commands/save.command.d.ts +12 -0
  14. package/dist/commands/intuned-cli/commands/save.command.js +46 -0
  15. package/dist/commands/intuned-cli/commands/types.d.ts +1 -1
  16. package/dist/commands/intuned-cli/constants/index.d.ts +0 -16
  17. package/dist/commands/intuned-cli/constants/index.js +1 -36
  18. package/dist/commands/intuned-cli/controller/__test__/api.test.js +1 -2
  19. package/dist/commands/intuned-cli/controller/api.js +1 -2
  20. package/dist/commands/intuned-cli/controller/authSession.js +3 -4
  21. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -12
  22. package/dist/commands/intuned-cli/controller/deploy.js +9 -284
  23. package/dist/commands/intuned-cli/controller/save.d.ts +14 -0
  24. package/dist/commands/intuned-cli/controller/save.js +364 -0
  25. package/dist/commands/intuned-cli/helpers/backend.js +4 -3
  26. package/dist/commands/intuned-cli/helpers/errors.d.ts +2 -2
  27. package/dist/commands/intuned-cli/helpers/errors.js +8 -4
  28. package/dist/commands/intuned-cli/main.js +7 -0
  29. package/dist/commands/intuned-cli/types.d.ts +0 -2
  30. package/dist/commands/intuned-cli/types.js +1 -2
  31. package/dist/common/asyncLocalStorage/index.d.ts +1 -0
  32. package/dist/common/constants.d.ts +6 -0
  33. package/dist/common/constants.js +8 -2
  34. package/dist/common/jwtTokenManager.d.ts +1 -0
  35. package/dist/common/jwtTokenManager.js +37 -7
  36. package/dist/common/playwrightContext.d.ts +54 -0
  37. package/dist/common/{getPlaywrightConstructs.js → playwrightContext.js} +148 -79
  38. package/dist/common/runApi/errors.d.ts +9 -2
  39. package/dist/common/runApi/errors.js +17 -3
  40. package/dist/common/runApi/importUsingImportFunction.d.ts +9 -0
  41. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  42. package/dist/common/runApi/index.d.ts +2 -7
  43. package/dist/common/runApi/index.js +99 -173
  44. package/dist/common/runApi/types.d.ts +3 -7
  45. package/dist/common/runApi/types.js +1 -2
  46. package/dist/common/setupContextHook.d.ts +17 -0
  47. package/dist/common/setupContextHook.js +22 -0
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +13 -19
  50. package/dist/runtime/attemptStore.d.ts +2 -0
  51. package/dist/runtime/attemptStore.js +23 -0
  52. package/dist/runtime/export.d.ts +51 -41
  53. package/dist/runtime/index.d.ts +1 -2
  54. package/dist/runtime/index.js +7 -13
  55. package/package.json +3 -2
  56. package/.npmrc.d +0 -1
  57. package/dist/commands/intuned-cli/constants/readme.d.ts +0 -1
  58. package/dist/commands/intuned-cli/constants/readme.js +0 -150
  59. package/dist/commands/intuned-cli/controller/init.d.ts +0 -5
  60. package/dist/commands/intuned-cli/controller/init.js +0 -136
  61. package/dist/common/getPlaywrightConstructs.d.ts +0 -30
  62. package/dist/runtime/requestMoreInfo.d.ts +0 -18
  63. package/dist/runtime/requestMoreInfo.js +0 -25
@@ -1,8 +1,7 @@
1
1
  export { extendPayload } from "./extendPayload";
2
2
  export { extendTimeout } from "./extendTimeout";
3
+ export { attemptStore } from "./attemptStore";
3
4
  export { getAuthSessionParameters } from "./getAuthSessionParameters";
4
5
  export { runInfo } from "./runInfo";
5
6
  export { RunError } from "./RunError";
6
- export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
7
- export type { RequestMoreInfoDetails } from "./requestMoreInfo";
8
7
  export { getDownloadDirectoryPath } from "./downloadDirectory";
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "RunError", {
9
9
  return _RunError.RunError;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "attemptStore", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _attemptStore.attemptStore;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "extendPayload", {
13
19
  enumerable: true,
14
20
  get: function () {
@@ -33,18 +39,6 @@ Object.defineProperty(exports, "getDownloadDirectoryPath", {
33
39
  return _downloadDirectory.getDownloadDirectoryPath;
34
40
  }
35
41
  });
36
- Object.defineProperty(exports, "requestMultipleChoice", {
37
- enumerable: true,
38
- get: function () {
39
- return _requestMoreInfo.requestMultipleChoice;
40
- }
41
- });
42
- Object.defineProperty(exports, "requestOTP", {
43
- enumerable: true,
44
- get: function () {
45
- return _requestMoreInfo.requestOTP;
46
- }
47
- });
48
42
  Object.defineProperty(exports, "runInfo", {
49
43
  enumerable: true,
50
44
  get: function () {
@@ -53,8 +47,8 @@ Object.defineProperty(exports, "runInfo", {
53
47
  });
54
48
  var _extendPayload = require("./extendPayload");
55
49
  var _extendTimeout = require("./extendTimeout");
50
+ var _attemptStore = require("./attemptStore");
56
51
  var _getAuthSessionParameters = require("./getAuthSessionParameters");
57
52
  var _runInfo = require("./runInfo");
58
53
  var _RunError = require("./RunError");
59
- var _requestMoreInfo = require("./requestMoreInfo");
60
54
  var _downloadDirectory = require("./downloadDirectory");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -79,6 +79,7 @@
79
79
  "nanoid": "3",
80
80
  "neverthrow": "6.1.0",
81
81
  "playwright-extra": "4.3.6",
82
+ "portfinder": "^1.0.37",
82
83
  "prettier": "2.8.0",
83
84
  "promptly": "3.2.0",
84
85
  "rollup": "3.26.2",
@@ -118,7 +119,7 @@
118
119
  "eslint-plugin-deprecation": "^1.3.3",
119
120
  "eslint-plugin-prettier": "^4.2.1",
120
121
  "msw": "^2.1.2",
121
- "playwright": "1.44.1",
122
+ "playwright": "^1.55.0",
122
123
  "typedoc": "^0.25.13",
123
124
  "typedoc-plugin-frontmatter": "^1.0.0",
124
125
  "typedoc-plugin-markdown": "^4.0.2",
package/.npmrc.d DELETED
@@ -1 +0,0 @@
1
- //registry.npmjs.org/:_authToken=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
@@ -1 +0,0 @@
1
- export declare const readme = "# Intuned CLI\n## Development Commands\n\nFor each command, add `--help` to see more details and options.\n\n### Initialize a Project\n`npx -p @intuned/runtime intuned init`\n\n### Run an API\n`yarn intuned run api <api-name> <parameters>`\nor\n`npm run intuned run api <api-name> <parameters>`\n\n\n### Build a Project\n`yarn intuned build`\n\n### Deploy a Project\n`yarn intuned deploy [project-name]`\nor\n`npm run intuned deploy [project-name]`\n\n\n\n### Create an auth session\n`yarn intuned run authsession create <parameters>`\nor\n`npm run intuned run authsession create <parameters>`\n\n\n\n### Validate an auth session\n`yarn intuned run authsession validate <auth-session-name>`\nor\n`npm run intuned run authsession validate <auth-session-name>`\n\n## Configuration\n\n### Environment Variables and Settings\n- `workspaceId`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))\n - Set in `intuned.json` file under the `workspaceId` property\n - Or provide via CLI with `--workspace-id` flag during deployment\n \n- `projectName`: The name of your Intuned project\n - Set in `intuned.json` file under the `projectName` property\n - Or override via command line when deploying with `yarn intuned deploy my-project-name` or `npm run intuned deploy my-project-name`\n\n- `INTUNED_API_KEY`: Your Intuned API key\n - Set as an environment variable: `export INTUNED_API_KEY=your_api_key_here`\n - Or include in your .env file for development\n - Or provide via CLI with `--api-key` flag during deployment\n\n## Project Structure\n\n### Generated Artifacts\n- `./intuned.json`: Project configuration file\n- `./api`: Folder containing API implementation files\n- `./auth-sessions`: Folder containing auth-session APIs if you use them\n- `./auth-sessions-instances`: Folder containing auth session instances\n\n## Types of auth sessions\n- `MANUAL`: Manual auth session, records the session using a recorder and stores it in the `auth-sessions-instances` folder\n- `API`: Auth session created via create API, stores the session in the `auth-sessions-instances` folder\n\n### Notes\n- You can use either `yarn` or `npm run` to execute commands\n- All commands must be run from the project root directory\n- Verify you're in the correct location by confirming the presence of package.json and intuned.json\n- Running commands from subdirectories may result in errors\n- You can manage your deployed projects through the Intuned platform\n- \u26A0\uFE0F WARNING: Changes to TS Config may break some Intuned functionalities\n\n## `Intuned.json` Reference\n```jsonc\n{\n // Your Intuned workspace ID. \n // Optional - If not provided here, it must be supplied via the `--workspace-id` flag during deployment.\n \"workspaceId\": \"your_workspace_id\",\n\n // The name of your Intuned project. \n // Optional - If not provided here, it must be supplied via the command line when deploying.\n \"projectName\": \"your_project_name\",\n\n // Replication settings\n \"replication\": {\n // The maximum number of concurrent executions allowed via Intuned API. This does not affect jobs.\n // A number of machines equal to this will be allocated to handle API requests.\n // Not applicable if api access is disabled.\n \"maxConcurrentRequests\": 1,\n\n // The machine size to use for this project. This is applicable for both API requests and jobs.\n // \"standard\": Standard machine size (6 shared vCPUs, 2GB RAM)\n // \"large\": Large machine size (8 shared vCPUs, 4GB RAM)\n // \"xlarge\": Extra large machine size (1 performance vCPU, 8GB RAM)\n \"size\": \"standard\"\n }\n\n // Auth session settings\n \"authSessions\": {\n // Whether auth sessions are enabled for this project.\n // If enabled, \"auth-sessions/check.ts\" API must be implemented to validate the auth session.\n \"enabled\": true,\n\n // Whether to save Playwright traces for auth session runs.\n \"saveTraces\": false,\n\n // The type of auth session to use.\n // \"API\" type requires implementing \"auth-sessions/create.ts\" API to create/recreate the auth session programmatically.\n // \"MANUAL\" type uses a recorder to manually create the auth session.\n \"type\": \"API\",\n \n\n // Recorder start URL for the recorder to navigate to when creating the auth session.\n // Required if \"type\" is \"MANUAL\". Not used if \"type\" is \"API\".\n \"startUrl\": \"https://example.com/login\",\n\n // Recorder finish URL for the recorder. Once this URL is reached, the recorder stops and saves the auth session.\n // Required if \"type\" is \"MANUAL\". Not used if \"type\" is \"API\".\n \"finishUrl\": \"https://example.com/dashboard\",\n\n // Recorder browser mode\n // \"fullscreen\": Launches the browser in fullscreen mode.\n // \"kiosk\": Launches the browser in kiosk mode (no address bar, no navigation controls).\n // Only applicable for \"MANUAL\" type.\n \"browserMode\": \"fullscreen\"\n }\n \n // API access settings\n \"apiAccess\": {\n // Whether to enable consumption through Intuned API. If this is false, the project can only be consumed through jobs.\n // This is required for projects that use auth sessions.\n \"enabled\": true\n },\n\n // Whether to run the deployed API in a headful browser. Running in headful can help with some anti-bot detections. However, it requires more resources and may work slower or crash if the machine size is \"standard\".\n \"headful\": false,\n\n // The region where your Intuned project is hosted.\n // For a list of available regions, contact support or refer to the documentation.\n // Optional - Default: \"us\"\n \"region\": \"us\"\n}\n```\n";
@@ -1,150 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.readme = void 0;
7
- const readme = exports.readme = `# Intuned CLI
8
- ## Development Commands
9
-
10
- For each command, add \`--help\` to see more details and options.
11
-
12
- ### Initialize a Project
13
- \`npx -p @intuned/runtime intuned init\`
14
-
15
- ### Run an API
16
- \`yarn intuned run api <api-name> <parameters>\`
17
- or
18
- \`npm run intuned run api <api-name> <parameters>\`
19
-
20
-
21
- ### Build a Project
22
- \`yarn intuned build\`
23
-
24
- ### Deploy a Project
25
- \`yarn intuned deploy [project-name]\`
26
- or
27
- \`npm run intuned deploy [project-name]\`
28
-
29
-
30
-
31
- ### Create an auth session
32
- \`yarn intuned run authsession create <parameters>\`
33
- or
34
- \`npm run intuned run authsession create <parameters>\`
35
-
36
-
37
-
38
- ### Validate an auth session
39
- \`yarn intuned run authsession validate <auth-session-name>\`
40
- or
41
- \`npm run intuned run authsession validate <auth-session-name>\`
42
-
43
- ## Configuration
44
-
45
- ### Environment Variables and Settings
46
- - \`workspaceId\`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))
47
- - Set in \`intuned.json\` file under the \`workspaceId\` property
48
- - Or provide via CLI with \`--workspace-id\` flag during deployment
49
-
50
- - \`projectName\`: The name of your Intuned project
51
- - Set in \`intuned.json\` file under the \`projectName\` property
52
- - Or override via command line when deploying with \`yarn intuned deploy my-project-name\` or \`npm run intuned deploy my-project-name\`
53
-
54
- - \`INTUNED_API_KEY\`: Your Intuned API key
55
- - Set as an environment variable: \`export INTUNED_API_KEY=your_api_key_here\`
56
- - Or include in your .env file for development
57
- - Or provide via CLI with \`--api-key\` flag during deployment
58
-
59
- ## Project Structure
60
-
61
- ### Generated Artifacts
62
- - \`./intuned.json\`: Project configuration file
63
- - \`./api\`: Folder containing API implementation files
64
- - \`./auth-sessions\`: Folder containing auth-session APIs if you use them
65
- - \`./auth-sessions-instances\`: Folder containing auth session instances
66
-
67
- ## Types of auth sessions
68
- - \`MANUAL\`: Manual auth session, records the session using a recorder and stores it in the \`auth-sessions-instances\` folder
69
- - \`API\`: Auth session created via create API, stores the session in the \`auth-sessions-instances\` folder
70
-
71
- ### Notes
72
- - You can use either \`yarn\` or \`npm run\` to execute commands
73
- - All commands must be run from the project root directory
74
- - Verify you're in the correct location by confirming the presence of package.json and intuned.json
75
- - Running commands from subdirectories may result in errors
76
- - You can manage your deployed projects through the Intuned platform
77
- - ⚠️ WARNING: Changes to TS Config may break some Intuned functionalities
78
-
79
- ## \`Intuned.json\` Reference
80
- \`\`\`jsonc
81
- {
82
- // Your Intuned workspace ID.
83
- // Optional - If not provided here, it must be supplied via the \`--workspace-id\` flag during deployment.
84
- "workspaceId": "your_workspace_id",
85
-
86
- // The name of your Intuned project.
87
- // Optional - If not provided here, it must be supplied via the command line when deploying.
88
- "projectName": "your_project_name",
89
-
90
- // Replication settings
91
- "replication": {
92
- // The maximum number of concurrent executions allowed via Intuned API. This does not affect jobs.
93
- // A number of machines equal to this will be allocated to handle API requests.
94
- // Not applicable if api access is disabled.
95
- "maxConcurrentRequests": 1,
96
-
97
- // The machine size to use for this project. This is applicable for both API requests and jobs.
98
- // "standard": Standard machine size (6 shared vCPUs, 2GB RAM)
99
- // "large": Large machine size (8 shared vCPUs, 4GB RAM)
100
- // "xlarge": Extra large machine size (1 performance vCPU, 8GB RAM)
101
- "size": "standard"
102
- }
103
-
104
- // Auth session settings
105
- "authSessions": {
106
- // Whether auth sessions are enabled for this project.
107
- // If enabled, "auth-sessions/check.ts" API must be implemented to validate the auth session.
108
- "enabled": true,
109
-
110
- // Whether to save Playwright traces for auth session runs.
111
- "saveTraces": false,
112
-
113
- // The type of auth session to use.
114
- // "API" type requires implementing "auth-sessions/create.ts" API to create/recreate the auth session programmatically.
115
- // "MANUAL" type uses a recorder to manually create the auth session.
116
- "type": "API",
117
-
118
-
119
- // Recorder start URL for the recorder to navigate to when creating the auth session.
120
- // Required if "type" is "MANUAL". Not used if "type" is "API".
121
- "startUrl": "https://example.com/login",
122
-
123
- // Recorder finish URL for the recorder. Once this URL is reached, the recorder stops and saves the auth session.
124
- // Required if "type" is "MANUAL". Not used if "type" is "API".
125
- "finishUrl": "https://example.com/dashboard",
126
-
127
- // Recorder browser mode
128
- // "fullscreen": Launches the browser in fullscreen mode.
129
- // "kiosk": Launches the browser in kiosk mode (no address bar, no navigation controls).
130
- // Only applicable for "MANUAL" type.
131
- "browserMode": "fullscreen"
132
- }
133
-
134
- // API access settings
135
- "apiAccess": {
136
- // Whether to enable consumption through Intuned API. If this is false, the project can only be consumed through jobs.
137
- // This is required for projects that use auth sessions.
138
- "enabled": true
139
- },
140
-
141
- // Whether to run the deployed API in a headful browser. Running in headful can help with some anti-bot detections. However, it requires more resources and may work slower or crash if the machine size is "standard".
142
- "headful": false,
143
-
144
- // The region where your Intuned project is hosted.
145
- // For a list of available regions, contact support or refer to the documentation.
146
- // Optional - Default: "us"
147
- "region": "us"
148
- }
149
- \`\`\`
150
- `;
@@ -1,5 +0,0 @@
1
- import { FileSystemTree, TemplateId } from "../types";
2
- export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
3
- export declare function checkEmptyDirectory(): Promise<boolean>;
4
- export declare function selectTemplate(templateName: string): Promise<TemplateId>;
5
- export declare function scaffoldProject(templateId: string, isTargetDirectoryEmpty: boolean): Promise<void>;
@@ -1,136 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.checkEmptyDirectory = checkEmptyDirectory;
7
- exports.mountFiles = mountFiles;
8
- exports.scaffoldProject = scaffoldProject;
9
- exports.selectTemplate = selectTemplate;
10
- var fs = _interopRequireWildcard(require("fs-extra"));
11
- var _types = require("../types");
12
- var _path = _interopRequireDefault(require("path"));
13
- var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
14
- var _constants = require("../constants");
15
- var _helpers = require("../helpers");
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
- function isDirectoryNode(node) {
20
- return node.directory !== undefined;
21
- }
22
- function isFileNode(node) {
23
- return node.file !== undefined;
24
- }
25
- async function mountFiles(cwd, tree) {
26
- for (const name in tree) {
27
- const fullPath = _path.default.join(cwd, name);
28
- const node = tree[name];
29
- if (isDirectoryNode(node)) {
30
- await fs.ensureDir(fullPath);
31
- await mountFiles(fullPath, node.directory);
32
- } else if (isFileNode(node)) {
33
- await fs.writeFile(fullPath, node.file.contents);
34
- }
35
- }
36
- }
37
- async function checkEmptyDirectory() {
38
- const currentDir = process.cwd();
39
- try {
40
- const stats = await fs.stat(currentDir);
41
- if (!stats.isDirectory()) {
42
- throw new _helpers.CLIError("The current path is not a directory.");
43
- }
44
- const files = await fs.readdir(currentDir);
45
- const significantFiles = files.filter(file => !_projectExclusions.default.includes(file));
46
- return significantFiles.length === 0;
47
- } catch (error) {
48
- if (error.code === "ENOENT") {
49
- throw new _helpers.CLIError("The specified directory does not exist.");
50
- }
51
- throw error;
52
- }
53
- }
54
- async function selectTemplate(templateName) {
55
- if (templateName) {
56
- if (!_types.templateIds.includes(templateName)) {
57
- throw new _helpers.CLIError(`Template "${templateName}" not found.`);
58
- }
59
- return templateName;
60
- }
61
- (0, _helpers.terminal)("^+Select a template (ESC to cancel):^:\n");
62
- const {
63
- promise: selectedCommandPromise
64
- } = _helpers.terminal.singleColumnMenu(_types.templateIds, {
65
- cancelable: true
66
- });
67
- const selectedTemplateIndex = (await selectedCommandPromise).selectedIndex;
68
- if (selectedTemplateIndex === undefined) {
69
- throw new _helpers.CLIError("^y^+Project initialization cancelled.^:\n", {
70
- autoColor: false
71
- });
72
- }
73
- return _types.templateIds[selectedTemplateIndex];
74
- }
75
- async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
76
- if (!isTargetDirectoryEmpty) {
77
- (0, _helpers.terminal)("^+The current directory is not empty. Do you want to proceed and override files?^: (y/N)");
78
- const {
79
- promise
80
- } = _helpers.terminal.yesOrNo({
81
- no: ["n", "ENTER", "ESCAPE"],
82
- yes: ["y"],
83
- echoNo: " no\n",
84
- echoYes: " yes\n"
85
- });
86
- const confirm = await promise;
87
- if (!confirm) {
88
- throw new _helpers.CLIError("^y^+Project initialization cancelled^:\n", {
89
- autoColor: false
90
- });
91
- }
92
- }
93
- const cwd = process.cwd();
94
- (0, _helpers.terminal)(`^c🚀 Initializing ^:^+${templateId}^:^c project...\n`);
95
- const template = await fetchProjectTemplate(templateId);
96
- (0, _helpers.terminal)(`^c🔨 Creating project files...^:\n`);
97
- const codeTree = template;
98
- await prepareCLITemplate(codeTree);
99
- await mountFiles(cwd, codeTree);
100
- (0, _helpers.terminal)(`^g^+🎉 Project initialized successfully!^ ^GRun ^:^+yarn^:^G to install dependencies and start coding!\n`);
101
- }
102
- async function fetchProjectTemplate(templateId) {
103
- const baseUrl = (0, _helpers.getBaseUrl)();
104
- const url = `${baseUrl}/api/templates/${templateId}`;
105
- const response = await fetch(url);
106
- if (!response.ok) {
107
- throw new _helpers.CLIError(`^r^+Error fetching template:\n^:^R${response.statusText} ${response.status}\n^r^+Failed to initialize project^:\n`, {
108
- autoColor: false
109
- });
110
- }
111
- const data = await response.json();
112
- if (!data) {
113
- throw new _helpers.CLIError("Error fetching template: Template not found");
114
- }
115
- return data.template;
116
- }
117
- async function prepareCLITemplate(codeTree) {
118
- codeTree["parameters"] = {
119
- directory: {}
120
- };
121
- codeTree["tsconfig.json"] = {
122
- file: {
123
- contents: JSON.stringify(_constants.tsConfigCli, null, 2)
124
- }
125
- };
126
- if (isFileNode(codeTree["package.json"]) && codeTree["package.json"].file) {
127
- const packageJson = JSON.parse(codeTree["package.json"].file.contents);
128
- packageJson.scripts = _constants.userCLIScripts;
129
- codeTree["package.json"].file.contents = JSON.stringify(packageJson, null, 2);
130
- }
131
- codeTree["README.md"] = {
132
- file: {
133
- contents: _constants.readme
134
- }
135
- };
136
- }
@@ -1,30 +0,0 @@
1
- import * as playwright from "playwright";
2
- import type { RunApiSession } from "./runApi";
3
- interface Proxy {
4
- server: string;
5
- username: string;
6
- password: string;
7
- }
8
- interface GetPlaywrightConstructsOptions {
9
- proxy?: Proxy;
10
- headless?: boolean;
11
- storageState?: RunApiSession;
12
- downloadsPath: string;
13
- }
14
- export declare function getProductionPlaywrightConstructs({ proxy, headless, storageState, downloadsPath, }: GetPlaywrightConstructsOptions): Promise<{
15
- page: playwright.Page;
16
- context: playwright.BrowserContext;
17
- }>;
18
- export declare function getPlaywrightConstructsForMode(mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless", cdpAddress: string | undefined, authSession?: RunApiSession): Promise<{
19
- page: playwright.Page;
20
- context: playwright.BrowserContext;
21
- }>;
22
- export declare function loadSessionToContext({ context, session, }: {
23
- context: playwright.BrowserContext;
24
- session: RunApiSession;
25
- }): Promise<void>;
26
- export declare function getRemotePlaywrightContext(cdpAddress: string): Promise<{
27
- browser: playwright.Browser;
28
- context: playwright.BrowserContext;
29
- }>;
30
- export {};
@@ -1,18 +0,0 @@
1
- interface RequestMoreInfoReturnTypeBase {
2
- [REQUEST_MORE_INFO_KEY]: true;
3
- action: "request_more_info";
4
- }
5
- interface RequestMultipleChoiceReturnType extends RequestMoreInfoReturnTypeBase {
6
- messageToUser: string;
7
- choices: string[];
8
- requestType: "multiple_choice";
9
- }
10
- interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase {
11
- messageToUser: string;
12
- requestType: "otp";
13
- }
14
- declare const REQUEST_MORE_INFO_KEY: unique symbol;
15
- export declare function requestOTP(messageToUser: string): RequestOtpReturnType;
16
- export declare function requestMultipleChoice(messageToUser: string, choices: string[]): RequestMultipleChoiceReturnType;
17
- export type RequestMoreInfoDetails = RequestMultipleChoiceReturnType | RequestOtpReturnType;
18
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.requestMultipleChoice = requestMultipleChoice;
7
- exports.requestOTP = requestOTP;
8
- const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
9
- function requestOTP(messageToUser) {
10
- return {
11
- [REQUEST_MORE_INFO_KEY]: true,
12
- action: "request_more_info",
13
- messageToUser,
14
- requestType: "otp"
15
- };
16
- }
17
- function requestMultipleChoice(messageToUser, choices) {
18
- return {
19
- [REQUEST_MORE_INFO_KEY]: true,
20
- action: "request_more_info",
21
- messageToUser,
22
- requestType: "multiple_choice",
23
- choices
24
- };
25
- }