pipe-kan 0.23.2 → 0.23.4

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/pipe-kan.js +70 -7
  2. package/package.json +1 -1
package/dist/pipe-kan.js CHANGED
@@ -601,13 +601,76 @@ function createJiraCli(opts = {}) {
601
601
  console.log("Refresh children skipped; no valid parent keys");
602
602
  return "[]";
603
603
  }
604
- const list = validKeys.map((key) => `"${key}"`).join(", ");
605
- return listAll([
606
- "issue",
607
- "list",
608
- "-q",
609
- `(parent in (${list}) OR "Epic Link" in (${list}))`
610
- ]);
604
+ const issues = [];
605
+ const seen = new Set;
606
+ let anyFailed = false;
607
+ let lockedMode;
608
+ function buildJql(chunkKeys, mode) {
609
+ const list = chunkKeys.map((key) => `"${key}"`).join(", ");
610
+ if (mode === "epic")
611
+ return `"Epic Link" in (${list})`;
612
+ if (mode === "parent")
613
+ return `parent in (${list})`;
614
+ return `(parent in (${list}) OR "Epic Link" in (${list}))`;
615
+ }
616
+ function chunkSizeFor(mode) {
617
+ return mode === "or" ? 50 : 100;
618
+ }
619
+ async function fetchChunk(chunk, chunkIndex, preferredMode) {
620
+ const modes = preferredMode ? [preferredMode, "or", "epic", "parent"].filter((m, i, arr) => arr.indexOf(m) === i) : ["or", "epic", "parent"];
621
+ let lastError;
622
+ for (const mode of modes) {
623
+ const size = chunkSizeFor(mode);
624
+ if (chunk.length > size)
625
+ continue;
626
+ try {
627
+ const chunkIssues = JSON.parse(await listAll([
628
+ "issue",
629
+ "list",
630
+ "-q",
631
+ buildJql(chunk, mode)
632
+ ]));
633
+ return { issues: chunkIssues, used: mode };
634
+ } catch (err) {
635
+ lastError = err instanceof Error ? err.message : String(err);
636
+ }
637
+ }
638
+ console.log(`Refresh children chunk ${chunkIndex + 1} failed; ${lastError ?? "unknown error"}`);
639
+ return { issues: [], error: lastError };
640
+ }
641
+ const concurrency = 5;
642
+ const chunks = [];
643
+ let cursor = 0;
644
+ for (let i = 0;i < validKeys.length; i += chunkSizeFor(lockedMode ?? "or")) {
645
+ const size = chunkSizeFor(lockedMode ?? "or");
646
+ const chunk = validKeys.slice(i, i + size);
647
+ chunks.push({ chunk, index: cursor++ });
648
+ }
649
+ async function processChunk({ chunk, index }) {
650
+ const preferred = lockedMode;
651
+ const result = await fetchChunk(chunk, index, preferred);
652
+ if (result.used && !lockedMode) {
653
+ lockedMode = result.used;
654
+ }
655
+ if (result.error) {
656
+ anyFailed = true;
657
+ return;
658
+ }
659
+ for (const issue of result.issues) {
660
+ const key = issueKey(issue);
661
+ if (key && !seen.has(key)) {
662
+ seen.add(key);
663
+ issues.push(issue);
664
+ }
665
+ }
666
+ }
667
+ for (let i = 0;i < chunks.length; i += concurrency) {
668
+ await Promise.all(chunks.slice(i, i + concurrency).map(processChunk));
669
+ }
670
+ if (anyFailed && issues.length === 0) {
671
+ throw new Error("Epic children fetch failed for all batches");
672
+ }
673
+ return JSON.stringify(issues);
611
674
  },
612
675
  async move(key, status) {
613
676
  const result = await runRetry(["issue", "move", key, status]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pipe-kan",
3
- "version": "0.23.2",
3
+ "version": "0.23.4",
4
4
  "description": "Local Kanban for jira-cli",
5
5
  "license": "MIT",
6
6
  "type": "module",