spur-board 0.104.2 → 0.104.3

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/daemon.mjs +225 -218
  2. package/package.json +1 -1
package/dist/daemon.mjs CHANGED
@@ -15262,7 +15262,7 @@ const uncounted = (reason) => reason === "ticket_reopened" || reason === "mode_c
15262
15262
  const indexOf$1 = (column) => COLUMN_IDS.indexOf(column);
15263
15263
  const isColumn = (text) => COLUMN_IDS.includes(text);
15264
15264
  /** A left move as a return with its causes, or null when it is no counted return. */
15265
- function counted$1(move, blocked) {
15265
+ function counted$2(move, blocked) {
15266
15266
  if (indexOf$1(move.to) >= indexOf$1(move.from) || uncounted(move.reason)) return null;
15267
15267
  const [first, ...rest] = returnCauses(move.gate ?? [], blocked);
15268
15268
  return first === void 0 ? null : {
@@ -15304,7 +15304,7 @@ async function returnCounts(trx, taskId, column) {
15304
15304
  continue;
15305
15305
  }
15306
15306
  const moved = eventPayloadSchemas.task_moved.safeParse(JSON.parse(row.payload));
15307
- const event = moved.success ? counted$1(moved.data, moved.data.block !== void 0) : null;
15307
+ const event = moved.success ? counted$2(moved.data, moved.data.block !== void 0) : null;
15308
15308
  if (event === null) continue;
15309
15309
  events.cycle.push(event);
15310
15310
  events.course.push(event);
@@ -15421,13 +15421,13 @@ async function openFindings(trx, taskId) {
15421
15421
  */
15422
15422
  async function shadowCourseCheck(trx, taskId, move, project) {
15423
15423
  const every = project.columns.find((column) => column.id === move.from)?.courseCheck ?? 0;
15424
- const current = counted$1(move, false);
15424
+ const current = counted$2(move, false);
15425
15425
  if (every <= 0 || current === null) return false;
15426
15426
  const rows = await trx.selectFrom("event").select("payload").where("task_id", "=", taskId).where("kind", "=", "task_shadow_moved").orderBy("id").execute();
15427
15427
  const past = [];
15428
15428
  for (const row of rows) {
15429
15429
  const moved = eventPayloadSchemas.task_shadow_moved.safeParse(JSON.parse(row.payload));
15430
- const event = moved.success ? counted$1(moved.data, false) : null;
15430
+ const event = moved.success ? counted$2(moved.data, false) : null;
15431
15431
  if (event !== null) past.push(event);
15432
15432
  }
15433
15433
  const before = countCycles(past, move.from, every).count;
@@ -20839,7 +20839,7 @@ const CLOSING_FIELDS = "nodes { number repository { nameWithOwner } } pageInfo {
20839
20839
  const prFields = (number, closing = false) => `id number url title updatedAt mergedAt closedAt state isDraft mergeable mergeStateStatus
20840
20840
  author { login } headRefName headRefOid
20841
20841
  statusCheckRollup { contexts(first: 100) { nodes {
20842
- ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: ${String(number)}) }
20842
+ ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt workflowRun { workflow { id } } app { id } } isRequired(pullRequestNumber: ${String(number)}) }
20843
20843
  ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: ${String(number)}) }
20844
20844
  } pageInfo { hasNextPage endCursor } } }
20845
20845
  reviews(first: 100) { nodes { ${REVIEW_FIELDS} } pageInfo { hasNextPage endCursor } }
@@ -20868,7 +20868,7 @@ function detailQuery(numbers, closing = false) {
20868
20868
  function pageQuery(connection, bootstrap = false) {
20869
20869
  if (connection === "comments") return `query PrPage($owner: String!, $repo: String!, $number: Int!, $before: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { comments(last: 100, before: $before) { ${COMMENT_FIELDS} } } } }`;
20870
20870
  if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
20871
- return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "closingIssuesReferences" ? `closingIssuesReferences(first: 100, after: $after) { ${CLOSING_FIELDS} }` : connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? REVIEW_FIELDS : connection === "reviewThreads" ? THREAD_FIELDS : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
20871
+ return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "closingIssuesReferences" ? `closingIssuesReferences(first: 100, after: $after) { ${CLOSING_FIELDS} }` : connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt workflowRun { workflow { id } } app { id } } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? REVIEW_FIELDS : connection === "reviewThreads" ? THREAD_FIELDS : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
20872
20872
  }
20873
20873
  /**
20874
20874
  * The failure that GraphQL `errors` mean for the whole request, in rule order: a rate limit is
@@ -20957,6 +20957,217 @@ var GithubClient = class {
20957
20957
  };
20958
20958
  }
20959
20959
  };
20960
+ // ../adapters/src/github/checks.ts
20961
+ const checkRunWire = z.object({
20962
+ __typename: z.literal("CheckRun"),
20963
+ name: z.string(),
20964
+ status: z.string(),
20965
+ conclusion: z.string().nullable(),
20966
+ startedAt: z.string().nullish(),
20967
+ completedAt: z.string().nullable(),
20968
+ checkSuite: z.object({
20969
+ createdAt: z.string(),
20970
+ workflowRun: z.object({ workflow: z.object({ id: z.string().min(1) }) }).nullish(),
20971
+ app: z.object({ id: z.string().min(1) }).nullish()
20972
+ }).nullish(),
20973
+ isRequired: z.boolean().nullish()
20974
+ }).refine((run) => run.status !== "COMPLETED" || run.conclusion !== null, { path: ["conclusion"] });
20975
+ const statusContextWire = z.object({
20976
+ __typename: z.literal("StatusContext"),
20977
+ context: z.string(),
20978
+ state: z.string(),
20979
+ createdAt: z.string(),
20980
+ isRequired: z.boolean().nullish()
20981
+ });
20982
+ const contextWire = z.discriminatedUnion("__typename", [checkRunWire, statusContextWire]);
20983
+ /** The contracts check state of a check run or commit status. */
20984
+ function checkState(node) {
20985
+ if (node.__typename === "StatusContext") {
20986
+ const state = node.state.toLowerCase();
20987
+ return state === "success" ? "success" : state === "pending" ? "pending" : state === "expected" ? "expected" : "failure";
20988
+ }
20989
+ if (node.status !== "COMPLETED") return "pending";
20990
+ const value = node.conclusion?.toLowerCase();
20991
+ return [
20992
+ "success",
20993
+ "neutral",
20994
+ "skipped",
20995
+ "failure",
20996
+ "cancelled",
20997
+ "timed_out",
20998
+ "action_required",
20999
+ "stale"
21000
+ ].find((state) => state === value) ?? "error";
21001
+ }
21002
+ /** When a context ran, to keep the latest of each check; an empty string sorts first. */
21003
+ function contextAt(node) {
21004
+ return node.__typename === "StatusContext" ? node.createdAt : node.startedAt ?? node.checkSuite?.createdAt ?? node.completedAt ?? "";
21005
+ }
21006
+ /** The display name of a check run or commit status. */
21007
+ function contextName(node) {
21008
+ return node.__typename === "StatusContext" ? node.context : node.name;
21009
+ }
21010
+ /**
21011
+ * Only reruns of one check replace each other: a commit status by its context, an Actions check
21012
+ * run by its workflow and job name, another check run by its app and name. A check run with
21013
+ * neither, as in the older recordings, falls back to its name.
21014
+ */
21015
+ function checkKey(node) {
21016
+ if (node.__typename === "StatusContext") return `status:${node.context}`;
21017
+ const workflow = node.checkSuite?.workflowRun?.workflow.id;
21018
+ if (workflow !== void 0) return `check:${workflow}:${node.name}`;
21019
+ const app = node.checkSuite?.app?.id;
21020
+ return app === void 0 ? `name:${node.name}` : `app:${app}:${node.name}`;
21021
+ }
21022
+ /**
21023
+ * The latest node of each check (see `checkKey`), sorted by display name, then key. Of two runs
21024
+ * with one time the later node wins.
21025
+ */
21026
+ function latestContexts(nodes) {
21027
+ const latest = /* @__PURE__ */ new Map();
21028
+ for (const node of nodes) {
21029
+ const key = checkKey(node);
21030
+ const old = latest.get(key);
21031
+ if (old !== void 0 && contextAt(old) > contextAt(node)) continue;
21032
+ latest.set(key, node);
21033
+ }
21034
+ return [...latest.entries()].sort(([a, x], [b, y]) => contextName(x).localeCompare(contextName(y)) || a.localeCompare(b)).map(([, node]) => node);
21035
+ }
21036
+ // ../adapters/src/github/discovery.ts
21037
+ const timestamp$1 = z.string().min(1).refine((value) => !Number.isNaN(Date.parse(value)));
21038
+ const discoveryNodeWire = z.object({
21039
+ number: z.int().positive(),
21040
+ state: z.string().optional(),
21041
+ updatedAt: timestamp$1,
21042
+ author: z.object({ login: z.string() }).nullable()
21043
+ });
21044
+ const baselineNodeWire = z.object({ updatedAt: timestamp$1 });
21045
+ function latestUpdatedAt(nodes, previous) {
21046
+ let high = previous;
21047
+ for (const node of nodes) {
21048
+ const updated = sourceCursorSchema.parse(node.updatedAt);
21049
+ if (high === void 0 || Date.parse(updated) > Date.parse(high)) high = updated;
21050
+ }
21051
+ return high;
21052
+ }
21053
+ /** The high-water cursor is an ISO timestamp. Equal timestamps are revisited. */
21054
+ function discover(nodes, previous, login) {
21055
+ let high = previous;
21056
+ const numbers = /* @__PURE__ */ new Set();
21057
+ const states = /* @__PURE__ */ new Map();
21058
+ for (const node of nodes) {
21059
+ const updated = sourceCursorSchema.parse(node.updatedAt);
21060
+ const updatedMs = Date.parse(updated);
21061
+ if (high === void 0 || updatedMs > Date.parse(high)) high = updated;
21062
+ if (previous !== void 0 && updatedMs < Date.parse(previous)) continue;
21063
+ states.set(node.number, node.state);
21064
+ if (node.author?.login.toLowerCase() !== login.toLowerCase()) continue;
21065
+ numbers.add(node.number);
21066
+ }
21067
+ return {
21068
+ numbers: [...numbers],
21069
+ states,
21070
+ ...high === void 0 ? {} : { cursor: high }
21071
+ };
21072
+ }
21073
+ /** Pages are sorted newest first; older nodes end the scan, while ties must be revisited. */
21074
+ function pastCursor(nodes, previous) {
21075
+ const oldest = nodes.at(-1);
21076
+ if (previous === void 0 || oldest === void 0) return false;
21077
+ return Date.parse(oldest.updatedAt) < Date.parse(previous);
21078
+ }
21079
+ function nextPage(connection) {
21080
+ const { hasNextPage, endCursor } = connection.pageInfo;
21081
+ if (!hasNextPage) return void 0;
21082
+ if (!endCursor) throw new Error("Malformed GitHub pagination");
21083
+ return endCursor;
21084
+ }
21085
+ const branchCheckRunWire = z.object({
21086
+ __typename: z.literal("CheckRun"),
21087
+ name: z.string(),
21088
+ status: z.string(),
21089
+ conclusion: z.string().nullable(),
21090
+ startedAt: z.string().nullish(),
21091
+ completedAt: z.string().nullable(),
21092
+ detailsUrl: z.string().nullish(),
21093
+ checkSuite: z.object({
21094
+ createdAt: z.string(),
21095
+ workflowRun: z.object({
21096
+ event: z.string(),
21097
+ workflow: z.object({ id: z.string().min(1) })
21098
+ }).nullish()
21099
+ }).nullish()
21100
+ });
21101
+ const branchStatusWire = z.object({
21102
+ __typename: z.literal("StatusContext"),
21103
+ context: z.string(),
21104
+ state: z.string(),
21105
+ createdAt: z.string(),
21106
+ targetUrl: z.string().nullish()
21107
+ });
21108
+ const branchContextWire = z.discriminatedUnion("__typename", [branchCheckRunWire, branchStatusWire]);
21109
+ const defaultBranchWire = z.object({ defaultBranchRef: z.object({
21110
+ name: z.string(),
21111
+ target: z.object({
21112
+ __typename: z.literal("Commit"),
21113
+ oid: z.string(),
21114
+ statusCheckRollup: z.object({ contexts: z.object({
21115
+ nodes: z.array(branchContextWire),
21116
+ pageInfo: z.object({ hasNextPage: z.boolean() })
21117
+ }) })
21118
+ })
21119
+ }) });
21120
+ function counted$1(node) {
21121
+ return node.__typename === "StatusContext" || node.checkSuite?.workflowRun?.event === "push";
21122
+ }
21123
+ const PASSED = /* @__PURE__ */ new Set([
21124
+ "success",
21125
+ "neutral",
21126
+ "skipped"
21127
+ ]);
21128
+ const RUNNING = /* @__PURE__ */ new Set(["pending", "expected"]);
21129
+ /**
21130
+ * The colour of the default-branch head in a discovery response's `repository`, or undefined
21131
+ * when it is unknown: an unexpected shape, a running head, no counted check, or a truncated page
21132
+ * with no failure in it. Only check runs of push-triggered workflows and commit statuses count;
21133
+ * the latest run of each check decides (see `latestContexts`). A run URL that is not http(s)
21134
+ * becomes null.
21135
+ */
21136
+ function defaultBranchFact(repository) {
21137
+ const parsed = defaultBranchWire.safeParse(repository);
21138
+ if (!parsed.success) return void 0;
21139
+ const { name: branch, target } = parsed.data.defaultBranchRef;
21140
+ const { nodes, pageInfo } = target.statusCheckRollup.contexts;
21141
+ const kept = latestContexts(nodes.filter(counted$1)).map((node) => ({
21142
+ check: contextName(node),
21143
+ node,
21144
+ state: checkState(node)
21145
+ }));
21146
+ const failing = kept.find(({ state }) => !PASSED.has(state) && !RUNNING.has(state));
21147
+ if (failing !== void 0) {
21148
+ const { check, node } = failing;
21149
+ const url = (node.__typename === "StatusContext" ? node.targetUrl : node.detailsUrl) ?? null;
21150
+ const red = {
21151
+ state: "red",
21152
+ branch,
21153
+ sha: target.oid,
21154
+ check,
21155
+ url
21156
+ };
21157
+ const fact = defaultBranchFactSchema.safeParse(red);
21158
+ if (fact.success) return fact.data;
21159
+ return url === null ? void 0 : defaultBranchFactSchema.safeParse({
21160
+ ...red,
21161
+ url: null
21162
+ }).data;
21163
+ }
21164
+ if (kept.length === 0 || pageInfo.hasNextPage || kept.some(({ state }) => !PASSED.has(state))) return void 0;
21165
+ return defaultBranchFactSchema.safeParse({
21166
+ state: "green",
21167
+ branch,
21168
+ sha: target.oid
21169
+ }).data;
21170
+ }
20960
21171
  // ../adapters/src/github/feedbackLinks.ts
20961
21172
  const threadCommentWire = z.object({
20962
21173
  id: z.string().min(1),
@@ -21008,24 +21219,6 @@ const typedActor = z.object({
21008
21219
  __typename: z.string(),
21009
21220
  login: z.string().min(1)
21010
21221
  }).nullable();
21011
- const checkRunWire = z.object({
21012
- __typename: z.literal("CheckRun"),
21013
- name: z.string(),
21014
- status: z.string(),
21015
- conclusion: z.string().nullable(),
21016
- startedAt: z.string().nullish(),
21017
- completedAt: z.string().nullable(),
21018
- checkSuite: z.object({ createdAt: z.string() }).nullish(),
21019
- isRequired: z.boolean().nullish()
21020
- }).refine((run) => run.status !== "COMPLETED" || run.conclusion !== null, { path: ["conclusion"] });
21021
- const statusContextWire = z.object({
21022
- __typename: z.literal("StatusContext"),
21023
- context: z.string(),
21024
- state: z.string(),
21025
- createdAt: z.string(),
21026
- isRequired: z.boolean().nullish()
21027
- });
21028
- const contextWire = z.discriminatedUnion("__typename", [checkRunWire, statusContextWire]);
21029
21222
  const reviewWire = z.object({
21030
21223
  id: z.string().min(1),
21031
21224
  author: typedActor,
@@ -21134,49 +21327,15 @@ function closingRefs(wire) {
21134
21327
  number: node.number
21135
21328
  }] : []);
21136
21329
  }
21137
- /** The contracts check state of a check run or commit status. */
21138
- function checkState(node) {
21139
- if (node.__typename === "StatusContext") {
21140
- const state = node.state.toLowerCase();
21141
- return state === "success" ? "success" : state === "pending" ? "pending" : state === "expected" ? "expected" : "failure";
21142
- }
21143
- if (node.status !== "COMPLETED") return "pending";
21144
- const value = node.conclusion?.toLowerCase();
21145
- return [
21146
- "success",
21147
- "neutral",
21148
- "skipped",
21149
- "failure",
21150
- "cancelled",
21151
- "timed_out",
21152
- "action_required",
21153
- "stale"
21154
- ].find((state) => state === value) ?? "error";
21155
- }
21156
- /** When a context ran, to keep the latest per name; an empty string sorts first. */
21157
- function contextAt(node) {
21158
- return node.__typename === "StatusContext" ? node.createdAt : node.startedAt ?? node.checkSuite?.createdAt ?? node.completedAt ?? "";
21159
- }
21160
21330
  function latestChecks(nodes) {
21161
- const latest = /* @__PURE__ */ new Map();
21162
- for (const node of nodes) {
21163
- const status = node.__typename === "StatusContext";
21164
- const name = status ? node.context : node.name;
21165
- const completedAt = status ? null : node.completedAt;
21166
- const at = contextAt(node);
21167
- const old = latest.get(name);
21168
- if (old !== void 0 && old.at > at) continue;
21169
- latest.set(name, {
21170
- check: {
21171
- name,
21172
- state: checkState(node),
21173
- completedAt
21174
- },
21175
- required: node.isRequired === true,
21176
- at
21177
- });
21178
- }
21179
- const values = [...latest.values()].sort((a, b) => a.check.name.localeCompare(b.check.name));
21331
+ const values = latestContexts(nodes).map((node) => ({
21332
+ check: {
21333
+ name: contextName(node),
21334
+ state: checkState(node),
21335
+ completedAt: node.__typename === "StatusContext" ? null : node.completedAt
21336
+ },
21337
+ required: node.isRequired === true
21338
+ }));
21180
21339
  return {
21181
21340
  checks: values.map((v) => v.check),
21182
21341
  requiredChecks: values.filter((v) => v.required).map((v) => v.check)
@@ -21389,158 +21548,6 @@ function normalizePr(repo, value, rule, feedbackComplete, held = []) {
21389
21548
  if (!parsed.success) throw new AdapterError("transient", "Malformed GitHub PR facts", { cause: parsed.error });
21390
21549
  return parsed.data;
21391
21550
  }
21392
- // ../adapters/src/github/discovery.ts
21393
- const timestamp$1 = z.string().min(1).refine((value) => !Number.isNaN(Date.parse(value)));
21394
- const discoveryNodeWire = z.object({
21395
- number: z.int().positive(),
21396
- state: z.string().optional(),
21397
- updatedAt: timestamp$1,
21398
- author: z.object({ login: z.string() }).nullable()
21399
- });
21400
- const baselineNodeWire = z.object({ updatedAt: timestamp$1 });
21401
- function latestUpdatedAt(nodes, previous) {
21402
- let high = previous;
21403
- for (const node of nodes) {
21404
- const updated = sourceCursorSchema.parse(node.updatedAt);
21405
- if (high === void 0 || Date.parse(updated) > Date.parse(high)) high = updated;
21406
- }
21407
- return high;
21408
- }
21409
- /** The high-water cursor is an ISO timestamp. Equal timestamps are revisited. */
21410
- function discover(nodes, previous, login) {
21411
- let high = previous;
21412
- const numbers = /* @__PURE__ */ new Set();
21413
- const states = /* @__PURE__ */ new Map();
21414
- for (const node of nodes) {
21415
- const updated = sourceCursorSchema.parse(node.updatedAt);
21416
- const updatedMs = Date.parse(updated);
21417
- if (high === void 0 || updatedMs > Date.parse(high)) high = updated;
21418
- if (previous !== void 0 && updatedMs < Date.parse(previous)) continue;
21419
- states.set(node.number, node.state);
21420
- if (node.author?.login.toLowerCase() !== login.toLowerCase()) continue;
21421
- numbers.add(node.number);
21422
- }
21423
- return {
21424
- numbers: [...numbers],
21425
- states,
21426
- ...high === void 0 ? {} : { cursor: high }
21427
- };
21428
- }
21429
- /** Pages are sorted newest first; older nodes end the scan, while ties must be revisited. */
21430
- function pastCursor(nodes, previous) {
21431
- const oldest = nodes.at(-1);
21432
- if (previous === void 0 || oldest === void 0) return false;
21433
- return Date.parse(oldest.updatedAt) < Date.parse(previous);
21434
- }
21435
- function nextPage(connection) {
21436
- const { hasNextPage, endCursor } = connection.pageInfo;
21437
- if (!hasNextPage) return void 0;
21438
- if (!endCursor) throw new Error("Malformed GitHub pagination");
21439
- return endCursor;
21440
- }
21441
- const branchCheckRunWire = z.object({
21442
- __typename: z.literal("CheckRun"),
21443
- name: z.string(),
21444
- status: z.string(),
21445
- conclusion: z.string().nullable(),
21446
- startedAt: z.string().nullish(),
21447
- completedAt: z.string().nullable(),
21448
- detailsUrl: z.string().nullish(),
21449
- checkSuite: z.object({
21450
- createdAt: z.string(),
21451
- workflowRun: z.object({
21452
- event: z.string(),
21453
- workflow: z.object({ id: z.string().min(1) })
21454
- }).nullish()
21455
- }).nullish()
21456
- });
21457
- const branchStatusWire = z.object({
21458
- __typename: z.literal("StatusContext"),
21459
- context: z.string(),
21460
- state: z.string(),
21461
- createdAt: z.string(),
21462
- targetUrl: z.string().nullish()
21463
- });
21464
- const branchContextWire = z.discriminatedUnion("__typename", [branchCheckRunWire, branchStatusWire]);
21465
- const defaultBranchWire = z.object({ defaultBranchRef: z.object({
21466
- name: z.string(),
21467
- target: z.object({
21468
- __typename: z.literal("Commit"),
21469
- oid: z.string(),
21470
- statusCheckRollup: z.object({ contexts: z.object({
21471
- nodes: z.array(branchContextWire),
21472
- pageInfo: z.object({ hasNextPage: z.boolean() })
21473
- }) })
21474
- })
21475
- }) });
21476
- /**
21477
- * Only reruns of one check replace each other: a commit status by its context, a check run by
21478
- * its workflow and job name. A check run outside a push-triggered workflow has no key.
21479
- */
21480
- function checkKey(node) {
21481
- if (node.__typename === "StatusContext") return `status:${node.context}`;
21482
- const run = node.checkSuite?.workflowRun;
21483
- if (run?.event !== "push") return void 0;
21484
- return `check:${run.workflow.id}:${node.name}`;
21485
- }
21486
- const PASSED = /* @__PURE__ */ new Set([
21487
- "success",
21488
- "neutral",
21489
- "skipped"
21490
- ]);
21491
- const RUNNING = /* @__PURE__ */ new Set(["pending", "expected"]);
21492
- /**
21493
- * The colour of the default-branch head in a discovery response's `repository`, or undefined
21494
- * when it is unknown: an unexpected shape, a running head, no counted check, or a truncated page
21495
- * with no failure in it. Only check runs of push-triggered workflows and commit statuses count;
21496
- * the latest run of each check decides (see `checkKey`). A run URL that is not http(s) becomes null.
21497
- */
21498
- function defaultBranchFact(repository) {
21499
- const parsed = defaultBranchWire.safeParse(repository);
21500
- if (!parsed.success) return void 0;
21501
- const { name: branch, target } = parsed.data.defaultBranchRef;
21502
- const { nodes, pageInfo } = target.statusCheckRollup.contexts;
21503
- const latest = /* @__PURE__ */ new Map();
21504
- for (const node of nodes) {
21505
- const key = checkKey(node);
21506
- if (key === void 0) continue;
21507
- const old = latest.get(key);
21508
- if (old !== void 0 && contextAt(old.node) > contextAt(node)) continue;
21509
- latest.set(key, {
21510
- check: node.__typename === "StatusContext" ? node.context : node.name,
21511
- node
21512
- });
21513
- }
21514
- const kept = [...latest.entries()].sort(([a, x], [b, y]) => x.check.localeCompare(y.check) || a.localeCompare(b)).map(([, { check, node }]) => ({
21515
- check,
21516
- node,
21517
- state: checkState(node)
21518
- }));
21519
- const failing = kept.find(({ state }) => !PASSED.has(state) && !RUNNING.has(state));
21520
- if (failing !== void 0) {
21521
- const { check, node } = failing;
21522
- const url = (node.__typename === "StatusContext" ? node.targetUrl : node.detailsUrl) ?? null;
21523
- const red = {
21524
- state: "red",
21525
- branch,
21526
- sha: target.oid,
21527
- check,
21528
- url
21529
- };
21530
- const fact = defaultBranchFactSchema.safeParse(red);
21531
- if (fact.success) return fact.data;
21532
- return url === null ? void 0 : defaultBranchFactSchema.safeParse({
21533
- ...red,
21534
- url: null
21535
- }).data;
21536
- }
21537
- if (kept.length === 0 || pageInfo.hasNextPage || kept.some(({ state }) => !PASSED.has(state))) return void 0;
21538
- return defaultBranchFactSchema.safeParse({
21539
- state: "green",
21540
- branch,
21541
- sha: target.oid
21542
- }).data;
21543
- }
21544
21551
  const counted = (node) => z.object({
21545
21552
  totalCount: z.int().nonnegative(),
21546
21553
  nodes: z.array(node)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.104.2",
3
+ "version": "0.104.3",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"