@intuned/runtime-dev 1.3.9-dev9 → 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 (223) hide show
  1. package/InterfaceTemplate/index.playwright.ts +1 -1
  2. package/WebTemplate.zip +0 -0
  3. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  4. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  5. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  6. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +3 -0
  7. package/dist/commands/intuned-cli/commands/types.d.ts +4 -0
  8. package/dist/commands/intuned-cli/commands/types.js +5 -3
  9. package/dist/commands/intuned-cli/controller/api.d.ts +1 -1
  10. package/dist/commands/intuned-cli/controller/api.js +4 -2
  11. package/dist/commands/intuned-cli/controller/authSession.d.ts +2 -2
  12. package/dist/commands/intuned-cli/controller/authSession.js +8 -4
  13. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -0
  14. package/dist/commands/intuned-cli/controller/deploy.js +141 -6
  15. package/dist/commands/intuned-cli/controller/save.d.ts +4 -1
  16. package/dist/commands/intuned-cli/controller/save.js +8 -2
  17. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +11 -0
  18. package/dist/commands/intuned-cli/helpers/backend.js +1 -1
  19. package/dist/commands/intuned-cli/helpers/browser.d.ts +2 -1
  20. package/dist/commands/intuned-cli/helpers/browser.js +8 -1
  21. package/dist/commands/intuned-cli/helpers/errors.d.ts +3 -0
  22. package/dist/commands/intuned-cli/helpers/errors.js +8 -1
  23. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +113 -11
  24. package/dist/commands/intuned-cli/helpers/intunedJson.js +19 -3
  25. package/dist/commands/intuned-cli/helpers/wrapper.js +7 -1
  26. package/dist/commands/intuned-cli/main.js +1 -0
  27. package/package.json +6 -2
  28. package/package/dist/commands/api/run.d.ts +0 -6
  29. package/package/dist/commands/api/run.js +0 -123
  30. package/package/dist/commands/auth-sessions/load.d.ts +0 -2
  31. package/package/dist/commands/auth-sessions/load.js +0 -35
  32. package/package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  33. package/package/dist/commands/auth-sessions/run-check.js +0 -74
  34. package/package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  35. package/package/dist/commands/auth-sessions/run-create.js +0 -78
  36. package/package/dist/commands/browser/save-state.d.ts +0 -2
  37. package/package/dist/commands/browser/save-state.js +0 -17
  38. package/package/dist/commands/browser/start-browser.d.ts +0 -2
  39. package/package/dist/commands/browser/start-browser.js +0 -14
  40. package/package/dist/commands/build.d.ts +0 -1
  41. package/package/dist/commands/build.js +0 -84
  42. package/package/dist/commands/common/browserUtils.d.ts +0 -14
  43. package/package/dist/commands/common/browserUtils.js +0 -58
  44. package/package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  45. package/package/dist/commands/common/getFirstLineNumber.js +0 -101
  46. package/package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  47. package/package/dist/commands/common/projectExclusions.d.ts +0 -2
  48. package/package/dist/commands/common/projectExclusions.js +0 -8
  49. package/package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  50. package/package/dist/commands/common/sendMessageToClient.js +0 -10
  51. package/package/dist/commands/common/tsNodeImport.d.ts +0 -2
  52. package/package/dist/commands/common/tsNodeImport.js +0 -34
  53. package/package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  54. package/package/dist/commands/common/utils/fileUtils.js +0 -33
  55. package/package/dist/commands/common/utils/settings.d.ts +0 -2
  56. package/package/dist/commands/common/utils/settings.js +0 -31
  57. package/package/dist/commands/common/utils/template.d.ts +0 -2
  58. package/package/dist/commands/common/utils/template.js +0 -31
  59. package/package/dist/commands/common/utils/unixSocket.d.ts +0 -9
  60. package/package/dist/commands/common/utils/unixSocket.js +0 -44
  61. package/package/dist/commands/interface/run.d.ts +0 -1
  62. package/package/dist/commands/interface/run.js +0 -216
  63. package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  64. package/package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  65. package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  66. package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  67. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  68. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  69. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  70. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  71. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  72. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  73. package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  74. package/package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  75. package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  76. package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -31
  77. package/package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  78. package/package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  79. package/package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  80. package/package/dist/commands/intuned-cli/commands/command.js +0 -9
  81. package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  82. package/package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
  83. package/package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  84. package/package/dist/commands/intuned-cli/commands/index.js +0 -203
  85. package/package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  86. package/package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  87. package/package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  88. package/package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  89. package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  90. package/package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  91. package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -28
  92. package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  93. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  94. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  95. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  96. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  97. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  98. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  99. package/package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
  100. package/package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  101. package/package/dist/commands/intuned-cli/commands/types.d.ts +0 -31
  102. package/package/dist/commands/intuned-cli/commands/types.js +0 -29
  103. package/package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  104. package/package/dist/commands/intuned-cli/constants/index.js +0 -25
  105. package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
  106. package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
  107. package/package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  108. package/package/dist/commands/intuned-cli/controller/api.js +0 -189
  109. package/package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  110. package/package/dist/commands/intuned-cli/controller/authSession.js +0 -420
  111. package/package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  112. package/package/dist/commands/intuned-cli/controller/build.js +0 -36
  113. package/package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -4
  114. package/package/dist/commands/intuned-cli/controller/deploy.js +0 -139
  115. package/package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  116. package/package/dist/commands/intuned-cli/controller/index.js +0 -46
  117. package/package/dist/commands/intuned-cli/controller/save.d.ts +0 -14
  118. package/package/dist/commands/intuned-cli/controller/save.js +0 -345
  119. package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -103
  120. package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
  121. package/package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  122. package/package/dist/commands/intuned-cli/helpers/api.js +0 -19
  123. package/package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  124. package/package/dist/commands/intuned-cli/helpers/auth.js +0 -144
  125. package/package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  126. package/package/dist/commands/intuned-cli/helpers/backend.js +0 -27
  127. package/package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -14
  128. package/package/dist/commands/intuned-cli/helpers/browser.js +0 -57
  129. package/package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  130. package/package/dist/commands/intuned-cli/helpers/context.js +0 -33
  131. package/package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -13
  132. package/package/dist/commands/intuned-cli/helpers/errors.js +0 -37
  133. package/package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  134. package/package/dist/commands/intuned-cli/helpers/index.js +0 -137
  135. package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -69
  136. package/package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -71
  137. package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  138. package/package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  139. package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  140. package/package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  141. package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  142. package/package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  143. package/package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  144. package/package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  145. package/package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  146. package/package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  147. package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  148. package/package/dist/commands/intuned-cli/helpers/wrapper.js +0 -60
  149. package/package/dist/commands/intuned-cli/index.d.ts +0 -1
  150. package/package/dist/commands/intuned-cli/index.js +0 -16
  151. package/package/dist/commands/intuned-cli/main.d.ts +0 -1
  152. package/package/dist/commands/intuned-cli/main.js +0 -22
  153. package/package/dist/commands/intuned-cli/types.d.ts +0 -41
  154. package/package/dist/commands/intuned-cli/types.js +0 -12
  155. package/package/dist/commands/ts-check.d.ts +0 -2
  156. package/package/dist/commands/ts-check.js +0 -56
  157. package/package/dist/common/Logger/Logger/index.d.ts +0 -12
  158. package/package/dist/common/Logger/Logger/index.js +0 -60
  159. package/package/dist/common/Logger/Logger/types.d.ts +0 -8
  160. package/package/dist/common/Logger/Logger/types.js +0 -5
  161. package/package/dist/common/Logger/index.d.ts +0 -12
  162. package/package/dist/common/Logger/index.js +0 -60
  163. package/package/dist/common/Logger/types.d.ts +0 -8
  164. package/package/dist/common/Logger/types.js +0 -5
  165. package/package/dist/common/assets/browser_scripts.js +0 -2580
  166. package/package/dist/common/asyncLocalStorage/index.d.ts +0 -16
  167. package/package/dist/common/asyncLocalStorage/index.js +0 -17
  168. package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  169. package/package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  170. package/package/dist/common/cleanEnvironmentVariables.d.ts +0 -1
  171. package/package/dist/common/cleanEnvironmentVariables.js +0 -16
  172. package/package/dist/common/constants.d.ts +0 -10
  173. package/package/dist/common/constants.js +0 -16
  174. package/package/dist/common/contextStorageStateHelpers.d.ts +0 -21
  175. package/package/dist/common/contextStorageStateHelpers.js +0 -81
  176. package/package/dist/common/extensionsHelpers.d.ts +0 -8
  177. package/package/dist/common/extensionsHelpers.js +0 -80
  178. package/package/dist/common/formatZodError.d.ts +0 -2
  179. package/package/dist/common/formatZodError.js +0 -18
  180. package/package/dist/common/jwtTokenManager.d.ts +0 -17
  181. package/package/dist/common/jwtTokenManager.js +0 -109
  182. package/package/dist/common/launchBrowser.d.ts +0 -25
  183. package/package/dist/common/launchBrowser.js +0 -172
  184. package/package/dist/common/playwrightContext.d.ts +0 -31
  185. package/package/dist/common/playwrightContext.js +0 -144
  186. package/package/dist/common/runApi/errors.d.ts +0 -72
  187. package/package/dist/common/runApi/errors.js +0 -169
  188. package/package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  189. package/package/dist/common/runApi/importUsingImportFunction.js +0 -46
  190. package/package/dist/common/runApi/index.d.ts +0 -11
  191. package/package/dist/common/runApi/index.js +0 -199
  192. package/package/dist/common/runApi/types.d.ts +0 -830
  193. package/package/dist/common/runApi/types.js +0 -73
  194. package/package/dist/common/settingsSchema.d.ts +0 -518
  195. package/package/dist/common/settingsSchema.js +0 -57
  196. package/package/dist/common/setupContextHook.d.ts +0 -17
  197. package/package/dist/common/setupContextHook.js +0 -22
  198. package/package/dist/common/telemetry.d.ts +0 -3
  199. package/package/dist/common/telemetry.js +0 -32
  200. package/package/dist/index.d.ts +0 -4
  201. package/package/dist/index.js +0 -69
  202. package/package/dist/runtime/RunError.d.ts +0 -5
  203. package/package/dist/runtime/RunError.js +0 -19
  204. package/package/dist/runtime/attemptStore.d.ts +0 -2
  205. package/package/dist/runtime/attemptStore.js +0 -23
  206. package/package/dist/runtime/downloadDirectory.d.ts +0 -1
  207. package/package/dist/runtime/downloadDirectory.js +0 -19
  208. package/package/dist/runtime/enums.d.js +0 -5
  209. package/package/dist/runtime/enums.d.ts +0 -11
  210. package/package/dist/runtime/enums.js +0 -18
  211. package/package/dist/runtime/executionHelpers.test.js +0 -52
  212. package/package/dist/runtime/export.d.js +0 -5
  213. package/package/dist/runtime/export.d.ts +0 -228
  214. package/package/dist/runtime/extendPayload.d.ts +0 -2
  215. package/package/dist/runtime/extendPayload.js +0 -21
  216. package/package/dist/runtime/extendTimeout.d.ts +0 -1
  217. package/package/dist/runtime/extendTimeout.js +0 -23
  218. package/package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  219. package/package/dist/runtime/getAuthSessionParameters.js +0 -20
  220. package/package/dist/runtime/index.d.ts +0 -7
  221. package/package/dist/runtime/index.js +0 -54
  222. package/package/dist/runtime/runInfo.d.ts +0 -2
  223. package/package/dist/runtime/runInfo.js +0 -21
@@ -1,420 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports._runCreateWithRetries = exports._runCreate = exports._runCheckWithRetries = exports._runCheck = void 0;
7
- exports.executeAttemptCheckAuthSessionCLI = executeAttemptCheckAuthSessionCLI;
8
- exports.executeAttemptCreateAuthSessionCLI = executeAttemptCreateAuthSessionCLI;
9
- exports.executeRecordAuthSessionCLI = executeRecordAuthSessionCLI;
10
- exports.executeRunCreateAuthSessionCLI = executeRunCreateAuthSessionCLI;
11
- exports.executeRunUpdateAuthSessionCLI = executeRunUpdateAuthSessionCLI;
12
- exports.executeRunValidateAuthSessionCLI = executeRunValidateAuthSessionCLI;
13
- var _helpers = require("../helpers");
14
- var _runApi = require("../../../common/runApi");
15
- var _constants = require("../../../common/constants");
16
- var _tsNodeImport = require("../../common/tsNodeImport");
17
- var _terminal = require("../helpers/terminal");
18
- var _browser = require("../helpers/browser");
19
- var _launchBrowser = require("../../../common/launchBrowser");
20
- var _promises = require("timers/promises");
21
- var _contextStorageStateHelpers = require("../../../common/contextStorageStateHelpers");
22
- async function executeRunValidateAuthSessionCLI({
23
- id,
24
- autoRecreate,
25
- checkRetries,
26
- createRetries,
27
- ...rest
28
- }) {
29
- (0, _terminal.terminal)(`^+Validating auth session with id ^c${id}^:\n`);
30
- const {
31
- storageState
32
- } = await (0, _helpers.loadAuthSessionInstance)(id);
33
- await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
34
- (0, _helpers.registerGetAuthSessionParameters)(id);
35
- const checkResult = await runCheckWithRetries({
36
- auth: storageState,
37
- retries: checkRetries,
38
- ...rest
39
- });
40
- if (!checkResult) {
41
- if (!autoRecreate) {
42
- throw new _helpers.CLIError("Auto recreate is disabled, please provide a new auth session or update it manually");
43
- }
44
- const {
45
- metadata
46
- } = await (0, _helpers.loadAuthSessionInstance)(id);
47
- if (metadata?.authSessionType === "MANUAL") {
48
- throw new _helpers.CLIError("Auth session is recorder-based, please provide a new one or update it manually");
49
- }
50
- (0, _terminal.terminal)("^+Auto recreate is enabled - trying to re-create it^:\n");
51
- await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
52
- const authSessionInput = metadata?.authSessionInput ?? {};
53
- const storageState = await runCreateWithRetries({
54
- authSessionId: id,
55
- authSessionInput,
56
- retries: createRetries,
57
- metadata,
58
- ...rest
59
- });
60
- const checkResult = await runCheckWithRetries({
61
- auth: storageState,
62
- retries: checkRetries,
63
- ...rest
64
- });
65
- if (!checkResult) {
66
- throw new _helpers.CLIError("Failed to re-create auth session");
67
- }
68
- }
69
- (0, _terminal.terminal)(`^+^gAuth session validated successfully^:\n`);
70
- return storageState;
71
- }
72
- async function executeRunCreateAuthSessionCLI({
73
- id,
74
- input,
75
- checkRetries,
76
- createRetries,
77
- log = true,
78
- ...rest
79
- }) {
80
- id = id ?? generateAuthSessionId();
81
- (0, _terminal.terminal)(`^+Creating auth session with id ^c${id}^:\n`);
82
- await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
83
- const createdStorageState = await runCreateWithRetries({
84
- authSessionId: id,
85
- authSessionInput: input,
86
- retries: createRetries,
87
- ...rest
88
- });
89
- const auth = createdStorageState;
90
- const checkResult = await runCheckWithRetries({
91
- auth,
92
- retries: checkRetries,
93
- ...rest
94
- });
95
- if (!checkResult) {
96
- throw new _helpers.CLIError("Failed to create auth session");
97
- }
98
- if (log) {
99
- (0, _terminal.terminal)(`^+^gAuth session created successfully^:\n`);
100
- }
101
- return auth;
102
- }
103
- async function executeRunUpdateAuthSessionCLI({
104
- id,
105
- input,
106
- checkRetries,
107
- createRetries,
108
- ...rest
109
- }) {
110
- (0, _terminal.terminal)(`^+Updating auth session with id ^c${id}^:\n`);
111
- let metadata = undefined;
112
- if (input === undefined) {
113
- ({
114
- metadata
115
- } = await (0, _helpers.loadAuthSessionInstance)(id));
116
- if (metadata?.authSessionType === "MANUAL") {
117
- throw new _helpers.CLIError("Auth session is recorder-based, it cannot be updated.");
118
- }
119
- input = metadata?.authSessionInput ?? {};
120
- }
121
- await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
122
- const authSession = await executeRunCreateAuthSessionCLI({
123
- id,
124
- input,
125
- checkRetries,
126
- createRetries,
127
- log: false,
128
- metadata,
129
- ...rest
130
- });
131
- (0, _terminal.terminal)(`^+^gAuth session updated successfully^:\n`);
132
- return authSession;
133
- }
134
- async function executeAttemptCreateAuthSessionCLI({
135
- id,
136
- input,
137
- ...rest
138
- }) {
139
- id = id ?? generateAuthSessionId(true);
140
- (0, _terminal.terminal)(`^+Executing create auth session attempt with id ^c${id}^:\n`);
141
- await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
142
- return await runCreateWithRetries({
143
- authSessionId: id,
144
- authSessionInput: input,
145
- ...rest
146
- });
147
- }
148
- async function executeAttemptCheckAuthSessionCLI({
149
- id,
150
- ...rest
151
- }) {
152
- (0, _terminal.terminal)(`^+Executing check auth session attempt with id ^c${id}^:\n`);
153
- await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
154
- (0, _helpers.registerGetAuthSessionParameters)(id);
155
- const {
156
- storageState
157
- } = await (0, _helpers.loadAuthSessionInstance)(id);
158
- const checkResult = await runCheckWithRetries({
159
- auth: storageState,
160
- ...rest
161
- });
162
- if (!checkResult) {
163
- throw new _helpers.CLIError("Check failed");
164
- }
165
- (0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
166
- return storageState;
167
- }
168
- async function runCheck({
169
- auth,
170
- proxy,
171
- headless,
172
- timeout,
173
- traceId,
174
- keepBrowserOpen
175
- }) {
176
- return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
177
- const runApiResult = await (0, _runApi.runApi)({
178
- automationFunction: {
179
- name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
180
- },
181
- runOptions: await (0, _browser.getCLIRunOptions)({
182
- headless,
183
- proxy,
184
- keepBrowserOpen
185
- }),
186
- auth: {
187
- session: {
188
- type: "state",
189
- state: auth
190
- }
191
- },
192
- tracing,
193
- importFunction: _tsNodeImport.tsNodeImport,
194
- abortSignal
195
- });
196
- if (runApiResult.isErr()) {
197
- throw runApiResult.error;
198
- }
199
- const result = runApiResult.value.result;
200
- if (!result) {
201
- return false;
202
- }
203
- return result;
204
- }, traceId), timeout);
205
- }
206
- const _runCheck = exports._runCheck = runCheck;
207
- async function runCreate({
208
- authSessionInput,
209
- proxy,
210
- headless,
211
- timeout,
212
- traceId,
213
- keepBrowserOpen
214
- }) {
215
- return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
216
- const result = await (0, _runApi.runApi)({
217
- automationFunction: {
218
- name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`,
219
- params: authSessionInput
220
- },
221
- runOptions: await (0, _browser.getCLIRunOptions)({
222
- headless,
223
- proxy,
224
- keepBrowserOpen
225
- }),
226
- retrieveSession: true,
227
- tracing,
228
- importFunction: _tsNodeImport.tsNodeImport,
229
- abortSignal
230
- });
231
- if (result.isErr()) {
232
- throw result.error;
233
- }
234
- return result.value.session;
235
- }, traceId), timeout);
236
- }
237
- const _runCreate = exports._runCreate = runCreate;
238
- async function runCheckWithRetries({
239
- auth,
240
- retries,
241
- ...rest
242
- }) {
243
- for (let i = 0; i < (retries ?? 1); i++) {
244
- (0, _terminal.terminal)(`\n^+Running ^cauth session check${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
245
- try {
246
- let traceId = undefined;
247
- if (rest.trace) {
248
- traceId = "authsession-check-attempt";
249
- if (retries) {
250
- traceId += `-${i + 1}`;
251
- }
252
- }
253
- const checkResult = await runCheck({
254
- auth,
255
- traceId,
256
- ...rest
257
- });
258
- if (checkResult) {
259
- (0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
260
- return true;
261
- }
262
- } catch (error) {
263
- if (error instanceof _runApi.RunAutomationError) {
264
- (0, _helpers.logAutomationError)(error);
265
- } else {
266
- throw error;
267
- }
268
- }
269
- (0, _terminal.terminal)(`^+^yAuth session check failed^:\n`);
270
- }
271
- (0, _terminal.terminal)(`^+^rAuth session check failed after ${retries} attempts^:\n`);
272
- return false;
273
- }
274
- const _runCheckWithRetries = exports._runCheckWithRetries = runCheckWithRetries;
275
- async function runCreateWithRetries({
276
- authSessionId,
277
- authSessionInput,
278
- retries,
279
- trace,
280
- metadata,
281
- ...rest
282
- }) {
283
- let newAuthSessionInstance = null;
284
- for (let i = 0; i < (retries ?? 1); i++) {
285
- (0, _terminal.terminal)(`\n^+Running ^cauth session create${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
286
- try {
287
- let traceId = undefined;
288
- if (trace) {
289
- traceId = "authsession-create-attempt";
290
- if (retries) {
291
- traceId += `-${i + 1}`;
292
- }
293
- }
294
- newAuthSessionInstance = await runCreate({
295
- authSessionInput,
296
- traceId,
297
- ...rest
298
- });
299
- (0, _terminal.terminal)(`^+^gAuth session create succeeded^:\n`);
300
- break;
301
- } catch (error) {
302
- if (error instanceof _runApi.RunAutomationError) {
303
- (0, _helpers.logAutomationError)(error);
304
- } else {
305
- throw error;
306
- }
307
- (0, _terminal.terminal)(`^+^yAuth session create failed^:\n`);
308
- }
309
- }
310
- if (!newAuthSessionInstance) {
311
- throw new _helpers.CLIError(`Failed to create auth session after ${retries} retries`);
312
- }
313
- await (0, _helpers.storeAuthSessionInstance)({
314
- state: newAuthSessionInstance,
315
- id: authSessionId,
316
- input: authSessionInput,
317
- proxy: rest.proxy,
318
- metadata
319
- });
320
- return newAuthSessionInstance;
321
- }
322
- const _runCreateWithRetries = exports._runCreateWithRetries = runCreateWithRetries;
323
- async function executeRecordAuthSessionCLI({
324
- id,
325
- checkRetries,
326
- timeout,
327
- headless,
328
- proxy,
329
- trace = false,
330
- keepBrowserOpen,
331
- startUrl,
332
- finishUrl
333
- }) {
334
- id = id ?? generateAuthSessionId();
335
- (0, _terminal.terminal)(`^+Recording auth session with id ^c${id}^:\n`);
336
- let authSession;
337
- try {
338
- authSession = await recordAuthSession({
339
- startUrl,
340
- finishUrl,
341
- timeout,
342
- proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
343
- });
344
- } catch (error) {
345
- if (error instanceof _helpers.CLIError) {
346
- throw new _helpers.CLIError(`Failed to record auth session: ${error.message}`);
347
- }
348
- throw error;
349
- }
350
- await (0, _helpers.storeAuthSessionInstance)({
351
- state: authSession,
352
- id,
353
- proxy,
354
- metadata: {
355
- createdAt: new Date().toISOString(),
356
- updatedAt: new Date().toISOString(),
357
- authSessionId: id,
358
- authSessionType: "MANUAL",
359
- recorderStartUrl: startUrl,
360
- recorderEndUrl: finishUrl
361
- }
362
- });
363
- await executeRunValidateAuthSessionCLI({
364
- id,
365
- headless,
366
- timeout,
367
- proxy,
368
- autoRecreate: false,
369
- checkRetries,
370
- createRetries: 0,
371
- trace,
372
- keepBrowserOpen
373
- });
374
- (0, _terminal.terminal)(`^+^gAuth session ^c${id}^ ^+^grecorded successfully^:\n`);
375
- }
376
- async function recordAuthSession({
377
- startUrl,
378
- finishUrl,
379
- timeout,
380
- proxy
381
- }) {
382
- const {
383
- context,
384
- page
385
- } = await (0, _launchBrowser.launchChromium)({
386
- headless: false,
387
- proxy,
388
- appModeInitialUrl: startUrl
389
- });
390
- try {
391
- if (!page.url().startsWith(startUrl)) {
392
- await page.goto(startUrl);
393
- }
394
- (0, _terminal.terminal)(`^+Navigated to^ ^_${startUrl}^:\n`);
395
- (0, _terminal.terminal)(`^+Waiting for^ ^_${finishUrl}^:...\n`);
396
- const timeoutTimestamp = Date.now() + timeout;
397
- while (true) {
398
- if (Date.now() > timeoutTimestamp) {
399
- throw new _helpers.CLIError("Timeout waiting for finish URL");
400
- }
401
- if (context.pages().length === 0) {
402
- throw new _helpers.CLIError("Browser was closed before reaching the finish URL");
403
- }
404
- if (context.pages()[0].url().startsWith(finishUrl)) {
405
- break;
406
- }
407
- await (0, _promises.setTimeout)(1000);
408
- }
409
- (0, _terminal.terminal)(`^+Finish URL reached, capturing auth session...^:\n`);
410
- await page.waitForLoadState("load");
411
- const authSession = await (0, _contextStorageStateHelpers.getStorageState)(context);
412
- return authSession;
413
- } finally {
414
- await context.close();
415
- }
416
- }
417
- function generateAuthSessionId(isAttempt = false) {
418
- if (isAttempt) return `auth-session-attempt-${Date.now()}`;
419
- return `auth-session-${Date.now()}`;
420
- }
@@ -1 +0,0 @@
1
- export declare const runBuild: () => Promise<boolean>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.runBuild = void 0;
7
- var fs = _interopRequireWildcard(require("fs-extra"));
8
- var path = _interopRequireWildcard(require("path"));
9
- var _child_process = require("child_process");
10
- var _util = require("util");
11
- var _terminal = require("../helpers/terminal");
12
- 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); }
13
- 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; }
14
- const execPromise = (0, _util.promisify)(_child_process.exec);
15
- const runBuild = async () => {
16
- const distPath = path.join(process.cwd(), "dist");
17
- if (await fs.exists(distPath)) {
18
- await fs.remove(distPath);
19
- }
20
- const buildCommand = "tsc";
21
- try {
22
- await execPromise(buildCommand);
23
- (0, _terminal.terminal)(`^g^+✨ Build completed successfully!^:\n`);
24
- return true;
25
- } catch (error) {
26
- (0, _terminal.terminal)(`^r^+An error occurred during the build process:^:\n`);
27
- if ("stdout" in error) {
28
- (0, _terminal.terminal)(`${error.stdout}\n`);
29
- } else {
30
- (0, _terminal.terminal)(`^${error.message}^:\n`);
31
- }
32
- (0, _terminal.terminal)(`^r^+Build failed^:\n`);
33
- return false;
34
- }
35
- };
36
- exports.runBuild = runBuild;
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
- import type { AuthCredentials } from "../types";
3
- export declare function runDeployProject(projectName: string, auth: AuthCredentials): Promise<void>;
4
- export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
@@ -1,139 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.projectNameSchema = 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
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- async function runDeployProject(projectName, auth) {
18
- await (0, _save.runSaveProject)(projectName, auth);
19
- const {
20
- workspaceId,
21
- apiKey
22
- } = auth;
23
- const baseUrl = (0, _helpers.getBaseUrl)();
24
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy`;
25
- const headers = {
26
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
27
- "Content-Type": "application/json"
28
- };
29
- const response = await fetch(url, {
30
- headers,
31
- method: "POST"
32
- });
33
- if (!response.ok) {
34
- if (response.status === 401) {
35
- throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
36
- }
37
- throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project deployment failed^:\n`, {
38
- autoColor: false
39
- });
40
- }
41
- (0, _terminal.terminal)("\n");
42
- const startTime = Date.now();
43
- const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
44
- function* getSpinnerGenerator() {
45
- while (true) {
46
- yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
47
- }
48
- }
49
- const spinnerGen = getSpinnerGenerator();
50
- let updateSpinnerInterval = null;
51
- if (_terminal.terminalStdout.isTTY) {
52
- updateSpinnerInterval = setInterval(() => {
53
- _terminal.terminal.previousLine(1);
54
- _terminal.terminal.column(0);
55
- _terminal.terminal.eraseLineAfter();
56
- (0, _terminal.terminal)(`${spinnerGen.next().value} ^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
57
- }, 50);
58
- (0, _terminal.terminal)("\n");
59
- } else {
60
- (0, _terminal.terminal)(`^cDeploying ^:\n`);
61
- }
62
- try {
63
- while (true) {
64
- await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
65
- if (!_terminal.terminalStdout.isTTY) {
66
- (0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
67
- }
68
- const {
69
- status,
70
- message,
71
- projectId,
72
- ...rest
73
- } = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
74
- if (status === "pending") {
75
- const elapsedTime = Date.now() - startTime;
76
- if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
77
- throw new _helpers.CLIError(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / (0, _ms.default)("1 minute"))} minutes`);
78
- }
79
- continue;
80
- }
81
- _terminal.terminal.previousLine(1);
82
- _terminal.terminal.eraseLine();
83
- if (updateSpinnerInterval) {
84
- clearTimeout(updateSpinnerInterval);
85
- }
86
- if (status === "completed") {
87
- const url = (0, _helpers.getBaseUrl)();
88
- (0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
89
- (0, _terminal.terminal)(`^+You can check your project on the platform:^s ^c^_${url}/projects/${projectId}/details^:\n`);
90
- return;
91
- }
92
- let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
93
- if (rest.reason) {
94
- errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
95
- }
96
- errorMessage += `^r^+Project deployment failed^:\n`;
97
- throw new _helpers.CLIError(errorMessage, {
98
- autoColor: false
99
- });
100
- }
101
- } catch (e) {
102
- if (updateSpinnerInterval) {
103
- clearTimeout(updateSpinnerInterval);
104
- }
105
- throw e;
106
- }
107
- }
108
- 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, {
109
- message: "Name cannot be a UUID"
110
- });
111
- const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
112
- const baseUrl = (0, _helpers.getBaseUrl)();
113
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy/result`;
114
- const headers = {
115
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
116
- "Content-Type": "application/json"
117
- };
118
- const response = await fetch(url, {
119
- headers,
120
- method: "GET"
121
- });
122
- if (response.status === 404) {
123
- return {
124
- status: "not_found",
125
- message: "Project not found"
126
- };
127
- }
128
- if (!response.ok) {
129
- throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
130
- }
131
- const data = await response.json();
132
- if (data.status) {
133
- return data;
134
- }
135
- return {
136
- status: "failed",
137
- message: `Deployment failed, please try again: ${data.message}`
138
- };
139
- };
@@ -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,14 +0,0 @@
1
- import { z } from "zod";
2
- import type { AuthCredentials } from "../types";
3
- export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<void>;
4
- export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
5
- export declare const validateProjectName: (projectName: string) => {
6
- isValid: true;
7
- } | {
8
- isValid: false;
9
- errorMessage: string;
10
- };
11
- export declare const validateIntunedProject: () => Promise<{
12
- isValid: boolean;
13
- errorMessage?: string;
14
- }>;