@intuned/runtime 1.2.0 → 1.3.0
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/CHANGELOG.md +2 -1
- package/dist/commands/intuned-cli/commands/init.command.js +4 -5
- package/dist/commands/intuned-cli/constants/index.d.ts +0 -16
- package/dist/commands/intuned-cli/constants/index.js +1 -36
- package/dist/commands/intuned-cli/helpers/backend.js +1 -1
- package/dist/commands/intuned-cli/types.d.ts +0 -2
- package/dist/commands/intuned-cli/types.js +1 -2
- package/dist/common/runApi/errors.d.ts +9 -2
- package/dist/common/runApi/errors.js +17 -3
- package/dist/common/runApi/index.js +12 -0
- package/package.json +1 -2
- package/.npmrc.d +0 -1
- package/WebTemplate.zip +0 -0
- package/dist/commands/intuned-cli/constants/readme.d.ts +0 -1
- package/dist/commands/intuned-cli/constants/readme.js +0 -150
- package/dist/commands/intuned-cli/controller/init.d.ts +0 -5
- package/dist/commands/intuned-cli/controller/init.js +0 -136
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initCommand = void 0;
|
|
7
|
-
var _init = require("../controller/init");
|
|
8
7
|
var _command = require("./command");
|
|
9
8
|
var _helpers = require("../helpers");
|
|
10
|
-
const initCommand = exports.initCommand = _command.program.command("init").description("Initialize a new Intuned project
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const initCommand = exports.initCommand = _command.program.command("init").description("Deprecated: Initialize a new Intuned project").allowExcessArguments(true).allowUnknownOption(true).action((0, _helpers.withErrorLogging)(async () => {
|
|
10
|
+
throw new _helpers.CLIError("^r^+The init command has been deprecated. Please use^ ^c^/npx create-intuned-project^ ^r^+instead.^:", {
|
|
11
|
+
autoColor: false
|
|
12
|
+
});
|
|
14
13
|
}));
|
|
@@ -2,21 +2,6 @@ export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
|
2
2
|
export declare const ProjectDeploymentStatus: readonly ["completed", "failed", "pending", "not_found"];
|
|
3
3
|
export declare const PROJECT_DEPLOY_TIMEOUT: number;
|
|
4
4
|
export declare const PROJECT_DEPLOY_CHECK_PERIOD: number;
|
|
5
|
-
export declare const userCLIScripts: {
|
|
6
|
-
"dev:local": string;
|
|
7
|
-
dev: string;
|
|
8
|
-
build: string;
|
|
9
|
-
"types-check": string;
|
|
10
|
-
"pre-publish": string;
|
|
11
|
-
start: string;
|
|
12
|
-
"run-api": string;
|
|
13
|
-
"browser-save-state": string;
|
|
14
|
-
"auth-session-check": string;
|
|
15
|
-
"auth-session-create": string;
|
|
16
|
-
"auth-session-refresh": string;
|
|
17
|
-
"auth-session-load": string;
|
|
18
|
-
intuned: string;
|
|
19
|
-
};
|
|
20
5
|
export declare const tsConfigCli: {
|
|
21
6
|
compilerOptions: {
|
|
22
7
|
moduleResolution: string;
|
|
@@ -30,4 +15,3 @@ export declare const tsConfigCli: {
|
|
|
30
15
|
include: string[];
|
|
31
16
|
exclude: string[];
|
|
32
17
|
};
|
|
33
|
-
export * from "./readme";
|
|
@@ -3,48 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
CURRENT_PLAYWRIGHT_VERSION: true,
|
|
8
|
-
ProjectDeploymentStatus: true,
|
|
9
|
-
PROJECT_DEPLOY_TIMEOUT: true,
|
|
10
|
-
PROJECT_DEPLOY_CHECK_PERIOD: true,
|
|
11
|
-
userCLIScripts: true,
|
|
12
|
-
tsConfigCli: true
|
|
13
|
-
};
|
|
14
|
-
exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_CHECK_PERIOD = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
6
|
+
exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_CHECK_PERIOD = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
15
7
|
var _ms = _interopRequireDefault(require("ms"));
|
|
16
|
-
var _readme = require("./readme");
|
|
17
|
-
Object.keys(_readme).forEach(function (key) {
|
|
18
|
-
if (key === "default" || key === "__esModule") return;
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
-
if (key in exports && exports[key] === _readme[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _readme[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
9
|
const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
30
10
|
const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
|
|
31
11
|
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = (0, _ms.default)("10 minutes");
|
|
32
12
|
const PROJECT_DEPLOY_CHECK_PERIOD = exports.PROJECT_DEPLOY_CHECK_PERIOD = (0, _ms.default)("5 seconds");
|
|
33
|
-
const userCLIScripts = exports.userCLIScripts = {
|
|
34
|
-
"dev:local": "intuned-api-run sample playwright -j '{}'",
|
|
35
|
-
dev: "intuned-api-run",
|
|
36
|
-
build: "intuned-build",
|
|
37
|
-
"types-check": "intuned-ts-check",
|
|
38
|
-
"pre-publish": "intuned-ts-check && intuned-build",
|
|
39
|
-
start: "node ./output/bundle_v2.js",
|
|
40
|
-
"run-api": "run-api",
|
|
41
|
-
"browser-save-state": "intuned-browser-save-state",
|
|
42
|
-
"auth-session-check": "intuned-auth-session-check",
|
|
43
|
-
"auth-session-create": "intuned-auth-session-create",
|
|
44
|
-
"auth-session-refresh": "intuned-auth-session-refresh",
|
|
45
|
-
"auth-session-load": "intuned-auth-session-load",
|
|
46
|
-
intuned: "intuned"
|
|
47
|
-
};
|
|
48
13
|
const tsConfigCli = exports.tsConfigCli = {
|
|
49
14
|
compilerOptions: {
|
|
50
15
|
moduleResolution: "NodeNext",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const templateIds: readonly ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
2
|
-
export type TemplateId = typeof templateIds[number];
|
|
3
1
|
export interface FileSystemTree {
|
|
4
2
|
[name: string]: DirectoryNode | FileNode;
|
|
5
3
|
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
6
|
+
exports.CHECK_FAILED_ERROR_MESSAGE = exports.ApiAuthSessionBehavior = void 0;
|
|
8
7
|
let ApiAuthSessionBehavior = exports.ApiAuthSessionBehavior = function (ApiAuthSessionBehavior) {
|
|
9
8
|
ApiAuthSessionBehavior["PERFORM_CHECK_AND_REFRESH"] = "PERFORM_CHECK_AND_REFRESH";
|
|
10
9
|
ApiAuthSessionBehavior["SKIP_CHECK_AND_REFRESH"] = "SKIP_CHECK_AND_REFRESH";
|
|
@@ -9,7 +9,8 @@ export declare const authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
|
9
9
|
export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
10
10
|
export declare const automationError = "AutomationError";
|
|
11
11
|
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const resultTooBigErrorCode = "ResultTooBigError";
|
|
13
|
+
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError", "ResultTooBigError"];
|
|
13
14
|
export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
|
|
14
15
|
export declare abstract class RunAutomationError<T = any> {
|
|
15
16
|
code: RunAutomationErrorCode;
|
|
@@ -19,7 +20,7 @@ export declare abstract class RunAutomationError<T = any> {
|
|
|
19
20
|
cause?: RunAutomationError;
|
|
20
21
|
details?: T;
|
|
21
22
|
get json(): {
|
|
22
|
-
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError";
|
|
23
|
+
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError" | "ResultTooBigError";
|
|
23
24
|
details: T | undefined;
|
|
24
25
|
cause: any;
|
|
25
26
|
};
|
|
@@ -63,3 +64,9 @@ export declare class AutomationError extends RunAutomationError<{
|
|
|
63
64
|
export declare class InternalInvalidInputError extends RunAutomationError {
|
|
64
65
|
constructor(message: string, details?: any);
|
|
65
66
|
}
|
|
67
|
+
export declare class ResultTooBigError extends RunAutomationError<{
|
|
68
|
+
sizeInBytes: number;
|
|
69
|
+
maxSizeInBytes: number;
|
|
70
|
+
}> {
|
|
71
|
+
constructor(sizeInBytes: number, maxSizeInBytes: number);
|
|
72
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
6
|
+
exports.runAutomationErrorCodes = exports.resultTooBigErrorCode = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.ResultTooBigError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
7
|
var _runtime = require("../../runtime");
|
|
8
8
|
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
9
9
|
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,7 +18,8 @@ const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFa
|
|
|
18
18
|
const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
19
19
|
const automationError = exports.automationError = "AutomationError";
|
|
20
20
|
const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
21
|
-
const
|
|
21
|
+
const resultTooBigErrorCode = exports.resultTooBigErrorCode = "ResultTooBigError";
|
|
22
|
+
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode, resultTooBigErrorCode];
|
|
22
23
|
class RunAutomationError {
|
|
23
24
|
wrapped = false;
|
|
24
25
|
get json() {
|
|
@@ -152,4 +153,17 @@ class InternalInvalidInputError extends RunAutomationError {
|
|
|
152
153
|
this.details = details;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
|
-
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
156
|
+
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
157
|
+
class ResultTooBigError extends RunAutomationError {
|
|
158
|
+
constructor(sizeInBytes, maxSizeInBytes) {
|
|
159
|
+
super();
|
|
160
|
+
this.code = resultTooBigErrorCode;
|
|
161
|
+
this.statusCode = 413;
|
|
162
|
+
this.message = `Automation result is too big. Size: ${Math.round(sizeInBytes / 1024 / 1024 * 100) / 100}MB, Max allowed: ${Math.round(maxSizeInBytes / 1024 / 1024 * 100) / 100}MB`;
|
|
163
|
+
this.details = {
|
|
164
|
+
sizeInBytes,
|
|
165
|
+
maxSizeInBytes
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.ResultTooBigError = ResultTooBigError;
|
|
@@ -47,6 +47,13 @@ var _formatZodError = require("../formatZodError");
|
|
|
47
47
|
var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
48
48
|
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); }
|
|
49
49
|
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; }
|
|
50
|
+
function getObjectSizeInBytes(obj) {
|
|
51
|
+
try {
|
|
52
|
+
return new TextEncoder().encode(JSON.stringify(obj)).length;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return new TextEncoder().encode(String(obj)).length;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
50
57
|
async function* runApiGenerator({
|
|
51
58
|
retrieveSession = false,
|
|
52
59
|
abortSignal,
|
|
@@ -184,6 +191,11 @@ async function* runApiGenerator({
|
|
|
184
191
|
} else {
|
|
185
192
|
result = await importedModule.func(...automationFunctionParameters);
|
|
186
193
|
}
|
|
194
|
+
const MAX_RESULT_SIZE_BYTES = 2 * 1024 * 1024;
|
|
195
|
+
const resultSizeInBytes = getObjectSizeInBytes(result);
|
|
196
|
+
if (resultSizeInBytes > MAX_RESULT_SIZE_BYTES) {
|
|
197
|
+
return (0, _neverthrow.err)(new _errors.ResultTooBigError(resultSizeInBytes, MAX_RESULT_SIZE_BYTES));
|
|
198
|
+
}
|
|
187
199
|
return (0, _neverthrow.ok)({
|
|
188
200
|
result,
|
|
189
201
|
extendedPayloads: (0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -118,7 +118,6 @@
|
|
|
118
118
|
"eslint-plugin-deprecation": "^1.3.3",
|
|
119
119
|
"eslint-plugin-prettier": "^4.2.1",
|
|
120
120
|
"msw": "^2.1.2",
|
|
121
|
-
"playwright": "1.44.1",
|
|
122
121
|
"typedoc": "^0.25.13",
|
|
123
122
|
"typedoc-plugin-frontmatter": "^1.0.0",
|
|
124
123
|
"typedoc-plugin-markdown": "^4.0.2",
|
package/.npmrc.d
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//registry.npmjs.org/:_authToken=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
|
package/WebTemplate.zip
DELETED
|
Binary file
|
|
@@ -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
|
-
}
|