@intuned/runtime-dev 1.3.9-dev9 → 1.3.11-deployment.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.
Files changed (223) hide show
  1. package/InterfaceTemplate/index.playwright.ts +1 -1
  2. package/WebTemplate.zip +0 -0
  3. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  4. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  5. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  6. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +3 -0
  7. package/dist/commands/intuned-cli/commands/types.d.ts +4 -0
  8. package/dist/commands/intuned-cli/commands/types.js +5 -3
  9. package/dist/commands/intuned-cli/controller/api.d.ts +1 -1
  10. package/dist/commands/intuned-cli/controller/api.js +4 -2
  11. package/dist/commands/intuned-cli/controller/authSession.d.ts +2 -2
  12. package/dist/commands/intuned-cli/controller/authSession.js +8 -4
  13. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -0
  14. package/dist/commands/intuned-cli/controller/deploy.js +142 -6
  15. package/dist/commands/intuned-cli/controller/save.d.ts +4 -1
  16. package/dist/commands/intuned-cli/controller/save.js +8 -2
  17. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +11 -0
  18. package/dist/commands/intuned-cli/helpers/backend.js +1 -1
  19. package/dist/commands/intuned-cli/helpers/browser.d.ts +2 -1
  20. package/dist/commands/intuned-cli/helpers/browser.js +8 -1
  21. package/dist/commands/intuned-cli/helpers/errors.d.ts +3 -0
  22. package/dist/commands/intuned-cli/helpers/errors.js +8 -1
  23. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +113 -11
  24. package/dist/commands/intuned-cli/helpers/intunedJson.js +19 -3
  25. package/dist/commands/intuned-cli/helpers/wrapper.js +7 -1
  26. package/dist/commands/intuned-cli/main.js +1 -0
  27. package/package.json +6 -2
  28. package/package/dist/commands/api/run.d.ts +0 -6
  29. package/package/dist/commands/api/run.js +0 -123
  30. package/package/dist/commands/auth-sessions/load.d.ts +0 -2
  31. package/package/dist/commands/auth-sessions/load.js +0 -35
  32. package/package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  33. package/package/dist/commands/auth-sessions/run-check.js +0 -74
  34. package/package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  35. package/package/dist/commands/auth-sessions/run-create.js +0 -78
  36. package/package/dist/commands/browser/save-state.d.ts +0 -2
  37. package/package/dist/commands/browser/save-state.js +0 -17
  38. package/package/dist/commands/browser/start-browser.d.ts +0 -2
  39. package/package/dist/commands/browser/start-browser.js +0 -14
  40. package/package/dist/commands/build.d.ts +0 -1
  41. package/package/dist/commands/build.js +0 -84
  42. package/package/dist/commands/common/browserUtils.d.ts +0 -14
  43. package/package/dist/commands/common/browserUtils.js +0 -58
  44. package/package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  45. package/package/dist/commands/common/getFirstLineNumber.js +0 -101
  46. package/package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  47. package/package/dist/commands/common/projectExclusions.d.ts +0 -2
  48. package/package/dist/commands/common/projectExclusions.js +0 -8
  49. package/package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  50. package/package/dist/commands/common/sendMessageToClient.js +0 -10
  51. package/package/dist/commands/common/tsNodeImport.d.ts +0 -2
  52. package/package/dist/commands/common/tsNodeImport.js +0 -34
  53. package/package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  54. package/package/dist/commands/common/utils/fileUtils.js +0 -33
  55. package/package/dist/commands/common/utils/settings.d.ts +0 -2
  56. package/package/dist/commands/common/utils/settings.js +0 -31
  57. package/package/dist/commands/common/utils/template.d.ts +0 -2
  58. package/package/dist/commands/common/utils/template.js +0 -31
  59. package/package/dist/commands/common/utils/unixSocket.d.ts +0 -9
  60. package/package/dist/commands/common/utils/unixSocket.js +0 -44
  61. package/package/dist/commands/interface/run.d.ts +0 -1
  62. package/package/dist/commands/interface/run.js +0 -216
  63. package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  64. package/package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  65. package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  66. package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  67. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  68. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  69. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  70. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  71. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  72. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  73. package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  74. package/package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  75. package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  76. package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -31
  77. package/package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  78. package/package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  79. package/package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  80. package/package/dist/commands/intuned-cli/commands/command.js +0 -9
  81. package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  82. package/package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
  83. package/package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  84. package/package/dist/commands/intuned-cli/commands/index.js +0 -203
  85. package/package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  86. package/package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  87. package/package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  88. package/package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  89. package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  90. package/package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  91. package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -28
  92. package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  93. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  94. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  95. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  96. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  97. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  98. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  99. package/package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
  100. package/package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  101. package/package/dist/commands/intuned-cli/commands/types.d.ts +0 -31
  102. package/package/dist/commands/intuned-cli/commands/types.js +0 -29
  103. package/package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  104. package/package/dist/commands/intuned-cli/constants/index.js +0 -25
  105. package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
  106. package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
  107. package/package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  108. package/package/dist/commands/intuned-cli/controller/api.js +0 -189
  109. package/package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  110. package/package/dist/commands/intuned-cli/controller/authSession.js +0 -420
  111. package/package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  112. package/package/dist/commands/intuned-cli/controller/build.js +0 -36
  113. package/package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -4
  114. package/package/dist/commands/intuned-cli/controller/deploy.js +0 -139
  115. package/package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  116. package/package/dist/commands/intuned-cli/controller/index.js +0 -46
  117. package/package/dist/commands/intuned-cli/controller/save.d.ts +0 -14
  118. package/package/dist/commands/intuned-cli/controller/save.js +0 -345
  119. package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -103
  120. package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
  121. package/package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  122. package/package/dist/commands/intuned-cli/helpers/api.js +0 -19
  123. package/package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  124. package/package/dist/commands/intuned-cli/helpers/auth.js +0 -144
  125. package/package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  126. package/package/dist/commands/intuned-cli/helpers/backend.js +0 -27
  127. package/package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -14
  128. package/package/dist/commands/intuned-cli/helpers/browser.js +0 -57
  129. package/package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  130. package/package/dist/commands/intuned-cli/helpers/context.js +0 -33
  131. package/package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -13
  132. package/package/dist/commands/intuned-cli/helpers/errors.js +0 -37
  133. package/package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  134. package/package/dist/commands/intuned-cli/helpers/index.js +0 -137
  135. package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -69
  136. package/package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -71
  137. package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  138. package/package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  139. package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  140. package/package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  141. package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  142. package/package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  143. package/package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  144. package/package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  145. package/package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  146. package/package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  147. package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  148. package/package/dist/commands/intuned-cli/helpers/wrapper.js +0 -60
  149. package/package/dist/commands/intuned-cli/index.d.ts +0 -1
  150. package/package/dist/commands/intuned-cli/index.js +0 -16
  151. package/package/dist/commands/intuned-cli/main.d.ts +0 -1
  152. package/package/dist/commands/intuned-cli/main.js +0 -22
  153. package/package/dist/commands/intuned-cli/types.d.ts +0 -41
  154. package/package/dist/commands/intuned-cli/types.js +0 -12
  155. package/package/dist/commands/ts-check.d.ts +0 -2
  156. package/package/dist/commands/ts-check.js +0 -56
  157. package/package/dist/common/Logger/Logger/index.d.ts +0 -12
  158. package/package/dist/common/Logger/Logger/index.js +0 -60
  159. package/package/dist/common/Logger/Logger/types.d.ts +0 -8
  160. package/package/dist/common/Logger/Logger/types.js +0 -5
  161. package/package/dist/common/Logger/index.d.ts +0 -12
  162. package/package/dist/common/Logger/index.js +0 -60
  163. package/package/dist/common/Logger/types.d.ts +0 -8
  164. package/package/dist/common/Logger/types.js +0 -5
  165. package/package/dist/common/assets/browser_scripts.js +0 -2580
  166. package/package/dist/common/asyncLocalStorage/index.d.ts +0 -16
  167. package/package/dist/common/asyncLocalStorage/index.js +0 -17
  168. package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  169. package/package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  170. package/package/dist/common/cleanEnvironmentVariables.d.ts +0 -1
  171. package/package/dist/common/cleanEnvironmentVariables.js +0 -16
  172. package/package/dist/common/constants.d.ts +0 -10
  173. package/package/dist/common/constants.js +0 -16
  174. package/package/dist/common/contextStorageStateHelpers.d.ts +0 -21
  175. package/package/dist/common/contextStorageStateHelpers.js +0 -81
  176. package/package/dist/common/extensionsHelpers.d.ts +0 -8
  177. package/package/dist/common/extensionsHelpers.js +0 -80
  178. package/package/dist/common/formatZodError.d.ts +0 -2
  179. package/package/dist/common/formatZodError.js +0 -18
  180. package/package/dist/common/jwtTokenManager.d.ts +0 -17
  181. package/package/dist/common/jwtTokenManager.js +0 -109
  182. package/package/dist/common/launchBrowser.d.ts +0 -25
  183. package/package/dist/common/launchBrowser.js +0 -172
  184. package/package/dist/common/playwrightContext.d.ts +0 -31
  185. package/package/dist/common/playwrightContext.js +0 -144
  186. package/package/dist/common/runApi/errors.d.ts +0 -72
  187. package/package/dist/common/runApi/errors.js +0 -169
  188. package/package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  189. package/package/dist/common/runApi/importUsingImportFunction.js +0 -46
  190. package/package/dist/common/runApi/index.d.ts +0 -11
  191. package/package/dist/common/runApi/index.js +0 -199
  192. package/package/dist/common/runApi/types.d.ts +0 -830
  193. package/package/dist/common/runApi/types.js +0 -73
  194. package/package/dist/common/settingsSchema.d.ts +0 -518
  195. package/package/dist/common/settingsSchema.js +0 -57
  196. package/package/dist/common/setupContextHook.d.ts +0 -17
  197. package/package/dist/common/setupContextHook.js +0 -22
  198. package/package/dist/common/telemetry.d.ts +0 -3
  199. package/package/dist/common/telemetry.js +0 -32
  200. package/package/dist/index.d.ts +0 -4
  201. package/package/dist/index.js +0 -69
  202. package/package/dist/runtime/RunError.d.ts +0 -5
  203. package/package/dist/runtime/RunError.js +0 -19
  204. package/package/dist/runtime/attemptStore.d.ts +0 -2
  205. package/package/dist/runtime/attemptStore.js +0 -23
  206. package/package/dist/runtime/downloadDirectory.d.ts +0 -1
  207. package/package/dist/runtime/downloadDirectory.js +0 -19
  208. package/package/dist/runtime/enums.d.js +0 -5
  209. package/package/dist/runtime/enums.d.ts +0 -11
  210. package/package/dist/runtime/enums.js +0 -18
  211. package/package/dist/runtime/executionHelpers.test.js +0 -52
  212. package/package/dist/runtime/export.d.js +0 -5
  213. package/package/dist/runtime/export.d.ts +0 -228
  214. package/package/dist/runtime/extendPayload.d.ts +0 -2
  215. package/package/dist/runtime/extendPayload.js +0 -21
  216. package/package/dist/runtime/extendTimeout.d.ts +0 -1
  217. package/package/dist/runtime/extendTimeout.js +0 -23
  218. package/package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  219. package/package/dist/runtime/getAuthSessionParameters.js +0 -20
  220. package/package/dist/runtime/index.d.ts +0 -7
  221. package/package/dist/runtime/index.js +0 -54
  222. package/package/dist/runtime/runInfo.d.ts +0 -2
  223. package/package/dist/runtime/runInfo.js +0 -21
@@ -1,345 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.projectNameSchema = void 0;
7
- exports.runSaveProject = runSaveProject;
8
- exports.validateProjectName = exports.validateIntunedProject = void 0;
9
- var fs = _interopRequireWildcard(require("fs-extra"));
10
- var path = _interopRequireWildcard(require("path"));
11
- var _minimatch = require("minimatch");
12
- var _zod = require("zod");
13
- var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
14
- var _constants = require("../constants");
15
- var _helpers = require("../helpers");
16
- var _lodash = require("lodash");
17
- var _uuid = require("uuid");
18
- var _terminal = require("../helpers/terminal");
19
- var _build = require("./build");
20
- var dotenv = _interopRequireWildcard(require("dotenv"));
21
- var _constants2 = require("../../../common/constants");
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
- 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); }
24
- 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; }
25
- const saveProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
26
- try {
27
- return JSON.parse(val);
28
- } catch (e) {
29
- ctx.addIssue({
30
- code: _zod.z.ZodIssueCode.custom,
31
- message: "Response is not valid JSON"
32
- });
33
- return _zod.z.NEVER;
34
- }
35
- }).pipe(_zod.z.object({
36
- id: _zod.z.string().uuid()
37
- }));
38
- async function runSaveProject(projectName, auth) {
39
- const {
40
- workspaceId,
41
- apiKey
42
- } = auth;
43
- const baseUrl = (0, _helpers.getBaseUrl)();
44
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}`;
45
- const headers = {
46
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
47
- "Content-Type": "application/json"
48
- };
49
- const projectPath = process.cwd();
50
- const codeTree = await convertProjectToCodeTree(projectPath);
51
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
52
- codeTree["Intuned.json"] = {
53
- file: {
54
- contents: JSON.stringify(intunedSettingsFile.parse(await fs.readFile(intunedSettingsFile.path, "utf-8")))
55
- }
56
- };
57
- codeTree["tsconfig.json"] = {
58
- file: {
59
- contents: JSON.stringify(_constants.tsConfigCli, null, 2)
60
- }
61
- };
62
- const saveProjectPayload = {
63
- codeTree,
64
- platformType: "CLI",
65
- language: "typescript"
66
- };
67
- const response = await fetch(url, {
68
- headers,
69
- method: "PUT",
70
- body: JSON.stringify(saveProjectPayload)
71
- });
72
- if (!response.ok) {
73
- if (response.status === 401) {
74
- throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
75
- }
76
- throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project save failed^:\n`, {
77
- autoColor: false
78
- });
79
- }
80
- (0, _terminal.terminal)("^g^+Project saved successfully!^:\n");
81
- const body = await response.text();
82
- const parseResult = saveProjectApiResponseSchema.safeParse(body);
83
- if (!parseResult.success) {
84
- (0, _terminal.terminal)(`^yWarning: Could not parse save project response:^:\n`);
85
- (0, _terminal.terminal)(body + "\n");
86
- return;
87
- }
88
- const {
89
- id: projectId
90
- } = parseResult.data;
91
- const dotEnvPath = path.join(projectPath, ".env");
92
- if (!(await fs.exists(dotEnvPath))) {
93
- await fs.writeFile(dotEnvPath, `${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}
94
- ${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
95
- ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
96
- (0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
97
- }
98
- const envContent = await fs.readFile(dotEnvPath, "utf-8");
99
- const dotenvContent = dotenv.parse(envContent);
100
- let contentToAppend = "";
101
- if (!dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] || dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] !== projectId) {
102
- contentToAppend += `\n${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}`;
103
- }
104
- if (!dotenvContent[_constants2.WORKSPACE_ID_ENV_VAR_KEY]) {
105
- contentToAppend += `\n${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}`;
106
- }
107
- if (!dotenvContent[_constants2.API_KEY_ENV_VAR_KEY]) {
108
- contentToAppend += `\n${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`;
109
- }
110
- if (contentToAppend) {
111
- await fs.appendFile(dotEnvPath, contentToAppend + "\n");
112
- (0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
113
- }
114
- }
115
- const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
116
- message: "Name cannot be a UUID"
117
- });
118
- const validateProjectName = projectName => {
119
- const validation = projectNameSchema.safeParse(projectName);
120
- if (!validation.success) {
121
- return {
122
- isValid: false,
123
- errorMessage: validation.error.errors[0].message
124
- };
125
- }
126
- return {
127
- isValid: true
128
- };
129
- };
130
- exports.validateProjectName = validateProjectName;
131
- const validateIntunedProject = async () => {
132
- const currentDirectoryToSave = process.cwd();
133
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
134
- const validationSteps = [{
135
- name: "build",
136
- check: async () => {
137
- try {
138
- const buildResult = await (0, _build.runBuild)();
139
- if (!buildResult) {
140
- return {
141
- isValid: false,
142
- errorMessage: "Build failed"
143
- };
144
- }
145
- return {
146
- isValid: true
147
- };
148
- } catch (error) {
149
- return {
150
- isValid: false,
151
- errorMessage: "Build failed"
152
- };
153
- }
154
- }
155
- }, {
156
- name: intunedSettingsFile.name,
157
- check: async () => {
158
- try {
159
- const intunedJsonPath = path.join(currentDirectoryToSave, intunedSettingsFile.name);
160
- await fs.exists(intunedJsonPath);
161
- return {
162
- isValid: true
163
- };
164
- } catch (error) {
165
- return {
166
- isValid: false,
167
- errorMessage: `${intunedSettingsFile.name} file not found`
168
- };
169
- }
170
- }
171
- }, {
172
- name: "api folder",
173
- check: async () => {
174
- try {
175
- const apiFolderPath = path.join(currentDirectoryToSave, "api");
176
- await fs.access(apiFolderPath);
177
- return {
178
- isValid: true
179
- };
180
- } catch (error) {
181
- return {
182
- isValid: false,
183
- errorMessage: "API folder not found"
184
- };
185
- }
186
- }
187
- }];
188
- for (const step of validationSteps) {
189
- const result = await step.check();
190
- if (!result.isValid) {
191
- return result;
192
- }
193
- }
194
- return {
195
- isValid: true
196
- };
197
- };
198
- exports.validateIntunedProject = validateIntunedProject;
199
- function ignoreFilesByPattern(filePath, patterns, projectPath) {
200
- const relativePath = path.relative(projectPath, filePath);
201
- if (relativePath.startsWith("node_modules")) {
202
- return true;
203
- }
204
- for (const pattern of patterns) {
205
- if (!pattern || pattern.startsWith("#")) continue;
206
- if (pattern.startsWith("!")) {
207
- if ((0, _minimatch.minimatch)(relativePath, pattern.substring(1))) {
208
- return false;
209
- }
210
- } else if ((0, _minimatch.minimatch)(relativePath, pattern)) {
211
- return true;
212
- }
213
- }
214
- return false;
215
- }
216
- function listFilesNotIgnored(projectPath, ignorePatterns) {
217
- const results = [];
218
- function traverseDirectory(dirPath) {
219
- try {
220
- const entries = fs.readdirSync(dirPath);
221
- for (const entry of entries) {
222
- const fullPath = path.join(dirPath, entry);
223
- if (ignoreFilesByPattern(fullPath, ignorePatterns, projectPath)) {
224
- continue;
225
- }
226
- try {
227
- const stats = fs.statSync(fullPath);
228
- if (stats.isDirectory()) {
229
- traverseDirectory(fullPath);
230
- } else if (stats.isFile()) {
231
- results.push(path.relative(projectPath, fullPath));
232
- }
233
- } catch (error) {
234
- (0, _terminal.terminal)(`^yWarning: Could not access ${fullPath}^:\n`);
235
- }
236
- }
237
- } catch (error) {
238
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
239
- }
240
- }
241
- traverseDirectory(projectPath);
242
- return results;
243
- }
244
- async function convertProjectToCodeTree(projectPath) {
245
- const filesToSave = listFilesNotIgnored(projectPath, _projectExclusions.default);
246
- const filesToSaveText = " " + filesToSave.join("\n ");
247
- (0, _terminal.terminal)("^CFiles to be saved:^:\n");
248
- (0, _terminal.terminal)(filesToSaveText + "\n");
249
- function readDirectory(dirPath) {
250
- const tree = {};
251
- try {
252
- const entries = fs.readdirSync(dirPath);
253
- for (const entry of entries) {
254
- const entryPath = path.join(dirPath, entry);
255
- if (ignoreFilesByPattern(entryPath, _projectExclusions.default, projectPath)) {
256
- continue;
257
- }
258
- try {
259
- const stats = fs.statSync(entryPath);
260
- if (stats.isFile()) {
261
- try {
262
- const content = fs.readFileSync(entryPath, "utf-8");
263
- tree[entry] = {
264
- file: {
265
- contents: content
266
- }
267
- };
268
- } catch (error) {
269
- (0, _terminal.terminal)(`^yWarning: Could not read file ${entryPath}^:\n`);
270
- }
271
- } else if (stats.isDirectory()) {
272
- const subTree = readDirectory(entryPath);
273
- if (Object.keys(subTree).length > 0) {
274
- tree[entry] = {
275
- directory: subTree
276
- };
277
- }
278
- }
279
- } catch (error) {
280
- (0, _terminal.terminal)(`^yWarning: Could not access ${entryPath}^:\n`);
281
- }
282
- }
283
- } catch (error) {
284
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
285
- }
286
- return tree;
287
- }
288
- const tree = readDirectory(projectPath);
289
- mapToIDEParams(tree);
290
- return tree;
291
- }
292
- function mapToIDEParams(tree) {
293
- if (!tree) {
294
- return;
295
- }
296
- if (!tree["parameters"] || "file" in tree["parameters"]) {
297
- return;
298
- }
299
- const apiParametersMap = {};
300
- const cliParameters = Object.keys(tree["parameters"].directory);
301
- const ____testParameters = {
302
- directory: {}
303
- };
304
- for (const parameterKey of cliParameters) {
305
- const parameter = tree["parameters"].directory[parameterKey];
306
- if ("directory" in parameter) {
307
- continue;
308
- }
309
- if ((0, _lodash.isEmpty)(parameter.file.contents)) {
310
- continue;
311
- }
312
- const parameterPayload = JSON.parse(parameter.file.contents);
313
- if (!parameterPayload["__api-name"]) {
314
- continue;
315
- }
316
- const api = parameterPayload["__api-name"];
317
- const {
318
- "__api-name": _,
319
- ...parameterValue
320
- } = parameterPayload;
321
- const testParameter = {
322
- name: parameterKey.replace(".json", ""),
323
- lastUsed: false,
324
- id: (0, _uuid.v4)(),
325
- value: JSON.stringify(parameterValue)
326
- };
327
- if (!apiParametersMap[api]) {
328
- apiParametersMap[api] = [];
329
- }
330
- apiParametersMap[api].push(testParameter);
331
- }
332
- for (const api in apiParametersMap) {
333
- if (apiParametersMap[api].length > 0) {
334
- apiParametersMap[api][apiParametersMap[api].length - 1].lastUsed = true;
335
- }
336
- ____testParameters.directory[`${api}.json`] = {
337
- file: {
338
- contents: JSON.stringify(apiParametersMap[api], null, 2)
339
- }
340
- };
341
- }
342
- delete tree["parameters"];
343
- tree["____testParameters"] = ____testParameters;
344
- return;
345
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _browser = require("../browser");
5
- var _launchBrowser = require("../../../../common/launchBrowser");
6
- function getTerminal() {
7
- return new Proxy(() => ({}), {
8
- get: () => getTerminal(),
9
- apply: () => ({})
10
- });
11
- }
12
- _vitest.vi.mock("fs-extra", () => ({
13
- exists: _vitest.vi.fn().mockResolvedValue(true)
14
- }));
15
- _vitest.vi.mock("portfinder", () => ({
16
- getPort: _vitest.vi.fn().mockResolvedValue(1234)
17
- }));
18
- _vitest.vi.mock("../../../../common/launchBrowser", () => ({
19
- launchChromium: _vitest.vi.fn().mockImplementation(async () => ({
20
- context: {
21
- close: _vitest.vi.fn().mockResolvedValue(undefined)
22
- },
23
- page: {}
24
- }))
25
- }));
26
- _vitest.vi.mock("../../helpers/terminal", () => ({
27
- terminal: getTerminal()
28
- }));
29
- _vitest.vi.mock("../../helpers/proxy", () => {
30
- return {
31
- parseUrlProxy: _vitest.vi.fn(v => v)
32
- };
33
- });
34
- _vitest.vi.mock("../../helpers", async importOriginal => {
35
- const original = await importOriginal();
36
- return {
37
- ...original,
38
- terminal: getTerminal()
39
- };
40
- });
41
- (0, _vitest.describe)("Browser CLI options", () => {
42
- (0, _vitest.it)("returns standalone options if keepBrowserOpen is not set", async () => {
43
- const options = await (0, _browser.getCLIRunOptions)({
44
- keepBrowserOpen: false,
45
- headless: false
46
- });
47
- (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
48
- environment: "standalone",
49
- headless: false
50
- }));
51
- });
52
- (0, _vitest.describe)("when keepBrowserOpen is set", () => {
53
- beforeEach(async () => {
54
- _vitest.vi.clearAllMocks();
55
- await (0, _browser.closeCliBrowser)();
56
- });
57
- (0, _vitest.it)("launches a browser with correct parameters and returns cdp options", async () => {
58
- const options = await (0, _browser.getCLIRunOptions)({
59
- keepBrowserOpen: true,
60
- headless: false,
61
- proxy: "proxy"
62
- });
63
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledWith({
64
- headless: false,
65
- cdpPort: 1234,
66
- proxy: "proxy"
67
- });
68
- (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
69
- environment: "cdp",
70
- cdpAddress: "http://localhost:1234"
71
- }));
72
- });
73
- (0, _vitest.it)("keeps context open until new context", async () => {
74
- await (0, _browser.getCLIRunOptions)({
75
- keepBrowserOpen: true,
76
- headless: false,
77
- proxy: "proxy"
78
- });
79
- const firstContext = (0, _browser._getContextForTest)();
80
- (0, _vitest.expect)(firstContext).not.toBeNull();
81
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledTimes(1);
82
- await (0, _browser.getCLIRunOptions)({
83
- keepBrowserOpen: true,
84
- headless: false,
85
- proxy: "proxy"
86
- });
87
- const secondContext = (0, _browser._getContextForTest)();
88
- (0, _vitest.expect)(secondContext).not.toBeNull();
89
- (0, _vitest.expect)(firstContext).not.toBe(secondContext);
90
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledTimes(2);
91
- });
92
- (0, _vitest.it)("keeps context open until explicitly closed", async () => {
93
- await (0, _browser.getCLIRunOptions)({
94
- keepBrowserOpen: true,
95
- headless: false,
96
- proxy: "proxy"
97
- });
98
- (0, _vitest.expect)((0, _browser._getContextForTest)()).not.toBeNull();
99
- await (0, _browser.closeCliBrowser)();
100
- (0, _vitest.expect)((0, _browser._getContextForTest)()).toBeNull();
101
- });
102
- });
103
- });
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _ = require("..");
5
- function getTerminal() {
6
- return new Proxy(() => ({}), {
7
- get: () => getTerminal(),
8
- apply: () => ({})
9
- });
10
- }
11
- _vitest.vi.mock("fs-extra", () => ({
12
- exists: _vitest.vi.fn().mockResolvedValue(true)
13
- }));
14
- _vitest.vi.mock("../../helpers/terminal", () => ({
15
- terminal: getTerminal()
16
- }));
17
- _vitest.vi.mock("../../helpers", async importOriginal => {
18
- const original = await importOriginal();
19
- return {
20
- ...original,
21
- terminal: getTerminal()
22
- };
23
- });
24
- (0, _vitest.describe)("Tracing wrapper", () => {
25
- (0, _vitest.it)("calls wrapped function with disabled tracing when id is undefined", async () => {
26
- const fn = _vitest.vi.fn();
27
- await (0, _.withCLITrace)(fn, undefined);
28
- (0, _vitest.expect)(fn).toHaveBeenCalledWith({
29
- enabled: false
30
- });
31
- });
32
- (0, _vitest.it)("calls wrapped function with enabled tracing when id is defined", async () => {
33
- const fn = _vitest.vi.fn();
34
- await (0, _.withCLITrace)(fn, "trace-id");
35
- (0, _vitest.expect)(fn).toHaveBeenCalledWith({
36
- enabled: true,
37
- filePath: _vitest.expect.stringContaining("trace-id")
38
- });
39
- });
40
- });
@@ -1,3 +0,0 @@
1
- import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
2
- export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
3
- export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assertApiFileExists = assertApiFileExists;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _fsExtra = require("fs-extra");
9
- var _errors = require("./errors");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- async function assertApiFileExists(dirname, api) {
12
- const file = `${dirname}/${api}.ts`;
13
- const filePath = _path.default.join(process.cwd(), file);
14
- if (!(await (0, _fsExtra.exists)(filePath))) {
15
- throw new _errors.CLIAssertionError(`^+^r API^ ^+${dirname}/${api}^ ^r^+is not implemented.^:`, {
16
- autoColor: false
17
- });
18
- }
19
- }
@@ -1,46 +0,0 @@
1
- import type { AuthSessionMetadata } from "../types";
2
- import { RunApiStorageState as StorageState } from "../../../common/runApi";
3
- export declare function isAuthEnabled(): Promise<boolean>;
4
- export declare function assertAuthEnabled(): Promise<void>;
5
- export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
6
- export declare function loadAuthSessionInstance(authSessionId: string): Promise<{
7
- storageState: {
8
- cookies: {
9
- value: string;
10
- name: string;
11
- path: string;
12
- domain: string;
13
- expires: number;
14
- httpOnly: boolean;
15
- secure: boolean;
16
- sameSite: "Strict" | "Lax" | "None";
17
- }[];
18
- origins: {
19
- origin: string;
20
- localStorage: {
21
- value: string;
22
- name: string;
23
- }[];
24
- }[];
25
- sessionStorage?: {
26
- sessionStorage: {
27
- value: string;
28
- name: string;
29
- }[];
30
- origin: string;
31
- }[] | undefined;
32
- };
33
- metadata: AuthSessionMetadata;
34
- }>;
35
- export declare function storeAuthSessionInstance({ state, id, input, proxy, metadata, }: {
36
- state: StorageState;
37
- id: string;
38
- input?: Record<string, any>;
39
- proxy?: string;
40
- metadata?: AuthSessionMetadata;
41
- }): Promise<string>;
42
- export declare function registerGetAuthSessionParameters(authSessionId?: string): void;
43
- export declare function getAuthSessionRecorderParameters(): Promise<{
44
- startUrl: string;
45
- finishUrl: string;
46
- }>;