@intuned/runtime-dev 1.0.6-cli-auth.0.0.5-test → 1.0.6-cli-auth.0.0.7-test
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/bin/check-auth-session +3 -0
- package/dist/commands/cli-auth-sessions/check.d.ts +2 -0
- package/dist/commands/cli-auth-sessions/check.js +45 -1
- package/dist/commands/cli-auth-sessions/create.js +33 -15
- package/dist/commands/cli-auth-sessions/utils.d.ts +7 -3
- package/dist/commands/cli-auth-sessions/utils.js +79 -12
- package/dist/commands/run-api-cli/run-api.js +4 -2
- package/dist/commands/run-api-cli/utils.d.ts +5 -1
- package/dist/commands/run-api-cli/utils.js +40 -1
- package/dist/common/cli/types.d.ts +4 -0
- package/dist/common/cli/types.js +7 -2
- package/package.json +3 -2
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
6
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
+
_dotenv.default.config({
|
|
14
|
+
path: `.env`
|
|
15
|
+
});
|
|
16
|
+
_commander.program.description("Check an auth session, if it is still valid or not").option("-a, --auth-session <session>", "Name of the auth session instance to use").action(async options => {
|
|
17
|
+
try {
|
|
18
|
+
if (!options.authSession) {
|
|
19
|
+
throw new Error("Auth session path is required");
|
|
20
|
+
}
|
|
21
|
+
const authSessionInstancePath = _path.default.resolve(process.cwd(), options.authSession);
|
|
22
|
+
if (!(await fs.exists(authSessionInstancePath))) {
|
|
23
|
+
throw new Error(`Auth session file not found at ${authSessionInstancePath}, please provide a valid path`);
|
|
24
|
+
}
|
|
25
|
+
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
26
|
+
if (!_isAuthEnabled) {
|
|
27
|
+
throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
|
|
28
|
+
}
|
|
29
|
+
const checkApiExists = await (0, _utils.ensureAuthApi)("check");
|
|
30
|
+
if (!checkApiExists) {
|
|
31
|
+
throw new Error("Auth check creation API not implemented, please create it in the auth sessions specified directory");
|
|
32
|
+
}
|
|
33
|
+
const checkResult = await (0, _utils.runCheckApi)(authSessionInstancePath);
|
|
34
|
+
if (checkResult) {
|
|
35
|
+
console.log(_chalk.default.green("✓ Auth session checked successfully"));
|
|
36
|
+
} else {
|
|
37
|
+
console.log(_chalk.default.red("✗ Auth session is not valid, check failed"));
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(_chalk.default.red(`Failed to create auth session: ${error.message}`));
|
|
41
|
+
} finally {
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
_commander.program.parse(process.argv);
|
|
@@ -14,21 +14,39 @@ _dotenv.default.config({
|
|
|
14
14
|
path: `.env`
|
|
15
15
|
});
|
|
16
16
|
_commander.program.description("Create an auth session").option("-i, --input <input>", "Auth session input parameters file").option("-n, --auth-session-name <output>", "Custom name for the auth session instance stored").action(async options => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
try {
|
|
18
|
+
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
19
|
+
if (!_isAuthEnabled) {
|
|
20
|
+
throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
|
|
21
|
+
}
|
|
22
|
+
const createApiExists = await (0, _utils.ensureAuthApi)("create");
|
|
23
|
+
if (!createApiExists) {
|
|
24
|
+
throw new Error("Auth session creation API not implemented, please create it in the auth sessions specified directory");
|
|
25
|
+
}
|
|
26
|
+
let authSessionInput = {};
|
|
27
|
+
if (options.input) {
|
|
28
|
+
const inputFilePath = _path.default.resolve(process.cwd(), options.input);
|
|
29
|
+
if (!(await fs.exists(inputFilePath))) {
|
|
30
|
+
throw new Error(`Auth session input file not found at ${inputFilePath}`);
|
|
31
|
+
}
|
|
32
|
+
const authSessionInputFile = options.input;
|
|
33
|
+
const authSessionInputPath = _path.default.join(process.cwd(), authSessionInputFile);
|
|
34
|
+
authSessionInput = await fs.readJSON(authSessionInputPath);
|
|
35
|
+
}
|
|
36
|
+
const session = await (0, _utils.runCreateApi)(authSessionInput);
|
|
37
|
+
if (!session) {
|
|
38
|
+
console.error(_chalk.default.red("Failed to create auth session."));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
const authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, options.authSessionName, authSessionInput);
|
|
42
|
+
console.log(_chalk.default.green("✓ Auth session created successfully!"));
|
|
43
|
+
if (authSessionInstancePath) {
|
|
44
|
+
console.log(_chalk.default.underline.green.white(`🔒 Auth session instance and metadata stored at ${authSessionInstancePath}`));
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(_chalk.default.red(`Failed to create auth session: ${error.message}`));
|
|
48
|
+
} finally {
|
|
49
|
+
process.exit(0);
|
|
32
50
|
}
|
|
33
51
|
});
|
|
34
52
|
_commander.program.parse(process.argv);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { StorageState } from "../../common/contextStorageStateHelpers";
|
|
2
2
|
export declare function isAuthEnabled(): Promise<boolean>;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function runCreateApi(authSessionInput: Record<string, any>): Promise<
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function ensureAuthApi(operation: "create" | "check"): Promise<boolean>;
|
|
4
|
+
export declare function runCreateApi(authSessionInput: Record<string, any>): Promise<StorageState>;
|
|
5
|
+
export declare function runCheckApi(authSessionPath: string): Promise<boolean>;
|
|
6
|
+
export declare function runCreateApiViaCLI(authSessionInput: Record<string, any>): Promise<StorageState>;
|
|
7
|
+
export declare function runCheckApiViaCLI(authSessionPath: string): Promise<boolean>;
|
|
8
|
+
export declare function storeAuthSessionInstance(authSessionInstance: StorageState, customName?: string, authSessionInput?: Record<string, any>): Promise<string>;
|
|
9
|
+
export declare function retrieveAuthSessionInstance(): Promise<void>;
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ensureAuthApi = ensureAuthApi;
|
|
7
7
|
exports.isAuthEnabled = isAuthEnabled;
|
|
8
|
+
exports.retrieveAuthSessionInstance = retrieveAuthSessionInstance;
|
|
9
|
+
exports.runCheckApi = runCheckApi;
|
|
10
|
+
exports.runCheckApiViaCLI = runCheckApiViaCLI;
|
|
8
11
|
exports.runCreateApi = runCreateApi;
|
|
9
|
-
exports.
|
|
12
|
+
exports.runCreateApiViaCLI = runCreateApiViaCLI;
|
|
13
|
+
exports.storeAuthSessionInstance = storeAuthSessionInstance;
|
|
10
14
|
var _path = _interopRequireDefault(require("path"));
|
|
11
15
|
var _constants = require("../../common/constants");
|
|
12
16
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
@@ -16,6 +20,7 @@ var _nanoid = require("nanoid");
|
|
|
16
20
|
var _runApi = require("../../common/runApi");
|
|
17
21
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
18
22
|
var _promptly = require("promptly");
|
|
23
|
+
var _utils = require("../../common/cli/utils");
|
|
19
24
|
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); }
|
|
20
25
|
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; }
|
|
21
26
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -28,24 +33,37 @@ async function isAuthEnabled() {
|
|
|
28
33
|
return false;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
|
-
async function
|
|
32
|
-
const createApiFile = `${_constants.AUTH_SESSIONS_FOLDER_NAME}
|
|
36
|
+
async function ensureAuthApi(operation) {
|
|
37
|
+
const createApiFile = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/${operation}.ts`;
|
|
33
38
|
const createApiFilePath = _path.default.join(process.cwd(), createApiFile);
|
|
34
39
|
return await fs.exists(createApiFilePath);
|
|
35
40
|
}
|
|
36
41
|
async function runCreateApi(authSessionInput) {
|
|
37
42
|
try {
|
|
38
|
-
const
|
|
43
|
+
const createApiOperationId = (0, _nanoid.nanoid)();
|
|
39
44
|
const authSessionInstance = await (0, _asyncLocalStorage.runWithContext)({
|
|
40
45
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
41
46
|
extendedPayloads: [],
|
|
42
|
-
runId:
|
|
47
|
+
runId: createApiOperationId
|
|
43
48
|
}, () => runCreateApiViaCLI(authSessionInput));
|
|
44
49
|
return authSessionInstance;
|
|
45
50
|
} catch (error) {
|
|
46
51
|
throw new Error(`Error running the create API: ${error.message}`);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
54
|
+
async function runCheckApi(authSessionPath) {
|
|
55
|
+
try {
|
|
56
|
+
const checkApiOperationId = (0, _nanoid.nanoid)();
|
|
57
|
+
const checkResult = await (0, _asyncLocalStorage.runWithContext)({
|
|
58
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
59
|
+
extendedPayloads: [],
|
|
60
|
+
runId: checkApiOperationId
|
|
61
|
+
}, () => runCheckApiViaCLI(authSessionPath));
|
|
62
|
+
return checkResult;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new Error(`Error running the create API: ${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
49
67
|
async function runCreateApiViaCLI(authSessionInput) {
|
|
50
68
|
const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
|
|
51
69
|
const generator = (0, _runApi.runApiGenerator)({
|
|
@@ -93,17 +111,66 @@ async function runCreateApiViaCLI(authSessionInput) {
|
|
|
93
111
|
}
|
|
94
112
|
return session;
|
|
95
113
|
}
|
|
96
|
-
async function
|
|
114
|
+
async function runCheckApiViaCLI(authSessionPath) {
|
|
115
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
116
|
+
automationFunction: {
|
|
117
|
+
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
118
|
+
},
|
|
119
|
+
runOptions: {
|
|
120
|
+
headless: false,
|
|
121
|
+
environment: "standalone"
|
|
122
|
+
},
|
|
123
|
+
auth: {
|
|
124
|
+
session: {
|
|
125
|
+
type: "file",
|
|
126
|
+
path: authSessionPath
|
|
127
|
+
},
|
|
128
|
+
runCheck: false
|
|
129
|
+
},
|
|
130
|
+
importFunction: _tsNodeImport.tsNodeImport
|
|
131
|
+
});
|
|
132
|
+
if (runApiResult.isErr()) {
|
|
133
|
+
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
134
|
+
throw runApiResult.error.error;
|
|
135
|
+
}
|
|
136
|
+
console.error(runApiResult.error);
|
|
137
|
+
throw new Error("Error running auth session check");
|
|
138
|
+
}
|
|
139
|
+
const result = runApiResult.value.result;
|
|
140
|
+
if (!result) {
|
|
141
|
+
throw new Error("Auth session check failed");
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
async function storeAuthSessionInstance(authSessionInstance, customName, authSessionInput) {
|
|
97
146
|
try {
|
|
98
147
|
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
99
148
|
await fs.ensureDir(authSessionsDirectoryPath);
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
149
|
+
const authSessionInstanceId = customName ?? `auth-session-${Date.now()}`;
|
|
150
|
+
const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, authSessionInstanceId);
|
|
151
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
152
|
+
await fs.writeJSON(authSessionInstanceStoragePath, authSessionInstance, {
|
|
103
153
|
spaces: 2
|
|
104
154
|
});
|
|
105
|
-
|
|
155
|
+
const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
156
|
+
const authSessionMetadata = {
|
|
157
|
+
createdAt: new Date().toISOString(),
|
|
158
|
+
updatedAt: new Date().toISOString(),
|
|
159
|
+
authSessionInput: authSessionInput ?? {},
|
|
160
|
+
authSessionId: authSessionInstanceId,
|
|
161
|
+
authSessionType: projectAuthConfig.type ?? "API",
|
|
162
|
+
...(projectAuthConfig.type === "MANUAL" && {
|
|
163
|
+
recorderStartUrl: projectAuthConfig.startUrl,
|
|
164
|
+
recorderEndUrl: projectAuthConfig.endUrl
|
|
165
|
+
})
|
|
166
|
+
};
|
|
167
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
168
|
+
await fs.writeJSON(authSessionInstanceMetadataPath, authSessionMetadata, {
|
|
169
|
+
spaces: 2
|
|
170
|
+
});
|
|
171
|
+
return authSessionInstancePath;
|
|
106
172
|
} catch (error) {
|
|
107
173
|
throw new Error(`Error storing auth session instance: ${error.message}`);
|
|
108
174
|
}
|
|
109
|
-
}
|
|
175
|
+
}
|
|
176
|
+
async function retrieveAuthSessionInstance() {}
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
_dotenv.default.config({
|
|
13
13
|
path: `.env`
|
|
14
14
|
});
|
|
15
|
-
_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("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
|
|
15
|
+
_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) => {
|
|
16
16
|
try {
|
|
17
17
|
if (!apiName) {
|
|
18
18
|
throw new Error("API name is required, please provide it");
|
|
@@ -26,7 +26,9 @@ _commander.program.name("intuned-run").description("Run an Intuned API with para
|
|
|
26
26
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
27
27
|
extendedPayloads: [],
|
|
28
28
|
runId
|
|
29
|
-
}, () => (0, _utils.runApiViaCLI)(apiName, inputData
|
|
29
|
+
}, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
|
|
30
|
+
authSessionPath: options.authSession
|
|
31
|
+
}));
|
|
30
32
|
if (!result) {
|
|
31
33
|
console.log(_chalk.default.yellow("No result returned from the API"));
|
|
32
34
|
return;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Payload } from "../../runtime/export";
|
|
2
|
+
import { ApiAuthSessionBehavior } from "../../common/cli/types";
|
|
2
3
|
export declare function loadParameters(parametersFile: string): Promise<object | null>;
|
|
3
4
|
export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
|
|
4
|
-
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined
|
|
5
|
+
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options?: {
|
|
6
|
+
authSessionPath?: string;
|
|
7
|
+
authSessionsMode?: ApiAuthSessionBehavior;
|
|
8
|
+
}): Promise<{
|
|
5
9
|
result: any;
|
|
6
10
|
payloadToAppend: Payload[] | undefined;
|
|
7
11
|
}>;
|
|
@@ -12,6 +12,9 @@ var _Logger = require("../../common/Logger");
|
|
|
12
12
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
13
|
var _runApi = require("../../common/runApi");
|
|
14
14
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
15
|
+
var _utils = require("../../common/cli/utils");
|
|
16
|
+
var _types = require("../../common/cli/types");
|
|
17
|
+
var _utils2 = require("../cli-auth-sessions/utils");
|
|
15
18
|
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); }
|
|
16
19
|
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; }
|
|
17
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -59,7 +62,36 @@ async function writeResultToFile(runId, result, payloadToAppend) {
|
|
|
59
62
|
_Logger.logger.error(`Failed to write result to file: ${error.message}`);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
|
-
async function runApiViaCLI(apiName, inputData) {
|
|
65
|
+
async function runApiViaCLI(apiName, inputData, options) {
|
|
66
|
+
let authSessionPathToUse = null;
|
|
67
|
+
const authSessionsMode = (options === null || options === void 0 ? void 0 : options.authSessionsMode) ?? "PERFORM_CHECK_AND_REFRESH";
|
|
68
|
+
if (options !== null && options !== void 0 && options.authSessionPath) {
|
|
69
|
+
const authSessions = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
70
|
+
if (authSessions.enabled) {
|
|
71
|
+
if (!options.authSessionPath) {
|
|
72
|
+
throw new Error("Auth session is enabled but no auth session provided");
|
|
73
|
+
}
|
|
74
|
+
authSessionPathToUse = options.authSessionPath;
|
|
75
|
+
} else {
|
|
76
|
+
if (options.authSessionPath) {
|
|
77
|
+
throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (authSessionsMode === _types.ApiAuthSessionBehavior.PERFORM_CHECK_AND_REFRESH && authSessionPathToUse) {
|
|
82
|
+
const checkApiExists = await (0, _utils2.ensureAuthApi)("check");
|
|
83
|
+
if (!checkApiExists) {
|
|
84
|
+
throw new Error("Auth session check API not implemented, please create it in the auth sessions specified directory");
|
|
85
|
+
}
|
|
86
|
+
const checkResult = await (0, _utils2.runCheckApiViaCLI)(authSessionPathToUse);
|
|
87
|
+
if (!checkResult) {
|
|
88
|
+
console.log(_chalk.default.yellow("Auth session check failed, trying to refresh it..."));
|
|
89
|
+
const createApiExists = await (0, _utils2.ensureAuthApi)("create");
|
|
90
|
+
if (!createApiExists) {
|
|
91
|
+
throw new Error("Auth session creation API not implemented, please create it in the auth sessions specified directory");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
63
95
|
const runApiResult = await (0, _runApi.runApi)({
|
|
64
96
|
automationFunction: {
|
|
65
97
|
name: `api/${apiName}`,
|
|
@@ -69,6 +101,13 @@ async function runApiViaCLI(apiName, inputData) {
|
|
|
69
101
|
headless: false,
|
|
70
102
|
environment: "standalone"
|
|
71
103
|
},
|
|
104
|
+
auth: authSessionPathToUse ? {
|
|
105
|
+
session: {
|
|
106
|
+
type: "file",
|
|
107
|
+
path: authSessionPathToUse
|
|
108
|
+
},
|
|
109
|
+
runCheck: false
|
|
110
|
+
} : undefined,
|
|
72
111
|
importFunction: _tsNodeImport.tsNodeImport
|
|
73
112
|
});
|
|
74
113
|
if (runApiResult.isErr()) {
|
package/dist/common/cli/types.js
CHANGED
|
@@ -3,5 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.templateIds = void 0;
|
|
7
|
-
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
6
|
+
exports.templateIds = 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
|
+
}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.0.6-cli-auth.0.0.
|
|
3
|
+
"version": "1.0.6-cli-auth.0.0.7-test",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"run-api": "./bin/run-api",
|
|
55
55
|
"deploy": "./bin/deploy",
|
|
56
56
|
"cli-build": "./bin/cli-build",
|
|
57
|
-
"create-auth-session": "./bin/create-auth-session"
|
|
57
|
+
"create-auth-session": "./bin/create-auth-session",
|
|
58
|
+
"check-auth-session": "./bin/check-auth-session"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|