@intuned/runtime-dev 1.0.6-playwright-1.46.0 → 1.1.1-nt.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/WebTemplate.zip +0 -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/common/utils/unixSocket.d.ts +1 -0
- 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 +2 -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 +9 -3
- package/package.json +16 -5
|
@@ -15,9 +15,10 @@ var _unixSocket = require("../common/utils/unixSocket");
|
|
|
15
15
|
var _promises = require("timers/promises");
|
|
16
16
|
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
17
17
|
var _formatZodError = require("../../common/formatZodError");
|
|
18
|
+
var _neverthrow = require("neverthrow");
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
20
|
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); }
|
|
19
21
|
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; }
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
22
|
const startRunApiSchema = _zod.default.object({
|
|
22
23
|
type: _zod.default.literal("start"),
|
|
23
24
|
parameters: _runApi.runApiParametersSchema.extend({
|
|
@@ -47,7 +48,11 @@ const tokenUpdateSchema = _zod.default.object({
|
|
|
47
48
|
functionsToken: _zod.default.string()
|
|
48
49
|
})
|
|
49
50
|
});
|
|
50
|
-
const
|
|
51
|
+
const pingSchema = _zod.default.object({
|
|
52
|
+
type: _zod.default.literal("ping"),
|
|
53
|
+
parameters: _zod.default.object({}).optional()
|
|
54
|
+
});
|
|
55
|
+
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema, pingSchema]);
|
|
51
56
|
_dotenv.default.config({
|
|
52
57
|
path: `.env`
|
|
53
58
|
});
|
|
@@ -105,7 +110,7 @@ function runAutomationCLI(importFunction) {
|
|
|
105
110
|
generator = (0, _runApi.runApiGenerator)({
|
|
106
111
|
...message.parameters,
|
|
107
112
|
abortSignal: abortController.signal,
|
|
108
|
-
importFunction
|
|
113
|
+
importFunction: importFunction ?? _defaultImport
|
|
109
114
|
});
|
|
110
115
|
context = {
|
|
111
116
|
extendedPayloads: [],
|
|
@@ -180,6 +185,12 @@ function runAutomationCLI(importFunction) {
|
|
|
180
185
|
});
|
|
181
186
|
break;
|
|
182
187
|
}
|
|
188
|
+
if (message.type === "ping") {
|
|
189
|
+
jsonUnixSocket.sendJSON({
|
|
190
|
+
type: "pong"
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
183
194
|
await handleMessage(message);
|
|
184
195
|
receiveMessagesPromise = receiveMessages();
|
|
185
196
|
continue;
|
|
@@ -209,6 +220,22 @@ function getProxyUrlFromRunOptions(runOptions) {
|
|
|
209
220
|
url.password = proxy.password;
|
|
210
221
|
return url.toString();
|
|
211
222
|
}
|
|
223
|
+
const _defaultImport = async path => {
|
|
224
|
+
try {
|
|
225
|
+
const imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`../../../${path}.ts`);
|
|
226
|
+
return (0, _neverthrow.ok)(imported);
|
|
227
|
+
} catch (e) {
|
|
228
|
+
if ("code" in e && e.code === "MODULE_NOT_FOUND") {
|
|
229
|
+
return (0, _neverthrow.err)({
|
|
230
|
+
type: "not_found"
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return (0, _neverthrow.err)({
|
|
234
|
+
type: "other",
|
|
235
|
+
error: e
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
212
239
|
if (require.main === module) {
|
|
213
240
|
runAutomationCLI();
|
|
214
241
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
+
var _nanoid = require("nanoid");
|
|
7
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
var _enums = require("../../runtime/enums");
|
|
10
|
+
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
11
|
+
var _utils2 = require("../cli-auth-sessions/utils");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
_dotenv.default.config({
|
|
14
|
+
path: `.env`
|
|
15
|
+
});
|
|
16
|
+
_commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-i, --parameters-file <file>", "JSON file containing API parameters").option("-a, --auth-session <session>", "Name of the auth session instance to use").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
|
|
17
|
+
try {
|
|
18
|
+
if (!apiName) {
|
|
19
|
+
throw new Error("API name is required, please provide it");
|
|
20
|
+
}
|
|
21
|
+
const _isAuthEnabled = await (0, _utils2.isAuthEnabled)();
|
|
22
|
+
if (!_isAuthEnabled && options.authSession) {
|
|
23
|
+
throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
|
|
24
|
+
}
|
|
25
|
+
if (_isAuthEnabled && !options.authSession) {
|
|
26
|
+
throw new Error("Auth session is enabled but no auth session provided, please provide it");
|
|
27
|
+
}
|
|
28
|
+
const inputData = await (0, _utils.loadParameters)(options.parametersFile);
|
|
29
|
+
const runId = (0, _nanoid.nanoid)();
|
|
30
|
+
const {
|
|
31
|
+
result,
|
|
32
|
+
payloadToAppend
|
|
33
|
+
} = await (0, _asyncLocalStorage.runWithContext)({
|
|
34
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
35
|
+
extendedPayloads: [],
|
|
36
|
+
runId
|
|
37
|
+
}, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
|
|
38
|
+
authSession: options.authSession
|
|
39
|
+
}));
|
|
40
|
+
if (!result) {
|
|
41
|
+
console.log(_chalk.default.yellow("No result returned from the API"));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!options.storeResults) {
|
|
45
|
+
console.log(_chalk.default.green(`✓ API executed successfully`));
|
|
46
|
+
console.log(_chalk.default.green("Result:"));
|
|
47
|
+
console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await (0, _utils.writeResultToFile)(runId, result, payloadToAppend);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(_chalk.default.red(`\nError: ${error.message}`));
|
|
53
|
+
} finally {
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
_commander.program.parse(process.argv);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Payload } from "../../runtime/export";
|
|
2
|
+
export declare function loadParameters(parametersFile: string): Promise<object | null>;
|
|
3
|
+
export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
|
|
4
|
+
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options?: {
|
|
5
|
+
authSession?: string;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
result: any;
|
|
8
|
+
payloadToAppend: Payload[] | undefined;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadParameters = loadParameters;
|
|
7
|
+
exports.runApiViaCLI = runApiViaCLI;
|
|
8
|
+
exports.writeResultToFile = writeResultToFile;
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
+
var _Logger = require("../../common/Logger");
|
|
12
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
|
+
var _runApi = require("../../common/runApi");
|
|
14
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
15
|
+
var _utils = require("../cli-auth-sessions/utils");
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
async function loadParameters(parametersFile) {
|
|
20
|
+
if (!parametersFile) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const filePath = _path.default.join(process.cwd(), parametersFile);
|
|
25
|
+
await fs.access(filePath);
|
|
26
|
+
let inputData = null;
|
|
27
|
+
if (parametersFile) {
|
|
28
|
+
inputData = await fs.readJSON(filePath);
|
|
29
|
+
} else {
|
|
30
|
+
inputData = {};
|
|
31
|
+
}
|
|
32
|
+
return inputData;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error.code === "ENOENT") {
|
|
35
|
+
throw new Error(`Parameters file not found: ${parametersFile}`);
|
|
36
|
+
} else if (error instanceof SyntaxError) {
|
|
37
|
+
throw new Error(`Invalid JSON in parameters file: ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Error reading parameters file: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function writeResultToFile(runId, result, payloadToAppend) {
|
|
43
|
+
const outputDir = _path.default.join(process.cwd(), "output", runId);
|
|
44
|
+
const resultsPath = _path.default.join(outputDir, "results.json");
|
|
45
|
+
const extendedPayloadsPath = _path.default.join(outputDir, "extendedPayloads.json");
|
|
46
|
+
await fs.ensureDir(outputDir);
|
|
47
|
+
try {
|
|
48
|
+
await fs.writeJSON(resultsPath, result, {
|
|
49
|
+
spaces: 2
|
|
50
|
+
});
|
|
51
|
+
if (payloadToAppend && payloadToAppend.length > 0) {
|
|
52
|
+
await fs.writeJSON(extendedPayloadsPath, payloadToAppend, {
|
|
53
|
+
spaces: 2
|
|
54
|
+
});
|
|
55
|
+
_Logger.logger.info(_chalk.default.underline.green.white(`Payloads to append saved into (${extendedPayloadsPath})`));
|
|
56
|
+
}
|
|
57
|
+
console.log(_chalk.default.underline.green.white(`✓ API executed successfully. Results stored in ${outputDir}`));
|
|
58
|
+
console.log(_chalk.default.blue(`Run ID: ${runId}`));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
_Logger.logger.error(`Failed to write result to file: ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function runApiViaCLI(apiName, inputData, options) {
|
|
64
|
+
let authSessionPathToUse = null;
|
|
65
|
+
if (options !== null && options !== void 0 && options.authSession) {
|
|
66
|
+
const {
|
|
67
|
+
authSessionInstanceStoragePath
|
|
68
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession, true);
|
|
69
|
+
authSessionPathToUse = authSessionInstanceStoragePath;
|
|
70
|
+
}
|
|
71
|
+
if (authSessionPathToUse) {
|
|
72
|
+
const checkApiExists = await (0, _utils.ensureAuthApi)("check");
|
|
73
|
+
if (!checkApiExists) {
|
|
74
|
+
throw new Error("Auth session check API not implemented, please create it in the auth sessions specified directory");
|
|
75
|
+
}
|
|
76
|
+
const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
|
|
77
|
+
if (!checkResult) {
|
|
78
|
+
console.log(_chalk.default.yellow("Auth session check failed, trying to refresh it..."));
|
|
79
|
+
const createApiExists = await (0, _utils.ensureAuthApi)("create");
|
|
80
|
+
if (!createApiExists) {
|
|
81
|
+
throw new Error("Auth session creation API not implemented, please create it in the auth sessions specified directory");
|
|
82
|
+
}
|
|
83
|
+
const {
|
|
84
|
+
metadata
|
|
85
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession);
|
|
86
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.authSessionType) === "MANUAL") {
|
|
87
|
+
throw new Error("Expired Auth session is recorder-based, please provide a new one or refresh it manually");
|
|
88
|
+
}
|
|
89
|
+
const authSessionInput = (metadata === null || metadata === void 0 ? void 0 : metadata.authSessionInput) ?? {};
|
|
90
|
+
try {
|
|
91
|
+
const refresehAuthSessionInstance = await (0, _utils.runCreateApiViaCLI)(authSessionInput);
|
|
92
|
+
if (!refresehAuthSessionInstance) {
|
|
93
|
+
throw new Error("Failed to refresh auth session");
|
|
94
|
+
}
|
|
95
|
+
await (0, _utils.storeAuthSessionInstance)(refresehAuthSessionInstance, options === null || options === void 0 ? void 0 : options.authSession, authSessionInput);
|
|
96
|
+
const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
|
|
97
|
+
if (!checkResult) {
|
|
98
|
+
throw new Error("Failed to refresh auth session");
|
|
99
|
+
}
|
|
100
|
+
console.log(_chalk.default.green("✓ Auth session refreshed successfully on this run"));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw new Error(`Failed to refresh auth session: ${error.message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
107
|
+
automationFunction: {
|
|
108
|
+
name: `api/${apiName}`,
|
|
109
|
+
params: inputData
|
|
110
|
+
},
|
|
111
|
+
runOptions: {
|
|
112
|
+
headless: false,
|
|
113
|
+
environment: "standalone"
|
|
114
|
+
},
|
|
115
|
+
auth: authSessionPathToUse ? {
|
|
116
|
+
session: {
|
|
117
|
+
type: "file",
|
|
118
|
+
path: authSessionPathToUse
|
|
119
|
+
},
|
|
120
|
+
runCheck: false
|
|
121
|
+
} : undefined,
|
|
122
|
+
importFunction: _tsNodeImport.tsNodeImport
|
|
123
|
+
});
|
|
124
|
+
if (runApiResult.isErr()) {
|
|
125
|
+
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
126
|
+
throw runApiResult.error.error;
|
|
127
|
+
}
|
|
128
|
+
console.error(runApiResult.error);
|
|
129
|
+
throw new Error("An error occurred while running the API");
|
|
130
|
+
}
|
|
131
|
+
const {
|
|
132
|
+
result,
|
|
133
|
+
extendedPayloads: payloadToAppend
|
|
134
|
+
} = runApiResult.value;
|
|
135
|
+
const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
|
|
136
|
+
if (hasPayloadToAppend) {
|
|
137
|
+
_Logger.logger.info("payload to append:", payloadToAppend);
|
|
138
|
+
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
result,
|
|
142
|
+
payloadToAppend
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import { Payload, RunInfo } from "../../runtime/export";
|
|
3
4
|
export declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
|
|
4
5
|
export declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.asyncLocalStorage = void 0;
|
|
7
7
|
exports.getExecutionContext = getExecutionContext;
|
|
8
8
|
exports.runWithContext = runWithContext;
|
|
9
|
-
var
|
|
10
|
-
const asyncLocalStorage = exports.asyncLocalStorage = new
|
|
9
|
+
var _nodeAsync_hooks = require("node:async_hooks");
|
|
10
|
+
const asyncLocalStorage = exports.asyncLocalStorage = new _nodeAsync_hooks.AsyncLocalStorage();
|
|
11
11
|
function runWithContext(contextData, callback, ...args) {
|
|
12
12
|
return asyncLocalStorage.run(contextData, callback, ...args);
|
|
13
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cliReadme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a variaty of commands to develop your Intuned projects locally\n\n## Development Commands\n\n### Initialize a Project\n`npx -p @intuned/runtime init`\n\n### Run an API\n`yarn run-api <api-name>`\nor\n`npm run run-api <api-name>`\n\nOptions:\n- `-i, --parameters-file file-path`: JSON file containing API parameters\n- `-s, --store-results`: Store the results in `./output/[runId]/results.json` and `./output/[runId]/extendedPayloads.json`\n- `-a, --auth-session <session>`: Name of the auth session instance to use if project is auth-enabled\n\n### Build a Project\n`yarn cli-build`\n\n### Deploy a Project\n`yarn deploy <project-name>`\nor\n`npm run deploy <project-name>`\n\n- `project-name`: Optional name that overrides the one in intuned.json\n- Options:\n - `--workspace-id`: Overrides the workspace ID in intuned.json\n - `--api-key`: Overrides the API key from environment variables\n\n\n### Create an auth session\n`yarn create-auth-session <auth-session-name>`\nor\n`npm create-auth-session <auth-session-name>`\n\n- `auth-session-name`: Optional name/id of the auth session instance to use, if not provided, a name will be generated with the current timestamp\n- Options:\n - `--input`: Auth session input parameters file path\n\n### Check an auth session\n`yarn check-auth-session <auth-session-name>`\nor\n`npm check-auth-session <auth-session-name>`\n- `auth-session-name`: Name/id of the auth session instance to check, required\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 deploy my-project-name` or `npm run 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 APIs\n- `./parameters`: Folder for API parameters injection\n- `./output`: Folder containing generated output files\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- WARNING: \u26A0\uFE0F Changes to TS Config may break some Intuned functionalities\n";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cliReadme = void 0;
|
|
7
|
+
const cliReadme = exports.cliReadme = `# Intuned CLI
|
|
8
|
+
## Introduction
|
|
9
|
+
The Intuned CLI exposes a variaty of commands to develop your Intuned projects locally
|
|
10
|
+
|
|
11
|
+
## Development Commands
|
|
12
|
+
|
|
13
|
+
### Initialize a Project
|
|
14
|
+
\`npx -p @intuned/runtime init\`
|
|
15
|
+
|
|
16
|
+
### Run an API
|
|
17
|
+
\`yarn run-api <api-name>\`
|
|
18
|
+
or
|
|
19
|
+
\`npm run run-api <api-name>\`
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
- \`-i, --parameters-file file-path\`: JSON file containing API parameters
|
|
23
|
+
- \`-s, --store-results\`: Store the results in \`./output/[runId]/results.json\` and \`./output/[runId]/extendedPayloads.json\`
|
|
24
|
+
- \`-a, --auth-session <session>\`: Name of the auth session instance to use if project is auth-enabled
|
|
25
|
+
|
|
26
|
+
### Build a Project
|
|
27
|
+
\`yarn cli-build\`
|
|
28
|
+
|
|
29
|
+
### Deploy a Project
|
|
30
|
+
\`yarn deploy <project-name>\`
|
|
31
|
+
or
|
|
32
|
+
\`npm run deploy <project-name>\`
|
|
33
|
+
|
|
34
|
+
- \`project-name\`: Optional name that overrides the one in intuned.json
|
|
35
|
+
- Options:
|
|
36
|
+
- \`--workspace-id\`: Overrides the workspace ID in intuned.json
|
|
37
|
+
- \`--api-key\`: Overrides the API key from environment variables
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Create an auth session
|
|
41
|
+
\`yarn create-auth-session <auth-session-name>\`
|
|
42
|
+
or
|
|
43
|
+
\`npm create-auth-session <auth-session-name>\`
|
|
44
|
+
|
|
45
|
+
- \`auth-session-name\`: Optional name/id of the auth session instance to use, if not provided, a name will be generated with the current timestamp
|
|
46
|
+
- Options:
|
|
47
|
+
- \`--input\`: Auth session input parameters file path
|
|
48
|
+
|
|
49
|
+
### Check an auth session
|
|
50
|
+
\`yarn check-auth-session <auth-session-name>\`
|
|
51
|
+
or
|
|
52
|
+
\`npm check-auth-session <auth-session-name>\`
|
|
53
|
+
- \`auth-session-name\`: Name/id of the auth session instance to check, required
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
### Environment Variables and Settings
|
|
58
|
+
- \`workspaceId\`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))
|
|
59
|
+
- Set in \`intuned.json\` file under the \`workspaceId\` property
|
|
60
|
+
- Or provide via CLI with \`--workspace-id\` flag during deployment
|
|
61
|
+
|
|
62
|
+
- \`projectName\`: The name of your Intuned project
|
|
63
|
+
- Set in \`intuned.json\` file under the \`projectName\` property
|
|
64
|
+
- Or override via command line when deploying with \`yarn deploy my-project-name\` or \`npm run deploy my-project-name\`
|
|
65
|
+
|
|
66
|
+
- \`INTUNED_API_KEY\`: Your Intuned API key
|
|
67
|
+
- Set as an environment variable: \`export INTUNED_API_KEY=your_api_key_here\`
|
|
68
|
+
- Or include in your .env file for development
|
|
69
|
+
- Or provide via CLI with \`--api-key\` flag during deployment
|
|
70
|
+
|
|
71
|
+
## Project Structure
|
|
72
|
+
|
|
73
|
+
### Generated Artifacts
|
|
74
|
+
- \`./intuned.json\`: Project configuration file
|
|
75
|
+
- \`./api\`: Folder containing API implementation files
|
|
76
|
+
- \`./auth-sessions\`: Folder containing auth APIs
|
|
77
|
+
- \`./parameters\`: Folder for API parameters injection
|
|
78
|
+
- \`./output\`: Folder containing generated output files
|
|
79
|
+
- \`./auth-sessions-instances\`: Folder containing auth session instances
|
|
80
|
+
|
|
81
|
+
## Types of auth sessions
|
|
82
|
+
- \`MANUAL\`: Manual auth session, records the session using a recorder and stores it in the \`auth-sessions-instances\` folder
|
|
83
|
+
- \`API\`: Auth session created via create API, stores the session in the \`auth-sessions-instances\` folder
|
|
84
|
+
|
|
85
|
+
### Notes
|
|
86
|
+
- You can use either \`yarn\` or \`npm run\` to execute commands
|
|
87
|
+
- All commands must be run from the project root directory
|
|
88
|
+
- Verify you're in the correct location by confirming the presence of package.json and intuned.json
|
|
89
|
+
- Running commands from subdirectories may result in errors
|
|
90
|
+
- You can manage your deployed projects through the Intuned platform
|
|
91
|
+
- WARNING: ⚠️ Changes to TS Config may break some Intuned functionalities
|
|
92
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
2
|
+
export declare const ProjectDeploymentStatus: string[];
|
|
3
|
+
export declare const PROJECT_DEPLOY_TIMEOUT = 600000;
|
|
4
|
+
export declare const userCLIScripts: {
|
|
5
|
+
"dev:local": string;
|
|
6
|
+
dev: string;
|
|
7
|
+
build: string;
|
|
8
|
+
"types-check": string;
|
|
9
|
+
"pre-publish": string;
|
|
10
|
+
start: string;
|
|
11
|
+
"run-api": string;
|
|
12
|
+
"cli-build": string;
|
|
13
|
+
deploy: string;
|
|
14
|
+
"cli-create-auth-session": string;
|
|
15
|
+
"cli-check-auth-session": string;
|
|
16
|
+
"browser-save-state": string;
|
|
17
|
+
"auth-session-check": string;
|
|
18
|
+
"auth-session-create": string;
|
|
19
|
+
"auth-session-refresh": string;
|
|
20
|
+
"auth-session-load": string;
|
|
21
|
+
};
|
|
22
|
+
export declare const tsConfigCli: {
|
|
23
|
+
compilerOptions: {
|
|
24
|
+
moduleResolution: string;
|
|
25
|
+
target: string;
|
|
26
|
+
outDir: string;
|
|
27
|
+
sourceMap: boolean;
|
|
28
|
+
declaration: boolean;
|
|
29
|
+
esModuleInterop: boolean;
|
|
30
|
+
};
|
|
31
|
+
include: string[];
|
|
32
|
+
exclude: string[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
7
|
+
const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
8
|
+
const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
|
|
9
|
+
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = 600000;
|
|
10
|
+
const userCLIScripts = exports.userCLIScripts = {
|
|
11
|
+
"dev:local": "intuned-api-run sample playwright -j '{}'",
|
|
12
|
+
dev: "intuned-api-run",
|
|
13
|
+
build: "intuned-build",
|
|
14
|
+
"types-check": "intuned-ts-check",
|
|
15
|
+
"pre-publish": "intuned-ts-check && intuned-build",
|
|
16
|
+
start: "node ./output/bundle_v2.js",
|
|
17
|
+
"run-api": "run-api",
|
|
18
|
+
"cli-build": "cli-build",
|
|
19
|
+
deploy: "deploy",
|
|
20
|
+
"cli-create-auth-session": "create-auth-session",
|
|
21
|
+
"cli-check-auth-session": "check-auth-session",
|
|
22
|
+
"browser-save-state": "intuned-browser-save-state",
|
|
23
|
+
"auth-session-check": "intuned-auth-session-check",
|
|
24
|
+
"auth-session-create": "intuned-auth-session-create",
|
|
25
|
+
"auth-session-refresh": "intuned-auth-session-refresh",
|
|
26
|
+
"auth-session-load": "intuned-auth-session-load"
|
|
27
|
+
};
|
|
28
|
+
const tsConfigCli = exports.tsConfigCli = {
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
moduleResolution: "node",
|
|
31
|
+
target: "ES2021",
|
|
32
|
+
outDir: "./dist",
|
|
33
|
+
sourceMap: false,
|
|
34
|
+
declaration: true,
|
|
35
|
+
esModuleInterop: true
|
|
36
|
+
},
|
|
37
|
+
include: ["**/*.ts"],
|
|
38
|
+
exclude: ["node_modules", "dist"]
|
|
39
|
+
};
|
|
@@ -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
|
}
|