paperclip-github-plugin 0.16.0 → 0.16.1

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/dist/worker.js CHANGED
@@ -1586,11 +1586,29 @@ var GITHUB_PULL_REQUEST_CI_CONTEXTS_QUERY = `
1586
1586
  nodes {
1587
1587
  __typename
1588
1588
  ... on CheckRun {
1589
+ name
1589
1590
  status
1590
1591
  conclusion
1592
+ startedAt
1593
+ completedAt
1594
+ checkSuite {
1595
+ createdAt
1596
+ app {
1597
+ id
1598
+ slug
1599
+ }
1600
+ workflowRun {
1601
+ workflow {
1602
+ id
1603
+ }
1604
+ }
1605
+ }
1591
1606
  }
1592
1607
  ... on StatusContext {
1608
+ context
1593
1609
  state
1610
+ createdAt
1611
+ updatedAt
1594
1612
  }
1595
1613
  }
1596
1614
  }
@@ -1662,11 +1680,29 @@ var GITHUB_REPOSITORY_OPEN_PULL_REQUEST_STATUSES_QUERY = `
1662
1680
  nodes {
1663
1681
  __typename
1664
1682
  ... on CheckRun {
1683
+ name
1665
1684
  status
1666
1685
  conclusion
1686
+ startedAt
1687
+ completedAt
1688
+ checkSuite {
1689
+ createdAt
1690
+ app {
1691
+ id
1692
+ slug
1693
+ }
1694
+ workflowRun {
1695
+ workflow {
1696
+ id
1697
+ }
1698
+ }
1699
+ }
1667
1700
  }
1668
1701
  ... on StatusContext {
1702
+ context
1669
1703
  state
1704
+ createdAt
1705
+ updatedAt
1670
1706
  }
1671
1707
  }
1672
1708
  }
@@ -1756,11 +1792,29 @@ var GITHUB_PROJECT_PULL_REQUEST_INSIGHT_FIELDS = `
1756
1792
  nodes {
1757
1793
  __typename
1758
1794
  ... on CheckRun {
1795
+ name
1759
1796
  status
1760
1797
  conclusion
1798
+ startedAt
1799
+ completedAt
1800
+ checkSuite {
1801
+ createdAt
1802
+ app {
1803
+ id
1804
+ slug
1805
+ }
1806
+ workflowRun {
1807
+ workflow {
1808
+ id
1809
+ }
1810
+ }
1811
+ }
1761
1812
  }
1762
1813
  ... on StatusContext {
1814
+ context
1763
1815
  state
1816
+ createdAt
1817
+ updatedAt
1764
1818
  }
1765
1819
  }
1766
1820
  }
@@ -1810,11 +1864,29 @@ var GITHUB_PROJECT_PULL_REQUEST_METRICS_FIELDS = `
1810
1864
  nodes {
1811
1865
  __typename
1812
1866
  ... on CheckRun {
1867
+ name
1813
1868
  status
1814
1869
  conclusion
1870
+ startedAt
1871
+ completedAt
1872
+ checkSuite {
1873
+ createdAt
1874
+ app {
1875
+ id
1876
+ slug
1877
+ }
1878
+ workflowRun {
1879
+ workflow {
1880
+ id
1881
+ }
1882
+ }
1883
+ }
1815
1884
  }
1816
1885
  ... on StatusContext {
1886
+ context
1817
1887
  state
1888
+ createdAt
1889
+ updatedAt
1818
1890
  }
1819
1891
  }
1820
1892
  }
@@ -5968,12 +6040,45 @@ function sliceProjectPullRequestNumbers(pullRequestNumbers, pageIndex, pageSize
5968
6040
  hasPreviousPage: normalizedPageIndex > 0
5969
6041
  };
5970
6042
  }
6043
+ function getGitHubCiContextAttemptTimestamp(context) {
6044
+ const value = context.type === "checkRun" ? context.startedAt ?? context.createdAt : context.updatedAt ?? context.createdAt;
6045
+ if (!value) {
6046
+ return void 0;
6047
+ }
6048
+ const timestamp = Date.parse(value);
6049
+ return Number.isFinite(timestamp) ? timestamp : void 0;
6050
+ }
6051
+ function getEffectiveGitHubCiContexts(contexts) {
6052
+ const ungroupedContexts = [];
6053
+ const latestContexts = /* @__PURE__ */ new Map();
6054
+ for (const context of contexts) {
6055
+ const timestamp = getGitHubCiContextAttemptTimestamp(context);
6056
+ if (!context.identity || timestamp === void 0) {
6057
+ ungroupedContexts.push(context);
6058
+ continue;
6059
+ }
6060
+ const existing = latestContexts.get(context.identity);
6061
+ if (!existing) {
6062
+ latestContexts.set(context.identity, { contexts: [context], timestamp });
6063
+ continue;
6064
+ }
6065
+ if (timestamp > existing.timestamp) {
6066
+ latestContexts.set(context.identity, { contexts: [context], timestamp });
6067
+ continue;
6068
+ }
6069
+ if (timestamp === existing.timestamp) {
6070
+ existing.contexts.push(context);
6071
+ }
6072
+ }
6073
+ return [...ungroupedContexts, ...[...latestContexts.values()].flatMap(({ contexts: latest }) => latest)];
6074
+ }
5971
6075
  function classifyGitHubPullRequestCiState(contexts) {
5972
- if (contexts.length === 0) {
6076
+ const effectiveContexts = getEffectiveGitHubCiContexts(contexts);
6077
+ if (effectiveContexts.length === 0) {
5973
6078
  return "unfinished";
5974
6079
  }
5975
6080
  let hasPendingContext = false;
5976
- for (const context of contexts) {
6081
+ for (const context of effectiveContexts) {
5977
6082
  if (context.type === "statusContext") {
5978
6083
  const state = context.state?.toUpperCase();
5979
6084
  if (!state) {
@@ -6855,17 +6960,32 @@ function extractGitHubCiContextRecords(nodes) {
6855
6960
  continue;
6856
6961
  }
6857
6962
  if (node.__typename === "CheckRun") {
6963
+ const app = node.checkSuite?.app;
6964
+ const appId = typeof app?.id === "string" && app.id.trim() ? app.id.trim() : void 0;
6965
+ const appSlug = typeof app?.slug === "string" && app.slug.trim() ? app.slug.trim() : void 0;
6966
+ const producerIdentity = appId ? `app:${appId}` : appSlug ? `appSlug:${appSlug}` : void 0;
6967
+ const workflowId = node.checkSuite?.workflowRun?.workflow?.id?.trim();
6858
6968
  contexts.push({
6859
6969
  type: "checkRun",
6970
+ // A rendered check name is stable only within its producer and workflow.
6971
+ // If GitHub omits workflow provenance, retain the context instead of
6972
+ // accidentally hiding a distinct required check with the same name.
6973
+ ...typeof node.name === "string" && node.name.trim() && producerIdentity && workflowId ? { identity: `checkRun:${producerIdentity}:${workflowId}:${node.name.trim()}` } : {},
6860
6974
  status: node.status ?? void 0,
6861
- conclusion: node.conclusion ?? void 0
6975
+ conclusion: node.conclusion ?? void 0,
6976
+ startedAt: node.startedAt ?? void 0,
6977
+ completedAt: node.completedAt ?? void 0,
6978
+ createdAt: node.checkSuite?.createdAt ?? void 0
6862
6979
  });
6863
6980
  continue;
6864
6981
  }
6865
6982
  if (node.__typename === "StatusContext") {
6866
6983
  contexts.push({
6867
6984
  type: "statusContext",
6868
- state: node.state ?? void 0
6985
+ ...typeof node.context === "string" && node.context.trim() ? { identity: `statusContext:${node.context.trim()}` } : {},
6986
+ state: node.state ?? void 0,
6987
+ createdAt: node.createdAt ?? void 0,
6988
+ updatedAt: node.updatedAt ?? void 0
6869
6989
  });
6870
6990
  }
6871
6991
  }
@@ -7057,26 +7177,7 @@ async function getGitHubPullRequestCiSnapshot(octokit, repository, pullRequestNu
7057
7177
  headSha = responseHeadSha.trim().toLowerCase();
7058
7178
  }
7059
7179
  const connection = response.repository?.pullRequest?.statusCheckRollup?.contexts;
7060
- const nodes = connection?.nodes ?? [];
7061
- for (const node of nodes) {
7062
- if (!node?.__typename) {
7063
- continue;
7064
- }
7065
- if (node.__typename === "CheckRun") {
7066
- contexts.push({
7067
- type: "checkRun",
7068
- status: node.status ?? void 0,
7069
- conclusion: node.conclusion ?? void 0
7070
- });
7071
- continue;
7072
- }
7073
- if (node.__typename === "StatusContext") {
7074
- contexts.push({
7075
- type: "statusContext",
7076
- state: node.state ?? void 0
7077
- });
7078
- }
7079
- }
7180
+ contexts.push(...extractGitHubCiContextRecords(connection?.nodes ?? []));
7080
7181
  after = getPageCursor(connection?.pageInfo);
7081
7182
  } while (after);
7082
7183
  return {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
- "packageManager": "pnpm@11.9.0",
7
+ "packageManager": "pnpm@11.11.0",
8
8
  "engines": {
9
9
  "node": ">=20"
10
10
  },
@@ -49,11 +49,11 @@
49
49
  "remark-gfm": "^4.0.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/node": "24.13.2",
52
+ "@types/node": "24.13.3",
53
53
  "@types/react": "19.2.17",
54
54
  "esbuild": "0.28.1",
55
55
  "playwright": "1.61.1",
56
- "tsx": "4.22.4",
56
+ "tsx": "4.23.1",
57
57
  "typescript": "6.0.3"
58
58
  }
59
59
  }