@intuned/runtime-dev 0.1.0-test.30 → 0.1.0-test.31

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.
@@ -65,6 +65,7 @@ export async function runApi({
65
65
 
66
66
  const abortController = new AbortController();
67
67
 
68
+ backendFunctionsTokenManager.token = functionsToken;
68
69
  const resultWithTimeout = await waitWithExtendableTimeout({
69
70
  promise: runApiInternal({
70
71
  automationFunction: {
@@ -91,7 +92,6 @@ export async function runApi({
91
92
  filePath: getTraceFilePath(runId, attemptNumber),
92
93
  }
93
94
  : { enabled: false },
94
- functionsToken,
95
95
  abortSignal: abortController.signal,
96
96
  importFunction: importModule,
97
97
  }),
@@ -18,6 +18,7 @@ const startRunApiSchema = _zod.default.object({
18
18
  type: _zod.default.literal("start"),
19
19
  parameters: _runApi.runApiParametersSchema.extend({
20
20
  retrieveSession: _zod.default.boolean(),
21
+ functionsToken: _zod.default.string().optional(),
21
22
  context: _zod.default.object({
22
23
  jobId: _zod.default.string().optional(),
23
24
  jobRunId: _zod.default.string().optional(),
@@ -73,7 +74,9 @@ function main(importFunction) {
73
74
  const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
74
75
  async function runGeneratorAndSendResult(next) {
75
76
  const _generator = generator;
76
- if (_generator == null) return;
77
+ if (_generator == null) return {
78
+ done: true
79
+ };
77
80
  const result = await (0, _asyncLocalStorage.runWithContext)(context, () => _generator.next(next));
78
81
  if (result.done) {
79
82
  const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
@@ -83,14 +86,15 @@ function main(importFunction) {
83
86
  result: resultToSend,
84
87
  success
85
88
  });
86
- return true;
87
89
  } else {
88
90
  jsonUnixSocket.sendJSON({
89
91
  type: "yield",
90
92
  result: result.value
91
93
  });
92
- return false;
93
94
  }
95
+ return {
96
+ done: result.done ?? false
97
+ };
94
98
  }
95
99
  for await (const data of jsonUnixSocket.receiveJSON()) {
96
100
  const inputParseResult = inputSchema.safeParse(data);
@@ -99,7 +103,7 @@ function main(importFunction) {
99
103
  jsonUnixSocket.sendJSON({
100
104
  type: "done",
101
105
  result: {
102
- error: "InvalidInput",
106
+ error: "InternalInvalidInputError",
103
107
  message: "Invalid input",
104
108
  details: {
105
109
  errors: inputParseResult.error.errors
@@ -120,12 +124,12 @@ function main(importFunction) {
120
124
  break;
121
125
  }
122
126
  if (input.type === "start") {
123
- const gen = (0, _runApi.runApiGenerator)({
127
+ _jwtTokenManager.backendFunctionsTokenManager.token = input.parameters.functionsToken;
128
+ generator = (0, _runApi.runApiGenerator)({
124
129
  ...input.parameters,
125
130
  abortSignal: abortController.signal,
126
131
  importFunction
127
132
  });
128
- generator = gen;
129
133
  context = {
130
134
  extendedPayloads: [],
131
135
  runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
@@ -141,7 +145,10 @@ function main(importFunction) {
141
145
  ...(input.parameters.context ?? {}),
142
146
  proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
143
147
  };
144
- if (await runGeneratorAndSendResult()) {
148
+ const {
149
+ done
150
+ } = await runGeneratorAndSendResult();
151
+ if (done) {
145
152
  break;
146
153
  }
147
154
  continue;
@@ -150,7 +157,10 @@ function main(importFunction) {
150
157
  if (!generator) {
151
158
  throw new Error("generator not started");
152
159
  }
153
- if (await runGeneratorAndSendResult(input.parameters.value)) {
160
+ const {
161
+ done
162
+ } = await runGeneratorAndSendResult(input.parameters.value);
163
+ if (done) {
154
164
  break;
155
165
  }
156
166
  continue;
@@ -15,7 +15,6 @@ var _downloadDirectory = require("../../runtime/downloadDirectory");
15
15
  var _asyncLocalStorage = require("../asyncLocalStorage");
16
16
  var _fsExtra = _interopRequireWildcard(require("fs-extra"));
17
17
  var fs = _fsExtra;
18
- var _jwtTokenManager = require("../jwtTokenManager");
19
18
  var _contextStorageStateHelpers = require("../contextStorageStateHelpers");
20
19
  var _neverthrow = require("neverthrow");
21
20
  var _errors = require("./errors.js");
@@ -57,10 +56,8 @@ async function* runApiGenerator({
57
56
  automationFunction,
58
57
  runOptions,
59
58
  tracing,
60
- auth,
61
- functionsToken
59
+ auth
62
60
  } = _types.runApiParametersSchema.parse(input);
63
- _jwtTokenManager.backendFunctionsTokenManager.token = functionsToken;
64
61
  let page;
65
62
  let context;
66
63
  let downloadsPath;
@@ -125,7 +125,6 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
125
125
  };
126
126
  }>]>;
127
127
  export declare const runApiParametersSchema: z.ZodObject<{
128
- functionsToken: z.ZodOptional<z.ZodString>;
129
128
  automationFunction: z.ZodObject<{
130
129
  name: z.ZodString;
131
130
  params: z.ZodOptional<z.ZodAny>;
@@ -383,7 +382,6 @@ export declare const runApiParametersSchema: z.ZodObject<{
383
382
  cdpAddress: string;
384
383
  };
385
384
  retrieveSession: boolean;
386
- functionsToken?: string | undefined;
387
385
  auth?: {
388
386
  session: {
389
387
  type: "file";
@@ -419,7 +417,6 @@ export declare const runApiParametersSchema: z.ZodObject<{
419
417
  name: string;
420
418
  params?: any;
421
419
  };
422
- functionsToken?: string | undefined;
423
420
  tracing?: {
424
421
  enabled: false;
425
422
  } | {
@@ -14,7 +14,6 @@ const runApiSessionSchema = exports.runApiSessionSchema = _zod.default.discrimin
14
14
  state: _zod.default.custom(v => v)
15
15
  })]);
16
16
  const runApiParametersSchema = exports.runApiParametersSchema = _zod.default.object({
17
- functionsToken: _zod.default.string().optional(),
18
17
  automationFunction: _zod.default.object({
19
18
  name: _zod.default.string(),
20
19
  params: _zod.default.any().optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "0.1.0-test.30",
3
+ "version": "0.1.0-test.31",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -1,43 +0,0 @@
1
- import { defineConfig, devices } from "@intuned/playwright-test";
2
- /**
3
- * Read environment variables from file.
4
- * https://github.com/motdotla/dotenv
5
- */
6
- // require('dotenv').config();
7
- /**
8
- * See https://playwright.dev/docs/test-configuration.
9
- */
10
- export default defineConfig({
11
- testDir: "./e2e-tests",
12
- /* Run tests in files in parallel */
13
- fullyParallel: true,
14
- /* Fail the build on CI if you accidentally left test.only in the source code. */
15
- forbidOnly: !!process.env.CI,
16
- /* Retry on CI only */
17
- retries: process.env.CI ? 2 : 0,
18
- /* Opt out of parallel tests on CI. */
19
- workers: process.env.CI ? 1 : undefined,
20
- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
21
- reporter: "html",
22
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
23
- use: {
24
- /* Base URL to use in actions like `await page.goto('/')`. */
25
- // baseURL: 'http://127.0.0.1:3000',
26
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27
- trace: "on-first-retry",
28
- // headless: false,
29
- },
30
- /* Configure projects for major browsers */
31
- projects: [
32
- {
33
- name: "chromium",
34
- use: { ...devices["Desktop Chrome"] },
35
- },
36
- ],
37
- /* Run your local dev server before starting the tests */
38
- // webServer: {
39
- // command: 'npm run start',
40
- // url: 'http://127.0.0.1:3000',
41
- // reuseExistingServer: !process.env.CI,
42
- // },
43
- });
@@ -1,16 +0,0 @@
1
- module.exports = function ({ template }) {
2
- return {
3
- visitor: {
4
- CallExpression(path) {
5
- if (path.node.callee.type === "Import") {
6
- const buildRequire = template(`Promise.resolve(require(ARGUMENT))`);
7
- path.replaceWith(
8
- buildRequire({
9
- ARGUMENT: path.node.arguments[0],
10
- })
11
- );
12
- }
13
- },
14
- },
15
- };
16
- };
package/testing DELETED
Binary file
package/vite.config.js DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import macros from "vite-plugin-babel-macros";
3
- require('dotenv').config();
4
- export default defineConfig({
5
- test: {
6
- reporters: ['verbose', "html"],
7
- outputFile: { html: './reports/html/index.html' },
8
- testTimeout: 30000,
9
- env: {
10
- RUN_ENVIRONMENT: "AUTHORING",
11
- }
12
- },
13
- plugins: [
14
- macros(),
15
- ],
16
- });