@intuned/runtime-dev 1.3.9-deploy.0 → 1.3.9-dev10

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 -0
  2. package/bin/intuned +2 -0
  3. package/bin/intuned-api-run +2 -0
  4. package/bin/intuned-auth-session-check +2 -0
  5. package/bin/intuned-auth-session-create +2 -0
  6. package/bin/intuned-auth-session-load +2 -0
  7. package/dist/commands/common/utils/settings.js +3 -0
  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/controller/deploy.d.ts +0 -1
  12. package/dist/commands/intuned-cli/controller/deploy.js +6 -143
  13. package/dist/commands/intuned-cli/controller/save.d.ts +1 -4
  14. package/dist/commands/intuned-cli/controller/save.js +2 -8
  15. package/dist/commands/intuned-cli/helpers/backend.js +1 -1
  16. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -3
  17. package/dist/commands/intuned-cli/helpers/errors.js +1 -8
  18. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +11 -113
  19. package/dist/commands/intuned-cli/helpers/intunedJson.js +3 -19
  20. package/dist/commands/intuned-cli/helpers/wrapper.js +0 -5
  21. package/dist/common/binStartupScript.d.ts +1 -0
  22. package/dist/common/binStartupScript.js +34 -0
  23. package/dist/common/settingsSchema.d.ts +13 -0
  24. package/dist/common/settingsSchema.js +6 -0
  25. package/package/dist/commands/api/run.d.ts +6 -0
  26. package/package/dist/commands/api/run.js +123 -0
  27. package/package/dist/commands/auth-sessions/load.d.ts +2 -0
  28. package/package/dist/commands/auth-sessions/load.js +35 -0
  29. package/package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  30. package/package/dist/commands/auth-sessions/run-check.js +74 -0
  31. package/package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  32. package/package/dist/commands/auth-sessions/run-create.js +78 -0
  33. package/package/dist/commands/browser/save-state.d.ts +2 -0
  34. package/package/dist/commands/browser/save-state.js +17 -0
  35. package/package/dist/commands/browser/start-browser.d.ts +2 -0
  36. package/package/dist/commands/browser/start-browser.js +14 -0
  37. package/package/dist/commands/build.d.ts +1 -0
  38. package/package/dist/commands/build.js +84 -0
  39. package/package/dist/commands/common/browserUtils.d.ts +14 -0
  40. package/package/dist/commands/common/browserUtils.js +58 -0
  41. package/package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  42. package/package/dist/commands/common/getFirstLineNumber.js +101 -0
  43. package/package/dist/commands/common/getFirstLineNumber.test.js +228 -0
  44. package/package/dist/commands/common/projectExclusions.d.ts +2 -0
  45. package/package/dist/commands/common/projectExclusions.js +8 -0
  46. package/package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  47. package/package/dist/commands/common/sendMessageToClient.js +10 -0
  48. package/package/dist/commands/common/tsNodeImport.d.ts +2 -0
  49. package/package/dist/commands/common/tsNodeImport.js +34 -0
  50. package/package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  51. package/package/dist/commands/common/utils/fileUtils.js +33 -0
  52. package/package/dist/commands/common/utils/settings.d.ts +2 -0
  53. package/package/dist/commands/common/utils/settings.js +31 -0
  54. package/package/dist/commands/common/utils/template.d.ts +2 -0
  55. package/package/dist/commands/common/utils/template.js +31 -0
  56. package/package/dist/commands/common/utils/unixSocket.d.ts +9 -0
  57. package/package/dist/commands/common/utils/unixSocket.js +44 -0
  58. package/package/dist/commands/interface/run.d.ts +1 -0
  59. package/package/dist/commands/interface/run.js +216 -0
  60. package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  61. package/package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  62. package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  63. package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
  64. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  65. package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  66. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  67. package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
  68. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  69. package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
  70. package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
  71. package/package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
  72. package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
  73. package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
  74. package/package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  75. package/package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  76. package/package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  77. package/package/dist/commands/intuned-cli/commands/command.js +9 -0
  78. package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  79. package/package/dist/commands/intuned-cli/commands/deploy.command.js +38 -0
  80. package/package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
  81. package/package/dist/commands/intuned-cli/commands/index.js +203 -0
  82. package/package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  83. package/package/dist/commands/intuned-cli/commands/init.command.js +13 -0
  84. package/package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  85. package/package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  86. package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  87. package/package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
  88. package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +28 -0
  89. package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
  90. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  91. package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
  92. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  93. package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
  94. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  95. package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
  96. package/package/dist/commands/intuned-cli/commands/save.command.d.ts +13 -0
  97. package/package/dist/commands/intuned-cli/commands/save.command.js +42 -0
  98. package/package/dist/commands/intuned-cli/commands/types.d.ts +31 -0
  99. package/package/dist/commands/intuned-cli/commands/types.js +29 -0
  100. package/package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  101. package/package/dist/commands/intuned-cli/constants/index.js +25 -0
  102. package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +397 -0
  103. package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1059 -0
  104. package/package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
  105. package/package/dist/commands/intuned-cli/controller/api.js +189 -0
  106. package/package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
  107. package/package/dist/commands/intuned-cli/controller/authSession.js +420 -0
  108. package/package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  109. package/package/dist/commands/intuned-cli/controller/build.js +36 -0
  110. package/package/dist/commands/intuned-cli/controller/deploy.d.ts +4 -0
  111. package/package/dist/commands/intuned-cli/controller/deploy.js +139 -0
  112. package/package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  113. package/package/dist/commands/intuned-cli/controller/index.js +46 -0
  114. package/package/dist/commands/intuned-cli/controller/save.d.ts +14 -0
  115. package/package/dist/commands/intuned-cli/controller/save.js +345 -0
  116. package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
  117. package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
  118. package/package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  119. package/package/dist/commands/intuned-cli/helpers/api.js +19 -0
  120. package/package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
  121. package/package/dist/commands/intuned-cli/helpers/auth.js +144 -0
  122. package/package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  123. package/package/dist/commands/intuned-cli/helpers/backend.js +27 -0
  124. package/package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
  125. package/package/dist/commands/intuned-cli/helpers/browser.js +57 -0
  126. package/package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  127. package/package/dist/commands/intuned-cli/helpers/context.js +33 -0
  128. package/package/dist/commands/intuned-cli/helpers/errors.d.ts +13 -0
  129. package/package/dist/commands/intuned-cli/helpers/errors.js +37 -0
  130. package/package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
  131. package/package/dist/commands/intuned-cli/helpers/index.js +137 -0
  132. package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -0
  133. package/package/dist/commands/intuned-cli/helpers/intunedJson.js +71 -0
  134. package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  135. package/package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  136. package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  137. package/package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  138. package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  139. package/package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  140. package/package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
  141. package/package/dist/commands/intuned-cli/helpers/traces.js +32 -0
  142. package/package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  143. package/package/dist/commands/intuned-cli/helpers/validation.js +14 -0
  144. package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
  145. package/package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
  146. package/package/dist/commands/intuned-cli/index.d.ts +1 -0
  147. package/package/dist/commands/intuned-cli/index.js +16 -0
  148. package/package/dist/commands/intuned-cli/main.d.ts +1 -0
  149. package/package/dist/commands/intuned-cli/main.js +22 -0
  150. package/package/dist/commands/intuned-cli/types.d.ts +41 -0
  151. package/package/dist/commands/intuned-cli/types.js +12 -0
  152. package/package/dist/commands/ts-check.d.ts +2 -0
  153. package/package/dist/commands/ts-check.js +56 -0
  154. package/package/dist/common/Logger/Logger/index.d.ts +12 -0
  155. package/package/dist/common/Logger/Logger/index.js +60 -0
  156. package/package/dist/common/Logger/Logger/types.d.ts +8 -0
  157. package/package/dist/common/Logger/Logger/types.js +5 -0
  158. package/package/dist/common/Logger/index.d.ts +12 -0
  159. package/package/dist/common/Logger/index.js +60 -0
  160. package/package/dist/common/Logger/types.d.ts +8 -0
  161. package/package/dist/common/Logger/types.js +5 -0
  162. package/package/dist/common/assets/browser_scripts.js +2580 -0
  163. package/package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  164. package/package/dist/common/asyncLocalStorage/index.js +17 -0
  165. package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  166. package/package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  167. package/package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  168. package/package/dist/common/cleanEnvironmentVariables.js +16 -0
  169. package/package/dist/common/constants.d.ts +10 -0
  170. package/package/dist/common/constants.js +16 -0
  171. package/package/dist/common/contextStorageStateHelpers.d.ts +21 -0
  172. package/package/dist/common/contextStorageStateHelpers.js +81 -0
  173. package/package/dist/common/extensionsHelpers.d.ts +8 -0
  174. package/package/dist/common/extensionsHelpers.js +80 -0
  175. package/package/dist/common/formatZodError.d.ts +2 -0
  176. package/package/dist/common/formatZodError.js +18 -0
  177. package/package/dist/common/jwtTokenManager.d.ts +17 -0
  178. package/package/dist/common/jwtTokenManager.js +109 -0
  179. package/package/dist/common/launchBrowser.d.ts +25 -0
  180. package/package/dist/common/launchBrowser.js +172 -0
  181. package/package/dist/common/playwrightContext.d.ts +31 -0
  182. package/package/dist/common/playwrightContext.js +144 -0
  183. package/package/dist/common/runApi/errors.d.ts +72 -0
  184. package/package/dist/common/runApi/errors.js +169 -0
  185. package/package/dist/common/runApi/importUsingImportFunction.d.ts +9 -0
  186. package/package/dist/common/runApi/importUsingImportFunction.js +46 -0
  187. package/package/dist/common/runApi/index.d.ts +11 -0
  188. package/package/dist/common/runApi/index.js +199 -0
  189. package/package/dist/common/runApi/types.d.ts +830 -0
  190. package/package/dist/common/runApi/types.js +73 -0
  191. package/package/dist/common/settingsSchema.d.ts +518 -0
  192. package/package/dist/common/settingsSchema.js +57 -0
  193. package/package/dist/common/setupContextHook.d.ts +17 -0
  194. package/package/dist/common/setupContextHook.js +22 -0
  195. package/package/dist/common/telemetry.d.ts +3 -0
  196. package/package/dist/common/telemetry.js +32 -0
  197. package/package/dist/index.d.ts +4 -0
  198. package/package/dist/index.js +69 -0
  199. package/package/dist/runtime/RunError.d.ts +5 -0
  200. package/package/dist/runtime/RunError.js +19 -0
  201. package/package/dist/runtime/attemptStore.d.ts +2 -0
  202. package/package/dist/runtime/attemptStore.js +23 -0
  203. package/package/dist/runtime/downloadDirectory.d.ts +1 -0
  204. package/package/dist/runtime/downloadDirectory.js +19 -0
  205. package/package/dist/runtime/enums.d.js +5 -0
  206. package/package/dist/runtime/enums.d.ts +11 -0
  207. package/package/dist/runtime/enums.js +18 -0
  208. package/package/dist/runtime/executionHelpers.test.js +52 -0
  209. package/package/dist/runtime/export.d.js +5 -0
  210. package/package/dist/runtime/export.d.ts +228 -0
  211. package/package/dist/runtime/extendPayload.d.ts +2 -0
  212. package/package/dist/runtime/extendPayload.js +21 -0
  213. package/package/dist/runtime/extendTimeout.d.ts +1 -0
  214. package/package/dist/runtime/extendTimeout.js +23 -0
  215. package/package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  216. package/package/dist/runtime/getAuthSessionParameters.js +20 -0
  217. package/package/dist/runtime/index.d.ts +7 -0
  218. package/package/dist/runtime/index.js +54 -0
  219. package/package/dist/runtime/runInfo.d.ts +2 -0
  220. package/package/dist/runtime/runInfo.js +21 -0
  221. package/package.json +3 -5
  222. package/WebTemplate.zip +0 -0
  223. package/bin/intuned-auth-session-refresh +0 -2
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runAutomationCLI = runAutomationCLI;
7
+ var _commander = require("commander");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
10
+ var net = _interopRequireWildcard(require("net"));
11
+ var _zod = _interopRequireDefault(require("zod"));
12
+ var _runApi = require("../../common/runApi");
13
+ var _enums = require("../../runtime/enums");
14
+ var _unixSocket = require("../common/utils/unixSocket");
15
+ var _promises = require("timers/promises");
16
+ var _jwtTokenManager = require("../../common/jwtTokenManager");
17
+ var _formatZodError = require("../../common/formatZodError");
18
+ var _neverthrow = require("neverthrow");
19
+ var _getAuthSessionParameters = require("../../common/backendFunctions/getAuthSessionParameters");
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
+ 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); }
22
+ 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; }
23
+ const startRunApiSchema = _zod.default.object({
24
+ type: _zod.default.literal("start"),
25
+ parameters: _runApi.runApiParametersSchema.extend({
26
+ retrieveSession: _zod.default.boolean(),
27
+ functionsToken: _zod.default.string().optional(),
28
+ context: _zod.default.object({
29
+ jobId: _zod.default.string().optional(),
30
+ jobRunId: _zod.default.string().optional(),
31
+ runId: _zod.default.string().optional(),
32
+ queueId: _zod.default.string().optional(),
33
+ authSessionId: _zod.default.string().optional()
34
+ }).optional()
35
+ })
36
+ });
37
+ const nextRunApiSchema = _zod.default.object({
38
+ type: _zod.default.literal("next"),
39
+ parameters: _zod.default.object({
40
+ value: _zod.default.string()
41
+ })
42
+ });
43
+ const abortRunApiSchema = _zod.default.object({
44
+ type: _zod.default.literal("abort"),
45
+ parameters: _zod.default.object({}).optional()
46
+ });
47
+ const tokenUpdateSchema = _zod.default.object({
48
+ type: _zod.default.literal("tokenUpdate"),
49
+ parameters: _zod.default.object({
50
+ functionsToken: _zod.default.string()
51
+ })
52
+ });
53
+ const pingSchema = _zod.default.object({
54
+ type: _zod.default.literal("ping"),
55
+ parameters: _zod.default.object({}).optional()
56
+ });
57
+ const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema, pingSchema]);
58
+ _dotenv.default.config({
59
+ path: `.env`
60
+ });
61
+ function runAutomationCLI(importFunction) {
62
+ _commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
63
+ let context;
64
+ const throttleTime = 60 * 1000;
65
+ let timeoutTimestamp = Date.now();
66
+ const client = net.createConnection(socketPath);
67
+ const abortController = new AbortController();
68
+ const interruptSignalHandler = async () => {
69
+ abortController.abort();
70
+ await (0, _promises.setTimeout)(60_000);
71
+ client.end();
72
+ process.exit(1);
73
+ };
74
+ process.on("SIGINT", interruptSignalHandler);
75
+ process.on("SIGTERM", interruptSignalHandler);
76
+ const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
77
+ const messagesGenerator = jsonUnixSocket.receiveJSON();
78
+ async function receiveMessages() {
79
+ const data = await messagesGenerator.next();
80
+ if (data.done) {
81
+ return;
82
+ }
83
+ const inputParseResult = inputSchema.safeParse(data.value);
84
+ if (!inputParseResult.success) {
85
+ console.error("Validation error:", (0, _formatZodError.formatZodError)(inputParseResult.error));
86
+ return {
87
+ type: "error",
88
+ error: new _runApi.InternalInvalidInputError("Invalid input", (0, _formatZodError.formatZodError)(inputParseResult.error))
89
+ };
90
+ }
91
+ const input = inputParseResult.data;
92
+ return input;
93
+ }
94
+ let resultPromise = null;
95
+ async function handleMessage(message) {
96
+ if (message.type === "abort") {
97
+ abortController.abort();
98
+ return;
99
+ }
100
+ if (message.type === "tokenUpdate") {
101
+ _jwtTokenManager.backendFunctionsTokenManager.token = message.parameters.functionsToken;
102
+ return;
103
+ }
104
+ if (message.type === "start") {
105
+ context = {
106
+ extendedPayloads: [],
107
+ runEnvironment: message.parameters.runOptions.environment === "standalone" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
108
+ timeoutInfo: {
109
+ extendTimeoutCallback: async () => {
110
+ if (Date.now() - timeoutTimestamp < throttleTime) return;
111
+ timeoutTimestamp = Date.now();
112
+ jsonUnixSocket.sendJSON({
113
+ type: "extend"
114
+ });
115
+ }
116
+ },
117
+ getAuthSessionParameters: _getAuthSessionParameters.getAuthSessionParameters,
118
+ ...(message.parameters.context ?? {}),
119
+ proxy: getProxyUrlFromRunOptions(message.parameters.runOptions)
120
+ };
121
+ _jwtTokenManager.backendFunctionsTokenManager.token = message.parameters.functionsToken;
122
+ resultPromise = (0, _asyncLocalStorage.runWithContext)(context, async () => {
123
+ return await (0, _runApi.runApi)({
124
+ ...message.parameters,
125
+ abortSignal: abortController.signal,
126
+ importFunction: importFunction ?? _defaultImport
127
+ });
128
+ });
129
+ return;
130
+ }
131
+ if (message.type === "next") {
132
+ throw new Error("next not supported anymore");
133
+ }
134
+ }
135
+ let receiveMessagesPromise = receiveMessages();
136
+ while (true) {
137
+ const messageOrResult = await Promise.race([receiveMessagesPromise.then(message => ({
138
+ type: "message",
139
+ message
140
+ })), ...(resultPromise ? [resultPromise.then(result => ({
141
+ type: "result",
142
+ result
143
+ }))] : [])]);
144
+ if (messageOrResult.type === "message") {
145
+ const {
146
+ message
147
+ } = messageOrResult;
148
+ if (message === undefined) {
149
+ break;
150
+ }
151
+ if (message.type === "error") {
152
+ jsonUnixSocket.sendJSON({
153
+ type: "done",
154
+ result: message.error.json,
155
+ success: false
156
+ });
157
+ break;
158
+ }
159
+ if (message.type === "ping") {
160
+ jsonUnixSocket.sendJSON({
161
+ type: "pong"
162
+ });
163
+ break;
164
+ }
165
+ await handleMessage(message);
166
+ receiveMessagesPromise = receiveMessages();
167
+ continue;
168
+ }
169
+ const {
170
+ result
171
+ } = messageOrResult;
172
+ const success = result.isOk();
173
+ const resultToSend = success ? result.value : result.error.json;
174
+ jsonUnixSocket.sendJSON({
175
+ type: "done",
176
+ result: resultToSend,
177
+ success
178
+ });
179
+ break;
180
+ }
181
+ if (!client.closed) {
182
+ client.end();
183
+ await Promise.race([new Promise(resolve => client.once("close", resolve)), new Promise(resolve => client.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
184
+ }
185
+ process.exit(0);
186
+ });
187
+ _commander.program.parse(process.argv);
188
+ }
189
+ function getProxyUrlFromRunOptions(runOptions) {
190
+ if (runOptions?.environment !== "standalone") return undefined;
191
+ const proxy = runOptions.proxy;
192
+ if (!proxy) return undefined;
193
+ const url = new URL(proxy.server);
194
+ url.username = proxy.username;
195
+ url.password = proxy.password;
196
+ return url.toString();
197
+ }
198
+ const _defaultImport = async path => {
199
+ try {
200
+ const imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`../../../${path}.ts`);
201
+ return (0, _neverthrow.ok)(imported);
202
+ } catch (e) {
203
+ if ("code" in e && e.code === "MODULE_NOT_FOUND") {
204
+ return (0, _neverthrow.err)({
205
+ type: "not_found"
206
+ });
207
+ }
208
+ return (0, _neverthrow.err)({
209
+ type: "other",
210
+ error: e
211
+ });
212
+ }
213
+ };
214
+ if (require.main === module) {
215
+ runAutomationCLI();
216
+ }
@@ -0,0 +1 @@
1
+ export declare const attemptCommand: import("commander").Command;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptCommand = void 0;
7
+ var _command = require("./command");
8
+ const attemptCommand = exports.attemptCommand = _command.program.command("attempt").description("Execute an Intuned attempt");
@@ -0,0 +1 @@
1
+ export declare const attemptApiCommand: import("commander").Command;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptApiCommand = void 0;
7
+ var _api = require("../controller/api");
8
+ var _controller = require("../controller");
9
+ var _zod = require("zod");
10
+ var _types = require("./types");
11
+ var _helpers = require("../helpers");
12
+ var _attempt = require("./attempt.command");
13
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required")]);
14
+ const optionsSchema = _types.baseCommandOptionsSchema.extend({
15
+ authSession: _zod.z.string().optional(),
16
+ outputFile: _zod.z.string().optional()
17
+ });
18
+ const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>.json").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
19
+ authSession,
20
+ ...rest
21
+ }) => {
22
+ await (0, _helpers.assertAuthConsistent)(authSession);
23
+ const parametersData = await (0, _controller.loadParameters)(parameters);
24
+ await (0, _api.executeAttemptApiCLI)({
25
+ apiName,
26
+ inputData: parametersData,
27
+ authSessionId: authSession,
28
+ ...rest
29
+ });
30
+ }));
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCommand: import("commander").Command;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCommand = void 0;
7
+ var _attempt = require("./attempt.command");
8
+ const attemptAuthSessionCommand = exports.attemptAuthSessionCommand = _attempt.attemptCommand.command("authsession").description("Manage authentication sessions");
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCheckCommand: import("commander").Command;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCheckCommand = void 0;
7
+ var _zod = require("zod");
8
+ var _authSession = require("../controller/authSession");
9
+ var _attempt_authsession = require("./attempt_authsession.command");
10
+ var _helpers = require("../helpers");
11
+ var _types = require("./types");
12
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required")]);
13
+ const attemptAuthSessionCheckCommand = exports.attemptAuthSessionCheckCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("check").description("Check an existing auth session").argument("<id>", "ID of the auth session to check")).action((0, _helpers.cliCommandWrapper)(argsSchema, _types.baseCommandOptionsSchema, async ([id], options) => {
14
+ await (0, _helpers.assertAuthEnabled)();
15
+ await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
16
+ id,
17
+ ...options
18
+ });
19
+ }));
@@ -0,0 +1 @@
1
+ export declare const attemptAuthSessionCreateCommand: import("commander").Command;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attemptAuthSessionCreateCommand = void 0;
7
+ var _controller = require("../controller");
8
+ var _zod = require("zod");
9
+ var _authSession = require("../controller/authSession");
10
+ var _attempt_authsession = require("./attempt_authsession.command");
11
+ var _helpers = require("../helpers");
12
+ var _types = require("./types");
13
+ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required")]);
14
+ const optionsSchema = _types.baseCommandOptionsSchema.extend({
15
+ id: _zod.z.string().optional()
16
+ });
17
+ const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to ./auth-session-instances/[current timestamp].json")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], options) => {
18
+ await (0, _helpers.assertAuthEnabled)();
19
+ const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
20
+ await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
21
+ input: authSessionInput,
22
+ ...options
23
+ });
24
+ }));
@@ -0,0 +1 @@
1
+ export declare const authSessionCommand: import("commander").Command;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.authSessionCommand = void 0;
7
+ var _command = require("./command");
8
+ const authSessionCommand = exports.authSessionCommand = _command.program.command("authsession").description("Manage Auth Sessions");
@@ -0,0 +1 @@
1
+ export declare const authSessionRecordCommand: import("commander").Command;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.authSessionRecordCommand = void 0;
7
+ var _zod = require("zod");
8
+ var _authSession = require("../controller/authSession");
9
+ var _helpers = require("../helpers");
10
+ var _authsession = require("./authsession.command");
11
+ var _run_authsession = require("./run_authsession.command");
12
+ var _types = require("./types");
13
+ const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
14
+ id: _zod.z.string().optional()
15
+ });
16
+ const authSessionRecordCommand = exports.authSessionRecordCommand = (0, _types.withBaseOptions)(_authsession.authSessionCommand.command("record").description("Record a new auth session").option("--id <id>", "ID of the auth session to use for the command. Defaults to auth-session-[current timestamp]").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1")).action((0, _helpers.cliCommandWrapper)(undefined, optionsSchema, async (_, {
17
+ checkAttempts,
18
+ ...rest
19
+ }) => {
20
+ await (0, _helpers.assertAuthEnabled)();
21
+ const {
22
+ startUrl,
23
+ finishUrl
24
+ } = await (0, _helpers.getAuthSessionRecorderParameters)();
25
+ await (0, _authSession.executeRecordAuthSessionCLI)({
26
+ checkRetries: checkAttempts,
27
+ startUrl,
28
+ finishUrl,
29
+ ...rest
30
+ });
31
+ }));
@@ -0,0 +1 @@
1
+ export declare const buildCommand: import("commander").Command;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildCommand = void 0;
7
+ var _command = require("./command");
8
+ var _build = require("../controller/build");
9
+ var _helpers = require("../helpers");
10
+ const buildCommand = exports.buildCommand = _command.program.command("build").description("Build Intuned project").action((0, _helpers.cliCommandWrapper)(undefined, undefined, async () => {
11
+ await (0, _build.runBuild)();
12
+ }));
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const program: Command;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.program = void 0;
7
+ var _commander = require("commander");
8
+ const program = exports.program = new _commander.Command();
9
+ program.name("intuned").description("Intuned CLI for creating, developing and deploying Intuned projects").version("1.0.0").enablePositionalOptions(true);
@@ -0,0 +1 @@
1
+ export declare const deployCommand: import("commander").Command;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deployCommand = void 0;
7
+ var _command = require("./command");
8
+ var _dotenv = _interopRequireDefault(require("dotenv"));
9
+ var _save = require("../controller/save");
10
+ var _deploy = require("../controller/deploy");
11
+ var _helpers = require("../helpers");
12
+ var _save2 = require("./save.command");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ _dotenv.default.config({
15
+ path: `.env`
16
+ });
17
+ const deployCommand = exports.deployCommand = _command.program.command("deploy").description("Save and deploy an Intuned project to the platform").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action((0, _helpers.cliCommandWrapper)(_save2.saveOrDeployArgsSchema, _save2.saveOrDeployOptionsSchema, async ([projectName], options) => {
18
+ const {
19
+ isValid,
20
+ errorMessage
21
+ } = await (0, _save.validateIntunedProject)();
22
+ if (!isValid) {
23
+ const message = `^r^+Project to be deployed is not a valid Intuned project:^:^R ${errorMessage}:\n`;
24
+ throw new _helpers.CLIError(message, {
25
+ autoColor: false
26
+ });
27
+ }
28
+ const _projectName = projectName || (await (0, _helpers.loadIntunedJson)()).projectName;
29
+ if (!_projectName) {
30
+ throw new _helpers.CLIError("Project name is required");
31
+ }
32
+ const projectNameValidation = (0, _save.validateProjectName)(_projectName);
33
+ if (!projectNameValidation.isValid) {
34
+ throw new _helpers.CLIError(projectNameValidation.errorMessage);
35
+ }
36
+ const auth = await (0, _helpers.getAuthCredentials)(options);
37
+ await (0, _deploy.runDeployProject)(_projectName, auth);
38
+ }));
@@ -0,0 +1,18 @@
1
+ export * from "./command";
2
+ export * from "./build.command";
3
+ export * from "./deploy.command";
4
+ export * from "./save.command";
5
+ export * from "./init.command";
6
+ export * from "./run.command";
7
+ export * from "./run_api.command";
8
+ export * from "./run_authsession.command";
9
+ export * from "./run_authsession_create.command";
10
+ export * from "./run_authsession_update.command";
11
+ export * from "./run_authsession_validate.command";
12
+ export * from "./attempt.command";
13
+ export * from "./attempt_api.command";
14
+ export * from "./attempt_authsession.command";
15
+ export * from "./attempt_authsession_create.command";
16
+ export * from "./attempt_authsession_check.command";
17
+ export * from "./authsession.command";
18
+ export * from "./authsession_record.command";