@postman-cs/onboarding-repo-sync 2.10.4 → 2.10.5

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 (2) hide show
  1. package/dist/cli.cjs +44 -11
  2. package/package.json +2 -2
package/dist/cli.cjs CHANGED
@@ -130389,8 +130389,28 @@ function markerFromSpecContent(content) {
130389
130389
  function isGcCandidateName(name) {
130390
130390
  return / @[A-Za-z0-9._-]+/.test(name) || /^\[[A-Z][A-Z0-9]*\] /.test(name);
130391
130391
  }
130392
+ function exactCollectionName(payload) {
130393
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) return "";
130394
+ const record = payload;
130395
+ const info = record.info && typeof record.info === "object" && !Array.isArray(record.info) ? record.info : void 0;
130396
+ return String(record.name ?? info?.name ?? "").trim();
130397
+ }
130392
130398
  async function collectGcCandidates(postman, workspaceId) {
130393
130399
  const candidates = [];
130400
+ const exactCollectionNames = /* @__PURE__ */ new Map();
130401
+ const readGeneratedCollectionName = async (uid) => {
130402
+ if (exactCollectionNames.has(uid)) return exactCollectionNames.get(uid);
130403
+ let name;
130404
+ try {
130405
+ const candidate = exactCollectionName(await postman.getCollection(uid));
130406
+ name = candidate && isGcCandidateName(candidate) ? candidate : void 0;
130407
+ } catch {
130408
+ name = void 0;
130409
+ }
130410
+ exactCollectionNames.set(uid, name);
130411
+ return name;
130412
+ };
130413
+ const discoveredCollectionUids = /* @__PURE__ */ new Set();
130394
130414
  const environments = await postman.listEnvironments(workspaceId);
130395
130415
  for (const env of environments) {
130396
130416
  if (!isGcCandidateName(env.name)) continue;
@@ -130428,14 +130448,10 @@ async function collectGcCandidates(postman, workspaceId) {
130428
130448
  if (marker && monitor.collectionUid) ownedCollections.set(monitor.collectionUid, { marker });
130429
130449
  }
130430
130450
  for (const [uid, collection] of ownedCollections) {
130431
- try {
130432
- const payload = await postman.getCollection(uid);
130433
- const info = payload?.info && typeof payload.info === "object" ? payload.info : void 0;
130434
- const name = String(payload?.name ?? info?.name ?? "").trim();
130435
- if (name && isGcCandidateName(name)) {
130436
- candidates.push({ kind: "collection", uid, name, marker: collection.marker });
130437
- }
130438
- } catch {
130451
+ const name = await readGeneratedCollectionName(uid);
130452
+ if (name) {
130453
+ candidates.push({ kind: "collection", uid, name, marker: collection.marker });
130454
+ discoveredCollectionUids.add(uid);
130439
130455
  }
130440
130456
  }
130441
130457
  const specifications = await postman.listSpecifications(workspaceId);
@@ -130447,16 +130463,33 @@ async function collectGcCandidates(postman, workspaceId) {
130447
130463
  } catch {
130448
130464
  marker = void 0;
130449
130465
  }
130450
- candidates.push({ kind: "spec", uid: spec.uid, name: spec.name, marker });
130451
130466
  if (marker) {
130467
+ const linkedCandidates = [];
130468
+ let relationsResolved = true;
130452
130469
  try {
130453
130470
  for (const collection of await postman.listSpecCollections(spec.uid)) {
130454
- if (!ownedCollections.has(collection.uid) && isGcCandidateName(collection.name)) {
130455
- candidates.push({ kind: "collection", uid: collection.uid, name: collection.name || `${spec.name} collection`, marker });
130471
+ if (discoveredCollectionUids.has(collection.uid)) continue;
130472
+ const name = await readGeneratedCollectionName(collection.uid);
130473
+ if (!name) {
130474
+ relationsResolved = false;
130475
+ continue;
130456
130476
  }
130477
+ linkedCandidates.push({ kind: "collection", uid: collection.uid, name, marker });
130457
130478
  }
130458
130479
  } catch {
130480
+ relationsResolved = false;
130459
130481
  }
130482
+ if (!relationsResolved) {
130483
+ continue;
130484
+ }
130485
+ candidates.push({ kind: "spec", uid: spec.uid, name: spec.name, marker });
130486
+ for (const collection of linkedCandidates) {
130487
+ if (discoveredCollectionUids.has(collection.uid)) continue;
130488
+ candidates.push(collection);
130489
+ discoveredCollectionUids.add(collection.uid);
130490
+ }
130491
+ } else {
130492
+ candidates.push({ kind: "spec", uid: spec.uid, name: spec.name, marker });
130460
130493
  }
130461
130494
  }
130462
130495
  return candidates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cs/onboarding-repo-sync",
3
- "version": "2.10.4",
3
+ "version": "2.10.5",
4
4
  "description": "Postman repo sync GitHub Action.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -27,7 +27,7 @@
27
27
  "docs:tables": "node scripts/render-action-tables.mjs",
28
28
  "lint": "eslint .",
29
29
  "lint:fix": "eslint . --fix",
30
- "test": "vitest run --exclude tests/ci-workflow-template.test.ts && vitest run tests/ci-workflow-template.test.ts && node --test .github/scripts/dispatch-e2e-monitor.test.mjs .github/scripts/prefetch-vendored-deps.test.mjs",
30
+ "test": "vitest run --exclude tests/ci-workflow-template.test.ts && vitest run tests/ci-workflow-template.test.ts && node --test .github/scripts/dispatch-e2e-monitor.test.mjs .github/scripts/prefetch-vendored-deps.test.mjs .github/scripts/verify-e2e-release.test.mjs",
31
31
  "test:emulator:git": "vitest run --config vitest.emulator.config.ts",
32
32
  "typecheck": "tsc --noEmit -p tsconfig.json",
33
33
  "record:cassettes": "RECORD_FAKE_CASSETTES=1 vitest run tests/contract/record-fake-cassettes.test.ts"