UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

76 lines • 3.52 kB
import { type Shape } from './shape.ts'; /** A GraphQL connection as gh reads one: its nodes, and whether more follow. */ export interface Connection { nodes?: unknown[]; pageInfo?: { hasNextPage?: boolean; endCursor?: string | null; }; } /** * A connection `gh pr view` and `gh issue view` read to its end: its * selection given the clause that picks the page after `$endCursor` (or no * clause, for a field read apart), and where the connection sits in an * answer. */ export interface Pages { readonly select: (after: string) => string; readonly at: (node: Node) => Connection; } /** * One `--json` field of an issue or a pull request: the GraphQL selection * gh 2.85 puts on the wire for it (read off its query builder, and captured * with `GH_DEBUG=api`), and gh's own export of the answer (`ExportData`). * * `view` marks a field `gh pr view` or `gh issue view` leaves out of its * main query: `never` for one it never asks github.com for, and `apart` for * one it reads in a query of its own. The list commands ask for both * inline. `pages` marks a connection the view commands read to its end. */ export interface Field { readonly select: string; readonly view?: 'never' | 'apart'; readonly pages?: Pages; readonly export: (node: Node) => unknown; } export type FieldTable = ReadonlyMap<string, Field>; /** * Reads a selection of the issue or pull request a line names, with * `$endCursor` bound to `cursor` when the selection reads a later page. */ export type Fetch = (selection: string, cursor?: string) => Promise<Node>; export declare function record(value: unknown): Node; export declare function connection(value: unknown): Connection; export declare function nodesOf(value: unknown): unknown[]; export declare const LOGIN: Shape; export declare const AFTER = ", after: $endCursor"; export declare function plain(name: string, shape: Shape, select?: string): readonly [string, Field]; export declare function nodes(name: string, select: string, item: Shape, pages?: Pages): readonly [string, Field]; export declare function paged(name: string, select: (after: string) => string): Pages; /** * A list of references to issues or pull requests in some repository, the * shape gh gives both `closingIssuesReferences` and * `closedByPullRequestsReferences`: always a list, read to its end. */ export declare function references(name: string): readonly [string, Field]; /** * The fields issues and pull requests share, as gh 2.85's * `sharedIssuePRFields` names them. `projectItems` is read apart by both * views; `projectCards` is asked for as it stands, and each command says * whether its view does. */ export declare const SHARED_FIELDS: readonly (readonly [string, Field])[]; /** * The GraphQL selection for the fields named, in their order, each once. A * view leaves out the fields it reads some other way. */ export declare function selection(table: FieldTable, names: readonly string[], forView: boolean): string; /** One answer as gh exports the fields asked for. */ export declare function exportedNode(table: FieldTable, node: Node, fields: readonly string[]): Node; /** * Finish reading a view's answer: every connection gh follows read to its * end, and the fields it reads apart read that way, through `fetch`. */ export declare function readRest(table: FieldTable, node: Node, fields: readonly string[], fetch: Fetch): Promise<Node>; export type Node = Record<string, unknown>; //# sourceMappingURL=fields.d.ts.map