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

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.
Files changed (59) hide show
  1. package/Intuned.json +1 -1
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/async.ts +52 -48
  4. package/WebTemplate/controllers/authSessions/check.ts +3 -4
  5. package/WebTemplate/controllers/authSessions/create.ts +5 -7
  6. package/WebTemplate/controllers/authSessions/resumeOperation.ts +1 -1
  7. package/WebTemplate/controllers/runApi/helpers.ts +11 -6
  8. package/WebTemplate/index.playwright.ts +32 -42
  9. package/WebTemplate/jobs.ts +13 -2
  10. package/WebTemplate/utils.ts +51 -1
  11. package/api/test2.ts +7 -5
  12. package/auth-sessions/check.ts +3 -1
  13. package/auth-sessions/create.ts +10 -10
  14. package/bin/intuned-api-run +1 -1
  15. package/bin/intuned-auth-session-check +1 -1
  16. package/bin/intuned-auth-session-create +1 -1
  17. package/bin/intuned-auth-session-load +1 -1
  18. package/bin/intuned-auth-session-refresh +1 -1
  19. package/bin/intuned-browser-save-state +1 -1
  20. package/bin/intuned-browser-start +1 -1
  21. package/bin/intuned-build +1 -1
  22. package/bin/intuned-ts-check +1 -1
  23. package/dist/commands/api/run.js +4 -2
  24. package/dist/commands/auth-sessions/run-check.js +3 -1
  25. package/dist/commands/auth-sessions/run-create.js +5 -3
  26. package/dist/commands/build.js +6 -4
  27. package/dist/commands/common/browserUtils.js +1 -1
  28. package/dist/commands/common/getFirstLineNumber.test.js +2 -2
  29. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  30. package/dist/commands/common/{getDefaultExportFromFile.js → tsNodeImport.js} +6 -5
  31. package/dist/commands/common/utils/settings.js +1 -2
  32. package/dist/commands/common/utils/webTemplate.js +2 -2
  33. package/dist/commands/interface/run.js +122 -106
  34. package/dist/commands/ts-check.js +2 -2
  35. package/dist/common/Logger/Logger/index.d.ts +1 -1
  36. package/dist/common/Logger/index.d.ts +1 -1
  37. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  38. package/dist/common/getPlaywrightConstructs.js +3 -3
  39. package/dist/common/runApi/errors.d.ts +1 -1
  40. package/dist/common/runApi/index.d.ts +5 -5
  41. package/dist/common/runApi/index.js +21 -50
  42. package/dist/common/runApi/types.d.ts +2 -1
  43. package/dist/index.d.ts +4 -4
  44. package/dist/index.js +12 -12
  45. package/dist/runtime/RunError.d.ts +1 -1
  46. package/dist/runtime/executionHelpers.test.js +2 -2
  47. package/dist/runtime/export.d.ts +1 -1
  48. package/dist/runtime/extendPayload.d.ts +1 -1
  49. package/dist/runtime/extendPayload.js +1 -1
  50. package/dist/runtime/index.d.ts +7 -7
  51. package/dist/runtime/index.js +6 -6
  52. package/dist/runtime/runInfo.d.ts +1 -1
  53. package/dist/runtime/runInfo.js +1 -1
  54. package/package.json +6 -5
  55. package/playwright.config.js +43 -0
  56. package/preserve-dynamic-imports.js +16 -0
  57. package/tsconfig.json +1 -1
  58. package/vite.config.js +16 -0
  59. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
@@ -1,12 +1,12 @@
1
1
  import { Result } from "neverthrow";
2
- import { RunAutomationError } from "./errors";
2
+ import { RunAutomationError } from "./errors.js";
3
3
  import { Page, BrowserContext } from "@intuned/playwright-core";
4
- import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
5
- export * from "./types";
6
- export * from "./errors";
4
+ import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types.js";
5
+ export * from "./types.js";
6
+ export * from "./errors.js";
7
7
  export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters & {
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
11
  export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
12
- export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, retries?: number): Promise<Result<boolean, RunAutomationError>>;
12
+ export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, importFunction: ExtendedRunApiParameters["importFunction"], retries?: number): Promise<Result<boolean, RunAutomationError>>;
@@ -18,7 +18,7 @@ var fs = _fsExtra;
18
18
  var _jwtTokenManager = require("../jwtTokenManager");
19
19
  var _contextStorageStateHelpers = require("../contextStorageStateHelpers");
20
20
  var _neverthrow = require("neverthrow");
21
- var _errors = require("./errors");
21
+ var _errors = require("./errors.js");
22
22
  Object.keys(_errors).forEach(function (key) {
23
23
  if (key === "default" || key === "__esModule") return;
24
24
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -32,7 +32,7 @@ Object.keys(_errors).forEach(function (key) {
32
32
  });
33
33
  var _constants = require("../constants");
34
34
  var _getPlaywrightConstructs = require("../getPlaywrightConstructs");
35
- var _types = require("./types");
35
+ var _types = require("./types.js");
36
36
  Object.keys(_types).forEach(function (key) {
37
37
  if (key === "default" || key === "__esModule") return;
38
38
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -49,6 +49,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
49
49
  async function* runApiGenerator({
50
50
  retrieveSession = false,
51
51
  abortSignal,
52
+ importFunction,
52
53
  ...input
53
54
  }) {
54
55
  let traceStarted = false;
@@ -60,10 +61,11 @@ async function* runApiGenerator({
60
61
  functionsToken
61
62
  } = _types.runApiParametersSchema.parse(input);
62
63
  _jwtTokenManager.backendFunctionsTokenManager.token = functionsToken;
63
- const downloadsPath = (0, _downloadDirectory.getDownloadDirectoryPath)();
64
64
  let page;
65
65
  let context;
66
+ let downloadsPath;
66
67
  if (runOptions.environment === "deployed") {
68
+ downloadsPath = (0, _downloadDirectory.getDownloadDirectoryPath)();
67
69
  const {
68
70
  headless,
69
71
  proxy
@@ -87,10 +89,6 @@ async function* runApiGenerator({
87
89
  context
88
90
  } = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth === null || auth === void 0 ? void 0 : auth.session));
89
91
  }
90
- const executionContext = (0, _asyncLocalStorage.getExecutionContext)();
91
- if (!executionContext) {
92
- throw "";
93
- }
94
92
  async function saveTraceIfNeeded({
95
93
  errorMessage
96
94
  }) {
@@ -128,12 +126,10 @@ async function* runApiGenerator({
128
126
  var _getExecutionContext;
129
127
  if (auth !== null && auth !== void 0 && auth.runCheck) {
130
128
  if (!auth.session) {
131
- return (0, _neverthrow.err)({
132
- code: "AuthRequiredError"
133
- });
129
+ return (0, _neverthrow.err)(new _errors.AuthRequiredError());
134
130
  }
135
131
  console.log("Running auth check");
136
- const authCheckResult = await checkAuthSessionWithRetries(page, context, 2);
132
+ const authCheckResult = await checkAuthSessionWithRetries(page, context, importFunction, 2);
137
133
  if (authCheckResult.isErr()) {
138
134
  const error = authCheckResult.error;
139
135
  if (["APINotFoundError", "InvalidAPIError"].includes(error.code)) {
@@ -142,20 +138,17 @@ async function* runApiGenerator({
142
138
  return authCheckResult;
143
139
  }
144
140
  if (!authCheckResult.value) {
145
- return (0, _neverthrow.err)({
146
- code: "AuthCheckFailedError"
147
- });
141
+ return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
148
142
  }
149
143
  }
150
- console.log("Running function", automationFunction.name);
151
144
  const args = [...(automationFunction.params ? [automationFunction.params] : []), page, context];
152
- const importResult = await importFunction(automationFunction.name);
153
- if (importResult.isErr()) {
154
- return importResult;
145
+ const validatedModuleResult = await importUsingImportFunction(automationFunction.name, importFunction);
146
+ if (validatedModuleResult.isErr()) {
147
+ return validatedModuleResult;
155
148
  }
156
149
  let result;
157
- if (importResult.value.type === "async-generator") {
158
- const generator = importResult.value.generator(...args);
150
+ if (validatedModuleResult.value.type === "async-generator") {
151
+ const generator = validatedModuleResult.value.generator(...args);
159
152
  let next = undefined;
160
153
  while (true) {
161
154
  const generatorResult = await generator.next(...(next ? [next] : []));
@@ -167,7 +160,7 @@ async function* runApiGenerator({
167
160
  break;
168
161
  }
169
162
  } else {
170
- result = await importResult.value.func(...args);
163
+ result = await validatedModuleResult.value.func(...args);
171
164
  }
172
165
  return (0, _neverthrow.ok)({
173
166
  result,
@@ -197,7 +190,9 @@ async function* runApiGenerator({
197
190
  errorMessage: "failed to save trace"
198
191
  });
199
192
  await context.close();
200
- await fs.remove(downloadsPath);
193
+ if (downloadsPath !== undefined) {
194
+ await fs.remove(downloadsPath);
195
+ }
201
196
  }
202
197
  }
203
198
  async function runApi(params) {
@@ -211,13 +206,13 @@ async function runApi(params) {
211
206
  }
212
207
  return (0, _neverthrow.err)(new _errors.InvalidApiError("Expected API to be async function, got async generator"));
213
208
  }
214
- async function checkAuthSessionWithRetries(page, context, retries = 3) {
209
+ async function checkAuthSessionWithRetries(page, context, importFunction, retries = 3) {
215
210
  if (retries === 0) {
216
211
  return (0, _neverthrow.ok)(false);
217
212
  }
218
213
  let tryNumber = 0;
219
214
  console.log("Checking auth session with retries", `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`);
220
- const importResult = await importFunction(`${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`);
215
+ const importResult = await importUsingImportFunction(`${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`, importFunction);
221
216
  if (importResult.isErr()) {
222
217
  return (0, _neverthrow.err)(importResult.error);
223
218
  }
@@ -232,33 +227,9 @@ async function checkAuthSessionWithRetries(page, context, retries = 3) {
232
227
  }
233
228
  return (0, _neverthrow.ok)(false);
234
229
  }
235
- async function importFunction(path) {
236
- const functionNameParts = path.split("/");
237
- const functionNameDepth = functionNameParts.length;
230
+ async function importUsingImportFunction(path, importFunction) {
238
231
  try {
239
- let imported = undefined;
240
- switch (functionNameDepth) {
241
- case 1:
242
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}.ts`);
243
- break;
244
- case 2:
245
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}/${functionNameParts[1]}.ts`);
246
- break;
247
- case 3:
248
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`);
249
- break;
250
- case 4:
251
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`);
252
- break;
253
- case 5:
254
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`);
255
- break;
256
- case 6:
257
- imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}/${functionNameParts[5]}.ts`);
258
- break;
259
- default:
260
- return (0, _neverthrow.err)(new _errors.MaxLevelsExceededError(5));
261
- }
232
+ const imported = importFunction ? await importFunction(path) : await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`./${path}.ts`);
262
233
  if (!imported || !imported.default || !imported.default.constructor) {
263
234
  return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default export"));
264
235
  }
@@ -1,7 +1,7 @@
1
1
  import type { IntunedStorageState } from "../contextStorageStateHelpers";
2
2
  import type { Payload } from "../../runtime/export";
3
3
  import type { Result } from "neverthrow";
4
- import type { RunAutomationError } from "./errors";
4
+ import type { RunAutomationError } from "./errors.js";
5
5
  import z from "zod";
6
6
  export interface PayloadToAppend {
7
7
  apiName: string;
@@ -475,6 +475,7 @@ export type RunApiSession = z.infer<typeof runApiSessionSchema>;
475
475
  export type RunApiParameters = z.input<typeof runApiParametersSchema>;
476
476
  export type ExtendedRunApiParameters = RunApiParameters & {
477
477
  abortSignal?: AbortSignal;
478
+ importFunction?: (name: string) => Promise<any> | undefined;
478
479
  };
479
480
  export type RunApiResultOk<R = any> = {
480
481
  result: R;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP, } from "./runtime";
2
- export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage";
3
- export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
4
- export { getProductionPlaywrightConstructs } from "./common/getPlaywrightConstructs";
1
+ export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP, } from "./runtime/index.js";
2
+ export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage/index.js";
3
+ export { getDownloadDirectoryPath } from "./runtime/downloadDirectory.js";
4
+ export { getProductionPlaywrightConstructs } from "./common/getPlaywrightConstructs.js";
package/dist/index.js CHANGED
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "RunError", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _runtime.RunError;
9
+ return _index.RunError;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "extendPayload", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _runtime.extendPayload;
15
+ return _index.extendPayload;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "extendTimeout", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _runtime.extendTimeout;
21
+ return _index.extendTimeout;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "getDownloadDirectoryPath", {
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "getDownloadDirectoryPath", {
30
30
  Object.defineProperty(exports, "getExecutionContext", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _asyncLocalStorage.getExecutionContext;
33
+ return _index2.getExecutionContext;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "getProductionPlaywrightConstructs", {
@@ -42,28 +42,28 @@ Object.defineProperty(exports, "getProductionPlaywrightConstructs", {
42
42
  Object.defineProperty(exports, "requestMultipleChoice", {
43
43
  enumerable: true,
44
44
  get: function () {
45
- return _runtime.requestMultipleChoice;
45
+ return _index.requestMultipleChoice;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "requestOTP", {
49
49
  enumerable: true,
50
50
  get: function () {
51
- return _runtime.requestOTP;
51
+ return _index.requestOTP;
52
52
  }
53
53
  });
54
54
  Object.defineProperty(exports, "runInfo", {
55
55
  enumerable: true,
56
56
  get: function () {
57
- return _runtime.runInfo;
57
+ return _index.runInfo;
58
58
  }
59
59
  });
60
60
  Object.defineProperty(exports, "runWithContext", {
61
61
  enumerable: true,
62
62
  get: function () {
63
- return _asyncLocalStorage.runWithContext;
63
+ return _index2.runWithContext;
64
64
  }
65
65
  });
66
- var _runtime = require("./runtime");
67
- var _asyncLocalStorage = require("./common/asyncLocalStorage");
68
- var _downloadDirectory = require("./runtime/downloadDirectory");
69
- var _getPlaywrightConstructs = require("./common/getPlaywrightConstructs");
66
+ var _index = require("./runtime/index.js");
67
+ var _index2 = require("./common/asyncLocalStorage/index.js");
68
+ var _downloadDirectory = require("./runtime/downloadDirectory.js");
69
+ var _getPlaywrightConstructs = require("./common/getPlaywrightConstructs.js");
@@ -1,4 +1,4 @@
1
- import { RunErrorOptions } from "./export";
1
+ import { RunErrorOptions } from "./export.js";
2
2
  export declare class RunError extends Error {
3
3
  options: RunErrorOptions;
4
4
  constructor(message: string, options?: RunErrorOptions);
@@ -2,8 +2,8 @@
2
2
 
3
3
  var _vitest = require("vitest");
4
4
  var _asyncLocalStorage = require("../common/asyncLocalStorage");
5
- var _index = require("./index");
6
- var _enums = require("./enums");
5
+ var _index = require("./index.js");
6
+ var _enums = require("./enums.js");
7
7
  (0, _vitest.describe)("Execution Helpers", () => {
8
8
  (0, _vitest.it)("should be able to get execution info", () => {
9
9
  (0, _asyncLocalStorage.runWithContext)({
@@ -1,4 +1,4 @@
1
- import { RunEnvironment } from "./enums";
1
+ import { RunEnvironment } from "./enums.js";
2
2
 
3
3
  /**
4
4
  * ## Description
@@ -1,2 +1,2 @@
1
- import { Payload } from "./export";
1
+ import { Payload } from "./export.js";
2
2
  export declare function extendPayload(payload: Payload | Payload[]): void;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.extendPayload = extendPayload;
7
7
  var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
- var _extendTimeout = require("./extendTimeout");
8
+ var _extendTimeout = require("./extendTimeout.js");
9
9
  function extendPayload(payload) {
10
10
  const context = (0, _asyncLocalStorage.getExecutionContext)();
11
11
  if (!context) {
@@ -1,7 +1,7 @@
1
- export { extendPayload } from "./extendPayload";
2
- export { extendTimeout } from "./extendTimeout";
3
- export { runInfo } from "./runInfo";
4
- export { RunError } from "./RunError";
5
- export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
6
- export type { RequestMoreInfoDetails } from "./requestMoreInfo";
7
- export { getDownloadDirectoryPath } from "./downloadDirectory";
1
+ export { extendPayload } from "./extendPayload.js";
2
+ export { extendTimeout } from "./extendTimeout.js";
3
+ export { runInfo } from "./runInfo.js";
4
+ export { RunError } from "./RunError.js";
5
+ export { requestMultipleChoice, requestOTP } from "./requestMoreInfo.js";
6
+ export type { RequestMoreInfoDetails } from "./requestMoreInfo.js";
7
+ export { getDownloadDirectoryPath } from "./downloadDirectory.js";
@@ -45,9 +45,9 @@ Object.defineProperty(exports, "runInfo", {
45
45
  return _runInfo.runInfo;
46
46
  }
47
47
  });
48
- var _extendPayload = require("./extendPayload");
49
- var _extendTimeout = require("./extendTimeout");
50
- var _runInfo = require("./runInfo");
51
- var _RunError = require("./RunError");
52
- var _requestMoreInfo = require("./requestMoreInfo");
53
- var _downloadDirectory = require("./downloadDirectory");
48
+ var _extendPayload = require("./extendPayload.js");
49
+ var _extendTimeout = require("./extendTimeout.js");
50
+ var _runInfo = require("./runInfo.js");
51
+ var _RunError = require("./RunError.js");
52
+ var _requestMoreInfo = require("./requestMoreInfo.js");
53
+ var _downloadDirectory = require("./downloadDirectory.js");
@@ -1,2 +1,2 @@
1
- import { RunInfo } from "./export";
1
+ import { RunInfo } from "./export.js";
2
2
  export declare function runInfo(): RunInfo;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.runInfo = runInfo;
7
7
  var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
- var _enums = require("./enums");
8
+ var _enums = require("./enums.js");
9
9
  function runInfo() {
10
10
  const context = (0, _asyncLocalStorage.getExecutionContext)();
11
11
  if (!context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "0.1.0-test.3",
3
+ "version": "0.1.0-test.30",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -12,8 +12,7 @@
12
12
  "./dist/common/jwtTokenManager": "./dist/common/jwtTokenManager.js",
13
13
  "./dist/common/asyncLocalStorage": "./dist/common/asyncLocalStorage/index.js",
14
14
  "./dist/common/cleanEnvironmentVariables": "./dist/common/cleanEnvironmentVariables.js",
15
- "./dist/common/constants": "./dist/common/constants.js",
16
- "./dist/commands/interface/run": "./dist/commands/interface/run.js"
15
+ "./dist/common/constants": "./dist/common/constants.js"
17
16
  },
18
17
  "types": "./dist/index.d.ts",
19
18
  "author": "Intuned Team",
@@ -51,6 +50,7 @@
51
50
  "intuned-ts-check": "./bin/intuned-ts-check"
52
51
  },
53
52
  "dependencies": {
53
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
54
54
  "@intuned/playwright": "^1.44.1-4",
55
55
  "@intuned/playwright-core": "^1.44.1-4",
56
56
  "@rollup/plugin-commonjs": "^25.0.2",
@@ -65,6 +65,7 @@
65
65
  "@types/node": "^20.4.1",
66
66
  "applicationinsights": "^2.9.2",
67
67
  "async-retry": "^1.3.3",
68
+ "babel-plugin-dynamic-import-node": "^2.3.3",
68
69
  "chalk": "^4.1.2",
69
70
  "commander": "^11.0.0",
70
71
  "cross-fetch": "^4.0.0",
@@ -89,12 +90,12 @@
89
90
  "source-map": "^0.7.4",
90
91
  "stack-utils": "^2.0.6",
91
92
  "ts-morph": "^21.0.1",
92
- "ts-node": "^10.9.1",
93
93
  "tslib": "^2.6.0",
94
94
  "typescript": "^5.1.6",
95
95
  "wait-on": "^7.2.0",
96
96
  "zod": "^3.21.4",
97
- "zod-validation-error": "^3.0.3"
97
+ "zod-validation-error": "^3.0.3",
98
+ "ts-node": "^10.9.1"
98
99
  },
99
100
  "devDependencies": {
100
101
  "@babel/cli": "^7.23.4",
@@ -0,0 +1,43 @@
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
+ });
@@ -0,0 +1,16 @@
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/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "target": "es2021",
4
4
  "module": "esnext",
5
5
  "esModuleInterop": true,
6
- "moduleResolution": "bundler",
6
+ "moduleResolution": "node",
7
7
  "resolveJsonModule": true,
8
8
  "outDir": "./dist",
9
9
  "strict": false,
package/vite.config.js ADDED
@@ -0,0 +1,16 @@
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
+ });
@@ -1 +0,0 @@
1
- export declare function getDefaultExportFromFile(apiFilePath: string): Promise<any>;