@osdlc/typed-gh 0.13.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @osdlc/typed-gh
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c58f58b: `pickPrForBranch` takes the `ListResult` that `openPrsForBranch` and `prList` return, as well as plain rows, so `pickPrForBranch(verb.parse(result), branch)` works without a `.rows` unwrap. It also accepts a readonly array.
8
+
3
9
  ## 0.13.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -605,8 +605,9 @@ Each verb takes an optional `GhTarget` last. Each client method has a verb of th
605
605
  `createReview`, `issueList`, `issueView`, `labelList`, `setIssueLabel`, `createLabel`,
606
606
  `editLabel`, `issueCommentEdit`, `repoList`, `repoView`, `searchPrs`, `api`, `graphql`,
607
607
  `installed` and `authStatus`.
608
- - `pickPrForBranch`: the first row whose head branch is exactly the one you name, for rows that
609
- came from somewhere other than `prList({ head })`, such as a `head:` search.
608
+ - `pickPrForBranch`: the first row whose head branch is exactly the one you name. `prList({ head })`
609
+ already filters exactly. This is for rows from elsewhere, such as a `head:` search. It takes plain
610
+ rows or a `ListResult`, so `openPrsForBranch`'s or `prList`'s parsed answer passes straight in.
610
611
  - `nodesAt`: one connection's nodes, joined across `graphql` pages.
611
612
  - Field lists: `PR_REF_FIELDS` (enough to identify a PR), `PR_LIST_FIELDS` (for triage),
612
613
  `PR_VIEW_FIELDS` (the full set), `REPO_FIELDS` and `SEARCH_PR_FIELDS`.
package/dist/async.js CHANGED
@@ -133,7 +133,7 @@ export class AsyncGh {
133
133
  timeoutMs: opts.timeoutMs,
134
134
  signal: opts.signal,
135
135
  });
136
- return v.pickPrForBranch(rows.rows, branch);
136
+ return v.pickPrForBranch(rows, branch);
137
137
  }
138
138
  /** {@link prView}, asked again until GitHub has computed the merge state. See `Gh.prViewSettled`. */
139
139
  async prViewSettled(number, opts = {}) {
package/dist/sync.js CHANGED
@@ -187,7 +187,7 @@ export class Gh {
187
187
  fields: opts.fields ?? v.PR_REF_FIELDS,
188
188
  timeoutMs: opts.timeoutMs,
189
189
  });
190
- return v.pickPrForBranch(rows.rows, branch);
190
+ return v.pickPrForBranch(rows, branch);
191
191
  }
192
192
  /**
193
193
  * {@link prView}, asked again until GitHub has computed the merge state.
package/dist/verbs.d.ts CHANGED
@@ -487,11 +487,15 @@ export declare function createReview(number: number, opts: CreateReviewOptions,
487
487
  /**
488
488
  * The first row whose `headRefName` exactly equals `branch`, or null.
489
489
  *
490
- * `prList({ head })` already filters exactly. This is for rows from anywhere
491
- * else, such as a `search` query with gh's `head:` qualifier, which matches
492
- * `task/foo-2` for `task/foo`.
490
+ * Takes the rows, or the `ListResult` that {@link openPrsForBranch} and
491
+ * `prList` return, so their parsed answer passes straight in. Null (a failed
492
+ * call) stays null.
493
+ *
494
+ * `prList({ head })` already filters exactly. The filter here is for rows
495
+ * from anywhere else, such as a `search` query with gh's `head:` qualifier,
496
+ * which matches `task/foo-2` for `task/foo`.
493
497
  */
494
- export declare function pickPrForBranch(rows: PullRequest[] | null, branch: string): PullRequest | null;
498
+ export declare function pickPrForBranch(rows: readonly PullRequest[] | ListResult<PullRequest> | null, branch: string): PullRequest | null;
495
499
  /**
496
500
  * The PR a branch names, from `prList({ head, state: 'all' })` rows: the open
497
501
  * one, or else the first row (gh lists newest first). Null when there are no
package/dist/verbs.js CHANGED
@@ -1078,14 +1078,19 @@ export function createReview(number, opts, target) {
1078
1078
  /**
1079
1079
  * The first row whose `headRefName` exactly equals `branch`, or null.
1080
1080
  *
1081
- * `prList({ head })` already filters exactly. This is for rows from anywhere
1082
- * else, such as a `search` query with gh's `head:` qualifier, which matches
1083
- * `task/foo-2` for `task/foo`.
1081
+ * Takes the rows, or the `ListResult` that {@link openPrsForBranch} and
1082
+ * `prList` return, so their parsed answer passes straight in. Null (a failed
1083
+ * call) stays null.
1084
+ *
1085
+ * `prList({ head })` already filters exactly. The filter here is for rows
1086
+ * from anywhere else, such as a `search` query with gh's `head:` qualifier,
1087
+ * which matches `task/foo-2` for `task/foo`.
1084
1088
  */
1085
1089
  export function pickPrForBranch(rows, branch) {
1086
1090
  if (rows === null)
1087
1091
  return null;
1088
- return rows.find((r) => r.headRefName === branch) ?? null;
1092
+ const list = 'rows' in rows ? rows.rows : rows;
1093
+ return list.find((r) => r.headRefName === branch) ?? null;
1089
1094
  }
1090
1095
  /**
1091
1096
  * The PR a branch names, from `prList({ head, state: 'all' })` rows: the open
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdlc/typed-gh",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "A typed GitHub client for TypeScript over the gh CLI. A total PullRequest/Review/CheckRun model, pure argv builders and parsers, and a tri-modal client — queries return parsed values, mutations throw, raw() is the escape hatch. Uses gh's own credentials; reads no token.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "sksizer",
@@ -58,8 +58,8 @@
58
58
  "prettier": "3.9.6",
59
59
  "typescript": "~6.0.3",
60
60
  "vitest": "^5.0.5",
61
- "@osdlc/prettier-config": "^0.3.1",
62
- "@osdlc/tsconfig": "^0.4.1"
61
+ "@osdlc/tsconfig": "^0.4.1",
62
+ "@osdlc/prettier-config": "^0.3.1"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsc -p tsconfig.build.json",