@intuned/runtime-dev 1.3.32 → 1.3.33
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# UNRELEASED
|
|
2
2
|
|
|
3
|
+
- `persistentStore` now works in runs without a project id by falling back to the workspace-scoped kv-store endpoint
|
|
4
|
+
|
|
5
|
+
# 1.3.32
|
|
6
|
+
|
|
7
|
+
- add support for `__INTUNED__MAX_RESULT_SIZE_BYTES` env var to limit the size of the run result payload sent to the backend;
|
|
8
|
+
|
|
9
|
+
# 1.3.31
|
|
10
|
+
|
|
3
11
|
- add Math captcha auto-solver via LLM image recognition (image-based arithmetic captchas configured by CSS selectors)
|
|
4
12
|
- add Temu captcha auto-solver via SadCaptcha API (semantic shapes challenge type)
|
|
5
13
|
|
|
@@ -11,7 +11,12 @@ declare class JwtTokenManager {
|
|
|
11
11
|
private refreshToken;
|
|
12
12
|
fetchWithToken(...[input, init]: Parameters<typeof fetch>): Promise<Response>;
|
|
13
13
|
get backendFunctionsBaseUrl(): string | undefined;
|
|
14
|
+
getBackendFunctionsBaseUrl(options?: {
|
|
15
|
+
allowMissingProjectId?: boolean;
|
|
16
|
+
}): string | undefined;
|
|
14
17
|
}
|
|
15
18
|
export declare const backendFunctionsTokenManager: JwtTokenManager;
|
|
16
|
-
export declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1]
|
|
19
|
+
export declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1], options?: {
|
|
20
|
+
allowMissingProjectId?: boolean;
|
|
21
|
+
}): Promise<Response>;
|
|
17
22
|
export {};
|
|
@@ -85,6 +85,9 @@ class JwtTokenManager {
|
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
87
|
get backendFunctionsBaseUrl() {
|
|
88
|
+
return this.getBackendFunctionsBaseUrl();
|
|
89
|
+
}
|
|
90
|
+
getBackendFunctionsBaseUrl(options) {
|
|
88
91
|
try {
|
|
89
92
|
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
90
93
|
throw new Error(`Cannot call backend function - FUNCTIONS_DOMAIN not set`);
|
|
@@ -94,10 +97,13 @@ class JwtTokenManager {
|
|
|
94
97
|
throw new Error(`Cannot call backend function - ${_constants.WORKSPACE_ID_ENV_VAR_KEY} not set`);
|
|
95
98
|
}
|
|
96
99
|
const workspaceId = process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
|
|
97
|
-
|
|
100
|
+
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY];
|
|
101
|
+
if (!projectId) {
|
|
102
|
+
if (options?.allowMissingProjectId) {
|
|
103
|
+
return `${domain}/api/${workspaceId}/functions`;
|
|
104
|
+
}
|
|
98
105
|
throw new Error(`Cannot call backend function - ${_constants.PROJECT_ID_ENV_VAR_KEY} or INTUNED_INTEGRATION_ID not set`);
|
|
99
106
|
}
|
|
100
|
-
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY];
|
|
101
107
|
return `${domain}/api/${workspaceId}/functions/${projectId}`;
|
|
102
108
|
} catch (e) {
|
|
103
109
|
if (process.env[_constants.CLI_ENV_VAR_KEY] === "true") {
|
|
@@ -108,6 +114,6 @@ class JwtTokenManager {
|
|
|
108
114
|
}
|
|
109
115
|
const backendFunctionsTokenManager = exports.backendFunctionsTokenManager = new JwtTokenManager(`refreshBackendFunctionsToken`);
|
|
110
116
|
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
111
|
-
function callBackendFunctionWithToken(path, init) {
|
|
112
|
-
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsTokenManager.
|
|
117
|
+
function callBackendFunctionWithToken(path, init, options) {
|
|
118
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsTokenManager.getBackendFunctionsBaseUrl(options)}/${path}`, init);
|
|
113
119
|
}
|
|
@@ -17,6 +17,7 @@ var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
|
17
17
|
var _importUsingImportFunction = require("./importUsingImportFunction");
|
|
18
18
|
var _runtimeInterface = require("../../vendor/runtime-interface");
|
|
19
19
|
var _contextStorageStateHelpers = require("../contextStorageStateHelpers");
|
|
20
|
+
var _zod = require("zod");
|
|
20
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
21
22
|
function getObjectSizeInBytes(obj) {
|
|
22
23
|
try {
|
|
@@ -27,16 +28,9 @@ function getObjectSizeInBytes(obj) {
|
|
|
27
28
|
}
|
|
28
29
|
const DEFAULT_MAX_RESULT_SIZE_BYTES = 2 * 1024 * 1024;
|
|
29
30
|
const MAX_RESULT_SIZE_BYTES_ENV_VAR = "__INTUNED__MAX_RESULT_SIZE_BYTES";
|
|
31
|
+
const maxResultSizeBytesSchema = _zod.z.coerce.number().positive().finite().transform(Math.floor).catch(DEFAULT_MAX_RESULT_SIZE_BYTES);
|
|
30
32
|
function getMaxResultSizeBytes() {
|
|
31
|
-
|
|
32
|
-
if (!raw) {
|
|
33
|
-
return DEFAULT_MAX_RESULT_SIZE_BYTES;
|
|
34
|
-
}
|
|
35
|
-
const parsed = Number(raw);
|
|
36
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
37
|
-
return DEFAULT_MAX_RESULT_SIZE_BYTES;
|
|
38
|
-
}
|
|
39
|
-
return Math.floor(parsed);
|
|
33
|
+
return maxResultSizeBytesSchema.parse(process.env[MAX_RESULT_SIZE_BYTES_ENV_VAR]);
|
|
40
34
|
}
|
|
41
35
|
async function runApi({
|
|
42
36
|
abortSignal,
|
|
@@ -13,6 +13,8 @@ const persistentStore = exports.persistentStore = Object.freeze({
|
|
|
13
13
|
const parsedKey = keySchema.parse(key);
|
|
14
14
|
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`kv-store/${parsedKey}`, {
|
|
15
15
|
method: "GET"
|
|
16
|
+
}, {
|
|
17
|
+
allowMissingProjectId: true
|
|
16
18
|
});
|
|
17
19
|
const json = await response.json();
|
|
18
20
|
if (!response.ok) {
|
|
@@ -28,6 +30,8 @@ const persistentStore = exports.persistentStore = Object.freeze({
|
|
|
28
30
|
headers: {
|
|
29
31
|
"Content-Type": "application/json"
|
|
30
32
|
}
|
|
33
|
+
}, {
|
|
34
|
+
allowMissingProjectId: true
|
|
31
35
|
});
|
|
32
36
|
const json = await response.json();
|
|
33
37
|
if (!response.ok) {
|
|
@@ -24,6 +24,8 @@ _vitest.vi.mock("../common/jwtTokenManager", () => ({
|
|
|
24
24
|
(0, _vitest.expect)(result).toBe("cached_data");
|
|
25
25
|
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
26
26
|
method: "GET"
|
|
27
|
+
}, {
|
|
28
|
+
allowMissingProjectId: true
|
|
27
29
|
});
|
|
28
30
|
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
29
31
|
});
|
|
@@ -64,6 +66,8 @@ _vitest.vi.mock("../common/jwtTokenManager", () => ({
|
|
|
64
66
|
headers: {
|
|
65
67
|
"Content-Type": "application/json"
|
|
66
68
|
}
|
|
69
|
+
}, {
|
|
70
|
+
allowMissingProjectId: true
|
|
67
71
|
});
|
|
68
72
|
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
69
73
|
});
|