@intuned/runtime 1.0.5 → 1.1.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/InterfaceTemplate/utils.ts +53 -31
- package/LICENSE +43 -0
- package/bin/check-auth-session +3 -0
- package/bin/cli-build +3 -0
- package/bin/create-auth-session +3 -0
- package/bin/deploy +3 -0
- package/bin/init +3 -0
- package/bin/run-api +3 -0
- package/dist/commands/cli-auth-sessions/check.d.ts +2 -0
- package/dist/commands/cli-auth-sessions/check.js +40 -0
- package/dist/commands/cli-auth-sessions/create.d.ts +2 -0
- package/dist/commands/cli-auth-sessions/create.js +53 -0
- package/dist/commands/cli-auth-sessions/utils.d.ts +28 -0
- package/dist/commands/cli-auth-sessions/utils.js +285 -0
- package/dist/commands/cli-build/cli-build.d.ts +2 -0
- package/dist/commands/cli-build/cli-build.js +20 -0
- package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/dist/commands/common/projectExclusions.js +8 -0
- package/dist/commands/common/tsNodeImport.d.ts +2 -1
- package/dist/commands/common/tsNodeImport.js +19 -5
- package/dist/commands/deploy/deploy.d.ts +2 -0
- package/dist/commands/deploy/deploy.js +47 -0
- package/dist/commands/deploy/utils.d.ts +16 -0
- package/dist/commands/deploy/utils.js +408 -0
- package/dist/commands/init/init.d.ts +2 -0
- package/dist/commands/init/init.js +22 -0
- package/dist/commands/init/utils.d.ts +11 -0
- package/dist/commands/init/utils.js +181 -0
- package/dist/commands/interface/run.js +30 -3
- package/dist/commands/run-api-cli/run-api.d.ts +2 -0
- package/dist/commands/run-api-cli/run-api.js +57 -0
- package/dist/commands/run-api-cli/utils.d.ts +9 -0
- package/dist/commands/run-api-cli/utils.js +144 -0
- package/dist/common/asyncLocalStorage/index.d.ts +1 -1
- package/dist/common/asyncLocalStorage/index.js +2 -2
- package/dist/common/cli/cliReadme.d.ts +1 -0
- package/dist/common/cli/cliReadme.js +92 -0
- package/dist/common/cli/constants.d.ts +33 -0
- package/dist/common/cli/constants.js +39 -0
- package/dist/common/cli/types.d.ts +74 -0
- package/dist/common/cli/types.js +13 -0
- package/dist/common/cli/utils.d.ts +6 -0
- package/dist/common/cli/utils.js +35 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +3 -2
- package/dist/common/runApi/index.d.ts +1 -0
- package/dist/common/runApi/index.js +9 -2
- package/dist/common/runApi/types.d.ts +7 -1
- package/package.json +15 -4
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare const templateIds: string[];
|
|
2
|
+
export type TemplateId = (typeof templateIds)[number];
|
|
3
|
+
/**
|
|
4
|
+
* A simple, tree-like structure to describe the contents of a folder to be mounted.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* const tree = {
|
|
9
|
+
* myproject: {
|
|
10
|
+
* directory: {
|
|
11
|
+
* 'foo.js': {
|
|
12
|
+
* file: {
|
|
13
|
+
* contents: 'const x = 1;',
|
|
14
|
+
* },
|
|
15
|
+
* },
|
|
16
|
+
* .envrc: {
|
|
17
|
+
* file: {
|
|
18
|
+
* contents: 'ENVIRONMENT=staging'
|
|
19
|
+
* }
|
|
20
|
+
* },
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* emptyFolder: {
|
|
24
|
+
* directory: {}
|
|
25
|
+
* },
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface FileSystemTree {
|
|
30
|
+
[name: string]: DirectoryNode | FileNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents a directory, see {@link FileSystemTree}.
|
|
34
|
+
*/
|
|
35
|
+
export interface DirectoryNode {
|
|
36
|
+
directory: FileSystemTree;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Represents a file, see {@link FileSystemTree}.
|
|
40
|
+
*/
|
|
41
|
+
export interface FileNode {
|
|
42
|
+
file: {
|
|
43
|
+
/**
|
|
44
|
+
* The contents of the file, either as a UTF-8 string or as raw binary.
|
|
45
|
+
*/
|
|
46
|
+
contents: string | Uint8Array;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface AuthCredentials {
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
apiKey: string;
|
|
52
|
+
}
|
|
53
|
+
export declare enum ApiAuthSessionBehavior {
|
|
54
|
+
PERFORM_CHECK_AND_REFRESH = "PERFORM_CHECK_AND_REFRESH",
|
|
55
|
+
SKIP_CHECK_AND_REFRESH = "SKIP_CHECK_AND_REFRESH"
|
|
56
|
+
}
|
|
57
|
+
export declare const CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
|
|
58
|
+
export type AuthSessionType = "API" | "MANUAL";
|
|
59
|
+
export type AuthSessionMetadata = {
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
authSessionId: string;
|
|
63
|
+
authSessionType: AuthSessionType;
|
|
64
|
+
authSessionInput?: Record<string, any>;
|
|
65
|
+
recorderStartUrl?: string;
|
|
66
|
+
recorderEndUrl?: string;
|
|
67
|
+
};
|
|
68
|
+
export interface SessionStorageState {
|
|
69
|
+
origin: string;
|
|
70
|
+
sessionStorage: {
|
|
71
|
+
name: string;
|
|
72
|
+
value: string;
|
|
73
|
+
}[];
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.templateIds = exports.CHECK_FAILED_ERROR_MESSAGE = exports.ApiAuthSessionBehavior = void 0;
|
|
7
|
+
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
8
|
+
let ApiAuthSessionBehavior = exports.ApiAuthSessionBehavior = function (ApiAuthSessionBehavior) {
|
|
9
|
+
ApiAuthSessionBehavior["PERFORM_CHECK_AND_REFRESH"] = "PERFORM_CHECK_AND_REFRESH";
|
|
10
|
+
ApiAuthSessionBehavior["SKIP_CHECK_AND_REFRESH"] = "SKIP_CHECK_AND_REFRESH";
|
|
11
|
+
return ApiAuthSessionBehavior;
|
|
12
|
+
}({});
|
|
13
|
+
const CHECK_FAILED_ERROR_MESSAGE = exports.CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAuthCredentials = getAuthCredentials;
|
|
7
|
+
exports.getBaseUrl = getBaseUrl;
|
|
8
|
+
exports.getSettingIntunedJSON = getSettingIntunedJSON;
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
async function getAuthCredentials(options) {
|
|
15
|
+
const workspaceId = options.workspaceId || (await getSettingIntunedJSON("workspaceId"));
|
|
16
|
+
const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
|
|
17
|
+
if (!workspaceId || !apiKey) {
|
|
18
|
+
throw new Error("Authentication details are required. Please provide them via command line options(api key, workspace id), intuned.json(workspace id) or environment variables(api key).");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
workspaceId,
|
|
22
|
+
apiKey
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getBaseUrl() {
|
|
26
|
+
return process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`;
|
|
27
|
+
}
|
|
28
|
+
async function getSettingIntunedJSON(key) {
|
|
29
|
+
const intunedJsonPath = _path.default.join(process.cwd(), "Intuned.json");
|
|
30
|
+
const intunedJson = await fs.readJSON(intunedJsonPath);
|
|
31
|
+
if (intunedJson && intunedJson[key]) {
|
|
32
|
+
return intunedJson[key];
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
package/dist/common/constants.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
7
|
-
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
6
|
+
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
7
|
+
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
8
|
+
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
@@ -10,3 +10,4 @@ export declare function runApiGenerator<ResultType = any, _YieldType = any, _Nex
|
|
|
10
10
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters): AsyncGenerator<_YieldType, RunApiResult<ResultType>, _NextType>;
|
|
11
11
|
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
12
12
|
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, checkFn: (..._: any) => Promise<boolean>, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
13
|
+
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
@@ -242,7 +242,14 @@ async function checkAuthSessionWithRetries(page, context, checkFn, retries = 3)
|
|
|
242
242
|
}
|
|
243
243
|
async function importUsingImportFunction(path, importFunction) {
|
|
244
244
|
try {
|
|
245
|
-
const
|
|
245
|
+
const importedResult = await importFunction(path);
|
|
246
|
+
if (importedResult.isErr()) {
|
|
247
|
+
if (importedResult.error.type === "not_found") {
|
|
248
|
+
return (0, _neverthrow.err)(new _errors.ApiNotFoundError(path));
|
|
249
|
+
}
|
|
250
|
+
return (0, _neverthrow.err)(new _errors.AutomationError(importedResult.error.error));
|
|
251
|
+
}
|
|
252
|
+
const imported = importedResult.value;
|
|
246
253
|
if (!imported || !imported.default || !imported.default.constructor) {
|
|
247
254
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default export"));
|
|
248
255
|
}
|
|
@@ -260,6 +267,6 @@ async function importUsingImportFunction(path, importFunction) {
|
|
|
260
267
|
}
|
|
261
268
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default async function/generator export"));
|
|
262
269
|
} catch (error) {
|
|
263
|
-
return (0, _neverthrow.err)(new _errors.
|
|
270
|
+
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
264
271
|
}
|
|
265
272
|
}
|
|
@@ -688,9 +688,15 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
688
688
|
}>;
|
|
689
689
|
export type RunApiSession = z.infer<typeof runApiSessionSchema>;
|
|
690
690
|
export type RunApiParameters = z.input<typeof runApiParametersSchema>;
|
|
691
|
+
export type ImportFunctionError = {
|
|
692
|
+
type: "not_found";
|
|
693
|
+
} | {
|
|
694
|
+
type: "other";
|
|
695
|
+
error: any;
|
|
696
|
+
};
|
|
691
697
|
export type ExtendedRunApiParameters = RunApiParameters & {
|
|
692
698
|
abortSignal?: AbortSignal;
|
|
693
|
-
importFunction
|
|
699
|
+
importFunction: (name: string) => Promise<Result<any, ImportFunctionError>>;
|
|
694
700
|
};
|
|
695
701
|
export type RunApiResultOk<R = any> = {
|
|
696
702
|
result: R;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"./dist/common/asyncLocalStorage": "./dist/common/asyncLocalStorage/index.js",
|
|
14
14
|
"./dist/common/cleanEnvironmentVariables": "./dist/common/cleanEnvironmentVariables.js",
|
|
15
15
|
"./dist/common/constants": "./dist/common/constants.js",
|
|
16
|
-
"./dist/commands/interface/run": "./dist/commands/interface/run.js"
|
|
16
|
+
"./dist/commands/interface/run": "./dist/commands/interface/run.js",
|
|
17
|
+
"./dist/commands/intuned-run/intuned-run": "./dist/commands/intuned-run/intuned-run.js"
|
|
17
18
|
},
|
|
18
19
|
"types": "./dist/index.d.ts",
|
|
19
20
|
"author": "Intuned Team",
|
|
20
|
-
"license": "
|
|
21
|
+
"license": "Elastic-2.0",
|
|
21
22
|
"scripts": {
|
|
22
23
|
"intuned-api-run": "vite-node ./src/commands/api/run.ts",
|
|
23
24
|
"intuned-browser-save-state": "vite-node ./src/commands/browser/save-state.ts",
|
|
@@ -48,7 +49,13 @@
|
|
|
48
49
|
"intuned-build": "./bin/intuned-build",
|
|
49
50
|
"intuned-browser-start": "./bin/intuned-browser-start",
|
|
50
51
|
"intuned-browser-save-state": "./bin/intuned-browser-save-state",
|
|
51
|
-
"intuned-ts-check": "./bin/intuned-ts-check"
|
|
52
|
+
"intuned-ts-check": "./bin/intuned-ts-check",
|
|
53
|
+
"init": "./bin/init",
|
|
54
|
+
"run-api": "./bin/run-api",
|
|
55
|
+
"deploy": "./bin/deploy",
|
|
56
|
+
"cli-build": "./bin/cli-build",
|
|
57
|
+
"create-auth-session": "./bin/create-auth-session",
|
|
58
|
+
"check-auth-session": "./bin/check-auth-session"
|
|
52
59
|
},
|
|
53
60
|
"dependencies": {
|
|
54
61
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
@@ -65,6 +72,7 @@
|
|
|
65
72
|
"applicationinsights": "^2.9.2",
|
|
66
73
|
"async-retry": "^1.3.3",
|
|
67
74
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
75
|
+
"boxen": "8.0.1",
|
|
68
76
|
"chalk": "^4.1.2",
|
|
69
77
|
"commander": "^11.0.0",
|
|
70
78
|
"cross-fetch": "^4.0.0",
|
|
@@ -75,9 +83,11 @@
|
|
|
75
83
|
"fs-extra": "^11.3.0",
|
|
76
84
|
"https-proxy-agent": "^7.0.5",
|
|
77
85
|
"image-size": "^1.1.1",
|
|
86
|
+
"inquirer": "12.6.0",
|
|
78
87
|
"jsonwebtoken": "^9.0.2",
|
|
79
88
|
"lodash": "^4.17.21",
|
|
80
89
|
"milliparsec": "^2.3.0",
|
|
90
|
+
"minimatch": "10.0.1",
|
|
81
91
|
"ms": "^2.1.3",
|
|
82
92
|
"nanoid": "3",
|
|
83
93
|
"neverthrow": "^6.1.0",
|
|
@@ -93,6 +103,7 @@
|
|
|
93
103
|
"ts-node": "^10.9.1",
|
|
94
104
|
"tslib": "^2.6.0",
|
|
95
105
|
"typescript": "^5.1.6",
|
|
106
|
+
"uuid": "11.1.0",
|
|
96
107
|
"wait-on": "^7.2.0",
|
|
97
108
|
"zod": "^3.21.4",
|
|
98
109
|
"zod-validation-error": "^3.0.3"
|