@intuned/runtime 1.3.16 → 1.3.18-interface.6

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 (295) hide show
  1. package/bin/intuned +0 -0
  2. package/bin/intuned-interface +7 -0
  3. package/dist/chunk-6ZRJOUQS.mjs +16 -0
  4. package/dist/chunk-6ZRJOUQS.mjs.map +1 -0
  5. package/dist/chunk-7YL2JUTE.mjs +146 -0
  6. package/dist/chunk-7YL2JUTE.mjs.map +1 -0
  7. package/dist/chunk-B3T6RXPC.mjs +794 -0
  8. package/dist/chunk-B3T6RXPC.mjs.map +1 -0
  9. package/dist/chunk-FGV5T6SI.mjs +27 -0
  10. package/dist/chunk-FGV5T6SI.mjs.map +1 -0
  11. package/dist/chunk-G4PO5RIV.mjs +85 -0
  12. package/dist/chunk-G4PO5RIV.mjs.map +1 -0
  13. package/dist/chunk-LZOMFHX3.mjs +38 -0
  14. package/dist/chunk-LZOMFHX3.mjs.map +1 -0
  15. package/dist/{common/formatZodError.js → chunk-NDMVGENG.mjs} +9 -9
  16. package/dist/chunk-NDMVGENG.mjs.map +1 -0
  17. package/dist/chunk-W4UX6G4X.mjs +17 -0
  18. package/dist/chunk-W4UX6G4X.mjs.map +1 -0
  19. package/dist/chunk-XC75QGFG.mjs +1106 -0
  20. package/dist/chunk-XC75QGFG.mjs.map +1 -0
  21. package/dist/chunk-XOAZ2MGA.mjs +59 -0
  22. package/dist/chunk-XOAZ2MGA.mjs.map +1 -0
  23. package/dist/commands/interface/run.d.mts +3 -0
  24. package/dist/commands/interface/run.d.ts +3 -1
  25. package/dist/commands/interface/run.js +2060 -178
  26. package/dist/commands/interface/run.js.map +1 -0
  27. package/dist/commands/interface/run.mjs +255 -0
  28. package/dist/commands/interface/run.mjs.map +1 -0
  29. package/dist/common/asyncLocalStorage/index.d.mts +17 -0
  30. package/dist/common/asyncLocalStorage/index.d.ts +9 -8
  31. package/dist/common/asyncLocalStorage/index.js +34 -9
  32. package/dist/common/asyncLocalStorage/index.js.map +1 -0
  33. package/dist/common/asyncLocalStorage/index.mjs +12 -0
  34. package/dist/common/asyncLocalStorage/index.mjs.map +1 -0
  35. package/dist/common/binStartupScript.d.mts +2 -0
  36. package/dist/common/binStartupScript.d.ts +2 -1
  37. package/dist/common/binStartupScript.js +127 -11
  38. package/dist/common/binStartupScript.js.map +1 -0
  39. package/dist/common/binStartupScript.mjs +135 -0
  40. package/dist/common/binStartupScript.mjs.map +1 -0
  41. package/dist/common/cleanEnvironmentVariables.d.mts +3 -0
  42. package/dist/common/cleanEnvironmentVariables.d.ts +3 -1
  43. package/dist/common/cleanEnvironmentVariables.js +30 -7
  44. package/dist/common/cleanEnvironmentVariables.js.map +1 -0
  45. package/dist/common/cleanEnvironmentVariables.mjs +8 -0
  46. package/dist/common/cleanEnvironmentVariables.mjs.map +1 -0
  47. package/dist/common/constants.d.mts +13 -0
  48. package/dist/common/constants.d.ts +13 -10
  49. package/dist/common/constants.js +58 -14
  50. package/dist/common/constants.js.map +1 -0
  51. package/dist/common/constants.mjs +28 -0
  52. package/dist/common/constants.mjs.map +1 -0
  53. package/dist/common/contextStorageStateHelpers.d.mts +24 -0
  54. package/dist/common/contextStorageStateHelpers.d.ts +8 -5
  55. package/dist/common/contextStorageStateHelpers.js +51 -23
  56. package/dist/common/contextStorageStateHelpers.js.map +1 -0
  57. package/dist/common/contextStorageStateHelpers.mjs +10 -0
  58. package/dist/common/contextStorageStateHelpers.mjs.map +1 -0
  59. package/dist/common/jwtTokenManager.d.mts +19 -0
  60. package/dist/common/jwtTokenManager.d.ts +6 -4
  61. package/dist/common/jwtTokenManager.js +112 -40
  62. package/dist/common/jwtTokenManager.js.map +1 -0
  63. package/dist/common/jwtTokenManager.mjs +11 -0
  64. package/dist/common/jwtTokenManager.mjs.map +1 -0
  65. package/dist/common/runApi/index.d.mts +11 -0
  66. package/dist/common/runApi/index.d.ts +10 -10
  67. package/dist/common/runApi/index.js +1776 -93
  68. package/dist/common/runApi/index.js.map +1 -0
  69. package/dist/common/runApi/index.mjs +18 -0
  70. package/dist/common/runApi/index.mjs.map +1 -0
  71. package/dist/common/settingsSchema.d.mts +536 -0
  72. package/dist/common/settingsSchema.d.ts +9 -6
  73. package/dist/common/settingsSchema.js +55 -20
  74. package/dist/common/settingsSchema.js.map +1 -0
  75. package/dist/common/settingsSchema.mjs +10 -0
  76. package/dist/common/settingsSchema.mjs.map +1 -0
  77. package/dist/common/telemetry.d.mts +6 -0
  78. package/dist/common/telemetry.d.ts +6 -3
  79. package/dist/common/telemetry.js +41 -9
  80. package/dist/common/telemetry.js.map +1 -0
  81. package/dist/common/telemetry.mjs +31 -0
  82. package/dist/common/telemetry.mjs.map +1 -0
  83. package/dist/export.d-BAUMB-lG.d.mts +140 -0
  84. package/dist/export.d-BAUMB-lG.d.ts +140 -0
  85. package/dist/index.d.mts +6 -0
  86. package/dist/index.d.ts +6 -5
  87. package/dist/index.js +783 -98
  88. package/dist/index.js.map +1 -0
  89. package/dist/index.mjs +47 -0
  90. package/dist/index.mjs.map +1 -0
  91. package/dist/runtime/index.d.mts +163 -0
  92. package/dist/runtime/index.d.ts +163 -10
  93. package/dist/runtime/index.js +779 -88
  94. package/dist/runtime/index.js.map +1 -0
  95. package/dist/runtime/index.mjs +42 -0
  96. package/dist/runtime/index.mjs.map +1 -0
  97. package/package.json +80 -23
  98. package/.babelrc +0 -21
  99. package/.eslintignore +0 -10
  100. package/.eslintrc.js +0 -39
  101. package/InterfaceTemplate/index.playwright.ts +0 -6
  102. package/InterfaceTemplate/utils.ts +0 -61
  103. package/dist/commands/api/run.d.ts +0 -6
  104. package/dist/commands/api/run.js +0 -123
  105. package/dist/commands/auth-sessions/load.d.ts +0 -2
  106. package/dist/commands/auth-sessions/load.js +0 -35
  107. package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  108. package/dist/commands/auth-sessions/run-check.js +0 -74
  109. package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  110. package/dist/commands/auth-sessions/run-create.js +0 -78
  111. package/dist/commands/browser/save-state.d.ts +0 -2
  112. package/dist/commands/browser/save-state.js +0 -17
  113. package/dist/commands/browser/start-browser.d.ts +0 -2
  114. package/dist/commands/browser/start-browser.js +0 -14
  115. package/dist/commands/build.d.ts +0 -1
  116. package/dist/commands/build.js +0 -84
  117. package/dist/commands/common/browserUtils.d.ts +0 -14
  118. package/dist/commands/common/browserUtils.js +0 -58
  119. package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  120. package/dist/commands/common/getFirstLineNumber.js +0 -101
  121. package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  122. package/dist/commands/common/projectExclusions.d.ts +0 -2
  123. package/dist/commands/common/projectExclusions.js +0 -8
  124. package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  125. package/dist/commands/common/sendMessageToClient.js +0 -10
  126. package/dist/commands/common/tsNodeImport.d.ts +0 -2
  127. package/dist/commands/common/tsNodeImport.js +0 -34
  128. package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  129. package/dist/commands/common/utils/fileUtils.js +0 -33
  130. package/dist/commands/common/utils/settings.d.ts +0 -2
  131. package/dist/commands/common/utils/settings.js +0 -31
  132. package/dist/commands/common/utils/template.d.ts +0 -2
  133. package/dist/commands/common/utils/template.js +0 -31
  134. package/dist/commands/common/utils/unixSocket.d.ts +0 -23
  135. package/dist/commands/common/utils/unixSocket.js +0 -87
  136. package/dist/commands/get-headless-user-agent.d.ts +0 -1
  137. package/dist/commands/get-headless-user-agent.js +0 -18
  138. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  139. package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  140. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  141. package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  142. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  143. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  144. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  145. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  146. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  147. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  148. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  149. package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  150. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  151. package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
  152. package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  153. package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  154. package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  155. package/dist/commands/intuned-cli/commands/command.js +0 -9
  156. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  157. package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
  158. package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  159. package/dist/commands/intuned-cli/commands/index.js +0 -203
  160. package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  161. package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  162. package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  163. package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  164. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  165. package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  166. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
  167. package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  168. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  169. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  170. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  171. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  172. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  173. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  174. package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
  175. package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  176. package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
  177. package/dist/commands/intuned-cli/commands/types.js +0 -31
  178. package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  179. package/dist/commands/intuned-cli/constants/index.js +0 -25
  180. package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
  181. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
  182. package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  183. package/dist/commands/intuned-cli/controller/api.js +0 -191
  184. package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  185. package/dist/commands/intuned-cli/controller/authSession.js +0 -424
  186. package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  187. package/dist/commands/intuned-cli/controller/build.js +0 -36
  188. package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
  189. package/dist/commands/intuned-cli/controller/deploy.js +0 -276
  190. package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  191. package/dist/commands/intuned-cli/controller/index.js +0 -46
  192. package/dist/commands/intuned-cli/controller/save.d.ts +0 -17
  193. package/dist/commands/intuned-cli/controller/save.js +0 -351
  194. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -114
  195. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
  196. package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  197. package/dist/commands/intuned-cli/helpers/api.js +0 -19
  198. package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  199. package/dist/commands/intuned-cli/helpers/auth.js +0 -144
  200. package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  201. package/dist/commands/intuned-cli/helpers/backend.js +0 -27
  202. package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
  203. package/dist/commands/intuned-cli/helpers/browser.js +0 -64
  204. package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  205. package/dist/commands/intuned-cli/helpers/context.js +0 -33
  206. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
  207. package/dist/commands/intuned-cli/helpers/errors.js +0 -44
  208. package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  209. package/dist/commands/intuned-cli/helpers/index.js +0 -137
  210. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
  211. package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
  212. package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  213. package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  214. package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  215. package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  216. package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  217. package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  218. package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  219. package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  220. package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  221. package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  222. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  223. package/dist/commands/intuned-cli/helpers/wrapper.js +0 -66
  224. package/dist/commands/intuned-cli/index.d.ts +0 -1
  225. package/dist/commands/intuned-cli/index.js +0 -16
  226. package/dist/commands/intuned-cli/main.d.ts +0 -1
  227. package/dist/commands/intuned-cli/main.js +0 -23
  228. package/dist/commands/intuned-cli/types.d.ts +0 -41
  229. package/dist/commands/intuned-cli/types.js +0 -12
  230. package/dist/commands/ts-check.d.ts +0 -2
  231. package/dist/commands/ts-check.js +0 -56
  232. package/dist/common/Logger/Logger/index.d.ts +0 -12
  233. package/dist/common/Logger/Logger/index.js +0 -60
  234. package/dist/common/Logger/Logger/types.d.ts +0 -8
  235. package/dist/common/Logger/Logger/types.js +0 -5
  236. package/dist/common/Logger/index.d.ts +0 -12
  237. package/dist/common/Logger/index.js +0 -60
  238. package/dist/common/Logger/types.d.ts +0 -8
  239. package/dist/common/Logger/types.js +0 -5
  240. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  241. package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  242. package/dist/common/extension/extensionsHelpers.d.ts +0 -11
  243. package/dist/common/extension/extensionsHelpers.js +0 -147
  244. package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
  245. package/dist/common/extension/intunedExtensionServer.js +0 -178
  246. package/dist/common/extension/types.d.ts +0 -212
  247. package/dist/common/extension/types.js +0 -51
  248. package/dist/common/formatZodError.d.ts +0 -2
  249. package/dist/common/intunedJson.d.ts +0 -229
  250. package/dist/common/intunedJson.js +0 -133
  251. package/dist/common/launchBrowser.d.ts +0 -31
  252. package/dist/common/launchBrowser.js +0 -207
  253. package/dist/common/playwrightContext.d.ts +0 -31
  254. package/dist/common/playwrightContext.js +0 -144
  255. package/dist/common/runApi/errors.d.ts +0 -72
  256. package/dist/common/runApi/errors.js +0 -169
  257. package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  258. package/dist/common/runApi/importUsingImportFunction.js +0 -46
  259. package/dist/common/runApi/types.d.ts +0 -830
  260. package/dist/common/runApi/types.js +0 -73
  261. package/dist/common/setupContextHook.d.ts +0 -17
  262. package/dist/common/setupContextHook.js +0 -22
  263. package/dist/runtime/RunError.d.ts +0 -5
  264. package/dist/runtime/RunError.js +0 -19
  265. package/dist/runtime/attemptStore.d.ts +0 -2
  266. package/dist/runtime/attemptStore.js +0 -23
  267. package/dist/runtime/captcha.d.ts +0 -15
  268. package/dist/runtime/captcha.js +0 -191
  269. package/dist/runtime/captcha.test.js +0 -821
  270. package/dist/runtime/downloadDirectory.d.ts +0 -1
  271. package/dist/runtime/downloadDirectory.js +0 -19
  272. package/dist/runtime/enums.d.js +0 -5
  273. package/dist/runtime/enums.d.ts +0 -11
  274. package/dist/runtime/enums.js +0 -18
  275. package/dist/runtime/executionHelpers.test.js +0 -52
  276. package/dist/runtime/export.d.js +0 -5
  277. package/dist/runtime/export.d.ts +0 -284
  278. package/dist/runtime/extendPayload.d.ts +0 -2
  279. package/dist/runtime/extendPayload.js +0 -21
  280. package/dist/runtime/extendTimeout.d.ts +0 -1
  281. package/dist/runtime/extendTimeout.js +0 -23
  282. package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
  283. package/dist/runtime/getAiGatewayConfig.js +0 -16
  284. package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  285. package/dist/runtime/getAuthSessionParameters.js +0 -20
  286. package/dist/runtime/persistentStore.d.ts +0 -2
  287. package/dist/runtime/persistentStore.js +0 -37
  288. package/dist/runtime/persistentStore.test.js +0 -101
  289. package/dist/runtime/runInfo.d.ts +0 -2
  290. package/dist/runtime/runInfo.js +0 -21
  291. package/template.tsconfig.json +0 -11
  292. package/tsconfig.eslint.json +0 -5
  293. package/tsconfig.json +0 -25
  294. package/typedoc.json +0 -49
  295. /package/dist/common/assets/{browser_scripts.js → assets/browser_scripts.js} +0 -0
@@ -1,276 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.projectNameSchema = exports.START_RUN_INPUT_QUERY_PARAM_KEY = void 0;
7
- exports.runDeployProject = runDeployProject;
8
- var _zod = require("zod");
9
- var _constants = require("../constants");
10
- var _helpers = require("../helpers");
11
- var _terminal = require("../helpers/terminal");
12
- var _promises = require("timers/promises");
13
- var _ms = _interopRequireDefault(require("ms"));
14
- var _save = require("./save");
15
- var _constants2 = require("../../../common/constants");
16
- var _path = _interopRequireDefault(require("path"));
17
- var fs = _interopRequireWildcard(require("fs-extra"));
18
- var _prompts = _interopRequireDefault(require("prompts"));
19
- var _terminalLink = _interopRequireDefault(require("terminal-link"));
20
- 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); }
21
- 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; }
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
- const START_RUN_INPUT_QUERY_PARAM_KEY = exports.START_RUN_INPUT_QUERY_PARAM_KEY = "startRunInput";
24
- async function runDeployProject(projectName, auth) {
25
- const result = await (0, _save.runSaveProject)(projectName, auth);
26
- const enableFirstRunExperience = result?.enableFirstRunExperience ?? false;
27
- let firstRunExperienceInput = undefined;
28
- const settings = await (0, _helpers.loadIntunedJson)();
29
- if (enableFirstRunExperience) {
30
- firstRunExperienceInput = await promptFirstRunExperience(settings);
31
- }
32
- const {
33
- workspaceId,
34
- apiKey
35
- } = auth;
36
- const baseUrl = (0, _helpers.getBaseUrl)();
37
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy`;
38
- const headers = {
39
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
40
- "Content-Type": "application/json"
41
- };
42
- const response = await fetch(url, {
43
- headers,
44
- method: "POST",
45
- body: JSON.stringify({
46
- firstRunExperienceInput
47
- })
48
- });
49
- if (!response.ok) {
50
- if (response.status === 401) {
51
- throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
52
- }
53
- throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project deployment failed^:\n`, {
54
- autoColor: false
55
- });
56
- }
57
- (0, _terminal.terminal)("\n");
58
- const startTime = Date.now();
59
- const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
60
- function* getSpinnerGenerator() {
61
- while (true) {
62
- yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
63
- }
64
- }
65
- const spinnerGen = getSpinnerGenerator();
66
- let updateSpinnerInterval = null;
67
- if (_terminal.terminalStdout.isTTY) {
68
- updateSpinnerInterval = setInterval(() => {
69
- _terminal.terminal.previousLine(1);
70
- _terminal.terminal.column(0);
71
- _terminal.terminal.eraseLineAfter();
72
- (0, _terminal.terminal)(`${spinnerGen.next().value} ^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
73
- }, 50);
74
- (0, _terminal.terminal)("\n");
75
- } else {
76
- (0, _terminal.terminal)(`^cDeploying ^:\n`);
77
- }
78
- try {
79
- while (true) {
80
- await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
81
- if (!_terminal.terminalStdout.isTTY) {
82
- (0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
83
- }
84
- const {
85
- status,
86
- message,
87
- projectId,
88
- ...rest
89
- } = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
90
- if (status === "pending") {
91
- const elapsedTime = Date.now() - startTime;
92
- if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
93
- throw new _helpers.CLIError(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / (0, _ms.default)("1 minute"))} minutes`);
94
- }
95
- continue;
96
- }
97
- _terminal.terminal.previousLine(1);
98
- _terminal.terminal.eraseLine();
99
- if (updateSpinnerInterval) {
100
- clearTimeout(updateSpinnerInterval);
101
- }
102
- if (status === "completed") {
103
- const url = (0, _helpers.getBaseUrl)();
104
- (0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n\n`);
105
- const projectUrl = `${url}/projects/${projectId}`;
106
- const runsUrl = `${projectUrl}/runs`;
107
- const jobsUrl = `${projectUrl}/jobs`;
108
- const runsPlaygroundUrl = `${runsUrl}?${buildRunsPlaygroundQueryParams({
109
- enableFirstRunExperience,
110
- settings,
111
- testAuthSessionId: rest.testAuthSessionId
112
- })}`;
113
- const defaultJobTriggerUrl = rest.defaultJobId ? `${jobsUrl}/${rest.defaultJobId}?action=trigger` : undefined;
114
- const actions = [{
115
- label: "View Project",
116
- url: runsUrl
117
- }, ...(settings.apiAccess.enabled ? [{
118
- label: "Run Playground",
119
- url: runsPlaygroundUrl
120
- }] : []), {
121
- label: "Manage Jobs",
122
- url: jobsUrl
123
- }, ...(defaultJobTriggerUrl !== undefined ? [{
124
- label: "Trigger Default Job",
125
- url: defaultJobTriggerUrl
126
- }] : [])];
127
- if (_terminalLink.default.isSupported) {
128
- for (const action of actions) {
129
- const link = (0, _terminalLink.default)(`[ ${action.label} ]`, action.url);
130
- (0, _terminal.terminal)(`^+${link.replaceAll("%", "%%")}^ `);
131
- }
132
- (0, _terminal.terminal)("\n");
133
- } else {
134
- for (const action of actions) {
135
- (0, _terminal.terminal)(`^+${action.label}:^ ^c^_${action.url}^:\n`);
136
- }
137
- }
138
- return;
139
- }
140
- let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
141
- if (rest.reason) {
142
- errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
143
- }
144
- errorMessage += `^r^+Project deployment failed^:\n`;
145
- throw new _helpers.CLIError(errorMessage, {
146
- autoColor: false
147
- });
148
- }
149
- } catch (e) {
150
- if (updateSpinnerInterval) {
151
- clearTimeout(updateSpinnerInterval);
152
- }
153
- throw e;
154
- }
155
- }
156
- 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, {
157
- message: "Name cannot be a UUID"
158
- });
159
- const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
160
- const baseUrl = (0, _helpers.getBaseUrl)();
161
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy/result`;
162
- const headers = {
163
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
164
- "Content-Type": "application/json"
165
- };
166
- const response = await fetch(url, {
167
- headers,
168
- method: "GET"
169
- });
170
- if (response.status === 404) {
171
- return {
172
- status: "not_found",
173
- message: "Project not found"
174
- };
175
- }
176
- if (!response.ok) {
177
- throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
178
- }
179
- const data = await response.json();
180
- if (data.status) {
181
- return data;
182
- }
183
- return {
184
- status: "failed",
185
- message: `Deployment failed, please try again: ${data.message}`
186
- };
187
- };
188
- async function promptFirstRunExperience(settings) {
189
- let testAuthSessionInput = undefined;
190
- const shouldPromptForTestAuthSession = settings.authSessions.enabled && settings.authSessions.type === "API";
191
- const defaultJobInput = settings.metadata?.defaultJobInput;
192
- const shouldPromptForDefaultJob = defaultJobInput !== undefined;
193
- if (shouldPromptForTestAuthSession) {
194
- testAuthSessionInput = await promptFirstRunExperienceTestAuthSessionParameters({
195
- shouldPromptForDefaultJob
196
- });
197
- if (!testAuthSessionInput) {
198
- return {};
199
- }
200
- }
201
- return {
202
- testAuthSessionInput,
203
- defaultJobInput: shouldPromptForDefaultJob ? await promptFirstRunExperienceDefaultJobParameters({
204
- defaultJobInput
205
- }) : undefined
206
- };
207
- }
208
- async function promptFirstRunExperienceTestAuthSessionParameters({
209
- shouldPromptForDefaultJob
210
- }) {
211
- const authSessionInstancesDirectory = _path.default.join(process.cwd(), _constants2.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
212
- if (!(await fs.exists(authSessionInstancesDirectory))) {
213
- return;
214
- }
215
- const authSessionId = (await fs.readdir(authSessionInstancesDirectory)).shift();
216
- if (!authSessionId) {
217
- return;
218
- }
219
- const {
220
- metadata
221
- } = await (0, _helpers.loadAuthSessionInstance)(authSessionId);
222
- if (!metadata.authSessionId) {
223
- return;
224
- }
225
- const message = shouldPromptForDefaultJob ? `^:^+Create a test auth session using^ ^c${authSessionId}^:^+ parameters?^ ^/(required for creating default job)^:` : `^:^+Create a test auth session using^ ^c${authSessionId}^:^+ parameters?^:`;
226
- const {
227
- value
228
- } = await (0, _prompts.default)({
229
- type: "confirm",
230
- name: "value",
231
- message: _terminal.terminal.str(message).toString(),
232
- initial: true
233
- });
234
- if (value === undefined) {
235
- throw new _helpers.AbortedCLIError();
236
- }
237
- if (value) {
238
- return metadata.authSessionInput;
239
- }
240
- }
241
- async function promptFirstRunExperienceDefaultJobParameters({
242
- defaultJobInput
243
- }) {
244
- const {
245
- value
246
- } = await (0, _prompts.default)({
247
- type: "confirm",
248
- name: "value",
249
- message: _terminal.terminal.str(`^:^+Create a default job with sample parameters?^:`).toString(),
250
- initial: true
251
- });
252
- if (value === undefined) {
253
- throw new _helpers.AbortedCLIError();
254
- }
255
- if (value) {
256
- return defaultJobInput;
257
- }
258
- }
259
- function buildRunsPlaygroundQueryParams({
260
- enableFirstRunExperience,
261
- settings,
262
- testAuthSessionId
263
- }) {
264
- const params = new URLSearchParams();
265
- if (!enableFirstRunExperience) return params.toString();
266
- params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({}));
267
- const input = settings.metadata?.defaultRunPlaygroundInput;
268
- if (!input) return params.toString();
269
- if (testAuthSessionId) {
270
- input.authSessionId = testAuthSessionId;
271
- }
272
- params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({
273
- ...input
274
- }));
275
- return params.toString();
276
- }
@@ -1 +0,0 @@
1
- export declare function loadParameters(parameters: string): Promise<object | null>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadParameters = loadParameters;
7
- var fs = _interopRequireWildcard(require("fs-extra"));
8
- var _helpers = require("../helpers");
9
- 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); }
10
- 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; }
11
- async function loadParameters(parameters) {
12
- let inputData;
13
- if (await fs.exists(parameters)) {
14
- inputData = await loadParametersFromFile(parameters);
15
- } else {
16
- try {
17
- inputData = JSON.parse(parameters);
18
- } catch (err) {
19
- throw new _helpers.CLIError("Parameters must be a valid JSON string or a path to a JSON file");
20
- }
21
- }
22
- return inputData;
23
- }
24
- async function loadParametersFromFile(parametersFile) {
25
- if (!parametersFile) {
26
- return {};
27
- }
28
- try {
29
- const filePath = parametersFile;
30
- await fs.access(filePath);
31
- let inputData = null;
32
- if (parametersFile) {
33
- inputData = await fs.readJSON(filePath);
34
- } else {
35
- inputData = {};
36
- }
37
- return inputData;
38
- } catch (error) {
39
- if (error.code === "ENOENT") {
40
- throw new _helpers.CLIError(`Parameters file not found: ${parametersFile}`);
41
- } else if (error instanceof SyntaxError) {
42
- throw new _helpers.CLIError(`Invalid JSON in parameters file: ${error.message}`);
43
- }
44
- throw new _helpers.CLIError(`Error reading parameters file: ${error.message}`);
45
- }
46
- }
@@ -1,17 +0,0 @@
1
- import { z } from "zod";
2
- import type { AuthCredentials } from "../types";
3
- export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<{
4
- projectId: string;
5
- enableFirstRunExperience: boolean | undefined;
6
- } | undefined>;
7
- export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
8
- export declare const validateProjectName: (projectName: string) => {
9
- isValid: true;
10
- } | {
11
- isValid: false;
12
- errorMessage: string;
13
- };
14
- export declare const validateIntunedProject: () => Promise<{
15
- isValid: boolean;
16
- errorMessage?: string;
17
- }>;
@@ -1,351 +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
- enableFirstRunExperience: _zod.z.boolean().optional()
38
- }));
39
- async function runSaveProject(projectName, auth) {
40
- const {
41
- workspaceId,
42
- apiKey
43
- } = auth;
44
- const baseUrl = (0, _helpers.getBaseUrl)();
45
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}`;
46
- const headers = {
47
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
48
- "Content-Type": "application/json"
49
- };
50
- const projectPath = process.cwd();
51
- const codeTree = await convertProjectToCodeTree(projectPath);
52
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
53
- codeTree["Intuned.json"] = {
54
- file: {
55
- contents: JSON.stringify(intunedSettingsFile.parse(await fs.readFile(intunedSettingsFile.path, "utf-8")))
56
- }
57
- };
58
- codeTree["tsconfig.json"] = {
59
- file: {
60
- contents: JSON.stringify(_constants.tsConfigCli, null, 2)
61
- }
62
- };
63
- const saveProjectPayload = {
64
- codeTree,
65
- platformType: "CLI",
66
- language: "typescript"
67
- };
68
- const response = await fetch(url, {
69
- headers,
70
- method: "PUT",
71
- body: JSON.stringify(saveProjectPayload)
72
- });
73
- if (!response.ok) {
74
- if (response.status === 401) {
75
- throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
76
- }
77
- throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project save failed^:\n`, {
78
- autoColor: false
79
- });
80
- }
81
- (0, _terminal.terminal)("^g^+Project saved successfully!^:\n");
82
- const body = await response.text();
83
- const parseResult = saveProjectApiResponseSchema.safeParse(body);
84
- if (!parseResult.success) {
85
- (0, _terminal.terminal)(`^yWarning: Could not parse save project response:^:\n`);
86
- (0, _terminal.terminal)(body + "\n");
87
- return;
88
- }
89
- const {
90
- id: projectId,
91
- enableFirstRunExperience
92
- } = parseResult.data;
93
- const dotEnvPath = path.join(projectPath, ".env");
94
- if (!(await fs.exists(dotEnvPath))) {
95
- await fs.writeFile(dotEnvPath, `${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}
96
- ${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
97
- ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
98
- (0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
99
- }
100
- const envContent = await fs.readFile(dotEnvPath, "utf-8");
101
- const dotenvContent = dotenv.parse(envContent);
102
- let contentToAppend = "";
103
- if (!dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] || dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] !== projectId) {
104
- contentToAppend += `\n${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}`;
105
- }
106
- if (!dotenvContent[_constants2.WORKSPACE_ID_ENV_VAR_KEY]) {
107
- contentToAppend += `\n${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}`;
108
- }
109
- if (!dotenvContent[_constants2.API_KEY_ENV_VAR_KEY]) {
110
- contentToAppend += `\n${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`;
111
- }
112
- if (contentToAppend) {
113
- await fs.appendFile(dotEnvPath, contentToAppend + "\n");
114
- (0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
115
- }
116
- return {
117
- projectId,
118
- enableFirstRunExperience
119
- };
120
- }
121
- 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, {
122
- message: "Name cannot be a UUID"
123
- });
124
- const validateProjectName = projectName => {
125
- const validation = projectNameSchema.safeParse(projectName);
126
- if (!validation.success) {
127
- return {
128
- isValid: false,
129
- errorMessage: validation.error.errors[0].message
130
- };
131
- }
132
- return {
133
- isValid: true
134
- };
135
- };
136
- exports.validateProjectName = validateProjectName;
137
- const validateIntunedProject = async () => {
138
- const currentDirectoryToSave = process.cwd();
139
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
140
- const validationSteps = [{
141
- name: "build",
142
- check: async () => {
143
- try {
144
- const buildResult = await (0, _build.runBuild)();
145
- if (!buildResult) {
146
- return {
147
- isValid: false,
148
- errorMessage: "Build failed"
149
- };
150
- }
151
- return {
152
- isValid: true
153
- };
154
- } catch (error) {
155
- return {
156
- isValid: false,
157
- errorMessage: "Build failed"
158
- };
159
- }
160
- }
161
- }, {
162
- name: intunedSettingsFile.name,
163
- check: async () => {
164
- try {
165
- const intunedJsonPath = path.join(currentDirectoryToSave, intunedSettingsFile.name);
166
- await fs.exists(intunedJsonPath);
167
- return {
168
- isValid: true
169
- };
170
- } catch (error) {
171
- return {
172
- isValid: false,
173
- errorMessage: `${intunedSettingsFile.name} file not found`
174
- };
175
- }
176
- }
177
- }, {
178
- name: "api folder",
179
- check: async () => {
180
- try {
181
- const apiFolderPath = path.join(currentDirectoryToSave, "api");
182
- await fs.access(apiFolderPath);
183
- return {
184
- isValid: true
185
- };
186
- } catch (error) {
187
- return {
188
- isValid: false,
189
- errorMessage: "API folder not found"
190
- };
191
- }
192
- }
193
- }];
194
- for (const step of validationSteps) {
195
- const result = await step.check();
196
- if (!result.isValid) {
197
- return result;
198
- }
199
- }
200
- return {
201
- isValid: true
202
- };
203
- };
204
- exports.validateIntunedProject = validateIntunedProject;
205
- function ignoreFilesByPattern(filePath, patterns, projectPath) {
206
- const relativePath = path.relative(projectPath, filePath);
207
- if (relativePath.startsWith("node_modules")) {
208
- return true;
209
- }
210
- for (const pattern of patterns) {
211
- if (!pattern || pattern.startsWith("#")) continue;
212
- if (pattern.startsWith("!")) {
213
- if ((0, _minimatch.minimatch)(relativePath, pattern.substring(1))) {
214
- return false;
215
- }
216
- } else if ((0, _minimatch.minimatch)(relativePath, pattern)) {
217
- return true;
218
- }
219
- }
220
- return false;
221
- }
222
- function listFilesNotIgnored(projectPath, ignorePatterns) {
223
- const results = [];
224
- function traverseDirectory(dirPath) {
225
- try {
226
- const entries = fs.readdirSync(dirPath);
227
- for (const entry of entries) {
228
- const fullPath = path.join(dirPath, entry);
229
- if (ignoreFilesByPattern(fullPath, ignorePatterns, projectPath)) {
230
- continue;
231
- }
232
- try {
233
- const stats = fs.statSync(fullPath);
234
- if (stats.isDirectory()) {
235
- traverseDirectory(fullPath);
236
- } else if (stats.isFile()) {
237
- results.push(path.relative(projectPath, fullPath));
238
- }
239
- } catch (error) {
240
- (0, _terminal.terminal)(`^yWarning: Could not access ${fullPath}^:\n`);
241
- }
242
- }
243
- } catch (error) {
244
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
245
- }
246
- }
247
- traverseDirectory(projectPath);
248
- return results;
249
- }
250
- async function convertProjectToCodeTree(projectPath) {
251
- const filesToSave = listFilesNotIgnored(projectPath, _projectExclusions.default);
252
- const filesToSaveText = " " + filesToSave.join("\n ");
253
- (0, _terminal.terminal)("^CFiles to be saved:^:\n");
254
- (0, _terminal.terminal)(filesToSaveText + "\n");
255
- function readDirectory(dirPath) {
256
- const tree = {};
257
- try {
258
- const entries = fs.readdirSync(dirPath);
259
- for (const entry of entries) {
260
- const entryPath = path.join(dirPath, entry);
261
- if (ignoreFilesByPattern(entryPath, _projectExclusions.default, projectPath)) {
262
- continue;
263
- }
264
- try {
265
- const stats = fs.statSync(entryPath);
266
- if (stats.isFile()) {
267
- try {
268
- const content = fs.readFileSync(entryPath, "utf-8");
269
- tree[entry] = {
270
- file: {
271
- contents: content
272
- }
273
- };
274
- } catch (error) {
275
- (0, _terminal.terminal)(`^yWarning: Could not read file ${entryPath}^:\n`);
276
- }
277
- } else if (stats.isDirectory()) {
278
- const subTree = readDirectory(entryPath);
279
- if (Object.keys(subTree).length > 0) {
280
- tree[entry] = {
281
- directory: subTree
282
- };
283
- }
284
- }
285
- } catch (error) {
286
- (0, _terminal.terminal)(`^yWarning: Could not access ${entryPath}^:\n`);
287
- }
288
- }
289
- } catch (error) {
290
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
291
- }
292
- return tree;
293
- }
294
- const tree = readDirectory(projectPath);
295
- mapToIDEParams(tree);
296
- return tree;
297
- }
298
- function mapToIDEParams(tree) {
299
- if (!tree) {
300
- return;
301
- }
302
- if (!tree["parameters"] || "file" in tree["parameters"]) {
303
- return;
304
- }
305
- const apiParametersMap = {};
306
- const cliParameters = Object.keys(tree["parameters"].directory);
307
- const ____testParameters = {
308
- directory: {}
309
- };
310
- for (const parameterKey of cliParameters) {
311
- const parameter = tree["parameters"].directory[parameterKey];
312
- if ("directory" in parameter) {
313
- continue;
314
- }
315
- if ((0, _lodash.isEmpty)(parameter.file.contents)) {
316
- continue;
317
- }
318
- const parameterPayload = JSON.parse(parameter.file.contents);
319
- if (!parameterPayload["__api-name"]) {
320
- continue;
321
- }
322
- const api = parameterPayload["__api-name"];
323
- const {
324
- "__api-name": _,
325
- ...parameterValue
326
- } = parameterPayload;
327
- const testParameter = {
328
- name: parameterKey.replace(".json", ""),
329
- lastUsed: false,
330
- id: (0, _uuid.v4)(),
331
- value: JSON.stringify(parameterValue)
332
- };
333
- if (!apiParametersMap[api]) {
334
- apiParametersMap[api] = [];
335
- }
336
- apiParametersMap[api].push(testParameter);
337
- }
338
- for (const api in apiParametersMap) {
339
- if (apiParametersMap[api].length > 0) {
340
- apiParametersMap[api][apiParametersMap[api].length - 1].lastUsed = true;
341
- }
342
- ____testParameters.directory[`${api}.json`] = {
343
- file: {
344
- contents: JSON.stringify(apiParametersMap[api], null, 2)
345
- }
346
- };
347
- }
348
- delete tree["parameters"];
349
- tree["____testParameters"] = ____testParameters;
350
- return;
351
- }