@kud/gh 0.4.0 → 0.5.0

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/inbox.d.ts CHANGED
@@ -1,9 +1,31 @@
1
+ /**
2
+ * How much of each row to ask for.
3
+ *
4
+ * `full` carries health, conversation and labels — everything `computeHealth`
5
+ * and a conversation line need. `minimal` carries identity only: type, number,
6
+ * title, url, draft, timestamp, repo.
7
+ *
8
+ * This is a cost axis, not a taste one. Measured against GitHub's own
9
+ * `rateLimit { cost }`: the full query costs **111 points** of a 5000/hour
10
+ * budget, at a nodeCount of ~25,550 — because `statusCheckRollup.contexts`
11
+ * appears in five PR fragments and `reviewThreads(first: 50)` multiplies
12
+ * beneath each one. A caller that renders a title and a link was paying for
13
+ * every check run on every open PR. At 111 a poller gets 45 refreshes an hour.
14
+ */
15
+ export type InboxShape = "full" | "minimal";
1
16
  /** A repo-scoped or account-wide inbox. */
2
17
  export type InboxQueryOptions = {
3
18
  /** `owner/name`. Scopes every search to one repository. */
4
19
  repo?: string;
5
20
  /** How far back `recentlyDone` looks. Defaults to 14 days. */
6
21
  doneWithinDays?: number;
22
+ /**
23
+ * Defaults to `full`, so every existing caller keeps what it had. Reach for
24
+ * `minimal` only when nothing downstream reads health, conversation or
25
+ * labels — those fields do not degrade, they vanish, and `computeHealth`
26
+ * falls through to a wrong answer rather than an absent one.
27
+ */
28
+ shape?: InboxShape;
7
29
  };
8
30
  /**
9
31
  * Build the inbox query. Without `repo`, it is account-wide.
@@ -14,5 +36,5 @@ export type InboxQueryOptions = {
14
36
  * render empty and read as "nothing to do here". So `repo:` REPLACES
15
37
  * `user:@me` rather than joining it.
16
38
  */
17
- export declare const buildInboxQuery: ({ repo, doneWithinDays, }?: InboxQueryOptions) => string;
39
+ export declare const buildInboxQuery: ({ repo, doneWithinDays, shape, }?: InboxQueryOptions) => string;
18
40
  //# sourceMappingURL=inbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAQA,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAmDD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,4BAG7B,iBAAsB,WAoFxB,CAAA"}
1
+ {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAE3C,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB,CAAA;AA6DD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,mCAI7B,iBAAsB,WA6FxB,CAAA"}
package/dist/inbox.js CHANGED
@@ -8,10 +8,20 @@
8
8
  // computeHealth's precedence needs reviewDecision, mergeable and the check
9
9
  // rollup. A fragment that omits them does NOT degrade gracefully — it falls
10
10
  // straight through to whatever token is left, so a PR you already sent back
11
- // renders as "awaiting review" and a failing one renders as quiet. Every PR
12
- // fragment therefore carries the whole set; none of it is optional.
11
+ // renders as "awaiting review" and a failing one renders as quiet.
12
+ //
13
+ // So this set is all-or-nothing, which is exactly why `shape` drops it whole
14
+ // rather than field by field: a caller either computes health and needs every
15
+ // one of these, or renders none of it and should pay for none of it. There is
16
+ // no coherent middle, and the `minimal` shape is not a smaller health — it is
17
+ // the absence of health.
18
+ //
19
+ // `isDraft` is deliberately NOT in here. It is identity, not health, and a
20
+ // minimal caller still has to tell a draft from an open PR, so it sits in the
21
+ // base field list beside `number` and `title` where dropping health cannot
22
+ // take it with them.
13
23
  const PR_HEALTH = `
14
- isDraft reviewDecision mergeable
24
+ reviewDecision mergeable
15
25
  statusCheckRollup { contexts(first: 20) { nodes {
16
26
  ... on CheckRun { name conclusion status }
17
27
  ... on StatusContext { context state }
@@ -57,37 +67,45 @@ const sinceDay = (days) => new Date(Date.now() - days * 86400 * 1000).toISOStrin
57
67
  * render empty and read as "nothing to do here". So `repo:` REPLACES
58
68
  * `user:@me` rather than joining it.
59
69
  */
60
- export const buildInboxQuery = ({ repo, doneWithinDays = 14, } = {}) => {
70
+ export const buildInboxQuery = ({ repo, doneWithinDays = 14, shape = "full", } = {}) => {
61
71
  const scope = repo ? `repo:${repo} ` : "";
62
72
  const owned = repo ? "" : "user:@me ";
63
73
  const doneSince = sinceDay(doneWithinDays);
74
+ /* Interpolated as empty strings rather than branching the query text, so the
75
+ two shapes cannot drift into two separately-maintained queries. */
76
+ const full = shape === "full";
77
+ const health = full ? PR_HEALTH : "";
78
+ const conversation = full ? PR_CONVERSATION : "";
79
+ const issueConversation = full ? ISSUE_CONVERSATION : "";
80
+ const issueLabels = full ? ISSUE_LABELS : "";
64
81
  return `
65
82
  {
66
83
  viewer { login }
67
84
  myPRs: search(query: "${scope}is:pr is:open author:@me", type: ISSUE, first: 100) {
68
85
  nodes { __typename ... on PullRequest {
69
- number title createdAt url headRefName
86
+ number title createdAt url headRefName isDraft
70
87
  repository { nameWithOwner }
71
- ${PR_HEALTH}
72
- ${PR_CONVERSATION}
88
+ author { login }
89
+ ${health}
90
+ ${conversation}
73
91
  }}
74
92
  }
75
93
  reviewRequests: search(query: "${scope}is:pr is:open review-requested:@me", type: ISSUE, first: 20) {
76
94
  nodes { __typename ... on PullRequest {
77
- number title createdAt url headRefName
95
+ number title createdAt url headRefName isDraft
78
96
  repository { nameWithOwner }
79
97
  author { login }
80
- ${PR_HEALTH}
81
- ${PR_CONVERSATION}
98
+ ${health}
99
+ ${conversation}
82
100
  }}
83
101
  }
84
102
  reviewed: search(query: "${scope}is:pr is:open reviewed-by:@me -author:@me -review-requested:@me", type: ISSUE, first: 20) {
85
103
  nodes { __typename ... on PullRequest {
86
- number title createdAt url headRefName
104
+ number title createdAt url headRefName isDraft
87
105
  repository { nameWithOwner }
88
106
  author { login }
89
- ${PR_HEALTH}
90
- ${PR_CONVERSATION}
107
+ ${health}
108
+ ${conversation}
91
109
  }}
92
110
  }
93
111
  assigned: search(query: "${scope}is:open assignee:@me", type: ISSUE, first: 30) {
@@ -95,13 +113,13 @@ export const buildInboxQuery = ({ repo, doneWithinDays = 14, } = {}) => {
95
113
  __typename
96
114
  ... on Issue {
97
115
  number title createdAt url repository { nameWithOwner } author { login }
98
- ${ISSUE_CONVERSATION}
99
- ${ISSUE_LABELS}
116
+ ${issueConversation}
117
+ ${issueLabels}
100
118
  }
101
119
  ... on PullRequest {
102
- number title createdAt url headRefName repository { nameWithOwner } author { login }
103
- ${PR_HEALTH}
104
- ${PR_CONVERSATION}
120
+ number title createdAt url headRefName isDraft repository { nameWithOwner } author { login }
121
+ ${health}
122
+ ${conversation}
105
123
  }
106
124
  }
107
125
  }
@@ -110,8 +128,8 @@ export const buildInboxQuery = ({ repo, doneWithinDays = 14, } = {}) => {
110
128
  number title createdAt url
111
129
  repository { nameWithOwner }
112
130
  author { login }
113
- ${ISSUE_CONVERSATION}
114
- ${ISSUE_LABELS}
131
+ ${issueConversation}
132
+ ${issueLabels}
115
133
  }}
116
134
  }
117
135
  authoredIssues: search(query: "${scope}is:issue is:open author:@me archived:false", type: ISSUE, first: 30) {
@@ -119,17 +137,17 @@ export const buildInboxQuery = ({ repo, doneWithinDays = 14, } = {}) => {
119
137
  number title createdAt url
120
138
  repository { nameWithOwner }
121
139
  author { login }
122
- ${ISSUE_CONVERSATION}
123
- ${ISSUE_LABELS}
140
+ ${issueConversation}
141
+ ${issueLabels}
124
142
  }}
125
143
  }
126
144
  repoPRs: search(query: "${scope}${owned}is:pr is:open -author:@me archived:false", type: ISSUE, first: 30) {
127
145
  nodes { __typename ... on PullRequest {
128
- number title createdAt url headRefName
146
+ number title createdAt url headRefName isDraft
129
147
  repository { nameWithOwner }
130
148
  author { login }
131
- ${PR_HEALTH}
132
- ${PR_CONVERSATION}
149
+ ${health}
150
+ ${conversation}
133
151
  }}
134
152
  }
135
153
  recentlyDone: search(query: "${scope}is:pr author:@me -is:open closed:>=${doneSince}", type: ISSUE, first: 30) {
package/dist/inbox.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"inbox.js","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,qCAAqC;AACrC,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,uDAAuD;AAUvD,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,oEAAoE;AACpE,MAAM,SAAS,GAAG;;;;;YAKN,CAAA;AAEZ,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,+DAA+D;AAC/D,MAAM,eAAe,GAAG;;;;;;;8DAOsC,CAAA;AAE9D,MAAM,kBAAkB,GAAG;uFAC4D,CAAA;AAEvF,+EAA+E;AAC/E,qEAAqE;AACrE,MAAM,YAAY,GAAG;2CACsB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,IAAI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C,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IAE5C,OAAO;;;0BAGiB,KAAK;;;;;QAKvB,MAAM;QACN,YAAY;;;mCAGe,KAAK;;;;;QAKhC,MAAM;QACN,YAAY;;;6BAGS,KAAK;;;;;QAK1B,MAAM;QACN,YAAY;;;6BAGS,KAAK;;;;;UAKxB,iBAAiB;UACjB,WAAW;;;;UAIX,MAAM;UACN,YAAY;;;;+BAIS,KAAK,GAAG,KAAK;;;;;QAKpC,iBAAiB;QACjB,WAAW;;;mCAGgB,KAAK;;;;;QAKhC,iBAAiB;QACjB,WAAW;;;4BAGS,KAAK,GAAG,KAAK;;;;;QAKjC,MAAM;QACN,YAAY;;;iCAGa,KAAK,sCAAsC,SAAS;;;;;;;CAOpF,CAAA;AACD,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/gh",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Surface-agnostic GitHub core — gh CLI primitives, PR review comments, health, and webhook logic.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",