@intuned/runtime-dev 1.3.11-deployment.1 → 1.3.12-ua.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/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # UNRELEASED
2
2
 
3
+ -
4
+
5
+ # 1.3.11
6
+
7
+ - Deployment flow enhancements
8
+
9
+ <!----------------------------------------------------------->
10
+
3
11
  # 1.3.0
12
+
4
13
  - Limit Automation response size to 2MB at MAX.
5
14
 
6
15
  # 1.2.0
@@ -263,12 +263,13 @@ function buildRunsPlaygroundQueryParams({
263
263
  }) {
264
264
  const params = new URLSearchParams();
265
265
  if (!enableFirstRunExperience) return params.toString();
266
+ params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({}));
266
267
  const input = settings.metadata?.defaultRunPlaygroundInput;
267
268
  if (!input) return params.toString();
268
269
  if (testAuthSessionId) {
269
270
  input.authSessionId = testAuthSessionId;
270
271
  }
271
- params.append(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({
272
+ params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({
272
273
  ...input
273
274
  }));
274
275
  return params.toString();
@@ -86,10 +86,32 @@ async function launchChromium(options) {
86
86
  executablePath = undefined;
87
87
  }
88
88
  }
89
+ const viewport = null;
90
+ let userAgent = undefined;
91
+ if (headless) {
92
+ const tmpBrowser = await playwright.chromium.launch({
93
+ executablePath,
94
+ headless,
95
+ proxy,
96
+ downloadsPath,
97
+ args: extraArgs,
98
+ ignoreDefaultArgs: defaultArgsToIgnore
99
+ });
100
+ const tmpContext = await tmpBrowser.newContext({
101
+ viewport
102
+ });
103
+ const tmpPage = await tmpContext.newPage();
104
+ const ua = await tmpPage.evaluate(() => navigator.userAgent);
105
+ await tmpBrowser.close();
106
+ if (ua) {
107
+ userAgent = ua.replace("HeadlessChrome", "Chrome");
108
+ }
109
+ }
89
110
  const context = await playwright.chromium.launchPersistentContext(userDataDir, {
111
+ userAgent,
90
112
  executablePath,
91
113
  headless,
92
- viewport: null,
114
+ viewport,
93
115
  proxy,
94
116
  downloadsPath,
95
117
  args: extraArgs,
@@ -100,6 +100,7 @@ async function runApi({
100
100
  apiParameters: params,
101
101
  importFunction
102
102
  };
103
+ const intunedContext = (0, _asyncLocalStorage.getExecutionContext)();
103
104
  const runAutomationWithContext = async (context, page) => {
104
105
  async function saveTraceIfNeeded({
105
106
  errorMessage
@@ -148,7 +149,7 @@ async function runApi({
148
149
  }
149
150
  return (0, _neverthrow.ok)({
150
151
  result: automationFunctionResult,
151
- extendedPayloads: (0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads,
152
+ extendedPayloads: intunedContext?.extendedPayloads,
152
153
  session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
153
154
  });
154
155
  } catch (error) {
@@ -159,6 +160,9 @@ async function runApi({
159
160
  });
160
161
  }
161
162
  };
163
+ if (intunedContext?.store) {
164
+ intunedContext.store = {};
165
+ }
162
166
  if (runOptions.environment === "standalone") {
163
167
  const downloadsPath = (0, _downloadDirectory.getDownloadDirectoryPath)();
164
168
  try {
@@ -0,0 +1,6 @@
1
+ declare class Cache {
2
+ get(key: string): Promise<any>;
3
+ set(key: string, value: any): Promise<void>;
4
+ }
5
+ export declare const cache: Cache;
6
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cache = void 0;
7
+ var _zod = require("zod");
8
+ var _jwtTokenManager = require("../common/jwtTokenManager");
9
+ const forbiddenCharacters = /[:#]/g;
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
+ class Cache {
12
+ async get(key) {
13
+ const parsedKey = keySchema.parse(key);
14
+ const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`cache/${parsedKey}`, {
15
+ method: "GET"
16
+ });
17
+ const json = await response.json();
18
+ if (!response.ok) {
19
+ throw new Error(json.message);
20
+ }
21
+ return json.value;
22
+ }
23
+ async set(key, value) {
24
+ const keyResult = keySchema.parse(key);
25
+ const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`cache/${keyResult}`, {
26
+ method: "PUT",
27
+ body: JSON.stringify(value),
28
+ headers: {
29
+ "Content-Type": "application/json"
30
+ }
31
+ });
32
+ const json = await response.json();
33
+ if (!response.ok) {
34
+ throw new Error(json.message);
35
+ }
36
+ }
37
+ }
38
+ const cache = exports.cache = new Cache();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.3.11-deployment.1",
3
+ "version": "1.3.12-ua.1",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -27,7 +27,6 @@
27
27
  "intuned-build": "yarn prepublishOnly && vite-node ./src/commands/build.ts",
28
28
  "intuned-auth-session-check": "vite-node ./src/commands/auth/run-check.ts",
29
29
  "intuned-auth-session-create": "vite-node ./src/commands/auth/run-create.ts",
30
- "intuned-auth-session-refresh": "vite-node ./src/commands/auth/run-refresh.ts",
31
30
  "intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
32
31
  "intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
33
32
  "intuned": "vite-node ./src/commands/intuned-cli/main.ts",
@@ -43,16 +42,15 @@
43
42
  "copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist"
44
43
  },
45
44
  "bin": {
46
- "intuned-api-run": "./bin/intuned-api-run",
47
- "intuned-auth-session-create": "./bin/intuned-auth-session-create",
48
- "intuned-auth-session-refresh": "./bin/intuned-auth-session-refresh",
49
- "intuned-auth-session-load": "./bin/intuned-auth-session-load",
50
- "intuned-auth-session-check": "./bin/intuned-auth-session-check",
51
- "intuned-build": "./bin/intuned-build",
52
- "intuned-browser-start": "./bin/intuned-browser-start",
53
- "intuned-browser-save-state": "./bin/intuned-browser-save-state",
54
- "intuned-ts-check": "./bin/intuned-ts-check",
55
- "intuned": "./bin/intuned"
45
+ "intuned-api-run": "bin/intuned-api-run",
46
+ "intuned-auth-session-create": "bin/intuned-auth-session-create",
47
+ "intuned-auth-session-load": "bin/intuned-auth-session-load",
48
+ "intuned-auth-session-check": "bin/intuned-auth-session-check",
49
+ "intuned-build": "bin/intuned-build",
50
+ "intuned-browser-start": "bin/intuned-browser-start",
51
+ "intuned-browser-save-state": "bin/intuned-browser-save-state",
52
+ "intuned-ts-check": "bin/intuned-ts-check",
53
+ "intuned": "bin/intuned"
56
54
  },
57
55
  "dependencies": {
58
56
  "@babel/plugin-syntax-dynamic-import": "7.8.3",