@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,114 +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 cdp options if cdpUrl is set", async () => {
43
- const options = await (0, _browser.getCLIRunOptions)({
44
- keepBrowserOpen: true,
45
- headless: true,
46
- cdpUrl: "cdp_url"
47
- });
48
- (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
49
- environment: "cdp",
50
- cdpAddress: "cdp_url"
51
- }));
52
- });
53
- (0, _vitest.it)("returns standalone options if keepBrowserOpen is not set", async () => {
54
- const options = await (0, _browser.getCLIRunOptions)({
55
- keepBrowserOpen: false,
56
- headless: false
57
- });
58
- (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
59
- environment: "standalone",
60
- headless: false
61
- }));
62
- });
63
- (0, _vitest.describe)("when keepBrowserOpen is set", () => {
64
- beforeEach(async () => {
65
- _vitest.vi.clearAllMocks();
66
- await (0, _browser.closeCliBrowser)();
67
- });
68
- (0, _vitest.it)("launches a browser with correct parameters and returns cdp options", async () => {
69
- const options = await (0, _browser.getCLIRunOptions)({
70
- keepBrowserOpen: true,
71
- headless: false,
72
- proxy: "proxy"
73
- });
74
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledWith({
75
- headless: false,
76
- cdpPort: 1234,
77
- proxy: "proxy"
78
- });
79
- (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
80
- environment: "cdp",
81
- cdpAddress: "http://localhost:1234"
82
- }));
83
- });
84
- (0, _vitest.it)("keeps context open until new context", async () => {
85
- await (0, _browser.getCLIRunOptions)({
86
- keepBrowserOpen: true,
87
- headless: false,
88
- proxy: "proxy"
89
- });
90
- const firstContext = (0, _browser._getContextForTest)();
91
- (0, _vitest.expect)(firstContext).not.toBeNull();
92
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledTimes(1);
93
- await (0, _browser.getCLIRunOptions)({
94
- keepBrowserOpen: true,
95
- headless: false,
96
- proxy: "proxy"
97
- });
98
- const secondContext = (0, _browser._getContextForTest)();
99
- (0, _vitest.expect)(secondContext).not.toBeNull();
100
- (0, _vitest.expect)(firstContext).not.toBe(secondContext);
101
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledTimes(2);
102
- });
103
- (0, _vitest.it)("keeps context open until explicitly closed", async () => {
104
- await (0, _browser.getCLIRunOptions)({
105
- keepBrowserOpen: true,
106
- headless: false,
107
- proxy: "proxy"
108
- });
109
- (0, _vitest.expect)((0, _browser._getContextForTest)()).not.toBeNull();
110
- await (0, _browser.closeCliBrowser)();
111
- (0, _vitest.expect)((0, _browser._getContextForTest)()).toBeNull();
112
- });
113
- });
114
- });
@@ -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
- path: string;
10
- value: string;
11
- domain: string;
12
- name: 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
- origin: string;
27
- sessionStorage: {
28
- value: string;
29
- name: string;
30
- }[];
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
- }>;
@@ -1,144 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assertAuthConsistent = assertAuthConsistent;
7
- exports.assertAuthEnabled = assertAuthEnabled;
8
- exports.getAuthSessionRecorderParameters = getAuthSessionRecorderParameters;
9
- exports.isAuthEnabled = isAuthEnabled;
10
- exports.loadAuthSessionInstance = loadAuthSessionInstance;
11
- exports.registerGetAuthSessionParameters = registerGetAuthSessionParameters;
12
- exports.storeAuthSessionInstance = storeAuthSessionInstance;
13
- var _constants = require("../../../common/constants");
14
- var _path = _interopRequireDefault(require("path"));
15
- var _fsExtra = require("fs-extra");
16
- var _intunedJson = require("./intunedJson");
17
- var _errors = require("./errors");
18
- var _runApi = require("../../../common/runApi");
19
- var _formatZodError = require("../../../common/formatZodError");
20
- var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
21
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- async function isAuthEnabled() {
23
- try {
24
- const intunedJson = await (0, _intunedJson.loadIntunedJson)();
25
- return Boolean(intunedJson?.authSessions?.enabled);
26
- } catch (error) {
27
- return false;
28
- }
29
- }
30
- async function assertAuthEnabled() {
31
- if (!(await isAuthEnabled())) {
32
- throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
33
- }
34
- }
35
- async function assertAuthConsistent(authSession) {
36
- const _isAuthEnabled = await isAuthEnabled();
37
- if (_isAuthEnabled && !authSession) {
38
- throw new _errors.CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
39
- }
40
- if (!_isAuthEnabled && authSession) {
41
- throw new _errors.CLIAssertionError(`Auth session is not enabled, enable it in ${await (0, _intunedJson.getIntunedSettingsFileName)()} to use it`);
42
- }
43
- }
44
- async function loadAuthSessionInstance(authSessionId) {
45
- try {
46
- const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
47
- const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
48
- const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
49
- if (!(await (0, _fsExtra.exists)(authSessionInstanceStoragePath))) {
50
- throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} not found`);
51
- }
52
- const authSessionInstanceJson = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
53
- const authSessionInstanceParseResult = _runApi.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
54
- if (!authSessionInstanceParseResult.success) {
55
- throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
56
- }
57
- const metadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
58
- return {
59
- storageState: authSessionInstanceParseResult.data,
60
- metadata
61
- };
62
- } catch (error) {
63
- throw new _errors.CLIError(`Error retrieving auth session instance: ${error.message}`);
64
- }
65
- }
66
- async function storeAuthSessionInstance({
67
- state,
68
- id,
69
- input,
70
- proxy,
71
- metadata
72
- }) {
73
- try {
74
- const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
75
- await (0, _fsExtra.ensureDir)(authSessionsDirectoryPath);
76
- const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, id);
77
- await (0, _fsExtra.ensureDir)(authSessionInstancePath);
78
- const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
79
- await (0, _fsExtra.writeJSON)(authSessionInstanceStoragePath, state, {
80
- spaces: 2
81
- });
82
- const projectAuthConfig = (await (0, _intunedJson.loadIntunedJson)()).authSessions;
83
- if (!projectAuthConfig.enabled) {
84
- throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
85
- }
86
- const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
87
- const authSessionMetadata = {
88
- createdAt: metadata?.createdAt ?? new Date().toISOString(),
89
- updatedAt: new Date().toISOString(),
90
- ...(projectAuthConfig.type === "API" && {
91
- authSessionInput: input || metadata?.authSessionInput || {}
92
- }),
93
- authSessionId: id,
94
- authSessionType: projectAuthConfig.type ?? metadata?.authSessionType ?? "API",
95
- ...(projectAuthConfig.type === "MANUAL" && {
96
- recorderStartUrl: projectAuthConfig.startUrl,
97
- recorderEndUrl: projectAuthConfig.finishUrl
98
- }),
99
- authSessionInput: input || metadata?.authSessionInput || {},
100
- authSessionProxy: proxy || metadata?.authSessionProxy
101
- };
102
- await (0, _fsExtra.writeJSON)(authSessionInstanceMetadataPath, authSessionMetadata, {
103
- spaces: 2
104
- });
105
- return authSessionInstancePath;
106
- } catch (error) {
107
- throw new _errors.CLIError(`Error storing auth session instance: ${error.message}`);
108
- }
109
- }
110
- function registerGetAuthSessionParameters(authSessionId) {
111
- async function getAuthSessionParameters() {
112
- if (!authSessionId) {
113
- throw new Error("getAuthSessionParameters cannot be called without using an auth session");
114
- }
115
- const {
116
- metadata
117
- } = await loadAuthSessionInstance(authSessionId);
118
- if (metadata?.authSessionType === "MANUAL") {
119
- throw new Error("Auth session is recorder-based, it does not have parameters.");
120
- }
121
- return metadata?.authSessionInput ?? {};
122
- }
123
- (0, _asyncLocalStorage.getExecutionContext)().getAuthSessionParameters = getAuthSessionParameters;
124
- }
125
- async function getAuthSessionRecorderParameters() {
126
- const intunedJson = await (0, _intunedJson.loadIntunedJson)();
127
- if (!intunedJson.authSessions.enabled) {
128
- throw new _errors.CLIError(`Auth sessions are not enabled in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
129
- }
130
- if (intunedJson.authSessions.type !== "MANUAL") {
131
- throw new _errors.CLIError(`Auth session type is not recorder-based in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
132
- }
133
- const {
134
- startUrl,
135
- finishUrl
136
- } = intunedJson.authSessions;
137
- if (startUrl === undefined || finishUrl === undefined) {
138
- throw new _errors.CLIError(`Auth session type is recorder-based but start_url or finish_url is not set in ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
139
- }
140
- return {
141
- startUrl,
142
- finishUrl
143
- };
144
- }
@@ -1,8 +0,0 @@
1
- export declare function getAuthCredentials(options: {
2
- workspaceId?: string;
3
- apiKey?: string;
4
- }): Promise<{
5
- workspaceId: string;
6
- apiKey: string;
7
- }>;
8
- export declare function getBaseUrl(): string;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAuthCredentials = getAuthCredentials;
7
- exports.getBaseUrl = getBaseUrl;
8
- var _constants = require("../../../common/constants");
9
- var _errors = require("./errors");
10
- var _intunedJson = require("./intunedJson");
11
- async function getAuthCredentials(options) {
12
- const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId;
13
- const apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
14
- if (!workspaceId) {
15
- throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
16
- }
17
- if (!apiKey) {
18
- throw new _errors.CLIError(`API key is required. Please provide it via command line options or ${_constants.API_KEY_ENV_VAR_KEY} environment variable.`);
19
- }
20
- return {
21
- workspaceId,
22
- apiKey
23
- };
24
- }
25
- function getBaseUrl() {
26
- return new URL(process.env[_constants.API_BASE_URL_ENV_VAR_KEY] || process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`).origin;
27
- }
@@ -1,15 +0,0 @@
1
- import type { BrowserContext } from "playwright";
2
- import type { runApiParametersSchema } from "../../../common/runApi";
3
- import { z } from "zod";
4
- declare let context: BrowserContext | null;
5
- export declare function _getContextForTest(): typeof context;
6
- type RunApiRunOptions = z.infer<typeof runApiParametersSchema>["runOptions"];
7
- export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, }: {
8
- headless: boolean;
9
- proxy?: string;
10
- keepBrowserOpen: boolean;
11
- cdpUrl?: string;
12
- }): Promise<RunApiRunOptions>;
13
- export declare function isCliBrowserLaunched(): boolean;
14
- export declare function closeCliBrowser(): Promise<void>;
15
- export {};
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports._getContextForTest = _getContextForTest;
7
- exports.closeCliBrowser = closeCliBrowser;
8
- exports.getCLIRunOptions = getCLIRunOptions;
9
- exports.isCliBrowserLaunched = isCliBrowserLaunched;
10
- var _launchBrowser = require("../../../common/launchBrowser");
11
- var _portfinder = require("portfinder");
12
- var _proxy = require("./proxy");
13
- let context = null;
14
- function _getContextForTest() {
15
- if (process.env.NODE_ENV !== "test") {
16
- throw new Error("_getContextForTest should only be used in tests");
17
- }
18
- return context;
19
- }
20
- async function getCLIRunOptions({
21
- headless,
22
- proxy,
23
- keepBrowserOpen,
24
- cdpUrl
25
- }) {
26
- if (context) {
27
- await closeCliBrowser();
28
- }
29
- if (cdpUrl) {
30
- return {
31
- environment: "cdp",
32
- cdpAddress: cdpUrl
33
- };
34
- }
35
- if (!keepBrowserOpen) {
36
- return {
37
- environment: "standalone",
38
- headless,
39
- proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined
40
- };
41
- }
42
- const port = await (0, _portfinder.getPort)({});
43
- ({
44
- context
45
- } = await (0, _launchBrowser.launchChromium)({
46
- headless,
47
- proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
48
- cdpPort: port
49
- }));
50
- return {
51
- environment: "cdp",
52
- cdpAddress: `http://localhost:${port}`
53
- };
54
- }
55
- function isCliBrowserLaunched() {
56
- return context !== null;
57
- }
58
- async function closeCliBrowser() {
59
- if (!context) return;
60
- try {
61
- await context.close();
62
- context = null;
63
- } catch (e) {}
64
- }
@@ -1,3 +0,0 @@
1
- export declare function withCLIContext<R>(fn: () => Promise<R>, options?: {
2
- authSessionId?: string;
3
- }): Promise<R>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.withCLIContext = withCLIContext;
7
- var _nanoid = require("nanoid");
8
- var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
9
- var _enums = require("../../../runtime/enums");
10
- var _auth = require("./auth");
11
- async function withCLIContext(fn, options) {
12
- const runId = (0, _nanoid.nanoid)();
13
- async function getAuthSessionParameters() {
14
- const id = options?.authSessionId;
15
- if (!id) {
16
- throw new Error("getAuthSessionParameters cannot be called without using an auth session");
17
- }
18
- const {
19
- metadata
20
- } = await (0, _auth.loadAuthSessionInstance)(id);
21
- if (metadata?.authSessionType === "MANUAL") {
22
- throw new Error("Auth session is recorder-based, it does not have parameters.");
23
- }
24
- return metadata?.authSessionInput ?? {};
25
- }
26
- return await (0, _asyncLocalStorage.runWithContext)({
27
- runEnvironment: _enums.RunEnvironment.IDE,
28
- runId,
29
- extendedPayloads: [],
30
- timeoutInfo: {},
31
- getAuthSessionParameters
32
- }, fn);
33
- }
@@ -1,16 +0,0 @@
1
- import { RunAutomationError } from "../../../common/runApi/errors";
2
- export declare class CLIError extends Error {
3
- autoColor: boolean;
4
- constructor(message: string, options?: {
5
- autoColor?: boolean;
6
- });
7
- }
8
- export declare class AbortedCLIError extends CLIError {
9
- constructor();
10
- }
11
- export declare class CLIAssertionError extends CLIError {
12
- constructor(message: string, options?: {
13
- autoColor?: boolean;
14
- });
15
- }
16
- export declare function logAutomationError(error: RunAutomationError): void;
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CLIError = exports.CLIAssertionError = exports.AbortedCLIError = void 0;
7
- exports.logAutomationError = logAutomationError;
8
- var _errors = require("../../../common/runApi/errors");
9
- var _terminal = require("./terminal");
10
- class CLIError extends Error {
11
- constructor(message, options) {
12
- super(message);
13
- this.name = "CLIError";
14
- this.autoColor = options?.autoColor ?? true;
15
- }
16
- }
17
- exports.CLIError = CLIError;
18
- class AbortedCLIError extends CLIError {
19
- constructor() {
20
- super("Aborted");
21
- this.name = "AbortedCLIError";
22
- }
23
- }
24
- exports.AbortedCLIError = AbortedCLIError;
25
- class CLIAssertionError extends CLIError {
26
- constructor(message, options) {
27
- super(message, options);
28
- this.name = "CLIAssertionError";
29
- }
30
- }
31
- exports.CLIAssertionError = CLIAssertionError;
32
- function logAutomationError(error) {
33
- (0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
34
- if (error instanceof _errors.AutomationError) {
35
- if (error.error.stack) {
36
- const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
37
- (0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
38
- } else {
39
- (0, _terminal.terminal)(`^r${error.error.message}^:\n`);
40
- }
41
- } else {
42
- (0, _terminal.terminal)(`^r${error.message}^:\n`);
43
- }
44
- }
@@ -1,12 +0,0 @@
1
- export * from "./api";
2
- export * from "./auth";
3
- export * from "./context";
4
- export * from "./errors";
5
- export * from "./proxy";
6
- export * from "./terminal";
7
- export * from "./timeout";
8
- export * from "./validation";
9
- export * from "./intunedJson";
10
- export * from "./backend";
11
- export * from "./traces";
12
- export * from "./wrapper";