@nrwl/nx-cloud 15.0.4-beta.2 → 15.0.4-beta.3

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 (154) hide show
  1. package/bin/nx-cloud.d.ts +2 -0
  2. package/bin/nx-cloud.js +50 -0
  3. package/bin/nx-cloud.js.map +1 -0
  4. package/index.d.ts +2 -0
  5. package/index.js +5 -0
  6. package/index.js.map +1 -0
  7. package/lib/core/api/error-reporter.api.d.ts +6 -0
  8. package/lib/core/api/error-reporter.api.js +36 -0
  9. package/lib/core/api/error-reporter.api.js.map +1 -0
  10. package/lib/core/api/run-group.api.d.ts +7 -0
  11. package/lib/core/api/run-group.api.js +68 -0
  12. package/lib/core/api/run-group.api.js.map +1 -0
  13. package/lib/core/commands/clean-up-agents.d.ts +1 -0
  14. package/lib/core/commands/clean-up-agents.js +34 -0
  15. package/lib/core/commands/clean-up-agents.js.map +1 -0
  16. package/lib/core/commands/record-output.d.ts +1 -0
  17. package/lib/core/commands/record-output.js +177 -0
  18. package/lib/core/commands/record-output.js.map +1 -0
  19. package/lib/core/commands/start-ci-run.d.ts +1 -0
  20. package/lib/core/commands/start-ci-run.js +61 -0
  21. package/lib/core/commands/start-ci-run.js.map +1 -0
  22. package/lib/core/commands/stop-all-agents.d.ts +1 -0
  23. package/lib/core/commands/stop-all-agents.js +37 -0
  24. package/lib/core/commands/stop-all-agents.js.map +1 -0
  25. package/lib/core/commands/upload-and-show-run-details.d.ts +1 -0
  26. package/lib/core/commands/upload-and-show-run-details.js +60 -0
  27. package/lib/core/commands/upload-and-show-run-details.js.map +1 -0
  28. package/lib/core/error/print-invalid-runner-error.d.ts +1 -0
  29. package/lib/core/error/print-invalid-runner-error.js +17 -0
  30. package/lib/core/error/print-invalid-runner-error.js.map +1 -0
  31. package/lib/core/error/print-run-group-error.d.ts +1 -0
  32. package/lib/core/error/print-run-group-error.js +16 -0
  33. package/lib/core/error/print-run-group-error.js.map +1 -0
  34. package/lib/core/file-storage/e2e-encryption.d.ts +9 -0
  35. package/lib/core/file-storage/e2e-encryption.js +46 -0
  36. package/lib/core/file-storage/e2e-encryption.js.map +1 -0
  37. package/lib/core/file-storage/file-storage.d.ts +24 -0
  38. package/lib/core/file-storage/file-storage.js +262 -0
  39. package/lib/core/file-storage/file-storage.js.map +1 -0
  40. package/lib/core/models/cache-urls.model.d.ts +6 -0
  41. package/lib/core/models/cache-urls.model.js +3 -0
  42. package/lib/core/models/cache-urls.model.js.map +1 -0
  43. package/lib/core/models/cloud-task-runner-options.d.ts +20 -0
  44. package/lib/core/models/cloud-task-runner-options.js +3 -0
  45. package/lib/core/models/cloud-task-runner-options.js.map +1 -0
  46. package/lib/core/models/distributed-agent/grouped-tasks.model.d.ts +6 -0
  47. package/lib/core/models/distributed-agent/grouped-tasks.model.js +3 -0
  48. package/lib/core/models/distributed-agent/grouped-tasks.model.js.map +1 -0
  49. package/lib/core/models/distributed-agent/index.d.ts +3 -0
  50. package/lib/core/models/distributed-agent/index.js +20 -0
  51. package/lib/core/models/distributed-agent/index.js.map +1 -0
  52. package/lib/core/models/distributed-agent/task-to-execute.model.d.ts +7 -0
  53. package/lib/core/models/distributed-agent/task-to-execute.model.js +3 -0
  54. package/lib/core/models/distributed-agent/task-to-execute.model.js.map +1 -0
  55. package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +10 -0
  56. package/lib/core/models/distributed-agent/tasks-api-response.model.js +3 -0
  57. package/lib/core/models/distributed-agent/tasks-api-response.model.js.map +1 -0
  58. package/lib/core/models/machine-info.model.d.ts +6 -0
  59. package/lib/core/models/machine-info.model.js +3 -0
  60. package/lib/core/models/machine-info.model.js.map +1 -0
  61. package/lib/core/models/run-context.model.d.ts +128 -0
  62. package/lib/core/models/run-context.model.js +22 -0
  63. package/lib/core/models/run-context.model.js.map +1 -0
  64. package/lib/core/models/run-data.model.d.ts +11 -0
  65. package/lib/core/models/run-data.model.js +3 -0
  66. package/lib/core/models/run-data.model.js.map +1 -0
  67. package/lib/core/models/task-execution.model.d.ts +13 -0
  68. package/lib/core/models/task-execution.model.js +3 -0
  69. package/lib/core/models/task-execution.model.js.map +1 -0
  70. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +19 -0
  71. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +84 -0
  72. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -0
  73. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.d.ts +3 -0
  74. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +288 -0
  75. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -0
  76. package/lib/core/runners/cloud-enabled/cloud-remote-cache.d.ts +16 -0
  77. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +117 -0
  78. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -0
  79. package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +18 -0
  80. package/lib/core/runners/cloud-enabled/cloud-run.api.js +167 -0
  81. package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -0
  82. package/lib/core/runners/cloud-enabled/id-generator.d.ts +1 -0
  83. package/lib/core/runners/cloud-enabled/id-generator.js +16 -0
  84. package/lib/core/runners/cloud-enabled/id-generator.js.map +1 -0
  85. package/lib/core/runners/distributed-agent/distributed-agent.api.d.ts +13 -0
  86. package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -0
  87. package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -0
  88. package/lib/core/runners/distributed-agent/distributed-agent.impl.d.ts +1 -0
  89. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +269 -0
  90. package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -0
  91. package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +10 -0
  92. package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -0
  93. package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -0
  94. package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +1 -0
  95. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +241 -0
  96. package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -0
  97. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.d.ts +2 -0
  98. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -0
  99. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js.map +1 -0
  100. package/lib/core/runners/distributed-execution/task-graph-creator.d.ts +15 -0
  101. package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -0
  102. package/lib/core/runners/distributed-execution/task-graph-creator.js.map +1 -0
  103. package/lib/core/terminal-output/end-of-run-message.d.ts +8 -0
  104. package/lib/core/terminal-output/end-of-run-message.js +44 -0
  105. package/lib/core/terminal-output/end-of-run-message.js.map +1 -0
  106. package/lib/core/terminal-output/message-reporter.d.ts +11 -0
  107. package/lib/core/terminal-output/message-reporter.js +71 -0
  108. package/lib/core/terminal-output/message-reporter.js.map +1 -0
  109. package/lib/core/terminal-output/output-obfuscator.d.ts +6 -0
  110. package/lib/core/terminal-output/output-obfuscator.js +48 -0
  111. package/lib/core/terminal-output/output-obfuscator.js.map +1 -0
  112. package/lib/core/terminal-output/read-task-terminal-output.d.ts +2 -0
  113. package/lib/core/terminal-output/read-task-terminal-output.js +60 -0
  114. package/lib/core/terminal-output/read-task-terminal-output.js.map +1 -0
  115. package/lib/daemon/process-run-end.d.ts +3 -0
  116. package/lib/daemon/process-run-end.js +60 -0
  117. package/lib/daemon/process-run-end.js.map +1 -0
  118. package/lib/generators/init/init.d.ts +1 -0
  119. package/lib/generators/init/init.js +96 -0
  120. package/lib/generators/init/init.js.map +1 -0
  121. package/lib/nx-cloud-tasks-runner.d.ts +2 -0
  122. package/lib/nx-cloud-tasks-runner.js +146 -0
  123. package/lib/nx-cloud-tasks-runner.js.map +1 -0
  124. package/lib/utilities/axios.d.ts +10 -0
  125. package/lib/utilities/axios.js +87 -0
  126. package/lib/utilities/axios.js.map +1 -0
  127. package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
  128. package/lib/utilities/create-unchanged-value-timeout.js +24 -0
  129. package/lib/utilities/create-unchanged-value-timeout.js.map +1 -0
  130. package/lib/utilities/distributed-task-execution-detection.d.ts +2 -0
  131. package/lib/utilities/distributed-task-execution-detection.js +36 -0
  132. package/lib/utilities/distributed-task-execution-detection.js.map +1 -0
  133. package/lib/utilities/environment.d.ts +27 -0
  134. package/lib/utilities/environment.js +200 -0
  135. package/lib/utilities/environment.js.map +1 -0
  136. package/lib/utilities/is-ci.d.ts +1 -0
  137. package/lib/utilities/is-ci.js +21 -0
  138. package/lib/utilities/is-ci.js.map +1 -0
  139. package/lib/utilities/metric-logger.d.ts +22 -0
  140. package/lib/utilities/metric-logger.js +70 -0
  141. package/lib/utilities/metric-logger.js.map +1 -0
  142. package/lib/utilities/nx-imports.d.ts +0 -0
  143. package/lib/utilities/nx-imports.js +59 -0
  144. package/lib/utilities/nx-imports.js.map +1 -0
  145. package/lib/utilities/print-message.d.ts +1 -0
  146. package/lib/utilities/print-message.js +64 -0
  147. package/lib/utilities/print-message.js.map +1 -0
  148. package/lib/utilities/serializer-overrides.d.ts +2 -0
  149. package/lib/utilities/serializer-overrides.js +40 -0
  150. package/lib/utilities/serializer-overrides.js.map +1 -0
  151. package/lib/utilities/waiter.d.ts +6 -0
  152. package/lib/utilities/waiter.js +36 -0
  153. package/lib/utilities/waiter.js.map +1 -0
  154. package/package.json +1 -1
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudRemoteCache = void 0;
13
+ const environment_1 = require("../../../utilities/environment");
14
+ const { output } = require('../../../utilities/nx-imports');
15
+ class CloudRemoteCache {
16
+ constructor(messages, api, runContext, fileStorage) {
17
+ this.messages = messages;
18
+ this.api = api;
19
+ this.runContext = runContext;
20
+ this.fileStorage = fileStorage;
21
+ this.storeRequests = [];
22
+ }
23
+ retrieve(hash, cacheDirectory) {
24
+ var _a;
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (this.messages.cacheError)
27
+ return false;
28
+ const hashUrls = yield this.hashUrls(hash);
29
+ if (!hashUrls || !hashUrls.get) {
30
+ if (environment_1.VERBOSE_LOGGING) {
31
+ output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
32
+ }
33
+ this.runContext.statuses[hash] = 'cache-miss';
34
+ return false;
35
+ }
36
+ try {
37
+ yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
38
+ this.runContext.statuses[hash] = 'remote-cache-hit';
39
+ return true;
40
+ }
41
+ catch (ee) {
42
+ const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
43
+ if (e.response && e.response.status === 404) {
44
+ if (environment_1.VERBOSE_LOGGING) {
45
+ output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
46
+ }
47
+ // cache miss. print nothing
48
+ }
49
+ else {
50
+ this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
51
+ }
52
+ this.runContext.statuses[hash] = 'cache-miss';
53
+ return false;
54
+ }
55
+ });
56
+ }
57
+ store(hash, cacheDirectory) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ if (this.messages.cacheError)
60
+ return false;
61
+ const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
62
+ var _a;
63
+ const hashUrls = yield this.hashUrls(hash);
64
+ if (!hashUrls)
65
+ return false;
66
+ if (!hashUrls.put) {
67
+ if (environment_1.VERBOSE_LOGGING) {
68
+ output.note({
69
+ title: `Nx Cloud: Skipping storing ${hash}.`,
70
+ bodyLines: [
71
+ `There are several reasons why this can happen.`,
72
+ `Maybe you are using a read-only token or the artifact has already being uploaded.`,
73
+ ],
74
+ });
75
+ }
76
+ return true;
77
+ }
78
+ try {
79
+ yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
80
+ return true;
81
+ }
82
+ catch (ee) {
83
+ const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
84
+ this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
85
+ return false;
86
+ }
87
+ }));
88
+ this.storeRequests.push(res);
89
+ return res;
90
+ });
91
+ }
92
+ hashUrls(hash) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ if (hash in this.runContext.requests) {
95
+ return (yield this.runContext.requests[hash])[hash];
96
+ }
97
+ else {
98
+ const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
99
+ .filter((t) => !this.runContext.requests[t.hash])
100
+ .map((t) => t.hash);
101
+ if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
102
+ scheduledTaskHashesWithoutRequests.push(hash);
103
+ }
104
+ const request = this.api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
105
+ scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
106
+ this.runContext.requests[taskHash] = request;
107
+ });
108
+ return (yield request)[hash];
109
+ }
110
+ });
111
+ }
112
+ waitForStoreRequestsToComplete() {
113
+ return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
114
+ }
115
+ }
116
+ exports.CloudRemoteCache = CloudRemoteCache;
117
+ //# sourceMappingURL=cloud-remote-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-remote-cache.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-clo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IAED,8BAA8B;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAChD,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CACjC,CAAC;IACJ,CAAC;CACF;AA1GD,4CA0GC"}
@@ -0,0 +1,18 @@
1
+ import { RunContext } from '../../models/run-context.model';
2
+ import { MachineInfo } from '../../models/machine-info.model';
3
+ import { CacheUrls } from '../../models/cache-urls.model';
4
+ import { CloudTaskRunnerOptions } from '../../models/cloud-task-runner-options';
5
+ import { RunData } from '../../models/run-data.model';
6
+ import { MessageReporter } from '../../terminal-output/message-reporter';
7
+ import { TaskExecution } from '../../models/task-execution.model';
8
+ export declare class CloudRunApi {
9
+ private readonly messages;
10
+ private readonly runContext;
11
+ private readonly machineInfo;
12
+ private apiAxiosInstance;
13
+ constructor(messages: MessageReporter, runContext: RunContext, options: CloudTaskRunnerOptions, machineInfo: MachineInfo);
14
+ startRun(distributedExecutionId: string | undefined, hashes: string[]): Promise<CacheUrls>;
15
+ private createReqBody;
16
+ endRun(run: RunData, tasks: TaskExecution[], linkId?: string): Promise<boolean>;
17
+ private nxCloudVersion;
18
+ }
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudRunApi = void 0;
13
+ const axios_1 = require("../../../utilities/axios");
14
+ const environment_1 = require("../../../utilities/environment");
15
+ const fs_1 = require("fs");
16
+ const zlib_1 = require("zlib");
17
+ const util_1 = require("util");
18
+ const metric_logger_1 = require("../../../utilities/metric-logger");
19
+ const { output } = require('../../../utilities/nx-imports');
20
+ class CloudRunApi {
21
+ constructor(messages, runContext, options, machineInfo) {
22
+ this.messages = messages;
23
+ this.runContext = runContext;
24
+ this.machineInfo = machineInfo;
25
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
26
+ }
27
+ startRun(distributedExecutionId, hashes) {
28
+ var _a;
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
31
+ try {
32
+ const request = {
33
+ meta: {
34
+ nxCloudVersion: this.nxCloudVersion(),
35
+ },
36
+ branch: (0, environment_1.getBranch)(),
37
+ runGroup: (0, environment_1.getRunGroup)(),
38
+ distributedExecutionId,
39
+ hashes,
40
+ };
41
+ if (environment_1.VERBOSE_LOGGING) {
42
+ output.note({
43
+ title: 'RunStart',
44
+ bodyLines: ['\n' + JSON.stringify(request, null, 2)],
45
+ });
46
+ }
47
+ const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
48
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
49
+ if (resp.data && resp.data.message) {
50
+ this.messages.message = resp.data.message;
51
+ }
52
+ if (!resp.data || !resp.data.urls) {
53
+ this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
54
+ return {};
55
+ }
56
+ return resp.data.urls;
57
+ }
58
+ catch (e) {
59
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
60
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
61
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
62
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
63
+ return {};
64
+ }
65
+ });
66
+ }
67
+ createReqBody(run, tasks, linkId) {
68
+ const uncompressedReqBody = {
69
+ meta: {
70
+ nxCloudVersion: this.nxCloudVersion(),
71
+ },
72
+ tasks,
73
+ run,
74
+ linkId,
75
+ machineInfo: this.machineInfo,
76
+ };
77
+ return JSON.stringify(uncompressedReqBody);
78
+ }
79
+ endRun(run, tasks, linkId) {
80
+ var _a, _b;
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ // API is not working, don't make the end request
83
+ if (this.messages.apiError)
84
+ return false;
85
+ let uncompressedBodyString = this.createReqBody(run, tasks, linkId);
86
+ // if the req body is > 20mb, remove hashDetails
87
+ if (uncompressedBodyString.length > 20 * 1000 * 1000) {
88
+ uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))));
89
+ }
90
+ const uncompressedBuffer = Buffer.from(uncompressedBodyString);
91
+ const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
92
+ const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
93
+ try {
94
+ if (environment_1.VERBOSE_LOGGING) {
95
+ const t = tasks.map((tt) => {
96
+ return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
97
+ ? `${tt.terminalOutput.slice(0, 20)}...`
98
+ : undefined });
99
+ });
100
+ output.note({
101
+ title: 'RunEnd. Completed tasks',
102
+ bodyLines: ['\n' + JSON.stringify(t, null, 2)],
103
+ });
104
+ }
105
+ const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
106
+ headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
107
+ })));
108
+ if (resp) {
109
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
110
+ if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
111
+ this.runContext.runUrl = resp.data.runUrl;
112
+ return true;
113
+ }
114
+ if (resp.data && resp.data.status) {
115
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
116
+ }
117
+ else if (resp.data && typeof resp.data === 'string') {
118
+ if (resp.data !== 'success') {
119
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
120
+ }
121
+ }
122
+ else {
123
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
124
+ }
125
+ if (environment_1.VERBOSE_LOGGING) {
126
+ output.note({
127
+ title: 'Invalid end run response',
128
+ bodyLines: [JSON.stringify(resp.data, null, 2)],
129
+ });
130
+ }
131
+ }
132
+ else {
133
+ output.error({
134
+ title: 'Nx Cloud: Unknown Error Occurred',
135
+ bodyLines: [
136
+ 'Run completion responded with `undefined`.',
137
+ 'Run Details:',
138
+ JSON.stringify(run, null, 2),
139
+ 'Stack Trace:',
140
+ JSON.stringify(new Error().stack, null, 2),
141
+ ],
142
+ });
143
+ }
144
+ return false;
145
+ }
146
+ catch (ee) {
147
+ recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
148
+ ? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
149
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
150
+ const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
151
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
152
+ return false;
153
+ }
154
+ });
155
+ }
156
+ nxCloudVersion() {
157
+ try {
158
+ const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
159
+ return v.devDependencies['@nrwl/nx-cloud'];
160
+ }
161
+ catch (e) {
162
+ return 'unknown';
163
+ }
164
+ }
165
+ }
166
+ exports.CloudRunApi = CloudRunApi;
167
+ //# sourceMappingURL=cloud-run.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,oDAIkC;AAClC,gEAIwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;AACjC,oEAI0C;AAE1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5D,MAAa,WAAW;IAGtB,YACmB,QAAyB,EACzB,UAAsB,EACvC,OAA+B,EACd,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,eAAU,GAAV,UAAU,CAAY;QAEtB,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,QAAQ,CACZ,sBAA0C,EAC1C,MAAgB;;;YAEhB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,UAAU,CAAC,CAAC;YAElD,IAAI;gBACF,MAAM,OAAO,GAAG;oBACd,IAAI,EAAE;wBACJ,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;qBACtC;oBACD,MAAM,EAAE,IAAA,uBAAS,GAAE;oBACnB,QAAQ,EAAE,IAAA,yBAAW,GAAE;oBACvB,sBAAsB;oBACtB,MAAM;iBACP,CAAC;gBACF,IAAI,6BAAe,EAAE;oBACnB,MAAM,CAAC,IAAI,CAAC;wBACV,KAAK,EAAE,UAAU;wBACjB,SAAS,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;qBACrD,CAAC,CAAC;iBACJ;gBACD,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAmB,EAAE,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AAK,CAAC,IAAA,iBAAY,EAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AApMD,kCAoMC"}
@@ -0,0 +1 @@
1
+ export declare function generateUniqueLinkId(): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateUniqueLinkId = void 0;
4
+ const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
5
+ const digits = '0123456789';
6
+ const lower = upper.toLowerCase();
7
+ const alphanum = upper + lower + digits;
8
+ function generateUniqueLinkId() {
9
+ let res = '';
10
+ for (let i = 0; i < 10; ++i) {
11
+ res += alphanum[Math.floor(Math.random() * alphanum.length)];
12
+ }
13
+ return res;
14
+ }
15
+ exports.generateUniqueLinkId = generateUniqueLinkId;
16
+ //# sourceMappingURL=id-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/id-generator.ts"],"names":[],"mappings":";;;AAAA,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAC3C,MAAM,MAAM,GAAG,YAAY,CAAC;AAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;AAClC,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAExC,SAAgB,oBAAoB;IAClC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;QAC3B,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;KAC9D;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAND,oDAMC"}
@@ -0,0 +1,13 @@
1
+ import { CloudTaskRunnerOptions } from '../../models/cloud-task-runner-options';
2
+ import { TasksApiResponse } from '../../models/distributed-agent/tasks-api-response.model';
3
+ export declare class DistributedAgentApi {
4
+ private readonly runGroup;
5
+ private readonly agentName;
6
+ private apiAxiosInstance;
7
+ constructor(options: CloudTaskRunnerOptions, runGroup: string, agentName: string);
8
+ tasks(executionId: string | null, statusCode: number | null, completedTasks: {
9
+ taskId: string;
10
+ hash: string;
11
+ }[]): Promise<TasksApiResponse>;
12
+ completeRunGroupWithError(error: string): Promise<void>;
13
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DistributedAgentApi = void 0;
13
+ const axios_1 = require("../../../utilities/axios");
14
+ const environment_1 = require("../../../utilities/environment");
15
+ const metric_logger_1 = require("../../../utilities/metric-logger");
16
+ const { output } = require('../../../utilities/nx-imports');
17
+ class DistributedAgentApi {
18
+ constructor(options, runGroup, agentName) {
19
+ this.runGroup = runGroup;
20
+ this.agentName = agentName;
21
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
22
+ }
23
+ tasks(executionId, statusCode, completedTasks) {
24
+ var _a;
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
27
+ try {
28
+ const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
29
+ runGroup: this.runGroup,
30
+ agentName: this.agentName,
31
+ executionId,
32
+ statusCode,
33
+ completedTasks,
34
+ }));
35
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
36
+ return res.data;
37
+ }
38
+ catch (e) {
39
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
40
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
41
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
42
+ throw e;
43
+ }
44
+ });
45
+ }
46
+ completeRunGroupWithError(error) {
47
+ var _a;
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (environment_1.VERBOSE_LOGGING) {
50
+ output.note({
51
+ title: 'Completing run group with an error',
52
+ bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
53
+ });
54
+ }
55
+ const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
56
+ try {
57
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
58
+ runGroup: this.runGroup,
59
+ agentName: this.agentName,
60
+ criticalErrorMessage: error,
61
+ }));
62
+ if (environment_1.VERBOSE_LOGGING) {
63
+ output.note({
64
+ title: 'Completed run group with an error',
65
+ });
66
+ }
67
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
68
+ }
69
+ catch (e) {
70
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
71
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
72
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
73
+ console.error(e);
74
+ }
75
+ });
76
+ }
77
+ }
78
+ exports.DistributedAgentApi = DistributedAgentApi;
79
+ //# sourceMappingURL=distributed-agent.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributed-agent.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-agent/distributed-agent.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAGkC;AAElC,gEAAiE;AACjE,oEAI0C;AAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5D,MAAa,mBAAmB;IAG9B,YACE,OAA+B,EACd,QAAgB,EAChB,SAAiB;QADjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QAElC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,KAAK,CACT,WAA0B,EAC1B,UAAyB,EACzB,cAAkD;;;YAElD,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,cAAc,CAAC,CAAC;YAEtD,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,CACxC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,4BAA4B,EAAE;oBACvD,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,WAAW;oBACX,UAAU;oBACV,cAAc;iBACf,CAAC,CACH,CAAC;gBACF,QAAQ,CAAC,YAAY,CAAC,IAAA,kCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;gBAC/C,OAAO,GAAG,CAAC,IAAI,CAAC;aACjB;YAAC,OAAO,CAAM,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,Q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