@intuned/runtime-dev 1.3.9-dev8 → 1.3.11-deployment.0

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 (229) hide show
  1. package/InterfaceTemplate/index.playwright.ts +1 -1
  2. package/WebTemplate.zip +0 -0
  3. package/bin/intuned +1 -1
  4. package/bin/intuned-api-run +1 -1
  5. package/bin/intuned-auth-session-check +1 -1
  6. package/bin/intuned-auth-session-create +1 -1
  7. package/bin/intuned-auth-session-load +1 -1
  8. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  9. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  10. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  11. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +3 -0
  12. package/dist/commands/intuned-cli/commands/types.d.ts +4 -0
  13. package/dist/commands/intuned-cli/commands/types.js +5 -3
  14. package/dist/commands/intuned-cli/controller/api.d.ts +1 -1
  15. package/dist/commands/intuned-cli/controller/api.js +4 -2
  16. package/dist/commands/intuned-cli/controller/authSession.d.ts +2 -2
  17. package/dist/commands/intuned-cli/controller/authSession.js +8 -4
  18. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -0
  19. package/dist/commands/intuned-cli/controller/deploy.js +141 -6
  20. package/dist/commands/intuned-cli/controller/save.d.ts +4 -1
  21. package/dist/commands/intuned-cli/controller/save.js +8 -2
  22. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +11 -0
  23. package/dist/commands/intuned-cli/helpers/backend.js +1 -1
  24. package/dist/commands/intuned-cli/helpers/browser.d.ts +2 -1
  25. package/dist/commands/intuned-cli/helpers/browser.js +8 -1
  26. package/dist/commands/intuned-cli/helpers/errors.d.ts +3 -0
  27. package/dist/commands/intuned-cli/helpers/errors.js +8 -1
  28. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +113 -11
  29. package/dist/commands/intuned-cli/helpers/intunedJson.js +19 -3
  30. package/dist/commands/intuned-cli/helpers/wrapper.js +7 -1
  31. package/dist/commands/intuned-cli/main.js +1 -0
  32. package/{package/dist/commands/common/utils/fileUtils.js → dist/common/binStartupScript.js} +26 -25
  33. package/package.json +6 -2
  34. package/bin/common.js +0 -30
  35. package/package/dist/commands/api/run.d.ts +0 -6
  36. package/package/dist/commands/api/run.js +0 -123
  37. package/package/dist/commands/auth-sessions/load.d.ts +0 -2
  38. package/package/dist/commands/auth-sessions/load.js +0 -35
  39. package/package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  40. package/package/dist/commands/auth-sessions/run-check.js +0 -74
  41. package/package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  42. package/package/dist/commands/auth-sessions/run-create.js +0 -78
  43. package/package/dist/commands/browser/save-state.d.ts +0 -2
  44. package/package/dist/commands/browser/save-state.js +0 -17
  45. package/package/dist/commands/browser/start-browser.d.ts +0 -2
  46. package/package/dist/commands/browser/start-browser.js +0 -14
  47. package/package/dist/commands/build.js +0 -84
  48. package/package/dist/commands/common/browserUtils.d.ts +0 -14
  49. package/package/dist/commands/common/browserUtils.js +0 -58
  50. package/package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  51. package/package/dist/commands/common/getFirstLineNumber.js +0 -101
  52. package/package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  53. package/package/dist/commands/common/projectExclusions.d.ts +0 -2
  54. package/package/dist/commands/common/projectExclusions.js +0 -8
  55. package/package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  56. package/package/dist/commands/common/sendMessageToClient.js +0 -10
  57. package/package/dist/commands/common/tsNodeImport.d.ts +0 -2
  58. package/package/dist/commands/common/tsNodeImport.js +0 -34
  59. package/package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  60. package/package/dist/commands/common/utils/settings.d.ts +0 -2
  61. package/package/dist/commands/common/utils/settings.js +0 -31
  62. package/package/dist/commands/common/utils/template.d.ts +0 -2
  63. package/package/dist/commands/common/utils/template.js +0 -31
  64. package/package/dist/commands/common/utils/unixSocket.d.ts +0 -9
  65. package/package/dist/commands/common/utils/unixSocket.js +0 -44
  66. package/package/dist/commands/interface/run.d.ts +0 -1
  67. package/package/dist/commands/interface/run.js +0 -216
  68. package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  69. package/package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  70. package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  71. package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  72. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  73. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  74. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  75. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  76. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  77. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  78. package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  79. package/package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  80. package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  81. package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -31
  82. package/package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  83. package/package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  84. package/package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  85. package/package/dist/commands/intuned-cli/commands/command.js +0 -9
  86. package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  87. package/package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
  88. package/package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  89. package/package/dist/commands/intuned-cli/commands/index.js +0 -203
  90. package/package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  91. package/package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  92. package/package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  93. package/package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  94. package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  95. package/package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  96. package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -28
  97. package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  98. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  99. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  100. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  101. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  102. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  103. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  104. package/package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
  105. package/package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  106. package/package/dist/commands/intuned-cli/commands/types.d.ts +0 -31
  107. package/package/dist/commands/intuned-cli/commands/types.js +0 -29
  108. package/package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  109. package/package/dist/commands/intuned-cli/constants/index.js +0 -25
  110. package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
  111. package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
  112. package/package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  113. package/package/dist/commands/intuned-cli/controller/api.js +0 -189
  114. package/package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  115. package/package/dist/commands/intuned-cli/controller/authSession.js +0 -420
  116. package/package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  117. package/package/dist/commands/intuned-cli/controller/build.js +0 -36
  118. package/package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -4
  119. package/package/dist/commands/intuned-cli/controller/deploy.js +0 -139
  120. package/package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  121. package/package/dist/commands/intuned-cli/controller/index.js +0 -46
  122. package/package/dist/commands/intuned-cli/controller/save.d.ts +0 -14
  123. package/package/dist/commands/intuned-cli/controller/save.js +0 -345
  124. package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -103
  125. package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
  126. package/package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  127. package/package/dist/commands/intuned-cli/helpers/api.js +0 -19
  128. package/package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  129. package/package/dist/commands/intuned-cli/helpers/auth.js +0 -144
  130. package/package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  131. package/package/dist/commands/intuned-cli/helpers/backend.js +0 -27
  132. package/package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -14
  133. package/package/dist/commands/intuned-cli/helpers/browser.js +0 -57
  134. package/package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  135. package/package/dist/commands/intuned-cli/helpers/context.js +0 -33
  136. package/package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -13
  137. package/package/dist/commands/intuned-cli/helpers/errors.js +0 -37
  138. package/package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  139. package/package/dist/commands/intuned-cli/helpers/index.js +0 -137
  140. package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -69
  141. package/package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -71
  142. package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  143. package/package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  144. package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  145. package/package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  146. package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  147. package/package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  148. package/package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  149. package/package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  150. package/package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  151. package/package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  152. package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  153. package/package/dist/commands/intuned-cli/helpers/wrapper.js +0 -60
  154. package/package/dist/commands/intuned-cli/index.d.ts +0 -1
  155. package/package/dist/commands/intuned-cli/index.js +0 -16
  156. package/package/dist/commands/intuned-cli/main.d.ts +0 -1
  157. package/package/dist/commands/intuned-cli/main.js +0 -22
  158. package/package/dist/commands/intuned-cli/types.d.ts +0 -41
  159. package/package/dist/commands/intuned-cli/types.js +0 -12
  160. package/package/dist/commands/ts-check.d.ts +0 -2
  161. package/package/dist/commands/ts-check.js +0 -56
  162. package/package/dist/common/Logger/Logger/index.d.ts +0 -12
  163. package/package/dist/common/Logger/Logger/index.js +0 -60
  164. package/package/dist/common/Logger/Logger/types.d.ts +0 -8
  165. package/package/dist/common/Logger/Logger/types.js +0 -5
  166. package/package/dist/common/Logger/index.d.ts +0 -12
  167. package/package/dist/common/Logger/index.js +0 -60
  168. package/package/dist/common/Logger/types.d.ts +0 -8
  169. package/package/dist/common/Logger/types.js +0 -5
  170. package/package/dist/common/assets/browser_scripts.js +0 -2580
  171. package/package/dist/common/asyncLocalStorage/index.d.ts +0 -16
  172. package/package/dist/common/asyncLocalStorage/index.js +0 -17
  173. package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  174. package/package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  175. package/package/dist/common/cleanEnvironmentVariables.d.ts +0 -1
  176. package/package/dist/common/cleanEnvironmentVariables.js +0 -16
  177. package/package/dist/common/constants.d.ts +0 -10
  178. package/package/dist/common/constants.js +0 -16
  179. package/package/dist/common/contextStorageStateHelpers.d.ts +0 -21
  180. package/package/dist/common/contextStorageStateHelpers.js +0 -81
  181. package/package/dist/common/extensionsHelpers.d.ts +0 -8
  182. package/package/dist/common/extensionsHelpers.js +0 -80
  183. package/package/dist/common/formatZodError.d.ts +0 -2
  184. package/package/dist/common/formatZodError.js +0 -18
  185. package/package/dist/common/jwtTokenManager.d.ts +0 -17
  186. package/package/dist/common/jwtTokenManager.js +0 -109
  187. package/package/dist/common/launchBrowser.d.ts +0 -25
  188. package/package/dist/common/launchBrowser.js +0 -172
  189. package/package/dist/common/playwrightContext.d.ts +0 -31
  190. package/package/dist/common/playwrightContext.js +0 -144
  191. package/package/dist/common/runApi/errors.d.ts +0 -72
  192. package/package/dist/common/runApi/errors.js +0 -169
  193. package/package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  194. package/package/dist/common/runApi/importUsingImportFunction.js +0 -46
  195. package/package/dist/common/runApi/index.d.ts +0 -11
  196. package/package/dist/common/runApi/index.js +0 -199
  197. package/package/dist/common/runApi/types.d.ts +0 -830
  198. package/package/dist/common/runApi/types.js +0 -73
  199. package/package/dist/common/settingsSchema.d.ts +0 -518
  200. package/package/dist/common/settingsSchema.js +0 -57
  201. package/package/dist/common/setupContextHook.d.ts +0 -17
  202. package/package/dist/common/setupContextHook.js +0 -22
  203. package/package/dist/common/telemetry.d.ts +0 -3
  204. package/package/dist/common/telemetry.js +0 -32
  205. package/package/dist/index.d.ts +0 -4
  206. package/package/dist/index.js +0 -69
  207. package/package/dist/runtime/RunError.d.ts +0 -5
  208. package/package/dist/runtime/RunError.js +0 -19
  209. package/package/dist/runtime/attemptStore.d.ts +0 -2
  210. package/package/dist/runtime/attemptStore.js +0 -23
  211. package/package/dist/runtime/downloadDirectory.d.ts +0 -1
  212. package/package/dist/runtime/downloadDirectory.js +0 -19
  213. package/package/dist/runtime/enums.d.js +0 -5
  214. package/package/dist/runtime/enums.d.ts +0 -11
  215. package/package/dist/runtime/enums.js +0 -18
  216. package/package/dist/runtime/executionHelpers.test.js +0 -52
  217. package/package/dist/runtime/export.d.js +0 -5
  218. package/package/dist/runtime/export.d.ts +0 -228
  219. package/package/dist/runtime/extendPayload.d.ts +0 -2
  220. package/package/dist/runtime/extendPayload.js +0 -21
  221. package/package/dist/runtime/extendTimeout.d.ts +0 -1
  222. package/package/dist/runtime/extendTimeout.js +0 -23
  223. package/package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  224. package/package/dist/runtime/getAuthSessionParameters.js +0 -20
  225. package/package/dist/runtime/index.d.ts +0 -7
  226. package/package/dist/runtime/index.js +0 -54
  227. package/package/dist/runtime/runInfo.d.ts +0 -2
  228. package/package/dist/runtime/runInfo.js +0 -21
  229. /package/{package/dist/commands/build.d.ts → dist/common/binStartupScript.d.ts} +0 -0
@@ -1,397 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _api = require("../api");
5
- var _authSession = require("../authSession");
6
- var _helpers = require("../../helpers");
7
- var _neverthrow = require("neverthrow");
8
- var _runApi = require("../../../../common/runApi");
9
- var _fsExtra = require("fs-extra");
10
- var _browser = require("../../helpers/browser");
11
- function getTerminal() {
12
- return new Proxy(() => ({}), {
13
- get: () => getTerminal(),
14
- apply: () => ({})
15
- });
16
- }
17
- _vitest.vi.mock("fs-extra", () => ({
18
- writeJSON: _vitest.vi.fn(),
19
- exists: _vitest.vi.fn().mockResolvedValue(true)
20
- }));
21
- _vitest.vi.mock("../authSession", async importOriginal => {
22
- const original = await importOriginal();
23
- return {
24
- ...original,
25
- executeRunValidateAuthSessionCLI: _vitest.vi.fn()
26
- };
27
- });
28
- _vitest.vi.mock("../../../../common/runApi", async importOriginal => {
29
- const original = await importOriginal();
30
- return {
31
- ...original,
32
- runApi: _vitest.vi.fn().mockImplementation(() => (0, _neverthrow.ok)({}))
33
- };
34
- });
35
- _vitest.vi.mock("../../helpers/terminal", () => ({
36
- terminal: getTerminal()
37
- }));
38
- _vitest.vi.mock("../../helpers/proxy", async () => {
39
- return {
40
- parseUrlProxy: _vitest.vi.fn()
41
- };
42
- });
43
- _vitest.vi.mock("../../helpers/browser", async importOriginal => {
44
- const original = await importOriginal();
45
- return {
46
- getCLIRunOptions: _vitest.vi.fn(({
47
- keepBrowserOpen: _,
48
- ...rest
49
- }) => original.getCLIRunOptions({
50
- keepBrowserOpen: false,
51
- ...rest
52
- }))
53
- };
54
- });
55
- _vitest.vi.mock("../../helpers", async importOriginal => {
56
- const original = await importOriginal();
57
- return {
58
- ...original,
59
- terminal: getTerminal(),
60
- assertApiFileExists: _vitest.vi.fn(),
61
- withCLIContext: _vitest.vi.fn(fn => fn()),
62
- withTimeout: _vitest.vi.fn(fn => fn()),
63
- withCLITrace: _vitest.vi.fn(original.withCLITrace),
64
- registerGetAuthSessionParameters: _vitest.vi.fn()
65
- };
66
- });
67
- (0, _vitest.describe)("API controller", () => {
68
- (0, _vitest.beforeEach)(() => {
69
- _vitest.vi.clearAllMocks();
70
- });
71
- (0, _vitest.describe)("attemptApi", () => {
72
- (0, _vitest.it)("calls timeout middleware with timeout", async () => {
73
- await (0, _api._attemptApi)({
74
- apiName: "testApi",
75
- inputData: {},
76
- headless: false,
77
- timeout: 6000,
78
- keepBrowserOpen: false
79
- });
80
- (0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
81
- });
82
- (0, _vitest.it)("uses tracing wrapper with trace id", async () => {
83
- await (0, _api._attemptApi)({
84
- apiName: "testApi",
85
- inputData: {},
86
- headless: false,
87
- timeout: 6000,
88
- keepBrowserOpen: false
89
- });
90
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
91
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
92
- _vitest.vi.mocked(_runApi.runApi).mockClear();
93
- await (0, _api._attemptApi)({
94
- apiName: "testApi",
95
- inputData: {},
96
- headless: false,
97
- timeout: 6000,
98
- keepBrowserOpen: false,
99
- traceId: "trace-id"
100
- });
101
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
102
- });
103
- (0, _vitest.it)("uses cli browser helper", async () => {
104
- await (0, _api._attemptApi)({
105
- apiName: "testApi",
106
- inputData: {},
107
- headless: false,
108
- timeout: 6000,
109
- keepBrowserOpen: false
110
- });
111
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
112
- headless: false,
113
- keepBrowserOpen: false
114
- }));
115
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
116
- _vitest.vi.mocked(_runApi.runApi).mockClear();
117
- await (0, _api._attemptApi)({
118
- apiName: "testApi",
119
- inputData: {},
120
- headless: true,
121
- timeout: 6000,
122
- keepBrowserOpen: true
123
- });
124
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
125
- headless: true,
126
- keepBrowserOpen: true
127
- }));
128
- });
129
- (0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
130
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
131
- await (0, _api._attemptApi)({
132
- apiName: "testApi",
133
- inputData: "inputData",
134
- headless: "headless",
135
- auth: "auth",
136
- proxy: "proxy",
137
- timeout: 999999999,
138
- keepBrowserOpen: false
139
- });
140
- (0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
141
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
142
- automationFunction: {
143
- name: "api/testApi",
144
- params: "inputData"
145
- },
146
- runOptions: {
147
- headless: "headless",
148
- environment: "standalone",
149
- proxy: "parsed-proxy"
150
- },
151
- auth: {
152
- session: {
153
- type: "state",
154
- state: "auth"
155
- }
156
- },
157
- importFunction: _vitest.expect.anything()
158
- }));
159
- });
160
- (0, _vitest.it)("returns the result and extended payloads if runApi succeeds", async () => {
161
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.ok)({
162
- result: "result",
163
- extendedPayloads: "extendedPayloads"
164
- }));
165
- const result = await (0, _api._attemptApi)({
166
- apiName: "testApi",
167
- inputData: "inputData",
168
- headless: "headless",
169
- auth: "auth",
170
- timeout: 999999999,
171
- keepBrowserOpen: false
172
- });
173
- (0, _vitest.expect)(result).toEqual({
174
- result: "result",
175
- payloadToAppend: "extendedPayloads"
176
- });
177
- });
178
- (0, _vitest.it)("throws the error runApi fails with an error", async () => {
179
- const error = new Error("runApi failed");
180
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
181
- await (0, _vitest.expect)((0, _api._attemptApi)({
182
- apiName: "testApi",
183
- inputData: "inputData",
184
- headless: "headless",
185
- auth: "auth",
186
- timeout: 999999999,
187
- keepBrowserOpen: false
188
- })).rejects.toThrow(error);
189
- });
190
- });
191
- (0, _vitest.describe)("executeRunApiCLI", () => {
192
- (0, _vitest.it)("enables tracing correctly", async () => {
193
- await (0, _api.executeRunApiCLI)({
194
- apiName: "testApi",
195
- inputData: {},
196
- retries: 1,
197
- trace: false
198
- });
199
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
200
- tracing: {
201
- enabled: false
202
- }
203
- }));
204
- _vitest.vi.mocked(_runApi.runApi).mockClear();
205
- await (0, _api.executeRunApiCLI)({
206
- apiName: "testApi",
207
- inputData: {},
208
- retries: 1,
209
- trace: true
210
- });
211
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
212
- tracing: _vitest.expect.objectContaining({
213
- enabled: true
214
- })
215
- }));
216
- });
217
- (0, _vitest.it)("calls attemptApi once if success", async () => {
218
- await (0, _api.executeRunApiCLI)({
219
- apiName: "testApi",
220
- inputData: {},
221
- retries: 3
222
- });
223
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
224
- });
225
- (0, _vitest.it)("stops retrying after max retries", async () => {
226
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
227
- await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
228
- apiName: "testApi",
229
- inputData: {},
230
- retries: 10
231
- })).rejects.toThrow(_helpers.CLIError);
232
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
233
- });
234
- (0, _vitest.it)("stops retrying on non-automation errors", async () => {
235
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValue(new Error("runApi failed"));
236
- await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
237
- apiName: "testApi",
238
- inputData: {},
239
- retries: 3
240
- })).rejects.toThrow("runApi failed");
241
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
242
- });
243
- (0, _vitest.it)("stops retrying on success", async () => {
244
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
245
- result: "success"
246
- }));
247
- await (0, _api.executeRunApiCLI)({
248
- apiName: "testApi",
249
- inputData: {},
250
- retries: 10
251
- });
252
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
253
- });
254
- (0, _vitest.it)("validates auth session before each attempt if provided", async () => {
255
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
256
- result: "success"
257
- }));
258
- await (0, _api.executeRunApiCLI)({
259
- apiName: "testApi",
260
- inputData: {},
261
- authSession: {
262
- id: "authSessionId",
263
- autoRecreate: false,
264
- checkRetries: 1,
265
- createRetries: 2
266
- },
267
- retries: 10
268
- });
269
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toBeCalledTimes(2);
270
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith(_vitest.expect.objectContaining({
271
- id: "authSessionId",
272
- autoRecreate: false,
273
- checkRetries: 1,
274
- createRetries: 2
275
- }));
276
- });
277
- (0, _vitest.it)("doesn't validate auth session if not provided", async () => {
278
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
279
- result: "success"
280
- }));
281
- await (0, _api.executeRunApiCLI)({
282
- apiName: "testApi",
283
- inputData: {},
284
- retries: 1
285
- });
286
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).not.toHaveBeenCalled();
287
- });
288
- (0, _vitest.it)("fails if auth session is provided but not valid", async () => {
289
- _vitest.vi.mocked(_authSession.executeRunValidateAuthSessionCLI).mockRejectedValue(new _helpers.CLIError("Auth session validation failed"));
290
- await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
291
- apiName: "testApi",
292
- inputData: {},
293
- authSession: {
294
- id: "authSessionId",
295
- autoRecreate: false,
296
- checkRetries: 1,
297
- createRetries: 2
298
- },
299
- retries: 10
300
- })).rejects.toThrow("Auth session validation failed");
301
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith(_vitest.expect.objectContaining({
302
- id: "authSessionId",
303
- autoRecreate: false,
304
- checkRetries: 1,
305
- createRetries: 2
306
- }));
307
- (0, _vitest.expect)(_runApi.runApi).not.toHaveBeenCalled();
308
- });
309
- (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
310
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
311
- result: "result",
312
- extendedPayloads: "extendedPayloads"
313
- }));
314
- await (0, _api.executeRunApiCLI)({
315
- apiName: "testApi",
316
- inputData: {},
317
- outputFile: "output.json",
318
- retries: 1
319
- });
320
- (0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
321
- result: "result",
322
- extendedPayloads: "extendedPayloads"
323
- }, _vitest.expect.anything());
324
- });
325
- (0, _vitest.it)("asserts API file exists", async () => {
326
- await (0, _api.executeRunApiCLI)({
327
- apiName: "testApi",
328
- inputData: {},
329
- retries: 1
330
- });
331
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
332
- });
333
- });
334
- (0, _vitest.describe)("executeAttemptApiCLI", () => {
335
- (0, _vitest.it)("enables tracing correctly", async () => {
336
- await (0, _api.executeAttemptApiCLI)({
337
- apiName: "testApi",
338
- inputData: {},
339
- trace: false
340
- });
341
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
342
- tracing: {
343
- enabled: false
344
- }
345
- }));
346
- _vitest.vi.mocked(_runApi.runApi).mockClear();
347
- await (0, _api.executeAttemptApiCLI)({
348
- apiName: "testApi",
349
- inputData: {},
350
- trace: true
351
- });
352
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
353
- tracing: _vitest.expect.objectContaining({
354
- enabled: true
355
- })
356
- }));
357
- });
358
- (0, _vitest.it)("calls attemptApi once", async () => {
359
- await (0, _api.executeAttemptApiCLI)({
360
- apiName: "testApi",
361
- inputData: {},
362
- retries: 3
363
- });
364
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
365
- _vitest.vi.mocked(_runApi.runApi).mockReset();
366
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
367
- await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
368
- apiName: "testApi",
369
- inputData: {}
370
- })).rejects.toThrow(_runApi.AutomationError);
371
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
372
- });
373
- (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
374
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
375
- result: "result",
376
- extendedPayloads: "extendedPayloads"
377
- }));
378
- await (0, _api.executeAttemptApiCLI)({
379
- apiName: "testApi",
380
- inputData: {},
381
- outputFile: "output.json"
382
- });
383
- (0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
384
- result: "result",
385
- extendedPayloads: "extendedPayloads"
386
- }, _vitest.expect.anything());
387
- });
388
- (0, _vitest.it)("asserts API file exists", async () => {
389
- await (0, _api.executeRunApiCLI)({
390
- apiName: "testApi",
391
- inputData: {},
392
- retries: 1
393
- });
394
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
395
- });
396
- });
397
- });