@intuned/runtime-dev 1.3.0-dev-52 → 1.3.0-responseLimits.1
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/.babelrc +2 -2
- package/CHANGELOG.md +5 -1
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +4 -3
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/interface/run.js +5 -6
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
- package/dist/commands/intuned-cli/commands/index.js +170 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/init.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/types.js +21 -0
- package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
- package/dist/commands/intuned-cli/controller/api.js +181 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
- package/dist/commands/intuned-cli/controller/authSession.js +292 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
- package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
- package/dist/commands/intuned-cli/helpers/auth.js +129 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +12 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +15 -0
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
- package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +4 -12
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +9 -2
- package/dist/common/runApi/errors.js +21 -8
- package/dist/common/runApi/index.d.ts +4 -1
- package/dist/common/runApi/index.js +33 -21
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +15 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/package.json +14 -13
- package/tsconfig.json +2 -1
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/deploy +0 -3
- package/bin/init +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -285
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -47
- package/dist/commands/deploy/utils.d.ts +0 -16
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -22
- package/dist/commands/init/utils.d.ts +0 -11
- package/dist/commands/init/utils.js +0 -181
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +0 -92
- package/dist/common/cli/constants.d.ts +0 -33
- package/dist/common/cli/constants.js +0 -39
- package/dist/common/cli/utils.d.ts +0 -6
package/dist/common/constants.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
6
|
+
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_FOLDER_NAME = void 0;
|
|
7
|
+
const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
|
|
7
8
|
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
8
9
|
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
@@ -7,7 +7,7 @@ exports.getPlaywrightConstructsForMode = getPlaywrightConstructsForMode;
|
|
|
7
7
|
exports.getProductionPlaywrightConstructs = getProductionPlaywrightConstructs;
|
|
8
8
|
exports.getRemotePlaywrightContext = getRemotePlaywrightContext;
|
|
9
9
|
exports.loadSessionToContext = loadSessionToContext;
|
|
10
|
-
var playwright = _interopRequireWildcard(require("playwright
|
|
10
|
+
var playwright = _interopRequireWildcard(require("playwright"));
|
|
11
11
|
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
12
12
|
var fs = _fsExtra;
|
|
13
13
|
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
@@ -43,19 +43,12 @@ async function getProductionPlaywrightConstructs({
|
|
|
43
43
|
if (headless) {
|
|
44
44
|
extraArgs.push("--headless=new");
|
|
45
45
|
}
|
|
46
|
-
const executablePath = playwright.chromium.executablePath();
|
|
47
|
-
const chromium127Path = executablePath.replace("chromium-1117", "chromium-1124");
|
|
48
|
-
const isChrome127There = await (0, _fsExtra.exists)(chromium127Path);
|
|
49
|
-
const userAgent = `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${isChrome127There ? 127 : 125}.0.0.0 Safari/537.36`;
|
|
50
46
|
const userDataDir = await createUserDirWithPreferences();
|
|
51
47
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
52
48
|
headless,
|
|
53
|
-
|
|
49
|
+
viewport: null,
|
|
54
50
|
proxy,
|
|
55
|
-
|
|
56
|
-
args: extraArgs,
|
|
57
|
-
downloadsPath,
|
|
58
|
-
userAgent
|
|
51
|
+
downloadsPath
|
|
59
52
|
});
|
|
60
53
|
context.once("close", async () => {
|
|
61
54
|
try {
|
|
@@ -91,7 +84,6 @@ async function getProductionPlaywrightConstructs({
|
|
|
91
84
|
context
|
|
92
85
|
};
|
|
93
86
|
}
|
|
94
|
-
const getChromiumLaunchArgsToIgnore = () => ["--disable-field-trial-config", "--disable-background-networking", "--enable-features=NetworkService,NetworkServiceInProcess", "--disable-background-timer-throttling", "--disable-backgrounding-occluded-windows", "--disable-back-forward-cache", "--disable-breakpad", "--disable-client-side-phishing-detection", "--disable-component-extensions-with-background-pages", "--disable-component-update", "--no-default-browser-check", "--disable-default-apps", "--disable-dev-shm-usage", "--disable-extensions", "--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,TranslateUI", "--allow-pre-commit-input", "--disable-hang-monitor", "--disable-ipc-flooding-protection", "--disable-prompt-on-repost", "--disable-renderer-backgrounding", "--force-color-profile=srgb", "--metrics-recording-only", "--no-first-run", "--enable-automation", "--password-store=basic", "--use-mock-keychain", "--no-service-autorun", "--export-tagged-pdf", "--enable-use-zoom-for-dsf=false"];
|
|
95
87
|
async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
96
88
|
if (mode == "playwright-standalone") {
|
|
97
89
|
if (!cdpAddress) {
|
|
@@ -163,7 +155,7 @@ async function loadSessionToContext({
|
|
|
163
155
|
await (0, _contextStorageStateHelpers.setStorageState)(context, sessionToLoad);
|
|
164
156
|
}
|
|
165
157
|
async function getRemotePlaywrightContext(cdpAddress) {
|
|
166
|
-
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("playwright
|
|
158
|
+
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("playwright")));
|
|
167
159
|
let browser = null;
|
|
168
160
|
if (!cdpAddress) {
|
|
169
161
|
throw new Error("cdpAddress is required");
|
|
@@ -36,8 +36,7 @@ class JwtTokenManager {
|
|
|
36
36
|
return Math.max(timeToRefresh, timeWindow);
|
|
37
37
|
}
|
|
38
38
|
async scheduleTokenRefresh() {
|
|
39
|
-
|
|
40
|
-
if (((_process$env$RUN_ENVI = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI === void 0 ? void 0 : _process$env$RUN_ENVI.toLowerCase()) !== "authoring") return;
|
|
39
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
41
40
|
const timeToRefresh = this.timeToRefresh;
|
|
42
41
|
if (timeToRefresh === undefined) return;
|
|
43
42
|
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
@@ -51,8 +50,7 @@ class JwtTokenManager {
|
|
|
51
50
|
}, timeToRefresh);
|
|
52
51
|
}
|
|
53
52
|
async refreshToken() {
|
|
54
|
-
|
|
55
|
-
if (((_process$env$RUN_ENVI2 = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI2 === void 0 ? void 0 : _process$env$RUN_ENVI2.toLowerCase()) !== "authoring") return;
|
|
53
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
56
54
|
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
57
55
|
method: "GET"
|
|
58
56
|
});
|
|
@@ -65,7 +63,7 @@ class JwtTokenManager {
|
|
|
65
63
|
if (newToken) this._token = newToken;
|
|
66
64
|
}
|
|
67
65
|
fetchWithToken(...[input, init]) {
|
|
68
|
-
const headers = new Headers(init
|
|
66
|
+
const headers = new Headers(init?.headers);
|
|
69
67
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
70
68
|
return (0, _crossFetch.default)(input, {
|
|
71
69
|
...init,
|
|
@@ -9,7 +9,8 @@ export declare const authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
|
9
9
|
export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
10
10
|
export declare const automationError = "AutomationError";
|
|
11
11
|
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const resultTooBigErrorCode = "ResultTooBigError";
|
|
13
|
+
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError", "ResultTooBigError"];
|
|
13
14
|
export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
|
|
14
15
|
export declare abstract class RunAutomationError<T = any> {
|
|
15
16
|
code: RunAutomationErrorCode;
|
|
@@ -19,7 +20,7 @@ export declare abstract class RunAutomationError<T = any> {
|
|
|
19
20
|
cause?: RunAutomationError;
|
|
20
21
|
details?: T;
|
|
21
22
|
get json(): {
|
|
22
|
-
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError";
|
|
23
|
+
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError" | "ResultTooBigError";
|
|
23
24
|
details: T | undefined;
|
|
24
25
|
cause: any;
|
|
25
26
|
};
|
|
@@ -63,3 +64,9 @@ export declare class AutomationError extends RunAutomationError<{
|
|
|
63
64
|
export declare class InternalInvalidInputError extends RunAutomationError {
|
|
64
65
|
constructor(message: string, details?: any);
|
|
65
66
|
}
|
|
67
|
+
export declare class ResultTooBigError extends RunAutomationError<{
|
|
68
|
+
sizeInBytes: number;
|
|
69
|
+
maxSizeInBytes: number;
|
|
70
|
+
}> {
|
|
71
|
+
constructor(sizeInBytes: number, maxSizeInBytes: number);
|
|
72
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
6
|
+
exports.runAutomationErrorCodes = exports.resultTooBigErrorCode = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.ResultTooBigError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
7
|
var _runtime = require("../../runtime");
|
|
8
8
|
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -18,15 +18,15 @@ const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFa
|
|
|
18
18
|
const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
19
19
|
const automationError = exports.automationError = "AutomationError";
|
|
20
20
|
const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
21
|
-
const
|
|
21
|
+
const resultTooBigErrorCode = exports.resultTooBigErrorCode = "ResultTooBigError";
|
|
22
|
+
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode, resultTooBigErrorCode];
|
|
22
23
|
class RunAutomationError {
|
|
23
24
|
wrapped = false;
|
|
24
25
|
get json() {
|
|
25
|
-
var _this$cause;
|
|
26
26
|
return {
|
|
27
27
|
code: this.code,
|
|
28
28
|
details: this.details,
|
|
29
|
-
cause:
|
|
29
|
+
cause: this.cause?.json
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -136,10 +136,10 @@ class AutomationError extends RunAutomationError {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
this.statusCode = 500;
|
|
139
|
-
this.message = `[${
|
|
139
|
+
this.message = `[${error?.name ?? error}] ${error?.message}`;
|
|
140
140
|
this.details = {
|
|
141
|
-
name: error
|
|
142
|
-
message: error
|
|
141
|
+
name: error?.name,
|
|
142
|
+
message: error?.message
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -153,4 +153,17 @@ class InternalInvalidInputError extends RunAutomationError {
|
|
|
153
153
|
this.details = details;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
156
|
+
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
157
|
+
class ResultTooBigError extends RunAutomationError {
|
|
158
|
+
constructor(sizeInBytes, maxSizeInBytes) {
|
|
159
|
+
super();
|
|
160
|
+
this.code = resultTooBigErrorCode;
|
|
161
|
+
this.statusCode = 413;
|
|
162
|
+
this.message = `Automation result is too big. Size: ${Math.round(sizeInBytes / 1024 / 1024 * 100) / 100}MB, Max allowed: ${Math.round(maxSizeInBytes / 1024 / 1024 * 100) / 100}MB`;
|
|
163
|
+
this.details = {
|
|
164
|
+
sizeInBytes,
|
|
165
|
+
maxSizeInBytes
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.ResultTooBigError = ResultTooBigError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { RunAutomationError } from "./errors";
|
|
3
|
-
import { Page, BrowserContext } from "playwright
|
|
3
|
+
import { Page, BrowserContext } from "playwright";
|
|
4
4
|
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export * from "./errors";
|
|
@@ -8,6 +8,9 @@ export declare function runApiGenerator<ResultType = any, _YieldType = any, _Nex
|
|
|
8
8
|
retrieveSession: true;
|
|
9
9
|
}): AsyncGenerator<_YieldType, RunApiResult<ResultType, RunApiResultWithSessionOk>, _NextType>;
|
|
10
10
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters): AsyncGenerator<_YieldType, RunApiResult<ResultType>, _NextType>;
|
|
11
|
+
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters & {
|
|
12
|
+
retrieveSession: true;
|
|
13
|
+
}): Promise<RunApiResult<ResultType, RunApiResultWithSessionOk>>;
|
|
11
14
|
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
12
15
|
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, checkFn: (..._: any) => Promise<boolean>, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
13
16
|
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
@@ -47,6 +47,13 @@ var _formatZodError = require("../formatZodError");
|
|
|
47
47
|
var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
48
48
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
49
49
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
50
|
+
function getObjectSizeInBytes(obj) {
|
|
51
|
+
try {
|
|
52
|
+
return new TextEncoder().encode(JSON.stringify(obj)).length;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return new TextEncoder().encode(String(obj)).length;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
50
57
|
async function* runApiGenerator({
|
|
51
58
|
retrieveSession = false,
|
|
52
59
|
abortSignal,
|
|
@@ -80,17 +87,15 @@ async function* runApiGenerator({
|
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
89
|
try {
|
|
83
|
-
|
|
84
|
-
await ((_context = context) === null || _context === void 0 ? void 0 : _context.tracing.stop({
|
|
90
|
+
await context?.tracing.stop({
|
|
85
91
|
path: tracing.filePath
|
|
86
|
-
})
|
|
92
|
+
});
|
|
87
93
|
} catch (error) {
|
|
88
|
-
console.log(errorMessage, error
|
|
94
|
+
console.log(errorMessage, error?.message);
|
|
89
95
|
await (0, _fsExtra.remove)(tracing.filePath);
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
async function* runAutomation() {
|
|
93
|
-
var _getExecutionContext;
|
|
94
99
|
let page;
|
|
95
100
|
const validatedModuleResult = await importUsingImportFunction(automationFunction.name, importFunction);
|
|
96
101
|
if (validatedModuleResult.isErr()) {
|
|
@@ -98,7 +103,7 @@ async function* runApiGenerator({
|
|
|
98
103
|
}
|
|
99
104
|
const importedModule = validatedModuleResult.value;
|
|
100
105
|
let checkFn;
|
|
101
|
-
if (auth
|
|
106
|
+
if (auth?.runCheck) {
|
|
102
107
|
if (!auth.session) {
|
|
103
108
|
return (0, _neverthrow.err)(new _errors.AuthRequiredError());
|
|
104
109
|
}
|
|
@@ -130,7 +135,7 @@ async function* runApiGenerator({
|
|
|
130
135
|
headless,
|
|
131
136
|
proxy,
|
|
132
137
|
downloadsPath,
|
|
133
|
-
storageState: auth
|
|
138
|
+
storageState: auth?.session
|
|
134
139
|
}));
|
|
135
140
|
} else {
|
|
136
141
|
const {
|
|
@@ -140,7 +145,7 @@ async function* runApiGenerator({
|
|
|
140
145
|
({
|
|
141
146
|
page,
|
|
142
147
|
context
|
|
143
|
-
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth
|
|
148
|
+
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth?.session));
|
|
144
149
|
}
|
|
145
150
|
if (tracing.enabled) {
|
|
146
151
|
await context.tracing.start({
|
|
@@ -152,20 +157,23 @@ async function* runApiGenerator({
|
|
|
152
157
|
}
|
|
153
158
|
(0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
|
|
154
159
|
if (checkFn !== undefined) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
try {
|
|
161
|
+
console.log("Running auth check");
|
|
162
|
+
const authCheckResult = await checkAuthSessionWithRetries(page, context, checkFn, 2);
|
|
163
|
+
if (authCheckResult.isErr()) {
|
|
164
|
+
const error = authCheckResult.error;
|
|
165
|
+
if (["APINotFoundError", "InvalidAPIError"].includes(error.code)) {
|
|
166
|
+
return (0, _neverthrow.err)(new _errors.InvalidCheckError(`Auth session check function failed`, error));
|
|
167
|
+
}
|
|
168
|
+
return authCheckResult;
|
|
161
169
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
if (!authCheckResult.value) {
|
|
171
|
+
return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {
|
|
165
174
|
return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
|
-
console.log("Running automation");
|
|
169
177
|
const automationFunctionParameters = [...(automationFunction.params !== undefined ? [automationFunction.params] : []), page, context];
|
|
170
178
|
let result;
|
|
171
179
|
if (importedModule.type === "async-generator") {
|
|
@@ -183,9 +191,14 @@ async function* runApiGenerator({
|
|
|
183
191
|
} else {
|
|
184
192
|
result = await importedModule.func(...automationFunctionParameters);
|
|
185
193
|
}
|
|
194
|
+
const MAX_RESULT_SIZE_BYTES = 2 * 1024 * 1024;
|
|
195
|
+
const resultSizeInBytes = getObjectSizeInBytes(result);
|
|
196
|
+
if (resultSizeInBytes > MAX_RESULT_SIZE_BYTES) {
|
|
197
|
+
return (0, _neverthrow.err)(new _errors.ResultTooBigError(resultSizeInBytes, MAX_RESULT_SIZE_BYTES));
|
|
198
|
+
}
|
|
186
199
|
return (0, _neverthrow.ok)({
|
|
187
200
|
result,
|
|
188
|
-
extendedPayloads: (
|
|
201
|
+
extendedPayloads: (0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads,
|
|
189
202
|
session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
|
|
190
203
|
});
|
|
191
204
|
}
|
|
@@ -206,11 +219,10 @@ async function* runApiGenerator({
|
|
|
206
219
|
} catch (error) {
|
|
207
220
|
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
208
221
|
} finally {
|
|
209
|
-
var _context2;
|
|
210
222
|
await saveTraceIfNeeded({
|
|
211
223
|
errorMessage: "failed to save trace"
|
|
212
224
|
});
|
|
213
|
-
await
|
|
225
|
+
await context?.close();
|
|
214
226
|
if (downloadsPath !== undefined) {
|
|
215
227
|
await fs.remove(downloadsPath);
|
|
216
228
|
}
|
|
@@ -25,15 +25,146 @@ export interface RunAutomationResponse {
|
|
|
25
25
|
status: number;
|
|
26
26
|
body: RunAutomationResult;
|
|
27
27
|
}
|
|
28
|
+
export declare const runApiStorageStateSchema: z.ZodObject<{
|
|
29
|
+
cookies: z.ZodArray<z.ZodObject<{
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
value: z.ZodString;
|
|
32
|
+
domain: z.ZodString;
|
|
33
|
+
path: z.ZodString;
|
|
34
|
+
expires: z.ZodNumber;
|
|
35
|
+
httpOnly: z.ZodBoolean;
|
|
36
|
+
secure: z.ZodBoolean;
|
|
37
|
+
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
value: string;
|
|
40
|
+
name: string;
|
|
41
|
+
path: string;
|
|
42
|
+
domain: string;
|
|
43
|
+
expires: number;
|
|
44
|
+
httpOnly: boolean;
|
|
45
|
+
secure: boolean;
|
|
46
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
47
|
+
}, {
|
|
48
|
+
value: string;
|
|
49
|
+
name: string;
|
|
50
|
+
path: string;
|
|
51
|
+
domain: string;
|
|
52
|
+
expires: number;
|
|
53
|
+
httpOnly: boolean;
|
|
54
|
+
secure: boolean;
|
|
55
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
56
|
+
}>, "many">;
|
|
57
|
+
origins: z.ZodArray<z.ZodObject<{
|
|
58
|
+
origin: z.ZodString;
|
|
59
|
+
localStorage: z.ZodArray<z.ZodObject<{
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
value: z.ZodString;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
value: string;
|
|
64
|
+
name: string;
|
|
65
|
+
}, {
|
|
66
|
+
value: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}>, "many">;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
origin: string;
|
|
71
|
+
localStorage: {
|
|
72
|
+
value: string;
|
|
73
|
+
name: string;
|
|
74
|
+
}[];
|
|
75
|
+
}, {
|
|
76
|
+
origin: string;
|
|
77
|
+
localStorage: {
|
|
78
|
+
value: string;
|
|
79
|
+
name: string;
|
|
80
|
+
}[];
|
|
81
|
+
}>, "many">;
|
|
82
|
+
sessionStorage: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
83
|
+
origin: z.ZodString;
|
|
84
|
+
sessionStorage: z.ZodArray<z.ZodObject<{
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
value: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
value: string;
|
|
89
|
+
name: string;
|
|
90
|
+
}, {
|
|
91
|
+
value: string;
|
|
92
|
+
name: string;
|
|
93
|
+
}>, "many">;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
sessionStorage: {
|
|
96
|
+
value: string;
|
|
97
|
+
name: string;
|
|
98
|
+
}[];
|
|
99
|
+
origin: string;
|
|
100
|
+
}, {
|
|
101
|
+
sessionStorage: {
|
|
102
|
+
value: string;
|
|
103
|
+
name: string;
|
|
104
|
+
}[];
|
|
105
|
+
origin: string;
|
|
106
|
+
}>, "many">>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
cookies: {
|
|
109
|
+
value: string;
|
|
110
|
+
name: string;
|
|
111
|
+
path: string;
|
|
112
|
+
domain: string;
|
|
113
|
+
expires: number;
|
|
114
|
+
httpOnly: boolean;
|
|
115
|
+
secure: boolean;
|
|
116
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
117
|
+
}[];
|
|
118
|
+
origins: {
|
|
119
|
+
origin: string;
|
|
120
|
+
localStorage: {
|
|
121
|
+
value: string;
|
|
122
|
+
name: string;
|
|
123
|
+
}[];
|
|
124
|
+
}[];
|
|
125
|
+
sessionStorage?: {
|
|
126
|
+
sessionStorage: {
|
|
127
|
+
value: string;
|
|
128
|
+
name: string;
|
|
129
|
+
}[];
|
|
130
|
+
origin: string;
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
}, {
|
|
133
|
+
cookies: {
|
|
134
|
+
value: string;
|
|
135
|
+
name: string;
|
|
136
|
+
path: string;
|
|
137
|
+
domain: string;
|
|
138
|
+
expires: number;
|
|
139
|
+
httpOnly: boolean;
|
|
140
|
+
secure: boolean;
|
|
141
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
142
|
+
}[];
|
|
143
|
+
origins: {
|
|
144
|
+
origin: string;
|
|
145
|
+
localStorage: {
|
|
146
|
+
value: string;
|
|
147
|
+
name: string;
|
|
148
|
+
}[];
|
|
149
|
+
}[];
|
|
150
|
+
sessionStorage?: {
|
|
151
|
+
sessionStorage: {
|
|
152
|
+
value: string;
|
|
153
|
+
name: string;
|
|
154
|
+
}[];
|
|
155
|
+
origin: string;
|
|
156
|
+
}[] | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
export type RunApiStorageState = z.input<typeof runApiStorageStateSchema>;
|
|
28
159
|
export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
29
160
|
type: z.ZodLiteral<"file">;
|
|
30
161
|
path: z.ZodString;
|
|
31
162
|
}, "strip", z.ZodTypeAny, {
|
|
32
|
-
type: "file";
|
|
33
163
|
path: string;
|
|
34
|
-
}, {
|
|
35
164
|
type: "file";
|
|
165
|
+
}, {
|
|
36
166
|
path: string;
|
|
167
|
+
type: "file";
|
|
37
168
|
}>, z.ZodObject<{
|
|
38
169
|
type: z.ZodLiteral<"state">;
|
|
39
170
|
state: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -255,11 +386,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
255
386
|
type: z.ZodLiteral<"file">;
|
|
256
387
|
path: z.ZodString;
|
|
257
388
|
}, "strip", z.ZodTypeAny, {
|
|
258
|
-
type: "file";
|
|
259
389
|
path: string;
|
|
260
|
-
}, {
|
|
261
390
|
type: "file";
|
|
391
|
+
}, {
|
|
262
392
|
path: string;
|
|
393
|
+
type: "file";
|
|
263
394
|
}>, z.ZodObject<{
|
|
264
395
|
type: z.ZodLiteral<"state">;
|
|
265
396
|
state: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -452,8 +583,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
452
583
|
runCheck: z.ZodDefault<z.ZodBoolean>;
|
|
453
584
|
}, "strip", z.ZodTypeAny, {
|
|
454
585
|
session: {
|
|
455
|
-
type: "file";
|
|
456
586
|
path: string;
|
|
587
|
+
type: "file";
|
|
457
588
|
} | {
|
|
458
589
|
type: "state";
|
|
459
590
|
state?: {
|
|
@@ -486,8 +617,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
486
617
|
runCheck: boolean;
|
|
487
618
|
}, {
|
|
488
619
|
session: {
|
|
489
|
-
type: "file";
|
|
490
620
|
path: string;
|
|
621
|
+
type: "file";
|
|
491
622
|
} | {
|
|
492
623
|
type: "state";
|
|
493
624
|
state?: {
|
|
@@ -592,8 +723,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
592
723
|
retrieveSession: boolean;
|
|
593
724
|
auth?: {
|
|
594
725
|
session: {
|
|
595
|
-
type: "file";
|
|
596
726
|
path: string;
|
|
727
|
+
type: "file";
|
|
597
728
|
} | {
|
|
598
729
|
type: "state";
|
|
599
730
|
state?: {
|
|
@@ -638,8 +769,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
638
769
|
} | undefined;
|
|
639
770
|
auth?: {
|
|
640
771
|
session: {
|
|
641
|
-
type: "file";
|
|
642
772
|
path: string;
|
|
773
|
+
type: "file";
|
|
643
774
|
} | {
|
|
644
775
|
type: "state";
|
|
645
776
|
state?: {
|
|
@@ -703,6 +834,6 @@ export type RunApiResultOk<R = any> = {
|
|
|
703
834
|
extendedPayloads?: Payload[];
|
|
704
835
|
};
|
|
705
836
|
export type RunApiResultWithSessionOk<R = any> = RunApiResultOk<R> & {
|
|
706
|
-
session:
|
|
837
|
+
session: RunApiStorageState;
|
|
707
838
|
};
|
|
708
839
|
export type RunApiResult<R = any, FullResult extends RunApiResultOk<R> = RunApiResultOk<R>> = Result<FullResult, RunAutomationError>;
|
|
@@ -3,40 +3,41 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.runApiSessionSchema = exports.runApiParametersSchema = void 0;
|
|
6
|
+
exports.runApiStorageStateSchema = exports.runApiSessionSchema = exports.runApiParametersSchema = void 0;
|
|
7
7
|
var _zod = _interopRequireDefault(require("zod"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const runApiStorageStateSchema = exports.runApiStorageStateSchema = _zod.default.object({
|
|
10
|
+
cookies: _zod.default.array(_zod.default.object({
|
|
11
|
+
name: _zod.default.string(),
|
|
12
|
+
value: _zod.default.string(),
|
|
13
|
+
domain: _zod.default.string(),
|
|
14
|
+
path: _zod.default.string(),
|
|
15
|
+
expires: _zod.default.number(),
|
|
16
|
+
httpOnly: _zod.default.boolean(),
|
|
17
|
+
secure: _zod.default.boolean(),
|
|
18
|
+
sameSite: _zod.default.enum(["Strict", "Lax", "None"])
|
|
19
|
+
})),
|
|
20
|
+
origins: _zod.default.array(_zod.default.object({
|
|
21
|
+
origin: _zod.default.string(),
|
|
22
|
+
localStorage: _zod.default.array(_zod.default.object({
|
|
23
|
+
name: _zod.default.string(),
|
|
24
|
+
value: _zod.default.string()
|
|
25
|
+
}))
|
|
26
|
+
})),
|
|
27
|
+
sessionStorage: _zod.default.array(_zod.default.object({
|
|
28
|
+
origin: _zod.default.string(),
|
|
29
|
+
sessionStorage: _zod.default.array(_zod.default.object({
|
|
30
|
+
name: _zod.default.string(),
|
|
31
|
+
value: _zod.default.string()
|
|
32
|
+
}))
|
|
33
|
+
})).optional()
|
|
34
|
+
});
|
|
9
35
|
const runApiSessionSchema = exports.runApiSessionSchema = _zod.default.discriminatedUnion("type", [_zod.default.object({
|
|
10
36
|
type: _zod.default.literal("file"),
|
|
11
37
|
path: _zod.default.string()
|
|
12
38
|
}), _zod.default.object({
|
|
13
39
|
type: _zod.default.literal("state"),
|
|
14
|
-
state:
|
|
15
|
-
cookies: _zod.default.array(_zod.default.object({
|
|
16
|
-
name: _zod.default.string(),
|
|
17
|
-
value: _zod.default.string(),
|
|
18
|
-
domain: _zod.default.string(),
|
|
19
|
-
path: _zod.default.string(),
|
|
20
|
-
expires: _zod.default.number(),
|
|
21
|
-
httpOnly: _zod.default.boolean(),
|
|
22
|
-
secure: _zod.default.boolean(),
|
|
23
|
-
sameSite: _zod.default.enum(["Strict", "Lax", "None"])
|
|
24
|
-
})),
|
|
25
|
-
origins: _zod.default.array(_zod.default.object({
|
|
26
|
-
origin: _zod.default.string(),
|
|
27
|
-
localStorage: _zod.default.array(_zod.default.object({
|
|
28
|
-
name: _zod.default.string(),
|
|
29
|
-
value: _zod.default.string()
|
|
30
|
-
}))
|
|
31
|
-
})),
|
|
32
|
-
sessionStorage: _zod.default.array(_zod.default.object({
|
|
33
|
-
origin: _zod.default.string(),
|
|
34
|
-
sessionStorage: _zod.default.array(_zod.default.object({
|
|
35
|
-
name: _zod.default.string(),
|
|
36
|
-
value: _zod.default.string()
|
|
37
|
-
}))
|
|
38
|
-
})).optional()
|
|
39
|
-
}).nullable().optional()
|
|
40
|
+
state: runApiStorageStateSchema.nullable().optional()
|
|
40
41
|
})]);
|
|
41
42
|
const runApiParametersSchema = exports.runApiParametersSchema = _zod.default.object({
|
|
42
43
|
automationFunction: _zod.default.object({
|
|
@@ -24,13 +24,12 @@ var _enums = require("./enums");
|
|
|
24
24
|
runId: "test-run-id",
|
|
25
25
|
extendedPayloads: []
|
|
26
26
|
}, () => {
|
|
27
|
-
|
|
28
|
-
(0, _vitest.expect)((_getExecutionContext = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
|
|
27
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([]);
|
|
29
28
|
(0, _.extendPayload)({
|
|
30
29
|
api: "test-api",
|
|
31
30
|
parameters: {}
|
|
32
31
|
});
|
|
33
|
-
(0, _vitest.expect)((
|
|
32
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([{
|
|
34
33
|
api: "test-api",
|
|
35
34
|
parameters: {}
|
|
36
35
|
}]);
|
|
@@ -47,7 +46,7 @@ var _enums = require("./enums");
|
|
|
47
46
|
parameters: {}
|
|
48
47
|
});
|
|
49
48
|
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
50
|
-
(0, _vitest.expect)(context
|
|
49
|
+
(0, _vitest.expect)(context?.extendedPayloads).toHaveLength(4);
|
|
51
50
|
});
|
|
52
51
|
});
|
|
53
52
|
});
|
package/dist/runtime/export.d.ts
CHANGED
|
@@ -201,3 +201,18 @@ export declare function requestMultipleChoice(
|
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
203
|
export declare function requestOTP(message: string): unknown;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves the parameters for the authentication session currently being used.
|
|
207
|
+
*
|
|
208
|
+
* @returns {AuthSessionParameters} An object containing the parameters for the current authentication session.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript getAuthSessionParameters
|
|
212
|
+
* import { getAuthSessionParameters } from "@intuned/sdk/runtime"
|
|
213
|
+
*
|
|
214
|
+
* const authSessionParams = getAuthSessionParameters();
|
|
215
|
+
* console.log(authSessionParams);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -16,6 +16,6 @@ function extendPayload(payload) {
|
|
|
16
16
|
context.extendedPayloads = [...items];
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
context
|
|
19
|
+
context?.extendedPayloads.push(...items);
|
|
20
20
|
(0, _extendTimeout.extendTimeout)();
|
|
21
21
|
}
|