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