@daghis/teamcity-mcp 1.9.2 → 1.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.3](https://github.com/Daghis/teamcity-mcp/compare/v1.9.2...v1.9.3) (2025-09-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **teamcity:** resolve nested artifact downloads ([#188](https://github.com/Daghis/teamcity-mcp/issues/188)) ([e309b90](https://github.com/Daghis/teamcity-mcp/commit/e309b90de42fe121f072fe5b549ab25df3a91aaf))
9
+
3
10
  ## [1.9.2](https://github.com/Daghis/teamcity-mcp/compare/v1.9.1...v1.9.2) (2025-09-21)
4
11
 
5
12
 
package/dist/index.js CHANGED
@@ -1216,26 +1216,72 @@ var ArtifactManager = class _ArtifactManager {
1216
1216
  }
1217
1217
  return payload;
1218
1218
  }
1219
- parseArtifacts(data, buildId, includeNested, baseUrl) {
1219
+ parseArtifacts(data, buildId, includeNested, baseUrl, parentSegments = []) {
1220
1220
  const artifacts = [];
1221
1221
  const files = data.file ?? [];
1222
1222
  for (const file of files) {
1223
- if (file.children && includeNested) {
1224
- const nested = this.parseArtifacts(file.children, buildId, includeNested, baseUrl);
1225
- artifacts.push(...nested);
1226
- } else if (!file.children) {
1227
- artifacts.push({
1228
- name: file.name ?? "",
1229
- path: file.fullName ?? file.name ?? "",
1230
- size: file.size ?? 0,
1231
- modificationTime: file.modificationTime ?? "",
1232
- downloadUrl: `${baseUrl}/app/rest/builds/id:${buildId}/artifacts/content/${file.fullName ?? file.name ?? ""}`,
1233
- isDirectory: false
1234
- });
1235
- }
1223
+ const pathSegments = this.buildArtifactSegments(file, parentSegments);
1224
+ const resolvedPath = pathSegments.join("/");
1225
+ const isDirectory = Boolean(file.children);
1226
+ if (isDirectory) {
1227
+ if (includeNested && file.children) {
1228
+ const nested = this.parseArtifacts(
1229
+ file.children,
1230
+ buildId,
1231
+ includeNested,
1232
+ baseUrl,
1233
+ pathSegments
1234
+ );
1235
+ artifacts.push(...nested);
1236
+ }
1237
+ continue;
1238
+ }
1239
+ if (!resolvedPath) {
1240
+ continue;
1241
+ }
1242
+ artifacts.push({
1243
+ name: file.name ?? pathSegments[pathSegments.length - 1] ?? "",
1244
+ path: resolvedPath,
1245
+ size: file.size ?? 0,
1246
+ modificationTime: file.modificationTime ?? "",
1247
+ downloadUrl: `${baseUrl}/app/rest/builds/id:${buildId}/artifacts/content/${this.encodeArtifactPath(pathSegments)}`,
1248
+ isDirectory: false
1249
+ });
1236
1250
  }
1237
1251
  return artifacts;
1238
1252
  }
1253
+ buildArtifactSegments(file, parentSegments) {
1254
+ const fullName = typeof file.fullName === "string" ? file.fullName : void 0;
1255
+ const name = typeof file.name === "string" ? file.name : void 0;
1256
+ const segmentsFromFullName = fullName ? fullName.split("/").filter((segment) => segment.length > 0) : [];
1257
+ if (segmentsFromFullName.length === 0) {
1258
+ if (name && name.length > 0) {
1259
+ return [...parentSegments, name];
1260
+ }
1261
+ return [...parentSegments];
1262
+ }
1263
+ if (parentSegments.length === 0) {
1264
+ return segmentsFromFullName;
1265
+ }
1266
+ if (this.segmentsStartWithParent(segmentsFromFullName, parentSegments)) {
1267
+ return segmentsFromFullName;
1268
+ }
1269
+ return [...parentSegments, ...segmentsFromFullName];
1270
+ }
1271
+ segmentsStartWithParent(segments, parent) {
1272
+ if (parent.length === 0 || segments.length < parent.length) {
1273
+ return false;
1274
+ }
1275
+ for (let i = 0; i < parent.length; i += 1) {
1276
+ if (segments[i] !== parent[i]) {
1277
+ return false;
1278
+ }
1279
+ }
1280
+ return true;
1281
+ }
1282
+ encodeArtifactPath(segments) {
1283
+ return segments.map((segment) => encodeURIComponent(segment)).join("/");
1284
+ }
1239
1285
  ensureBinaryBuffer(payload) {
1240
1286
  if (Buffer.isBuffer(payload)) {
1241
1287
  return payload;