@ascribed/review 0.1.2-next.2

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 (70) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +183 -0
  3. package/dist/github/index.d.ts +7 -0
  4. package/dist/github/index.js +8 -0
  5. package/dist/github/index.js.map +1 -0
  6. package/dist/github/marker.d.ts +63 -0
  7. package/dist/github/marker.js +156 -0
  8. package/dist/github/marker.js.map +1 -0
  9. package/dist/github/queries.d.ts +16 -0
  10. package/dist/github/queries.js +174 -0
  11. package/dist/github/queries.js.map +1 -0
  12. package/dist/github/read.d.ts +84 -0
  13. package/dist/github/read.js +141 -0
  14. package/dist/github/read.js.map +1 -0
  15. package/dist/github/repository.d.ts +30 -0
  16. package/dist/github/repository.js +77 -0
  17. package/dist/github/repository.js.map +1 -0
  18. package/dist/github/requests.d.ts +65 -0
  19. package/dist/github/requests.js +274 -0
  20. package/dist/github/requests.js.map +1 -0
  21. package/dist/github/session.d.ts +143 -0
  22. package/dist/github/session.js +581 -0
  23. package/dist/github/session.js.map +1 -0
  24. package/dist/github/transport.d.ts +33 -0
  25. package/dist/github/transport.js +206 -0
  26. package/dist/github/transport.js.map +1 -0
  27. package/dist/marks/index.d.ts +92 -0
  28. package/dist/marks/index.js +766 -0
  29. package/dist/marks/index.js.map +1 -0
  30. package/dist/overlay/index.d.ts +4 -0
  31. package/dist/overlay/index.js +7 -0
  32. package/dist/overlay/index.js.map +1 -0
  33. package/dist/overlay/markdown.d.ts +4 -0
  34. package/dist/overlay/markdown.js +368 -0
  35. package/dist/overlay/markdown.js.map +1 -0
  36. package/dist/overlay/overlay.d.ts +47 -0
  37. package/dist/overlay/overlay.js +1710 -0
  38. package/dist/overlay/overlay.js.map +1 -0
  39. package/dist/overlay/style.d.ts +1 -0
  40. package/dist/overlay/style.js +570 -0
  41. package/dist/overlay/style.js.map +1 -0
  42. package/dist/overlay/text.d.ts +33 -0
  43. package/dist/overlay/text.js +200 -0
  44. package/dist/overlay/text.js.map +1 -0
  45. package/dist/overlay/types.d.ts +60 -0
  46. package/dist/overlay/types.js +2 -0
  47. package/dist/overlay/types.js.map +1 -0
  48. package/dist/place/anchor.d.ts +23 -0
  49. package/dist/place/anchor.js +49 -0
  50. package/dist/place/anchor.js.map +1 -0
  51. package/dist/place/index.d.ts +4 -0
  52. package/dist/place/index.js +6 -0
  53. package/dist/place/index.js.map +1 -0
  54. package/dist/place/lines.d.ts +56 -0
  55. package/dist/place/lines.js +280 -0
  56. package/dist/place/lines.js.map +1 -0
  57. package/dist/place/place.d.ts +77 -0
  58. package/dist/place/place.js +182 -0
  59. package/dist/place/place.js.map +1 -0
  60. package/dist/shared/errors.d.ts +40 -0
  61. package/dist/shared/errors.js +22 -0
  62. package/dist/shared/errors.js.map +1 -0
  63. package/dist/shared/git.d.ts +4 -0
  64. package/dist/shared/git.js +29 -0
  65. package/dist/shared/git.js.map +1 -0
  66. package/dist/shared/types.d.ts +56 -0
  67. package/dist/shared/types.js +3 -0
  68. package/dist/shared/types.js.map +1 -0
  69. package/package.json +61 -0
  70. package/src/marks/marks.css +361 -0
@@ -0,0 +1,156 @@
1
+ // Comments GitHub can't anchor to a line go on the pull request's
2
+ // conversation, each ending with a hidden marker naming its block:
3
+ //
4
+ // <!-- ascribe:anchor guides/install.md:12-14 build=site -->
5
+ //
6
+ // Several can share one body (a review's), one after another. A review's
7
+ // summary goes before them, ended by another marker:
8
+ //
9
+ // Looks good, a few notes below.
10
+ //
11
+ // <!-- ascribe:summary -->
12
+ //
13
+ // A comment quotes its block's source, or its text as the page shows it,
14
+ // escaped so GitHub shows it as written; the marker of one that quotes the
15
+ // shown text ends ` quote=text`.
16
+ const MARKER = /<!-- ascribe:anchor (\S+)(?: build=(\S+))?( quote=text)? -->/g;
17
+ /**
18
+ * The summary a pending review starts with. GitHub can't edit the summary of
19
+ * a pending review created without one, so the session's reviews start with
20
+ * this, which reading and submitting remove.
21
+ */
22
+ export const PLACEHOLDER = "<!-- ascribe:review -->";
23
+ /** Ends a review's summary when anchored comments follow it. */
24
+ export const SUMMARY_END = "<!-- ascribe:summary -->";
25
+ /** `body` without the placeholder summary. */
26
+ export function withoutPlaceholder(body) {
27
+ return body.split(PLACEHOLDER).join("").trim();
28
+ }
29
+ /**
30
+ * The marker for a block. Without a build (or with `""`), the comment is on
31
+ * every build's page. `shown` marks a quote of the shown text.
32
+ */
33
+ export function marker(source, build, shown = false) {
34
+ return `<!-- ascribe:anchor ${source}${build === undefined || build === "" ? "" : ` build=${build}`}${shown ? " quote=text" : ""} -->`;
35
+ }
36
+ /** Joins a mention or reference sign to what follows, so GitHub doesn't link it. */
37
+ const JOINER = "\u2060";
38
+ /**
39
+ * Plain text as Markdown that GitHub shows as the text: punctuation
40
+ * escaped, `@name` and `#123` not linked, line breaks and leading spaces
41
+ * kept.
42
+ */
43
+ export function escapeText(text) {
44
+ const lines = text.split(/\r?\n/).map((line) => {
45
+ const indent = /^ */.exec(line)?.[0].length ?? 0;
46
+ const rest = line
47
+ .slice(indent)
48
+ .replace(/[!-/:-@[-`{-~]/g, (c) => (c === "<" ? "&lt;" : `\\${c}`))
49
+ .replace(/[@#]/g, `$&${JOINER}`);
50
+ return "\u00a0".repeat(indent) + rest;
51
+ });
52
+ // A backslash at the end of a line breaks it, but not before a blank line.
53
+ return lines
54
+ .map((line, i) => (line !== "" && (lines[i + 1] ?? "") !== "" ? `${line}\\` : line))
55
+ .join("\n");
56
+ }
57
+ /** Text that `escapeText` wrote, as it was. */
58
+ export function unescapeText(text) {
59
+ return text
60
+ .split(/\r?\n/)
61
+ .map((line) => {
62
+ const trailing = /\\*$/.exec(line)?.[0].length ?? 0;
63
+ const unbroken = trailing % 2 === 1 ? line.slice(0, -1) : line;
64
+ const indent = /^\u00a0*/.exec(unbroken)?.[0].length ?? 0;
65
+ return (" ".repeat(indent) +
66
+ unbroken
67
+ .slice(indent)
68
+ .replace(new RegExp(`([@#])${JOINER}`, "g"), "$1")
69
+ .replace(/\\([!-/:-@[-`{-~])|&lt;/g, (_, c) => c ?? "<"));
70
+ })
71
+ .join("\n");
72
+ }
73
+ /**
74
+ * Writes a section: the block's text quoted, the comment, a line linking the
75
+ * block's lines, and the marker.
76
+ */
77
+ export function formatSection(options) {
78
+ const parts = [];
79
+ const shown = options.shown === true;
80
+ if (options.quote !== undefined && options.quote.trim() !== "") {
81
+ parts.push((shown ? escapeText(options.quote) : options.quote)
82
+ .split(/\r?\n/)
83
+ .map((line) => (line === "" ? ">" : `> ${line}`))
84
+ .join("\n"));
85
+ }
86
+ parts.push(options.body.trim());
87
+ const end = marker(options.source, options.build, shown);
88
+ parts.push(options.link === undefined
89
+ ? end
90
+ : `<sub>On [${options.link.label.replace(/[[\]]/g, "\\$&")}](${options.link.url})</sub>\n${end}`);
91
+ return parts.join("\n\n");
92
+ }
93
+ /**
94
+ * Splits a body into its summary, its marked sections, and the text after
95
+ * the last marker (`rest`), which isn't anchored either.
96
+ */
97
+ export function parseSections(text) {
98
+ let body = withoutPlaceholder(text);
99
+ let summary = "";
100
+ // The summary ends before the first comment, if it's there at all.
101
+ const end = body.indexOf(SUMMARY_END);
102
+ const first = body.search(new RegExp(MARKER.source));
103
+ if (end >= 0 && (first < 0 || end < first)) {
104
+ summary = body.slice(0, end).trim();
105
+ body = body.slice(end + SUMMARY_END.length).trim();
106
+ }
107
+ const sections = [];
108
+ let start = 0;
109
+ for (const match of body.matchAll(MARKER)) {
110
+ const source = match[1] ?? "";
111
+ const text = body.slice(start, match.index);
112
+ start = match.index + match[0].length;
113
+ const { body: comment, quote } = unwrap(text);
114
+ sections.push({
115
+ source,
116
+ build: match[2],
117
+ body: comment,
118
+ quote: quote !== undefined && match[3] !== undefined ? unescapeText(quote) : quote,
119
+ });
120
+ }
121
+ return { summary, sections, rest: body.slice(start).trim() };
122
+ }
123
+ function unwrap(text) {
124
+ let rest = text.replace(/\s*<sub>On \[[^\n]*\]\([^\n)]*\)<\/sub>\s*$/, "").trim();
125
+ let quote;
126
+ const lines = rest.split(/\r?\n/);
127
+ let quoted = 0;
128
+ while (quoted < lines.length && /^>( |$)/.test(lines[quoted] ?? ""))
129
+ quoted++;
130
+ if (quoted > 0 && quoted < lines.length && (lines[quoted] ?? "").trim() === "") {
131
+ quote = lines
132
+ .slice(0, quoted)
133
+ .map((line) => line.replace(/^> ?/, ""))
134
+ .join("\n");
135
+ rest = lines
136
+ .slice(quoted + 1)
137
+ .join("\n")
138
+ .trim();
139
+ }
140
+ return { body: rest, quote };
141
+ }
142
+ /**
143
+ * Joins a summary and sections into one body: the summary first, so it
144
+ * doesn't read as a remark on the last section.
145
+ */
146
+ export function joinSections(sections, summary) {
147
+ const held = sections.filter((part) => part.trim() !== "");
148
+ // A marker in the summary would be read as one of Ascribe's.
149
+ const lead = (summary ?? "").trim().replace(/(<!--\s*ascribe):/g, `$1${JOINER}:`);
150
+ if (lead === "")
151
+ return held.join("\n\n");
152
+ if (held.length === 0)
153
+ return lead;
154
+ return [lead, SUMMARY_END, ...held].join("\n\n");
155
+ }
156
+ //# sourceMappingURL=marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marker.js","sourceRoot":"","sources":["../../src/github/marker.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,mEAAmE;AACnE,EAAE;AACF,+DAA+D;AAC/D,EAAE;AACF,yEAAyE;AACzE,qDAAqD;AACrD,EAAE;AACF,mCAAmC;AACnC,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,iCAAiC;AAajC,MAAM,MAAM,GAAG,+DAA+D,CAAC;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAErD,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAEtD,8CAA8C;AAC9C,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,C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OAAO,CAAC,oBAAoB,EAAE,KAAK,MAAM,GAAG,CAAC,CAAC;IAClF,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const FIND_PULL_REQUEST = "\nquery FindPullRequest($owner: String!, $name: String!, $head: String!) {\n repository(owner: $owner, name: $name) {\n pullRequests(headRefName: $head, states: [OPEN], first: 20, orderBy: { field: CREATED_AT, direction: DESC }) {\n nodes {\n id\n number\n url\n baseRefName\n baseRefOid\n headRefName\n headRefOid\n headRepositoryOwner { login }\n headRepository { name }\n }\n }\n }\n}";
2
+ export declare const REVIEW_THREADS = "\nquery ReviewThreads($owner: String!, $name: String!, $number: Int!, $after: String) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n reviewThreads(first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { ...ReviewThread }\n }\n }\n }\n}\n\nfragment ReviewThread on PullRequestReviewThread {\n id\n path\n line\n startLine\n originalLine\n originalStartLine\n diffSide\n startDiffSide\n isResolved\n isOutdated\n subjectType\n viewerCanResolve\n viewerCanUnresolve\n viewerCanReply\n comments(first: 100) {\n pageInfo { hasNextPage endCursor }\n nodes { ...ReviewComment }\n }\n}\n\nfragment ReviewComment on PullRequestReviewComment {\n id\n body\n createdAt\n url\n state\n diffHunk\n author { login avatarUrl }\n commit { oid }\n originalCommit { oid }\n}";
3
+ export declare const THREAD_COMMENTS = "\nquery ThreadComments($id: ID!, $after: String) {\n node(id: $id) {\n ... on PullRequestReviewThread {\n comments(first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { ...ReviewComment }\n }\n }\n }\n}\n\nfragment ReviewComment on PullRequestReviewComment {\n id\n body\n createdAt\n url\n state\n diffHunk\n author { login avatarUrl }\n commit { oid }\n originalCommit { oid }\n}";
4
+ export declare const CONVERSATION = "\nquery Conversation($owner: String!, $name: String!, $number: Int!, $after: String) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n comments(first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { id body createdAt url author { login avatarUrl } }\n }\n }\n }\n}";
5
+ export declare const REVIEWS = "\nquery Reviews($owner: String!, $name: String!, $number: Int!, $after: String) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n reviews(first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { id state body createdAt url viewerDidAuthor author { login avatarUrl } }\n }\n }\n }\n}";
6
+ export declare const FILES = "\nquery Files($owner: String!, $name: String!, $number: Int!, $after: String) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n files(first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { path }\n }\n }\n }\n}";
7
+ export declare const ADD_REVIEW = "\nmutation AddReview($pullRequestId: ID!, $commit: GitObjectID, $body: String!) {\n addPullRequestReview(input: { pullRequestId: $pullRequestId, commitOID: $commit, body: $body }) {\n pullRequestReview { id }\n }\n}";
8
+ export declare const ADD_THREAD = "\nmutation AddThread($reviewId: ID!, $path: String!, $body: String!, $line: Int!, $startLine: Int) {\n addPullRequestReviewThread(\n input: { pullRequestReviewId: $reviewId, path: $path, body: $body, line: $line, side: RIGHT, startLine: $startLine, subjectType: LINE }\n ) {\n thread { ...ReviewThread }\n }\n}\n\nfragment ReviewThread on PullRequestReviewThread {\n id\n path\n line\n startLine\n originalLine\n originalStartLine\n diffSide\n startDiffSide\n isResolved\n isOutdated\n subjectType\n viewerCanResolve\n viewerCanUnresolve\n viewerCanReply\n comments(first: 100) {\n pageInfo { hasNextPage endCursor }\n nodes { ...ReviewComment }\n }\n}\n\nfragment ReviewComment on PullRequestReviewComment {\n id\n body\n createdAt\n url\n state\n diffHunk\n author { login avatarUrl }\n commit { oid }\n originalCommit { oid }\n}";
9
+ export declare const ADD_REPLY = "\nmutation AddReply($threadId: ID!, $body: String!, $reviewId: ID) {\n addPullRequestReviewThreadReply(\n input: { pullRequestReviewThreadId: $threadId, body: $body, pullRequestReviewId: $reviewId }\n ) {\n comment { ...ReviewComment }\n }\n}\n\nfragment ReviewComment on PullRequestReviewComment {\n id\n body\n createdAt\n url\n state\n diffHunk\n author { login avatarUrl }\n commit { oid }\n originalCommit { oid }\n}";
10
+ export declare const DELETE_COMMENT = "\nmutation DeleteComment($id: ID!) {\n deletePullRequestReviewComment(input: { id: $id }) { clientMutationId }\n}";
11
+ export declare const RESOLVE = "\nmutation Resolve($threadId: ID!) {\n resolveReviewThread(input: { threadId: $threadId }) {\n thread { id isResolved viewerCanResolve viewerCanUnresolve }\n }\n}";
12
+ export declare const UNRESOLVE = "\nmutation Unresolve($threadId: ID!) {\n unresolveReviewThread(input: { threadId: $threadId }) {\n thread { id isResolved viewerCanResolve viewerCanUnresolve }\n }\n}";
13
+ export declare const UPDATE_REVIEW = "\nmutation UpdateReview($reviewId: ID!, $body: String!) {\n updatePullRequestReview(input: { pullRequestReviewId: $reviewId, body: $body }) {\n pullRequestReview { id }\n }\n}";
14
+ export declare const SUBMIT_REVIEW = "\nmutation SubmitReview($reviewId: ID!, $event: PullRequestReviewEvent!, $body: String) {\n submitPullRequestReview(input: { pullRequestReviewId: $reviewId, event: $event, body: $body }) {\n pullRequestReview { id state }\n }\n}";
15
+ export declare const DELETE_REVIEW = "\nmutation DeleteReview($reviewId: ID!) {\n deletePullRequestReview(input: { pullRequestReviewId: $reviewId }) { clientMutationId }\n}";
16
+ export declare const VIEWER = "\nquery Viewer {\n viewer { login }\n}";
@@ -0,0 +1,174 @@
1
+ // The GraphQL documents this package sends.
2
+ const AUTHOR = "author { login avatarUrl }";
3
+ const COMMENT = `
4
+ fragment ReviewComment on PullRequestReviewComment {
5
+ id
6
+ body
7
+ createdAt
8
+ url
9
+ state
10
+ diffHunk
11
+ ${AUTHOR}
12
+ commit { oid }
13
+ originalCommit { oid }
14
+ }`;
15
+ const THREAD = `
16
+ fragment ReviewThread on PullRequestReviewThread {
17
+ id
18
+ path
19
+ line
20
+ startLine
21
+ originalLine
22
+ originalStartLine
23
+ diffSide
24
+ startDiffSide
25
+ isResolved
26
+ isOutdated
27
+ subjectType
28
+ viewerCanResolve
29
+ viewerCanUnresolve
30
+ viewerCanReply
31
+ comments(first: 100) {
32
+ pageInfo { hasNextPage endCursor }
33
+ nodes { ...ReviewComment }
34
+ }
35
+ }`;
36
+ const PAGE = "pageInfo { hasNextPage endCursor }";
37
+ export const FIND_PULL_REQUEST = `
38
+ query FindPullRequest($owner: String!, $name: String!, $head: String!) {
39
+ repository(owner: $owner, name: $name) {
40
+ pullRequests(headRefName: $head, states: [OPEN], first: 20, orderBy: { field: CREATED_AT, direction: DESC }) {
41
+ nodes {
42
+ id
43
+ number
44
+ url
45
+ baseRefName
46
+ baseRefOid
47
+ headRefName
48
+ headRefOid
49
+ headRepositoryOwner { login }
50
+ headRepository { name }
51
+ }
52
+ }
53
+ }
54
+ }`;
55
+ export const REVIEW_THREADS = `
56
+ query ReviewThreads($owner: String!, $name: String!, $number: Int!, $after: String) {
57
+ repository(owner: $owner, name: $name) {
58
+ pullRequest(number: $number) {
59
+ reviewThreads(first: 100, after: $after) {
60
+ ${PAGE}
61
+ nodes { ...ReviewThread }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ${THREAD}
67
+ ${COMMENT}`;
68
+ export const THREAD_COMMENTS = `
69
+ query ThreadComments($id: ID!, $after: String) {
70
+ node(id: $id) {
71
+ ... on PullRequestReviewThread {
72
+ comments(first: 100, after: $after) {
73
+ ${PAGE}
74
+ nodes { ...ReviewComment }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ${COMMENT}`;
80
+ export const CONVERSATION = `
81
+ query Conversation($owner: String!, $name: String!, $number: Int!, $after: String) {
82
+ repository(owner: $owner, name: $name) {
83
+ pullRequest(number: $number) {
84
+ comments(first: 100, after: $after) {
85
+ ${PAGE}
86
+ nodes { id body createdAt url ${AUTHOR} }
87
+ }
88
+ }
89
+ }
90
+ }`;
91
+ export const REVIEWS = `
92
+ query Reviews($owner: String!, $name: String!, $number: Int!, $after: String) {
93
+ repository(owner: $owner, name: $name) {
94
+ pullRequest(number: $number) {
95
+ reviews(first: 100, after: $after) {
96
+ ${PAGE}
97
+ nodes { id state body createdAt url viewerDidAuthor ${AUTHOR} }
98
+ }
99
+ }
100
+ }
101
+ }`;
102
+ export const FILES = `
103
+ query Files($owner: String!, $name: String!, $number: Int!, $after: String) {
104
+ repository(owner: $owner, name: $name) {
105
+ pullRequest(number: $number) {
106
+ files(first: 100, after: $after) {
107
+ ${PAGE}
108
+ nodes { path }
109
+ }
110
+ }
111
+ }
112
+ }`;
113
+ export const ADD_REVIEW = `
114
+ mutation AddReview($pullRequestId: ID!, $commit: GitObjectID, $body: String!) {
115
+ addPullRequestReview(input: { pullRequestId: $pullRequestId, commitOID: $commit, body: $body }) {
116
+ pullRequestReview { id }
117
+ }
118
+ }`;
119
+ export const ADD_THREAD = `
120
+ mutation AddThread($reviewId: ID!, $path: String!, $body: String!, $line: Int!, $startLine: Int) {
121
+ addPullRequestReviewThread(
122
+ input: { pullRequestReviewId: $reviewId, path: $path, body: $body, line: $line, side: RIGHT, startLine: $startLine, subjectType: LINE }
123
+ ) {
124
+ thread { ...ReviewThread }
125
+ }
126
+ }
127
+ ${THREAD}
128
+ ${COMMENT}`;
129
+ export const ADD_REPLY = `
130
+ mutation AddReply($threadId: ID!, $body: String!, $reviewId: ID) {
131
+ addPullRequestReviewThreadReply(
132
+ input: { pullRequestReviewThreadId: $threadId, body: $body, pullRequestReviewId: $reviewId }
133
+ ) {
134
+ comment { ...ReviewComment }
135
+ }
136
+ }
137
+ ${COMMENT}`;
138
+ export const DELETE_COMMENT = `
139
+ mutation DeleteComment($id: ID!) {
140
+ deletePullRequestReviewComment(input: { id: $id }) { clientMutationId }
141
+ }`;
142
+ export const RESOLVE = `
143
+ mutation Resolve($threadId: ID!) {
144
+ resolveReviewThread(input: { threadId: $threadId }) {
145
+ thread { id isResolved viewerCanResolve viewerCanUnresolve }
146
+ }
147
+ }`;
148
+ export const UNRESOLVE = `
149
+ mutation Unresolve($threadId: ID!) {
150
+ unresolveReviewThread(input: { threadId: $threadId }) {
151
+ thread { id isResolved viewerCanResolve viewerCanUnresolve }
152
+ }
153
+ }`;
154
+ export const UPDATE_REVIEW = `
155
+ mutation UpdateReview($reviewId: ID!, $body: String!) {
156
+ updatePullRequestReview(input: { pullRequestReviewId: $reviewId, body: $body }) {
157
+ pullRequestReview { id }
158
+ }
159
+ }`;
160
+ export const SUBMIT_REVIEW = `
161
+ mutation SubmitReview($reviewId: ID!, $event: PullRequestReviewEvent!, $body: String) {
162
+ submitPullRequestReview(input: { pullRequestReviewId: $reviewId, event: $event, body: $body }) {
163
+ pullRequestReview { id state }
164
+ }
165
+ }`;
166
+ export const DELETE_REVIEW = `
167
+ mutation DeleteReview($reviewId: ID!) {
168
+ deletePullRequestReview(input: { pullRequestReviewId: $reviewId }) { clientMutationId }
169
+ }`;
170
+ export const VIEWER = `
171
+ query Viewer {
172
+ viewer { login }
173
+ }`;
174
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/github/queries.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAE5C,MAAM,OAAO,GAAG;;;;;;;;IAQZ,MAAM;;;EAGR,CAAC;AAEH,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;EAoBb,CAAC;AAEH,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;EAiB/B,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;UAKpB,IAAI;;;;;;EAMZ,MAAM;EACN,OAAO,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;UAKrB,IAAI;;;;;;EAMZ,OAAO,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;UAKlB,IAAI;wCAC0B,MAAM;;;;EAI5C,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;UAKb,IAAI;8DACgD,MAAM;;;;EAIlE,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;UAKX,IAAI;;;;;EAKZ,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;EAKxB,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;EAQxB,MAAM;EACN,OAAO,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;EAQvB,OAAO,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,cAAc,GAAG;;;EAG5B,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;EAKrB,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;EAKvB,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;EAK3B,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;EAK3B,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;EAG3B,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG;;;EAGpB,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { Thread, ThreadComment } from "../shared/types.js";
2
+ import type { GitHubTransport } from "./transport.js";
3
+ /** A pull request, by repository and number. */
4
+ export interface PullRequestKey {
5
+ owner: string;
6
+ name: string;
7
+ number: number;
8
+ }
9
+ interface Page<T> {
10
+ pageInfo: {
11
+ hasNextPage: boolean;
12
+ endCursor: string | null;
13
+ };
14
+ nodes: (T | null)[];
15
+ }
16
+ interface RawAuthor {
17
+ login: string;
18
+ avatarUrl?: string | null;
19
+ }
20
+ interface RawComment {
21
+ id: string;
22
+ body: string;
23
+ createdAt: string;
24
+ url: string;
25
+ state: "PENDING" | "SUBMITTED";
26
+ diffHunk: string;
27
+ author: RawAuthor | null;
28
+ commit: {
29
+ oid: string;
30
+ } | null;
31
+ originalCommit: {
32
+ oid: string;
33
+ } | null;
34
+ }
35
+ /** A review thread as the API returns it. */
36
+ export interface RawThread {
37
+ id: string;
38
+ path: string;
39
+ line: number | null;
40
+ startLine: number | null;
41
+ originalLine: number | null;
42
+ originalStartLine: number | null;
43
+ diffSide: "LEFT" | "RIGHT";
44
+ startDiffSide: "LEFT" | "RIGHT" | null;
45
+ isResolved: boolean;
46
+ isOutdated: boolean;
47
+ subjectType: "LINE" | "FILE";
48
+ viewerCanResolve: boolean;
49
+ viewerCanUnresolve: boolean;
50
+ viewerCanReply: boolean;
51
+ comments: Page<RawComment>;
52
+ }
53
+ interface RawConversationComment {
54
+ id: string;
55
+ body: string;
56
+ createdAt: string;
57
+ url: string;
58
+ author: RawAuthor | null;
59
+ }
60
+ /** A review, as the API returns it. */
61
+ export interface RawReview extends RawConversationComment {
62
+ state: "PENDING" | "COMMENTED" | "APPROVED" | "CHANGES_REQUESTED" | "DISMISSED";
63
+ viewerDidAuthor: boolean;
64
+ }
65
+ /** Every review thread, each with all its comments. */
66
+ export declare function readReviewThreads(transport: GitHubTransport, key: PullRequestKey): Promise<RawThread[]>;
67
+ /** Reads the comments past a thread's first page into it. */
68
+ export declare function readRestOfComments(transport: GitHubTransport, thread: RawThread): Promise<void>;
69
+ /** The pull request's conversation comments. */
70
+ export declare function readConversation(transport: GitHubTransport, key: PullRequestKey): Promise<RawConversationComment[]>;
71
+ /** The pull request's reviews, the viewer's pending one included. */
72
+ export declare function readReviews(transport: GitHubTransport, key: PullRequestKey): Promise<RawReview[]>;
73
+ /** The repository paths of the files the pull request changes. */
74
+ export declare function readFiles(transport: GitHubTransport, key: PullRequestKey): Promise<Set<string>>;
75
+ /** A comment of a review thread. */
76
+ export declare function toComment(raw: RawComment): ThreadComment;
77
+ /** A review thread. */
78
+ export declare function toThread(raw: RawThread): Thread;
79
+ /**
80
+ * The anchored comments in a conversation comment's or a review's body, as
81
+ * threads. `contentPrefix` is the content root's path in the repository.
82
+ */
83
+ export declare function markedThreads(raw: RawConversationComment, contentPrefix: string, pending: boolean): Thread[];
84
+ export {};
@@ -0,0 +1,141 @@
1
+ // Reading a pull request's threads, reviews, and files, page by page.
2
+ import { parseSource } from "../place/anchor.js";
3
+ import { parseSections } from "./marker.js";
4
+ import { CONVERSATION, FILES, REVIEW_THREADS, REVIEWS, THREAD_COMMENTS } from "./queries.js";
5
+ /** Reads every page of one of the pull request's connections. */
6
+ async function readAll(transport, query, key, field) {
7
+ const items = [];
8
+ let after = null;
9
+ for (;;) {
10
+ const data = await transport.graphql(query, { ...key, after });
11
+ const page = data.repository?.pullRequest?.[field];
12
+ if (page === undefined)
13
+ break;
14
+ for (const node of page.nodes)
15
+ if (node !== null)
16
+ items.push(node);
17
+ if (!page.pageInfo.hasNextPage || page.pageInfo.endCursor === null)
18
+ break;
19
+ after = page.pageInfo.endCursor;
20
+ }
21
+ return items;
22
+ }
23
+ /** Every review thread, each with all its comments. */
24
+ export async function readReviewThreads(transport, key) {
25
+ const threads = await readAll(transport, REVIEW_THREADS, key, "reviewThreads");
26
+ for (const thread of threads)
27
+ await readRestOfComments(transport, thread);
28
+ return threads;
29
+ }
30
+ /** Reads the comments past a thread's first page into it. */
31
+ export async function readRestOfComments(transport, thread) {
32
+ let page = thread.comments;
33
+ while (page.pageInfo.hasNextPage && page.pageInfo.endCursor !== null) {
34
+ const data = await transport.graphql(THREAD_COMMENTS, { id: thread.id, after: page.pageInfo.endCursor });
35
+ if (data.node === null)
36
+ break;
37
+ page = data.node.comments;
38
+ thread.comments.nodes.push(...page.nodes);
39
+ }
40
+ thread.comments.pageInfo = page.pageInfo;
41
+ }
42
+ /** The pull request's conversation comments. */
43
+ export function readConversation(transport, key) {
44
+ return readAll(transport, CONVERSATION, key, "comments");
45
+ }
46
+ /** The pull request's reviews, the viewer's pending one included. */
47
+ export function readReviews(transport, key) {
48
+ return readAll(transport, REVIEWS, key, "reviews");
49
+ }
50
+ /** The repository paths of the files the pull request changes. */
51
+ export async function readFiles(transport, key) {
52
+ const files = await readAll(transport, FILES, key, "files");
53
+ return new Set(files.map((file) => file.path));
54
+ }
55
+ function author(raw) {
56
+ return raw === null ? null : { login: raw.login, avatarUrl: raw.avatarUrl ?? undefined };
57
+ }
58
+ /** A comment of a review thread. */
59
+ export function toComment(raw) {
60
+ return {
61
+ id: raw.id,
62
+ author: author(raw.author),
63
+ body: raw.body,
64
+ createdAt: raw.createdAt,
65
+ url: raw.url,
66
+ pending: raw.state === "PENDING",
67
+ };
68
+ }
69
+ /** A review thread. */
70
+ export function toThread(raw) {
71
+ const comments = raw.comments.nodes.filter((node) => node !== null);
72
+ const first = comments[0];
73
+ return {
74
+ id: raw.id,
75
+ kind: "review",
76
+ repositoryPath: raw.path,
77
+ subject: raw.subjectType === "FILE" ? "file" : "line",
78
+ side: raw.diffSide,
79
+ line: raw.line,
80
+ startLine: raw.startLine,
81
+ originalLine: raw.originalLine,
82
+ originalStartLine: raw.originalStartLine,
83
+ commit: first?.commit?.oid,
84
+ originalCommit: first?.originalCommit?.oid,
85
+ resolved: raw.isResolved,
86
+ outdated: raw.isOutdated,
87
+ canResolve: raw.viewerCanResolve,
88
+ canUnresolve: raw.viewerCanUnresolve,
89
+ canReply: raw.viewerCanReply,
90
+ comments: comments.map(toComment),
91
+ diffHunk: first?.diffHunk,
92
+ marker: undefined,
93
+ quote: undefined,
94
+ };
95
+ }
96
+ /**
97
+ * The anchored comments in a conversation comment's or a review's body, as
98
+ * threads. `contentPrefix` is the content root's path in the repository.
99
+ */
100
+ export function markedThreads(raw, contentPrefix, pending) {
101
+ const threads = [];
102
+ const { sections } = parseSections(raw.body);
103
+ sections.forEach((section, index) => {
104
+ const range = parseSource(section.source);
105
+ if (range === undefined)
106
+ return;
107
+ threads.push({
108
+ id: sections.length === 1 ? raw.id : `${raw.id}#${index}`,
109
+ kind: "conversation",
110
+ repositoryPath: `${contentPrefix}${range.path}`,
111
+ subject: "line",
112
+ side: "RIGHT",
113
+ line: range.last,
114
+ startLine: range.first === range.last ? null : range.first,
115
+ originalLine: range.last,
116
+ originalStartLine: range.first === range.last ? null : range.first,
117
+ commit: undefined,
118
+ originalCommit: undefined,
119
+ resolved: false,
120
+ outdated: false,
121
+ canResolve: false,
122
+ canUnresolve: false,
123
+ canReply: false,
124
+ comments: [
125
+ {
126
+ id: sections.length === 1 ? raw.id : `${raw.id}#${index}`,
127
+ author: author(raw.author),
128
+ body: section.body,
129
+ createdAt: raw.createdAt,
130
+ url: raw.url,
131
+ pending,
132
+ },
133
+ ],
134
+ diffHunk: undefined,
135
+ marker: { source: section.source, build: section.build },
136
+ quote: section.quote,
137
+ });
138
+ });
139
+ return threads;
140
+ }
141
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/github/read.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqE7F,iEAAiE;AACjE,KAAK,UAAU,OAAO,CACpB,SAA0B,EAC1B,KAAa,EACb,GAAmB,EACnB,KAAQ;IAER,MAAM,KAAK,GAAQ,EAAE,CAAC;IACtB,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,SAAS,CAAC;QACR,MAAM,IAAI,GAA0B,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,GAAG,GAAG,EAAE,KAAK,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;gBACR;oBACE,EAAE,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,KAAK,EAAE;oBACzD,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;oBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,SAAS,EAAE,GAAG,CAAC,SAAS;oBACxB,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,OAAO;iBACR;aACF;YACD,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE;YACxD,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** A repository on a GitHub host. */
2
+ export interface RepositoryRef {
3
+ /** `github.com`, or a GitHub Enterprise Server host. */
4
+ host: string;
5
+ owner: string;
6
+ name: string;
7
+ }
8
+ /**
9
+ * The repository a remote URL names, or `undefined` if it isn't a GitHub-style
10
+ * URL: `https://host/owner/name(.git)`, `git@host:owner/name(.git)`, or
11
+ * `ssh://git@host[:port]/owner/name(.git)`.
12
+ */
13
+ export declare function parseRemote(url: string): RepositoryRef | undefined;
14
+ /** The checkout's branch and the repositories a pull request for it could be in. */
15
+ export interface CheckoutInfo {
16
+ /** The repository's top-level directory. */
17
+ root: string;
18
+ /** The local branch, or `undefined` when `HEAD` is detached. */
19
+ branch: string | undefined;
20
+ /** The branch's name on its remote (its upstream's name, or the same name). */
21
+ headRef: string | undefined;
22
+ /** The repository the branch is pushed to. */
23
+ head: RepositoryRef | undefined;
24
+ /** Where to look for the pull request: an `upstream` remote first, then `head`. */
25
+ bases: RepositoryRef[];
26
+ /** The commit `HEAD` names. */
27
+ headOid: string;
28
+ }
29
+ /** Reads the checkout at `cwd`. Rejects with a `git` error if it isn't a repository. */
30
+ export declare function readCheckout(cwd: string): Promise<CheckoutInfo>;