@intuned/runtime-dev 1.2.1-hooks.9 → 1.2.1-results.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/api/run.js +6 -2
- package/dist/commands/auth-sessions/load.js +3 -3
- package/dist/commands/auth-sessions/run-check.js +2 -1
- package/dist/commands/auth-sessions/run-create.js +35 -12
- package/dist/commands/interface/run.d.ts +1 -1
- package/dist/commands/interface/run.js +40 -14
- package/dist/commands/intuned-cli/controller/api.js +2 -1
- package/dist/commands/intuned-cli/controller/authSession.d.ts +6 -6
- package/dist/commands/intuned-cli/controller/authSession.js +4 -3
- package/dist/commands/intuned-cli/helpers/auth.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/errors.d.ts +2 -2
- package/dist/commands/intuned-cli/helpers/errors.js +4 -8
- package/dist/common/asyncLocalStorage/index.d.ts +0 -1
- package/dist/common/getPlaywrightConstructs.d.ts +30 -0
- package/dist/common/{playwrightContext.js → getPlaywrightConstructs.js} +80 -132
- package/dist/common/runApi/errors.d.ts +9 -2
- package/dist/common/runApi/errors.js +17 -3
- package/dist/common/runApi/index.d.ts +7 -2
- package/dist/common/runApi/index.js +185 -87
- package/dist/common/runApi/types.d.ts +25 -21
- package/dist/common/runApi/types.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +20 -7
- package/dist/runtime/export.d.ts +43 -49
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +11 -5
- package/dist/runtime/requestMoreInfo.d.ts +18 -0
- package/dist/runtime/requestMoreInfo.js +25 -0
- package/package.json +1 -3
- package/dist/common/initializeContextHook.d.ts +0 -16
- package/dist/common/initializeContextHook.js +0 -15
- package/dist/common/playwrightContext.d.ts +0 -49
- package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
- package/dist/common/runApi/importUsingImportFunction.js +0 -46
- package/dist/runtime/store.d.ts +0 -2
- package/dist/runtime/store.js +0 -23
package/dist/runtime/export.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ export interface RunErrorOptions {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
+
* @deprecated This error is deprecated. it will be treated like any normal error
|
|
130
|
+
*
|
|
129
131
|
* Represents an error that occurs during a run.
|
|
130
132
|
*
|
|
131
133
|
* @class
|
|
@@ -154,73 +156,65 @@ export declare class RunError extends Error {
|
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
/**
|
|
157
|
-
*
|
|
159
|
+
* in the create auth session flow, you might to need a multiple choice answer from the user, requestMultipleChoice prompts the user with the question and possible options and returns their selection.
|
|
158
160
|
*
|
|
159
|
-
*
|
|
161
|
+
* **Note:** This function is currently in beta and may be subject to changes.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} message - The message to display to the user.
|
|
164
|
+
* @param {string[]} choices - An array of choices to present to the user.
|
|
160
165
|
*
|
|
161
166
|
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
*
|
|
167
|
+
* ```typescript requestMultipleChoice
|
|
168
|
+
* // in auth-sessions/create.ts
|
|
164
169
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
170
|
+
* import { requestMultipleChoice } from "@intuned/sdk/runtime"
|
|
171
|
+
*
|
|
172
|
+
* const message = "What is your favorite color?";
|
|
173
|
+
* const choices = ["Red", "Blue", "Green", "Yellow"];
|
|
174
|
+
*
|
|
175
|
+
* const selectedChoice = yield requestMultipleChoice(message, choices);
|
|
176
|
+
*
|
|
177
|
+
* console.log(selectedChoice);
|
|
167
178
|
* ```
|
|
168
179
|
*/
|
|
169
|
-
export declare function
|
|
180
|
+
export declare function requestMultipleChoice(
|
|
181
|
+
message: string,
|
|
182
|
+
choices: string[]
|
|
183
|
+
): unknown;
|
|
170
184
|
|
|
171
185
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
186
|
+
* **Note:** This function is currently in beta and may be subject to changes.
|
|
187
|
+
*
|
|
188
|
+
* requestOTP help you to ask the user for an otp in the create auth-session flow.
|
|
189
|
+
*
|
|
190
|
+
* @param {string} message - The message to display to the user.
|
|
175
191
|
*
|
|
176
192
|
* @example
|
|
177
|
-
* ```typescript
|
|
178
|
-
*
|
|
193
|
+
* ```typescript requestOTP
|
|
194
|
+
* // in auth-sessions/create.ts
|
|
195
|
+
*
|
|
196
|
+
* import { requestOTP } from "@intuned/sdk/runtime"
|
|
179
197
|
*
|
|
180
|
-
*
|
|
181
|
-
* store.set('userPreference', { theme: 'dark' });
|
|
198
|
+
* const message = "please submit and OTP from your authenticator app";
|
|
182
199
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
200
|
+
* const otp = yield requestOTP(message);
|
|
201
|
+
*
|
|
202
|
+
* console.log(otp);
|
|
185
203
|
* ```
|
|
186
204
|
*/
|
|
187
|
-
export
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves a value from the store by key.
|
|
190
|
-
*
|
|
191
|
-
* @param {string} key - The key to retrieve the value for
|
|
192
|
-
* @returns {any} The value associated with the key, or undefined if not found
|
|
193
|
-
*/
|
|
194
|
-
get(key: string): any;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Sets a value in the store by key.
|
|
198
|
-
*
|
|
199
|
-
* @param {string} key - The key to set the value for
|
|
200
|
-
* @param {any} value - The value to store
|
|
201
|
-
* @throws {Error} Throws an error if the store operation fails
|
|
202
|
-
*/
|
|
203
|
-
set(key: string, value: any): void;
|
|
204
|
-
}
|
|
205
|
+
export declare function requestOTP(message: string): unknown;
|
|
205
206
|
|
|
206
207
|
/**
|
|
207
|
-
*
|
|
208
|
-
* A persistent key-value store that maintains data within the execution context.
|
|
209
|
-
* This store allows you to share data between different parts of your API execution.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```typescript Store usage
|
|
213
|
-
* import { store } from "@intuned/sdk/runtime"
|
|
208
|
+
* Retrieves the parameters for the authentication session currently being used.
|
|
214
209
|
*
|
|
215
|
-
*
|
|
216
|
-
* store.set('sessionData', { userId: '123', token: 'abc' });
|
|
210
|
+
* @returns {AuthSessionParameters} An object containing the parameters for the current authentication session.
|
|
217
211
|
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript getAuthSessionParameters
|
|
214
|
+
* import { getAuthSessionParameters } from "@intuned/sdk/runtime"
|
|
221
215
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
216
|
+
* const authSessionParams = getAuthSessionParameters();
|
|
217
|
+
* console.log(authSessionParams);
|
|
224
218
|
* ```
|
|
225
219
|
*/
|
|
226
|
-
export declare
|
|
220
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { extendPayload } from "./extendPayload";
|
|
2
2
|
export { extendTimeout } from "./extendTimeout";
|
|
3
|
-
export { store } from "./store";
|
|
4
3
|
export { getAuthSessionParameters } from "./getAuthSessionParameters";
|
|
5
4
|
export { runInfo } from "./runInfo";
|
|
6
5
|
export { RunError } from "./RunError";
|
|
6
|
+
export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
|
|
7
|
+
export type { RequestMoreInfoDetails } from "./requestMoreInfo";
|
|
7
8
|
export { getDownloadDirectoryPath } from "./downloadDirectory";
|
package/dist/runtime/index.js
CHANGED
|
@@ -33,22 +33,28 @@ Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
|
33
33
|
return _downloadDirectory.getDownloadDirectoryPath;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "requestMultipleChoice", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _requestMoreInfo.requestMultipleChoice;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "requestOTP", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _requestMoreInfo.requestOTP;
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "runInfo", {
|
|
43
49
|
enumerable: true,
|
|
44
50
|
get: function () {
|
|
45
|
-
return
|
|
51
|
+
return _runInfo.runInfo;
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
54
|
var _extendPayload = require("./extendPayload");
|
|
49
55
|
var _extendTimeout = require("./extendTimeout");
|
|
50
|
-
var _store = require("./store");
|
|
51
56
|
var _getAuthSessionParameters = require("./getAuthSessionParameters");
|
|
52
57
|
var _runInfo = require("./runInfo");
|
|
53
58
|
var _RunError = require("./RunError");
|
|
59
|
+
var _requestMoreInfo = require("./requestMoreInfo");
|
|
54
60
|
var _downloadDirectory = require("./downloadDirectory");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface RequestMoreInfoReturnTypeBase {
|
|
2
|
+
[REQUEST_MORE_INFO_KEY]: true;
|
|
3
|
+
action: "request_more_info";
|
|
4
|
+
}
|
|
5
|
+
interface RequestMultipleChoiceReturnType extends RequestMoreInfoReturnTypeBase {
|
|
6
|
+
messageToUser: string;
|
|
7
|
+
choices: string[];
|
|
8
|
+
requestType: "multiple_choice";
|
|
9
|
+
}
|
|
10
|
+
interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase {
|
|
11
|
+
messageToUser: string;
|
|
12
|
+
requestType: "otp";
|
|
13
|
+
}
|
|
14
|
+
declare const REQUEST_MORE_INFO_KEY: unique symbol;
|
|
15
|
+
export declare function requestOTP(messageToUser: string): RequestOtpReturnType;
|
|
16
|
+
export declare function requestMultipleChoice(messageToUser: string, choices: string[]): RequestMultipleChoiceReturnType;
|
|
17
|
+
export type RequestMoreInfoDetails = RequestMultipleChoiceReturnType | RequestOtpReturnType;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.requestMultipleChoice = requestMultipleChoice;
|
|
7
|
+
exports.requestOTP = requestOTP;
|
|
8
|
+
const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
|
|
9
|
+
function requestOTP(messageToUser) {
|
|
10
|
+
return {
|
|
11
|
+
[REQUEST_MORE_INFO_KEY]: true,
|
|
12
|
+
action: "request_more_info",
|
|
13
|
+
messageToUser,
|
|
14
|
+
requestType: "otp"
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function requestMultipleChoice(messageToUser, choices) {
|
|
18
|
+
return {
|
|
19
|
+
[REQUEST_MORE_INFO_KEY]: true,
|
|
20
|
+
action: "request_more_info",
|
|
21
|
+
messageToUser,
|
|
22
|
+
requestType: "multiple_choice",
|
|
23
|
+
choices
|
|
24
|
+
};
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.2.1-
|
|
3
|
+
"version": "1.2.1-results.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
"cross-fetch": "^4.0.0",
|
|
71
71
|
"dotenv": "^16.3.1",
|
|
72
72
|
"fs-extra": "^11.3.0",
|
|
73
|
-
"get-port-please": "^3.2.0",
|
|
74
73
|
"image-size": "^1.1.1",
|
|
75
74
|
"inquirer": "12.6.0",
|
|
76
75
|
"jsonwebtoken": "9.0.2",
|
|
@@ -119,7 +118,6 @@
|
|
|
119
118
|
"eslint-plugin-deprecation": "^1.3.3",
|
|
120
119
|
"eslint-plugin-prettier": "^4.2.1",
|
|
121
120
|
"msw": "^2.1.2",
|
|
122
|
-
"playwright": "^1.55.0",
|
|
123
121
|
"typedoc": "^0.25.13",
|
|
124
122
|
"typedoc-plugin-frontmatter": "^1.0.0",
|
|
125
123
|
"typedoc-plugin-markdown": "^4.0.2",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type * as playwright from "playwright";
|
|
2
|
-
import type { RunAutomationError } from "./runApi/errors";
|
|
3
|
-
import type { Err, Ok } from "neverthrow";
|
|
4
|
-
import { type ImportFunction } from "./runApi/importUsingImportFunction";
|
|
5
|
-
export type InitializeContextHookOptions = {
|
|
6
|
-
apiName: string;
|
|
7
|
-
apiParameters: any;
|
|
8
|
-
cdpUrl: string;
|
|
9
|
-
};
|
|
10
|
-
export type InitializeContextHook = (options: InitializeContextHookOptions) => Promise<{
|
|
11
|
-
page: playwright.Page | null;
|
|
12
|
-
context: playwright.BrowserContext;
|
|
13
|
-
} | null>;
|
|
14
|
-
export declare function loadInitializeContextHook({ importFunction, }: {
|
|
15
|
-
importFunction: ImportFunction;
|
|
16
|
-
}): Promise<Ok<InitializeContextHook | null, any> | Err<any, RunAutomationError>>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadInitializeContextHook = loadInitializeContextHook;
|
|
7
|
-
var _importUsingImportFunction = require("./runApi/importUsingImportFunction");
|
|
8
|
-
async function loadInitializeContextHook({
|
|
9
|
-
importFunction
|
|
10
|
-
}) {
|
|
11
|
-
return await (0, _importUsingImportFunction.importUsingImportFunction)({
|
|
12
|
-
path: "hooks/initializeContext",
|
|
13
|
-
importFunction
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as playwright from "playwright";
|
|
2
|
-
import { RunAutomationError } from "./runApi/errors";
|
|
3
|
-
import type { RunApiSession } from "./runApi/types";
|
|
4
|
-
import { Err, Ok } from "neverthrow";
|
|
5
|
-
import { type ImportFunction } from "./runApi/importUsingImportFunction";
|
|
6
|
-
export interface Proxy {
|
|
7
|
-
server: string;
|
|
8
|
-
username: string;
|
|
9
|
-
password: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function launchChromium(options: {
|
|
12
|
-
proxy?: Proxy;
|
|
13
|
-
headless: boolean;
|
|
14
|
-
downloadsPath?: string;
|
|
15
|
-
cdpPort?: number;
|
|
16
|
-
}): Promise<{
|
|
17
|
-
page: playwright.Page;
|
|
18
|
-
context: playwright.BrowserContext;
|
|
19
|
-
}>;
|
|
20
|
-
export declare function launchChromium(options: {
|
|
21
|
-
cdpAddress: string;
|
|
22
|
-
}): Promise<{
|
|
23
|
-
page: playwright.Page;
|
|
24
|
-
context: playwright.BrowserContext;
|
|
25
|
-
}>;
|
|
26
|
-
export declare const browserScriptsFile: string;
|
|
27
|
-
type WithPlaywrightContextParameters = {
|
|
28
|
-
importFunction: ImportFunction;
|
|
29
|
-
apiName: string;
|
|
30
|
-
apiParameters: any;
|
|
31
|
-
};
|
|
32
|
-
export type WithPlaywrightContextWrappedFunction<R> = (context: playwright.BrowserContext, page: playwright.Page) => Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
33
|
-
export declare function withPlaywrightContext<R>(options: {
|
|
34
|
-
proxy?: Proxy;
|
|
35
|
-
headless: boolean;
|
|
36
|
-
downloadsPath: string;
|
|
37
|
-
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
38
|
-
export declare function withPlaywrightContext<R>(options: {
|
|
39
|
-
cdpAddress: string;
|
|
40
|
-
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
41
|
-
export declare function loadSessionToContext({ context, session, }: {
|
|
42
|
-
context: playwright.BrowserContext;
|
|
43
|
-
session: RunApiSession;
|
|
44
|
-
}): Promise<void>;
|
|
45
|
-
export declare function getRemotePlaywrightContext(cdpAddress: string): Promise<{
|
|
46
|
-
browser: playwright.Browser;
|
|
47
|
-
context: playwright.BrowserContext;
|
|
48
|
-
}>;
|
|
49
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Result } from "neverthrow";
|
|
2
|
-
import { RunAutomationError } from "./errors";
|
|
3
|
-
import { ExtendedRunApiParameters } from "./types";
|
|
4
|
-
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
5
|
-
export declare function importUsingImportFunction<_ReturnType = any>({ path, allowGenerators, importFunction, }: {
|
|
6
|
-
path: string;
|
|
7
|
-
importFunction: ImportFunction;
|
|
8
|
-
allowGenerators?: boolean;
|
|
9
|
-
}): Promise<Result<(..._: any) => Promise<_ReturnType>, RunAutomationError>>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.importUsingImportFunction = importUsingImportFunction;
|
|
7
|
-
var _neverthrow = require("neverthrow");
|
|
8
|
-
var _errors = require("./errors");
|
|
9
|
-
async function importUsingImportFunction({
|
|
10
|
-
path,
|
|
11
|
-
allowGenerators = true,
|
|
12
|
-
importFunction
|
|
13
|
-
}) {
|
|
14
|
-
try {
|
|
15
|
-
const importedResult = await importFunction(path);
|
|
16
|
-
if (importedResult.isErr()) {
|
|
17
|
-
if (importedResult.error.type === "not_found") {
|
|
18
|
-
return (0, _neverthrow.err)(new _errors.ApiNotFoundError(path));
|
|
19
|
-
}
|
|
20
|
-
return (0, _neverthrow.err)(new _errors.AutomationError(importedResult.error.error));
|
|
21
|
-
}
|
|
22
|
-
const imported = importedResult.value;
|
|
23
|
-
if (!imported || !imported.default || !imported.default.constructor) {
|
|
24
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} does not have a default export`));
|
|
25
|
-
}
|
|
26
|
-
if (imported.default.constructor.name === "AsyncGeneratorFunction") {
|
|
27
|
-
if (!allowGenerators) {
|
|
28
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} default export must be an async function`));
|
|
29
|
-
}
|
|
30
|
-
return (0, _neverthrow.ok)(async (...args) => {
|
|
31
|
-
const generator = imported.default(...args);
|
|
32
|
-
const result = await generator.next();
|
|
33
|
-
if (!result.done) {
|
|
34
|
-
throw new Error("Yield is not supported");
|
|
35
|
-
}
|
|
36
|
-
return result.value;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (imported.default.constructor.name === "AsyncFunction") {
|
|
40
|
-
return (0, _neverthrow.ok)(imported.default);
|
|
41
|
-
}
|
|
42
|
-
return (0, _neverthrow.err)(new _errors.InvalidApiError(`${path} default export must be an async function`));
|
|
43
|
-
} catch (error) {
|
|
44
|
-
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
45
|
-
}
|
|
46
|
-
}
|
package/dist/runtime/store.d.ts
DELETED
package/dist/runtime/store.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.store = void 0;
|
|
7
|
-
var _asyncLocalStorage = require("../common/asyncLocalStorage");
|
|
8
|
-
const store = exports.store = Object.freeze({
|
|
9
|
-
get: key => {
|
|
10
|
-
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
11
|
-
return context?.store ? context.store[key] : undefined;
|
|
12
|
-
},
|
|
13
|
-
set: (key, value) => {
|
|
14
|
-
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
15
|
-
if (!context) {
|
|
16
|
-
throw new Error("store.set failed due to an internal error.");
|
|
17
|
-
}
|
|
18
|
-
if (!context.store) {
|
|
19
|
-
context.store = {};
|
|
20
|
-
}
|
|
21
|
-
context.store[key] = value;
|
|
22
|
-
}
|
|
23
|
-
});
|