@intuned/runtime-dev 1.3.12-ua.6 → 1.3.13-ai-ootb.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/bin/intuned-get-headless-user-agent +0 -0
- package/dist/commands/get-headless-user-agent.js +3 -1
- package/dist/commands/intuned-cli/controller/authSession.d.ts +12 -12
- package/dist/commands/intuned-cli/helpers/auth.d.ts +2 -2
- package/dist/common/constants.d.ts +2 -0
- package/dist/common/constants.js +4 -2
- package/dist/common/launchBrowser.d.ts +1 -0
- package/dist/common/launchBrowser.js +12 -25
- package/dist/common/runApi/index.js +6 -0
- package/dist/common/runApi/types.d.ts +40 -40
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/runtime/attemptStore.d.ts +2 -2
- package/dist/runtime/export.d.ts +69 -13
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/persistentStore.d.ts +2 -0
- package/dist/runtime/{store.js → persistentStore.js} +8 -9
- package/dist/runtime/persistentStore.test.js +101 -0
- package/package.json +1 -1
- package/WebTemplate.zip +0 -0
- package/dist/runtime/store.d.ts +0 -6
|
File without changes
|
|
@@ -7,7 +7,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
_dotenv.default.config();
|
|
8
8
|
_commander.program.description("get headless user agent").action(async () => {
|
|
9
9
|
try {
|
|
10
|
-
console.log(await (0, _launchBrowser.getHeadlessUserAgent)({
|
|
10
|
+
console.log(await (0, _launchBrowser.getHeadlessUserAgent)({
|
|
11
|
+
executablePath: await (0, _launchBrowser.getBrowserExecutablePath)()
|
|
12
|
+
}));
|
|
11
13
|
} catch (error) {
|
|
12
14
|
console.error("Error getting headless user agent:", error);
|
|
13
15
|
process.exit(1);
|
|
@@ -16,9 +16,9 @@ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries
|
|
|
16
16
|
metadata?: AuthSessionMetadata;
|
|
17
17
|
} & BaseCommandOptions): Promise<{
|
|
18
18
|
cookies: {
|
|
19
|
+
path: string;
|
|
19
20
|
value: string;
|
|
20
21
|
name: string;
|
|
21
|
-
path: string;
|
|
22
22
|
domain: string;
|
|
23
23
|
expires: number;
|
|
24
24
|
httpOnly: boolean;
|
|
@@ -33,11 +33,11 @@ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries
|
|
|
33
33
|
}[];
|
|
34
34
|
}[];
|
|
35
35
|
sessionStorage?: {
|
|
36
|
+
origin: string;
|
|
36
37
|
sessionStorage: {
|
|
37
38
|
value: string;
|
|
38
39
|
name: string;
|
|
39
40
|
}[];
|
|
40
|
-
origin: string;
|
|
41
41
|
}[] | undefined;
|
|
42
42
|
}>;
|
|
43
43
|
export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries, createRetries, ...rest }: {
|
|
@@ -47,9 +47,9 @@ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries
|
|
|
47
47
|
createRetries: number;
|
|
48
48
|
} & BaseCommandOptions): Promise<{
|
|
49
49
|
cookies: {
|
|
50
|
+
path: string;
|
|
50
51
|
value: string;
|
|
51
52
|
name: string;
|
|
52
|
-
path: string;
|
|
53
53
|
domain: string;
|
|
54
54
|
expires: number;
|
|
55
55
|
httpOnly: boolean;
|
|
@@ -64,11 +64,11 @@ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries
|
|
|
64
64
|
}[];
|
|
65
65
|
}[];
|
|
66
66
|
sessionStorage?: {
|
|
67
|
+
origin: string;
|
|
67
68
|
sessionStorage: {
|
|
68
69
|
value: string;
|
|
69
70
|
name: string;
|
|
70
71
|
}[];
|
|
71
|
-
origin: string;
|
|
72
72
|
}[] | undefined;
|
|
73
73
|
}>;
|
|
74
74
|
export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest }: {
|
|
@@ -76,9 +76,9 @@ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest
|
|
|
76
76
|
input: any;
|
|
77
77
|
} & BaseCommandOptions): Promise<{
|
|
78
78
|
cookies: {
|
|
79
|
+
path: string;
|
|
79
80
|
value: string;
|
|
80
81
|
name: string;
|
|
81
|
-
path: string;
|
|
82
82
|
domain: string;
|
|
83
83
|
expires: number;
|
|
84
84
|
httpOnly: boolean;
|
|
@@ -93,20 +93,20 @@ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest
|
|
|
93
93
|
}[];
|
|
94
94
|
}[];
|
|
95
95
|
sessionStorage?: {
|
|
96
|
+
origin: string;
|
|
96
97
|
sessionStorage: {
|
|
97
98
|
value: string;
|
|
98
99
|
name: string;
|
|
99
100
|
}[];
|
|
100
|
-
origin: string;
|
|
101
101
|
}[] | undefined;
|
|
102
102
|
}>;
|
|
103
103
|
export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
|
|
104
104
|
id: string;
|
|
105
105
|
} & BaseCommandOptions): Promise<{
|
|
106
106
|
cookies: {
|
|
107
|
+
path: string;
|
|
107
108
|
value: string;
|
|
108
109
|
name: string;
|
|
109
|
-
path: string;
|
|
110
110
|
domain: string;
|
|
111
111
|
expires: number;
|
|
112
112
|
httpOnly: boolean;
|
|
@@ -121,11 +121,11 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
|
|
|
121
121
|
}[];
|
|
122
122
|
}[];
|
|
123
123
|
sessionStorage?: {
|
|
124
|
+
origin: string;
|
|
124
125
|
sessionStorage: {
|
|
125
126
|
value: string;
|
|
126
127
|
name: string;
|
|
127
128
|
}[];
|
|
128
|
-
origin: string;
|
|
129
129
|
}[] | undefined;
|
|
130
130
|
}>;
|
|
131
131
|
declare function runCheck({ auth, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
|
|
@@ -138,9 +138,9 @@ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId
|
|
|
138
138
|
traceId?: string;
|
|
139
139
|
} & Omit<BaseCommandOptions, "trace">): Promise<{
|
|
140
140
|
cookies: {
|
|
141
|
+
path: string;
|
|
141
142
|
value: string;
|
|
142
143
|
name: string;
|
|
143
|
-
path: string;
|
|
144
144
|
domain: string;
|
|
145
145
|
expires: number;
|
|
146
146
|
httpOnly: boolean;
|
|
@@ -155,11 +155,11 @@ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId
|
|
|
155
155
|
}[];
|
|
156
156
|
}[];
|
|
157
157
|
sessionStorage?: {
|
|
158
|
+
origin: string;
|
|
158
159
|
sessionStorage: {
|
|
159
160
|
value: string;
|
|
160
161
|
name: string;
|
|
161
162
|
}[];
|
|
162
|
-
origin: string;
|
|
163
163
|
}[] | undefined;
|
|
164
164
|
}>;
|
|
165
165
|
export declare const _runCreate: typeof runCreate;
|
|
@@ -175,9 +175,9 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
|
|
|
175
175
|
metadata?: AuthSessionMetadata;
|
|
176
176
|
} & BaseCommandOptions): Promise<{
|
|
177
177
|
cookies: {
|
|
178
|
+
path: string;
|
|
178
179
|
value: string;
|
|
179
180
|
name: string;
|
|
180
|
-
path: string;
|
|
181
181
|
domain: string;
|
|
182
182
|
expires: number;
|
|
183
183
|
httpOnly: boolean;
|
|
@@ -192,11 +192,11 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
|
|
|
192
192
|
}[];
|
|
193
193
|
}[];
|
|
194
194
|
sessionStorage?: {
|
|
195
|
+
origin: string;
|
|
195
196
|
sessionStorage: {
|
|
196
197
|
value: string;
|
|
197
198
|
name: string;
|
|
198
199
|
}[];
|
|
199
|
-
origin: string;
|
|
200
200
|
}[] | undefined;
|
|
201
201
|
}>;
|
|
202
202
|
export declare const _runCreateWithRetries: typeof runCreateWithRetries;
|
|
@@ -6,9 +6,9 @@ export declare function assertAuthConsistent(authSession: string | undefined): P
|
|
|
6
6
|
export declare function loadAuthSessionInstance(authSessionId: string): Promise<{
|
|
7
7
|
storageState: {
|
|
8
8
|
cookies: {
|
|
9
|
+
path: string;
|
|
9
10
|
value: string;
|
|
10
11
|
name: string;
|
|
11
|
-
path: string;
|
|
12
12
|
domain: string;
|
|
13
13
|
expires: number;
|
|
14
14
|
httpOnly: boolean;
|
|
@@ -23,11 +23,11 @@ export declare function loadAuthSessionInstance(authSessionId: string): Promise<
|
|
|
23
23
|
}[];
|
|
24
24
|
}[];
|
|
25
25
|
sessionStorage?: {
|
|
26
|
+
origin: string;
|
|
26
27
|
sessionStorage: {
|
|
27
28
|
value: string;
|
|
28
29
|
name: string;
|
|
29
30
|
}[];
|
|
30
|
-
origin: string;
|
|
31
31
|
}[] | undefined;
|
|
32
32
|
};
|
|
33
33
|
metadata: AuthSessionMetadata;
|
|
@@ -8,3 +8,5 @@ export declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
|
8
8
|
export declare const API_KEY_HEADER_NAME = "x-api-key";
|
|
9
9
|
export declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
10
10
|
export declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
11
|
+
export declare const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
|
|
12
|
+
export declare const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
|
package/dist/common/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.EXTENSION_PATH_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_KEY_HEADER_NAME = exports.API_KEY_ENV_VAR_KEY = exports.API_FOLDER_NAME = exports.API_BASE_URL_ENV_VAR_KEY = void 0;
|
|
6
|
+
exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = exports.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = exports.EXTENSION_PATH_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_KEY_HEADER_NAME = exports.API_KEY_ENV_VAR_KEY = exports.API_FOLDER_NAME = exports.API_BASE_URL_ENV_VAR_KEY = void 0;
|
|
7
7
|
const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
|
|
8
8
|
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
9
9
|
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
@@ -13,4 +13,6 @@ const PROJECT_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT
|
|
|
13
13
|
const API_KEY_ENV_VAR_KEY = exports.API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
14
14
|
const API_KEY_HEADER_NAME = exports.API_KEY_HEADER_NAME = "x-api-key";
|
|
15
15
|
const API_BASE_URL_ENV_VAR_KEY = exports.API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
16
|
-
const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
16
|
+
const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
17
|
+
const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = exports.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
|
|
18
|
+
const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = exports.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
|
|
@@ -21,6 +21,7 @@ export type LaunchChromiumCdpOptions = {
|
|
|
21
21
|
};
|
|
22
22
|
export declare function launchChromium(options: LaunchChromiumStandaloneOptions): Promise<LaunchBrowserResult>;
|
|
23
23
|
export declare function launchChromium(options: LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
24
|
+
export declare function getBrowserExecutablePath(): Promise<string | undefined>;
|
|
24
25
|
export declare function launchBrowser(options: Omit<LaunchChromiumStandaloneOptions, "executablePath"> | LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
25
26
|
export declare function getLocalCdpAddress(port: number): string;
|
|
26
27
|
export declare function getHeadlessUserAgent({ executablePath, args, ignoreDefaultArgs, }: {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getBrowserExecutablePath = getBrowserExecutablePath;
|
|
6
7
|
exports.getHeadlessUserAgent = getHeadlessUserAgent;
|
|
7
8
|
exports.getLocalCdpAddress = getLocalCdpAddress;
|
|
8
9
|
exports.launchBrowser = launchBrowser;
|
|
@@ -88,7 +89,7 @@ async function launchChromium(options) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
const viewport = null;
|
|
91
|
-
const userAgent = process.env.
|
|
92
|
+
const userAgent = process.env.__PLAYWRIGHT_USER_AGENT_OVERRIDE ?? (await getHeadlessUserAgent({
|
|
92
93
|
executablePath
|
|
93
94
|
}));
|
|
94
95
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
@@ -126,25 +127,20 @@ async function launchChromium(options) {
|
|
|
126
127
|
context
|
|
127
128
|
};
|
|
128
129
|
}
|
|
130
|
+
async function getBrowserExecutablePath() {
|
|
131
|
+
const browserType = getBrowserType();
|
|
132
|
+
if (browserType === "brave") {
|
|
133
|
+
return await getBraveExecutablePath();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
129
136
|
async function launchBrowser(options) {
|
|
130
137
|
if ("cdpAddress" in options) {
|
|
131
138
|
return launchChromium(options);
|
|
132
139
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return launchChromium(options);
|
|
138
|
-
}
|
|
139
|
-
case "brave":
|
|
140
|
-
{
|
|
141
|
-
const braveExecutablePath = await getBraveExecutablePath();
|
|
142
|
-
return launchChromium({
|
|
143
|
-
...options,
|
|
144
|
-
executablePath: braveExecutablePath
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
140
|
+
return launchChromium({
|
|
141
|
+
...options,
|
|
142
|
+
executablePath: await getBrowserExecutablePath()
|
|
143
|
+
});
|
|
148
144
|
}
|
|
149
145
|
function getBrowserType() {
|
|
150
146
|
if (process.env.BROWSER_TYPE === "brave") {
|
|
@@ -181,15 +177,6 @@ async function getHeadlessUserAgent({
|
|
|
181
177
|
args,
|
|
182
178
|
ignoreDefaultArgs
|
|
183
179
|
}) {
|
|
184
|
-
if (!executablePath) {
|
|
185
|
-
const browserType = getBrowserType();
|
|
186
|
-
if (browserType === "brave") {
|
|
187
|
-
const braveExecutablePath = await getBraveExecutablePath();
|
|
188
|
-
if (await fs.exists(braveExecutablePath)) {
|
|
189
|
-
executablePath = braveExecutablePath;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
180
|
const browser = await playwright.chromium.launch({
|
|
194
181
|
headless: true,
|
|
195
182
|
executablePath,
|
|
@@ -44,6 +44,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
44
44
|
var _formatZodError = require("../formatZodError");
|
|
45
45
|
var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
46
46
|
var _importUsingImportFunction = require("./importUsingImportFunction");
|
|
47
|
+
var _jwtTokenManager = require("../jwtTokenManager");
|
|
47
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); }
|
|
48
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; }
|
|
49
50
|
function getObjectSizeInBytes(obj) {
|
|
@@ -53,6 +54,10 @@ function getObjectSizeInBytes(obj) {
|
|
|
53
54
|
return new TextEncoder().encode(String(obj)).length;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
function injectRuntimeEnvVars() {
|
|
58
|
+
process.env[_constants.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR] = `${_jwtTokenManager.backendFunctionsTokenManager.backendFunctionsBaseUrl}/intuned-ai-gateway`;
|
|
59
|
+
process.env[_constants.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR] = _jwtTokenManager.backendFunctionsTokenManager.token ?? process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
60
|
+
}
|
|
56
61
|
async function runApi({
|
|
57
62
|
abortSignal,
|
|
58
63
|
importFunction,
|
|
@@ -80,6 +85,7 @@ async function runApi({
|
|
|
80
85
|
resolve(abortSymbol);
|
|
81
86
|
});
|
|
82
87
|
});
|
|
88
|
+
injectRuntimeEnvVars();
|
|
83
89
|
async function runAutomation() {
|
|
84
90
|
const validatedModuleResult = await (0, _importUsingImportFunction.importUsingImportFunction)({
|
|
85
91
|
path: name,
|
|
@@ -36,18 +36,18 @@ export declare const runApiStorageStateSchema: z.ZodObject<{
|
|
|
36
36
|
secure: z.ZodBoolean;
|
|
37
37
|
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
38
38
|
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
path: string;
|
|
39
40
|
value: string;
|
|
40
41
|
name: string;
|
|
41
|
-
path: string;
|
|
42
42
|
domain: string;
|
|
43
43
|
expires: number;
|
|
44
44
|
httpOnly: boolean;
|
|
45
45
|
secure: boolean;
|
|
46
46
|
sameSite: "Strict" | "Lax" | "None";
|
|
47
47
|
}, {
|
|
48
|
+
path: string;
|
|
48
49
|
value: string;
|
|
49
50
|
name: string;
|
|
50
|
-
path: string;
|
|
51
51
|
domain: string;
|
|
52
52
|
expires: number;
|
|
53
53
|
httpOnly: boolean;
|
|
@@ -92,23 +92,23 @@ export declare const runApiStorageStateSchema: z.ZodObject<{
|
|
|
92
92
|
name: string;
|
|
93
93
|
}>, "many">;
|
|
94
94
|
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
origin: string;
|
|
95
96
|
sessionStorage: {
|
|
96
97
|
value: string;
|
|
97
98
|
name: string;
|
|
98
99
|
}[];
|
|
99
|
-
origin: string;
|
|
100
100
|
}, {
|
|
101
|
+
origin: string;
|
|
101
102
|
sessionStorage: {
|
|
102
103
|
value: string;
|
|
103
104
|
name: string;
|
|
104
105
|
}[];
|
|
105
|
-
origin: string;
|
|
106
106
|
}>, "many">>;
|
|
107
107
|
}, "strip", z.ZodTypeAny, {
|
|
108
108
|
cookies: {
|
|
109
|
+
path: string;
|
|
109
110
|
value: string;
|
|
110
111
|
name: string;
|
|
111
|
-
path: string;
|
|
112
112
|
domain: string;
|
|
113
113
|
expires: number;
|
|
114
114
|
httpOnly: boolean;
|
|
@@ -123,17 +123,17 @@ export declare const runApiStorageStateSchema: z.ZodObject<{
|
|
|
123
123
|
}[];
|
|
124
124
|
}[];
|
|
125
125
|
sessionStorage?: {
|
|
126
|
+
origin: string;
|
|
126
127
|
sessionStorage: {
|
|
127
128
|
value: string;
|
|
128
129
|
name: string;
|
|
129
130
|
}[];
|
|
130
|
-
origin: string;
|
|
131
131
|
}[] | undefined;
|
|
132
132
|
}, {
|
|
133
133
|
cookies: {
|
|
134
|
+
path: string;
|
|
134
135
|
value: string;
|
|
135
136
|
name: string;
|
|
136
|
-
path: string;
|
|
137
137
|
domain: string;
|
|
138
138
|
expires: number;
|
|
139
139
|
httpOnly: boolean;
|
|
@@ -148,11 +148,11 @@ export declare const runApiStorageStateSchema: z.ZodObject<{
|
|
|
148
148
|
}[];
|
|
149
149
|
}[];
|
|
150
150
|
sessionStorage?: {
|
|
151
|
+
origin: string;
|
|
151
152
|
sessionStorage: {
|
|
152
153
|
value: string;
|
|
153
154
|
name: string;
|
|
154
155
|
}[];
|
|
155
|
-
origin: string;
|
|
156
156
|
}[] | undefined;
|
|
157
157
|
}>;
|
|
158
158
|
export type RunApiStorageState = z.input<typeof runApiStorageStateSchema>;
|
|
@@ -178,18 +178,18 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
178
178
|
secure: z.ZodBoolean;
|
|
179
179
|
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
180
180
|
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
path: string;
|
|
181
182
|
value: string;
|
|
182
183
|
name: string;
|
|
183
|
-
path: string;
|
|
184
184
|
domain: string;
|
|
185
185
|
expires: number;
|
|
186
186
|
httpOnly: boolean;
|
|
187
187
|
secure: boolean;
|
|
188
188
|
sameSite: "Strict" | "Lax" | "None";
|
|
189
189
|
}, {
|
|
190
|
+
path: string;
|
|
190
191
|
value: string;
|
|
191
192
|
name: string;
|
|
192
|
-
path: string;
|
|
193
193
|
domain: string;
|
|
194
194
|
expires: number;
|
|
195
195
|
httpOnly: boolean;
|
|
@@ -234,23 +234,23 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
234
234
|
name: string;
|
|
235
235
|
}>, "many">;
|
|
236
236
|
}, "strip", z.ZodTypeAny, {
|
|
237
|
+
origin: string;
|
|
237
238
|
sessionStorage: {
|
|
238
239
|
value: string;
|
|
239
240
|
name: string;
|
|
240
241
|
}[];
|
|
241
|
-
origin: string;
|
|
242
242
|
}, {
|
|
243
|
+
origin: string;
|
|
243
244
|
sessionStorage: {
|
|
244
245
|
value: string;
|
|
245
246
|
name: string;
|
|
246
247
|
}[];
|
|
247
|
-
origin: string;
|
|
248
248
|
}>, "many">>;
|
|
249
249
|
}, "strip", z.ZodTypeAny, {
|
|
250
250
|
cookies: {
|
|
251
|
+
path: string;
|
|
251
252
|
value: string;
|
|
252
253
|
name: string;
|
|
253
|
-
path: string;
|
|
254
254
|
domain: string;
|
|
255
255
|
expires: number;
|
|
256
256
|
httpOnly: boolean;
|
|
@@ -265,17 +265,17 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
265
265
|
}[];
|
|
266
266
|
}[];
|
|
267
267
|
sessionStorage?: {
|
|
268
|
+
origin: string;
|
|
268
269
|
sessionStorage: {
|
|
269
270
|
value: string;
|
|
270
271
|
name: string;
|
|
271
272
|
}[];
|
|
272
|
-
origin: string;
|
|
273
273
|
}[] | undefined;
|
|
274
274
|
}, {
|
|
275
275
|
cookies: {
|
|
276
|
+
path: string;
|
|
276
277
|
value: string;
|
|
277
278
|
name: string;
|
|
278
|
-
path: string;
|
|
279
279
|
domain: string;
|
|
280
280
|
expires: number;
|
|
281
281
|
httpOnly: boolean;
|
|
@@ -290,20 +290,20 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
290
290
|
}[];
|
|
291
291
|
}[];
|
|
292
292
|
sessionStorage?: {
|
|
293
|
+
origin: string;
|
|
293
294
|
sessionStorage: {
|
|
294
295
|
value: string;
|
|
295
296
|
name: string;
|
|
296
297
|
}[];
|
|
297
|
-
origin: string;
|
|
298
298
|
}[] | undefined;
|
|
299
299
|
}>>>;
|
|
300
300
|
}, "strip", z.ZodTypeAny, {
|
|
301
301
|
type: "state";
|
|
302
302
|
state?: {
|
|
303
303
|
cookies: {
|
|
304
|
+
path: string;
|
|
304
305
|
value: string;
|
|
305
306
|
name: string;
|
|
306
|
-
path: string;
|
|
307
307
|
domain: string;
|
|
308
308
|
expires: number;
|
|
309
309
|
httpOnly: boolean;
|
|
@@ -318,20 +318,20 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
318
318
|
}[];
|
|
319
319
|
}[];
|
|
320
320
|
sessionStorage?: {
|
|
321
|
+
origin: string;
|
|
321
322
|
sessionStorage: {
|
|
322
323
|
value: string;
|
|
323
324
|
name: string;
|
|
324
325
|
}[];
|
|
325
|
-
origin: string;
|
|
326
326
|
}[] | undefined;
|
|
327
327
|
} | null | undefined;
|
|
328
328
|
}, {
|
|
329
329
|
type: "state";
|
|
330
330
|
state?: {
|
|
331
331
|
cookies: {
|
|
332
|
+
path: string;
|
|
332
333
|
value: string;
|
|
333
334
|
name: string;
|
|
334
|
-
path: string;
|
|
335
335
|
domain: string;
|
|
336
336
|
expires: number;
|
|
337
337
|
httpOnly: boolean;
|
|
@@ -346,11 +346,11 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
346
346
|
}[];
|
|
347
347
|
}[];
|
|
348
348
|
sessionStorage?: {
|
|
349
|
+
origin: string;
|
|
349
350
|
sessionStorage: {
|
|
350
351
|
value: string;
|
|
351
352
|
name: string;
|
|
352
353
|
}[];
|
|
353
|
-
origin: string;
|
|
354
354
|
}[] | undefined;
|
|
355
355
|
} | null | undefined;
|
|
356
356
|
}>]>;
|
|
@@ -404,18 +404,18 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
404
404
|
secure: z.ZodBoolean;
|
|
405
405
|
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
406
406
|
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
path: string;
|
|
407
408
|
value: string;
|
|
408
409
|
name: string;
|
|
409
|
-
path: string;
|
|
410
410
|
domain: string;
|
|
411
411
|
expires: number;
|
|
412
412
|
httpOnly: boolean;
|
|
413
413
|
secure: boolean;
|
|
414
414
|
sameSite: "Strict" | "Lax" | "None";
|
|
415
415
|
}, {
|
|
416
|
+
path: string;
|
|
416
417
|
value: string;
|
|
417
418
|
name: string;
|
|
418
|
-
path: string;
|
|
419
419
|
domain: string;
|
|
420
420
|
expires: number;
|
|
421
421
|
httpOnly: boolean;
|
|
@@ -460,23 +460,23 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
460
460
|
name: string;
|
|
461
461
|
}>, "many">;
|
|
462
462
|
}, "strip", z.ZodTypeAny, {
|
|
463
|
+
origin: string;
|
|
463
464
|
sessionStorage: {
|
|
464
465
|
value: string;
|
|
465
466
|
name: string;
|
|
466
467
|
}[];
|
|
467
|
-
origin: string;
|
|
468
468
|
}, {
|
|
469
|
+
origin: string;
|
|
469
470
|
sessionStorage: {
|
|
470
471
|
value: string;
|
|
471
472
|
name: string;
|
|
472
473
|
}[];
|
|
473
|
-
origin: string;
|
|
474
474
|
}>, "many">>;
|
|
475
475
|
}, "strip", z.ZodTypeAny, {
|
|
476
476
|
cookies: {
|
|
477
|
+
path: string;
|
|
477
478
|
value: string;
|
|
478
479
|
name: string;
|
|
479
|
-
path: string;
|
|
480
480
|
domain: string;
|
|
481
481
|
expires: number;
|
|
482
482
|
httpOnly: boolean;
|
|
@@ -491,17 +491,17 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
491
491
|
}[];
|
|
492
492
|
}[];
|
|
493
493
|
sessionStorage?: {
|
|
494
|
+
origin: string;
|
|
494
495
|
sessionStorage: {
|
|
495
496
|
value: string;
|
|
496
497
|
name: string;
|
|
497
498
|
}[];
|
|
498
|
-
origin: string;
|
|
499
499
|
}[] | undefined;
|
|
500
500
|
}, {
|
|
501
501
|
cookies: {
|
|
502
|
+
path: string;
|
|
502
503
|
value: string;
|
|
503
504
|
name: string;
|
|
504
|
-
path: string;
|
|
505
505
|
domain: string;
|
|
506
506
|
expires: number;
|
|
507
507
|
httpOnly: boolean;
|
|
@@ -516,20 +516,20 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
516
516
|
}[];
|
|
517
517
|
}[];
|
|
518
518
|
sessionStorage?: {
|
|
519
|
+
origin: string;
|
|
519
520
|
sessionStorage: {
|
|
520
521
|
value: string;
|
|
521
522
|
name: string;
|
|
522
523
|
}[];
|
|
523
|
-
origin: string;
|
|
524
524
|
}[] | undefined;
|
|
525
525
|
}>>>;
|
|
526
526
|
}, "strip", z.ZodTypeAny, {
|
|
527
527
|
type: "state";
|
|
528
528
|
state?: {
|
|
529
529
|
cookies: {
|
|
530
|
+
path: string;
|
|
530
531
|
value: string;
|
|
531
532
|
name: string;
|
|
532
|
-
path: string;
|
|
533
533
|
domain: string;
|
|
534
534
|
expires: number;
|
|
535
535
|
httpOnly: boolean;
|
|
@@ -544,20 +544,20 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
544
544
|
}[];
|
|
545
545
|
}[];
|
|
546
546
|
sessionStorage?: {
|
|
547
|
+
origin: string;
|
|
547
548
|
sessionStorage: {
|
|
548
549
|
value: string;
|
|
549
550
|
name: string;
|
|
550
551
|
}[];
|
|
551
|
-
origin: string;
|
|
552
552
|
}[] | undefined;
|
|
553
553
|
} | null | undefined;
|
|
554
554
|
}, {
|
|
555
555
|
type: "state";
|
|
556
556
|
state?: {
|
|
557
557
|
cookies: {
|
|
558
|
+
path: string;
|
|
558
559
|
value: string;
|
|
559
560
|
name: string;
|
|
560
|
-
path: string;
|
|
561
561
|
domain: string;
|
|
562
562
|
expires: number;
|
|
563
563
|
httpOnly: boolean;
|
|
@@ -572,11 +572,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
572
572
|
}[];
|
|
573
573
|
}[];
|
|
574
574
|
sessionStorage?: {
|
|
575
|
+
origin: string;
|
|
575
576
|
sessionStorage: {
|
|
576
577
|
value: string;
|
|
577
578
|
name: string;
|
|
578
579
|
}[];
|
|
579
|
-
origin: string;
|
|
580
580
|
}[] | undefined;
|
|
581
581
|
} | null | undefined;
|
|
582
582
|
}>]>;
|
|
@@ -588,9 +588,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
588
588
|
type: "state";
|
|
589
589
|
state?: {
|
|
590
590
|
cookies: {
|
|
591
|
+
path: string;
|
|
591
592
|
value: string;
|
|
592
593
|
name: string;
|
|
593
|
-
path: string;
|
|
594
594
|
domain: string;
|
|
595
595
|
expires: number;
|
|
596
596
|
httpOnly: boolean;
|
|
@@ -605,11 +605,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
605
605
|
}[];
|
|
606
606
|
}[];
|
|
607
607
|
sessionStorage?: {
|
|
608
|
+
origin: string;
|
|
608
609
|
sessionStorage: {
|
|
609
610
|
value: string;
|
|
610
611
|
name: string;
|
|
611
612
|
}[];
|
|
612
|
-
origin: string;
|
|
613
613
|
}[] | undefined;
|
|
614
614
|
} | null | undefined;
|
|
615
615
|
};
|
|
@@ -621,9 +621,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
621
621
|
type: "state";
|
|
622
622
|
state?: {
|
|
623
623
|
cookies: {
|
|
624
|
+
path: string;
|
|
624
625
|
value: string;
|
|
625
626
|
name: string;
|
|
626
|
-
path: string;
|
|
627
627
|
domain: string;
|
|
628
628
|
expires: number;
|
|
629
629
|
httpOnly: boolean;
|
|
@@ -638,11 +638,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
638
638
|
}[];
|
|
639
639
|
}[];
|
|
640
640
|
sessionStorage?: {
|
|
641
|
+
origin: string;
|
|
641
642
|
sessionStorage: {
|
|
642
643
|
value: string;
|
|
643
644
|
name: string;
|
|
644
645
|
}[];
|
|
645
|
-
origin: string;
|
|
646
646
|
}[] | undefined;
|
|
647
647
|
} | null | undefined;
|
|
648
648
|
};
|
|
@@ -722,9 +722,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
722
722
|
type: "state";
|
|
723
723
|
state?: {
|
|
724
724
|
cookies: {
|
|
725
|
+
path: string;
|
|
725
726
|
value: string;
|
|
726
727
|
name: string;
|
|
727
|
-
path: string;
|
|
728
728
|
domain: string;
|
|
729
729
|
expires: number;
|
|
730
730
|
httpOnly: boolean;
|
|
@@ -739,11 +739,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
739
739
|
}[];
|
|
740
740
|
}[];
|
|
741
741
|
sessionStorage?: {
|
|
742
|
+
origin: string;
|
|
742
743
|
sessionStorage: {
|
|
743
744
|
value: string;
|
|
744
745
|
name: string;
|
|
745
746
|
}[];
|
|
746
|
-
origin: string;
|
|
747
747
|
}[] | undefined;
|
|
748
748
|
} | null | undefined;
|
|
749
749
|
};
|
|
@@ -767,9 +767,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
767
767
|
type: "state";
|
|
768
768
|
state?: {
|
|
769
769
|
cookies: {
|
|
770
|
+
path: string;
|
|
770
771
|
value: string;
|
|
771
772
|
name: string;
|
|
772
|
-
path: string;
|
|
773
773
|
domain: string;
|
|
774
774
|
expires: number;
|
|
775
775
|
httpOnly: boolean;
|
|
@@ -784,11 +784,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
784
784
|
}[];
|
|
785
785
|
}[];
|
|
786
786
|
sessionStorage?: {
|
|
787
|
+
origin: string;
|
|
787
788
|
sessionStorage: {
|
|
788
789
|
value: string;
|
|
789
790
|
name: string;
|
|
790
791
|
}[];
|
|
791
|
-
origin: string;
|
|
792
792
|
}[] | undefined;
|
|
793
793
|
} | null | undefined;
|
|
794
794
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { extendPayload, extendTimeout, runInfo, RunError, getAuthSessionParameters, attemptStore, } from "./runtime";
|
|
1
|
+
export { extendPayload, extendTimeout, runInfo, RunError, getAuthSessionParameters, attemptStore, persistentStore, } from "./runtime";
|
|
2
2
|
export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage";
|
|
3
3
|
export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
|
|
4
4
|
export { withPlaywrightContext } from "./common/playwrightContext";
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "getExecutionContext", {
|
|
|
45
45
|
return _asyncLocalStorage.getExecutionContext;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "persistentStore", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _runtime.persistentStore;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
48
54
|
Object.defineProperty(exports, "runInfo", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function () {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const attemptStore:
|
|
1
|
+
import { AttemptStore } from "./export";
|
|
2
|
+
export declare const attemptStore: AttemptStore;
|
package/dist/runtime/export.d.ts
CHANGED
|
@@ -171,22 +171,22 @@ export declare class RunError extends Error {
|
|
|
171
171
|
export declare function getAuthSessionParameters(): Promise<any>;
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* @interface
|
|
174
|
+
* @interface AttemptStore
|
|
175
175
|
* @property {function} get - Retrieves a value from the store by key
|
|
176
176
|
* @property {function} set - Sets a value in the store by key
|
|
177
177
|
*
|
|
178
178
|
* @example
|
|
179
|
-
* ```typescript
|
|
180
|
-
* import {
|
|
179
|
+
* ```typescript AttemptStore usage
|
|
180
|
+
* import { attemptStore } from "@intuned/sdk/runtime"
|
|
181
181
|
*
|
|
182
182
|
* // Set a value in the store
|
|
183
|
-
*
|
|
183
|
+
* attemptStore.set('openAiClient', openaiClient);
|
|
184
184
|
*
|
|
185
185
|
* // Get a value from the store
|
|
186
|
-
* const
|
|
186
|
+
* const openAiClient = attemptStore.get('openAiClient');
|
|
187
187
|
* ```
|
|
188
188
|
*/
|
|
189
|
-
export interface
|
|
189
|
+
export interface AttemptStore {
|
|
190
190
|
/**
|
|
191
191
|
* Retrieves a value from the store by key.
|
|
192
192
|
*
|
|
@@ -211,18 +211,74 @@ export interface Store {
|
|
|
211
211
|
* This store allows you to share data between different parts of your API execution.
|
|
212
212
|
*
|
|
213
213
|
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* import {
|
|
214
|
+
* ```typescript AttemptStore usage
|
|
215
|
+
* import { attemptStore } from "@intuned/sdk/runtime"
|
|
216
216
|
*
|
|
217
217
|
* // Set a value in the store
|
|
218
|
-
* store.set('
|
|
218
|
+
* store.set('openAiClient', openaiClient);
|
|
219
219
|
*
|
|
220
220
|
* // Get a value from the store
|
|
221
|
-
* const
|
|
222
|
-
*
|
|
221
|
+
* const openAiClient = attemptStore.get('openAiClient');
|
|
222
|
+
* openAiClient.doSomething();
|
|
223
223
|
*
|
|
224
224
|
* // Handle missing values
|
|
225
|
-
* const missingData =
|
|
225
|
+
* const missingData = attemptStore.get('nonexistent'); // undefined
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
export declare const attemptStore:
|
|
228
|
+
export declare const attemptStore: AttemptStore;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @interface PersistentStore
|
|
232
|
+
* @property {function} get - Retrieves a value from the store by key
|
|
233
|
+
* @property {function} set - Sets a value in the store by key
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript PersistentStore usage
|
|
237
|
+
* import { persistentStore } from "@intuned/sdk/runtime"
|
|
238
|
+
*
|
|
239
|
+
* // Set a value in the store
|
|
240
|
+
* persistentStore.set('data', { foo: 'bar' });
|
|
241
|
+
*
|
|
242
|
+
* // Get a value from the store
|
|
243
|
+
* await persistentStore.get('data');
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export interface PersistentStore {
|
|
247
|
+
/**
|
|
248
|
+
* Retrieves a value from the store by key.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} key - The key to retrieve the value for
|
|
251
|
+
* @returns {any} The value associated with the key, or undefined if not found
|
|
252
|
+
*/
|
|
253
|
+
get(key: string): Promise<any>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Sets a value in the store by key.
|
|
257
|
+
*
|
|
258
|
+
* @param {string} key - The key to set the value for
|
|
259
|
+
* @param {any} value - The value to store
|
|
260
|
+
* @throws {Error} Throws an error if the store operation fails
|
|
261
|
+
*/
|
|
262
|
+
set(key: string, value: any): Promise<void>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* ## Description
|
|
267
|
+
* A persistent key-value store that maintains data within the execution context.
|
|
268
|
+
* This store allows you to share data between different API executions.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript PersistentStore usage
|
|
272
|
+
* import { persistentStore } from "@intuned/sdk/runtime"
|
|
273
|
+
*
|
|
274
|
+
* // Set a value in the store
|
|
275
|
+
* persistentStore.set('data', { foo: 'bar' });
|
|
276
|
+
*
|
|
277
|
+
* // Get a value from the store
|
|
278
|
+
* await persistentStore.get('data');
|
|
279
|
+
*
|
|
280
|
+
* // Handle missing values
|
|
281
|
+
* const missingData = await persistentStore.get('nonexistent'); // undefined
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
export declare const persistentStore: PersistentStore;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { extendPayload } from "./extendPayload";
|
|
2
2
|
export { extendTimeout } from "./extendTimeout";
|
|
3
3
|
export { attemptStore } from "./attemptStore";
|
|
4
|
+
export { persistentStore } from "./persistentStore";
|
|
4
5
|
export { getAuthSessionParameters } from "./getAuthSessionParameters";
|
|
5
6
|
export { runInfo } from "./runInfo";
|
|
6
7
|
export { RunError } from "./RunError";
|
package/dist/runtime/index.js
CHANGED
|
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
|
39
39
|
return _downloadDirectory.getDownloadDirectoryPath;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "persistentStore", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _persistentStore.persistentStore;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
42
48
|
Object.defineProperty(exports, "runInfo", {
|
|
43
49
|
enumerable: true,
|
|
44
50
|
get: function () {
|
|
@@ -48,6 +54,7 @@ Object.defineProperty(exports, "runInfo", {
|
|
|
48
54
|
var _extendPayload = require("./extendPayload");
|
|
49
55
|
var _extendTimeout = require("./extendTimeout");
|
|
50
56
|
var _attemptStore = require("./attemptStore");
|
|
57
|
+
var _persistentStore = require("./persistentStore");
|
|
51
58
|
var _getAuthSessionParameters = require("./getAuthSessionParameters");
|
|
52
59
|
var _runInfo = require("./runInfo");
|
|
53
60
|
var _RunError = require("./RunError");
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.persistentStore = void 0;
|
|
7
7
|
var _zod = require("zod");
|
|
8
8
|
var _jwtTokenManager = require("../common/jwtTokenManager");
|
|
9
9
|
const forbiddenCharacters = /[:#]/g;
|
|
10
10
|
const keySchema = _zod.z.string().min(1, "Key must be at least 1 character long").refine(key => (key.match(forbiddenCharacters)?.length ?? 0) === 0, 'Key cannot contain the following characters: ":" or "#"');
|
|
11
|
-
|
|
12
|
-
async
|
|
11
|
+
const persistentStore = exports.persistentStore = Object.freeze({
|
|
12
|
+
get: async key => {
|
|
13
13
|
const parsedKey = keySchema.parse(key);
|
|
14
|
-
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`
|
|
14
|
+
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`kv-store/${parsedKey}`, {
|
|
15
15
|
method: "GET"
|
|
16
16
|
});
|
|
17
17
|
const json = await response.json();
|
|
@@ -19,10 +19,10 @@ class Cache {
|
|
|
19
19
|
throw new Error(json.message);
|
|
20
20
|
}
|
|
21
21
|
return json.value;
|
|
22
|
-
}
|
|
23
|
-
async
|
|
22
|
+
},
|
|
23
|
+
set: async (key, value) => {
|
|
24
24
|
const keyResult = keySchema.parse(key);
|
|
25
|
-
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`
|
|
25
|
+
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`kv-store/${keyResult}`, {
|
|
26
26
|
method: "PUT",
|
|
27
27
|
body: JSON.stringify(value),
|
|
28
28
|
headers: {
|
|
@@ -34,5 +34,4 @@ class Cache {
|
|
|
34
34
|
throw new Error(json.message);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
}
|
|
38
|
-
const cache = exports.cache = new Cache();
|
|
37
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _zod = require("zod");
|
|
5
|
+
var _persistentStore = require("./persistentStore");
|
|
6
|
+
var _jwtTokenManager = require("../common/jwtTokenManager");
|
|
7
|
+
_vitest.vi.mock("../common/jwtTokenManager", () => ({
|
|
8
|
+
callBackendFunctionWithToken: _vitest.vi.fn()
|
|
9
|
+
}));
|
|
10
|
+
(0, _vitest.describe)("Cache", () => {
|
|
11
|
+
(0, _vitest.beforeEach)(() => {
|
|
12
|
+
_vitest.vi.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
(0, _vitest.describe)("get", () => {
|
|
15
|
+
(0, _vitest.it)("should return value when successful", async () => {
|
|
16
|
+
const mockResponse = {
|
|
17
|
+
ok: true,
|
|
18
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
19
|
+
value: "cached_data"
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
23
|
+
const result = await _persistentStore.persistentStore.get("test_key");
|
|
24
|
+
(0, _vitest.expect)(result).toBe("cached_data");
|
|
25
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
26
|
+
method: "GET"
|
|
27
|
+
});
|
|
28
|
+
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
31
|
+
const mockResponse = {
|
|
32
|
+
ok: false,
|
|
33
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
34
|
+
message: "Cache miss"
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
38
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("test_key")).rejects.toThrow("Cache miss");
|
|
39
|
+
});
|
|
40
|
+
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
41
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("")).rejects.toThrow(_zod.ZodError);
|
|
42
|
+
});
|
|
43
|
+
(0, _vitest.it)("should throw error for key with colon", async () => {
|
|
44
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid:key")).rejects.toThrow(_zod.ZodError);
|
|
45
|
+
});
|
|
46
|
+
(0, _vitest.it)("should throw error for key with hash", async () => {
|
|
47
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid#key")).rejects.toThrow(_zod.ZodError);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
(0, _vitest.describe)("set", () => {
|
|
51
|
+
(0, _vitest.it)("should call backend correctly when successful", async () => {
|
|
52
|
+
const mockResponse = {
|
|
53
|
+
ok: true,
|
|
54
|
+
json: _vitest.vi.fn().mockResolvedValue({})
|
|
55
|
+
};
|
|
56
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
57
|
+
const testValue = {
|
|
58
|
+
data: "test"
|
|
59
|
+
};
|
|
60
|
+
await _persistentStore.persistentStore.set("test_key", testValue);
|
|
61
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
62
|
+
method: "PUT",
|
|
63
|
+
body: JSON.stringify(testValue),
|
|
64
|
+
headers: {
|
|
65
|
+
"Content-Type": "application/json"
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
71
|
+
const mockResponse = {
|
|
72
|
+
ok: false,
|
|
73
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
74
|
+
message: "Set failed"
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
78
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("test_key", "value")).rejects.toThrow("Set failed");
|
|
79
|
+
});
|
|
80
|
+
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
81
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("", "value")).rejects.toThrow(_zod.ZodError);
|
|
82
|
+
});
|
|
83
|
+
(0, _vitest.it)("should throw error for key with forbidden characters", async () => {
|
|
84
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid:key", "value")).rejects.toThrow(_zod.ZodError);
|
|
85
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid#key", "value")).rejects.toThrow(_zod.ZodError);
|
|
86
|
+
});
|
|
87
|
+
(0, _vitest.it)("should handle different value types", async () => {
|
|
88
|
+
const mockResponse = {
|
|
89
|
+
ok: true,
|
|
90
|
+
json: _vitest.vi.fn().mockResolvedValue({})
|
|
91
|
+
};
|
|
92
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
93
|
+
await _persistentStore.persistentStore.set("key1", "string_value");
|
|
94
|
+
await _persistentStore.persistentStore.set("key2", {
|
|
95
|
+
object: "value"
|
|
96
|
+
});
|
|
97
|
+
await _persistentStore.persistentStore.set("key3", 123);
|
|
98
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledTimes(3);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
package/package.json
CHANGED
package/WebTemplate.zip
DELETED
|
Binary file
|