@useairfoil/producer-github 0.0.1 → 0.0.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 (59) hide show
  1. package/README.md +116 -0
  2. package/dist/index.d.mts +1939 -0
  3. package/dist/index.mjs +3 -0
  4. package/dist/main.d.mts +1 -0
  5. package/dist/main.mjs +698 -0
  6. package/dist/main.mjs.map +1 -0
  7. package/dist/manifest.d.mts +56 -0
  8. package/dist/manifest.mjs +137 -0
  9. package/dist/manifest.mjs.map +1 -0
  10. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  11. package/dist/src-D6cTmVtF.mjs +1566 -0
  12. package/dist/src-D6cTmVtF.mjs.map +1 -0
  13. package/package.json +45 -7
  14. package/src/client/auth.ts +113 -0
  15. package/src/client/client.ts +192 -0
  16. package/src/client/constants.ts +4 -0
  17. package/src/connector.ts +97 -0
  18. package/src/create-table.ts +5 -0
  19. package/src/demo/changes.ts +420 -0
  20. package/src/demo/index.ts +59 -0
  21. package/src/demo/setup.ts +34 -0
  22. package/src/demo/shared.ts +101 -0
  23. package/src/index.ts +13 -0
  24. package/src/main.ts +22 -0
  25. package/src/manifest.ts +45 -0
  26. package/src/resources/check-runs.ts +72 -0
  27. package/src/resources/commit-statuses.ts +84 -0
  28. package/src/resources/commits.ts +101 -0
  29. package/src/resources/issue-comments.ts +75 -0
  30. package/src/resources/issues.ts +78 -0
  31. package/src/resources/pull-request-commits.ts +91 -0
  32. package/src/resources/pull-request-review-comments.ts +78 -0
  33. package/src/resources/pull-request-reviews.ts +76 -0
  34. package/src/resources/pull-requests.ts +79 -0
  35. package/src/resources/releases.ts +74 -0
  36. package/src/resources/repositories.ts +101 -0
  37. package/src/resources/shared.ts +480 -0
  38. package/src/resources/workflow-jobs.ts +73 -0
  39. package/src/resources/workflow-runs.ts +70 -0
  40. package/src/sandbox.ts +35 -0
  41. package/src/schemas/check-runs.ts +48 -0
  42. package/src/schemas/commit-statuses.ts +31 -0
  43. package/src/schemas/commits.ts +64 -0
  44. package/src/schemas/events.ts +139 -0
  45. package/src/schemas/issue-comments.ts +38 -0
  46. package/src/schemas/issues.ts +62 -0
  47. package/src/schemas/pull-request-commits.ts +28 -0
  48. package/src/schemas/pull-request-review-comments.ts +67 -0
  49. package/src/schemas/pull-request-reviews.ts +37 -0
  50. package/src/schemas/pull-requests.ts +75 -0
  51. package/src/schemas/releases.ts +53 -0
  52. package/src/schemas/repositories.ts +53 -0
  53. package/src/schemas/shared.ts +86 -0
  54. package/src/schemas/workflow-jobs.ts +54 -0
  55. package/src/schemas/workflow-runs.ts +55 -0
  56. package/src/start.ts +47 -0
  57. package/src/tables.ts +31 -0
  58. package/src/webhook/route.ts +46 -0
  59. package/src/webhook/signature.ts +20 -0
@@ -0,0 +1,48 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Timestamp, field, readVersion } from "./shared";
5
+
6
+ export const CheckRunSchema = Schema.Struct({
7
+ id: Long.pipe(field(1, "Unique check run ID.")),
8
+ version: readVersion(2, "check run"),
9
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the check run.")),
10
+ repository_id: Long.pipe(field(4, "ID of the repository the check run belongs to.")),
11
+ head_sha: Schema.String.pipe(field(5, "SHA of the commit the check ran on.")),
12
+ name: Schema.String.pipe(field(6, "Check name.")),
13
+ status: Schema.String.pipe(field(7, "Status, such as queued, in_progress, or completed.")),
14
+ conclusion: Schema.NullOr(Schema.String).pipe(
15
+ field(8, "Result of a completed check, such as success or failure."),
16
+ ),
17
+ started_at: Schema.NullOr(Timestamp).pipe(field(9, "Time the check started.")),
18
+ completed_at: Schema.NullOr(Timestamp).pipe(field(10, "Time the check completed.")),
19
+ app: Schema.NullOr(
20
+ Schema.Struct({
21
+ id: Long.pipe(field(100, "GitHub App ID.")),
22
+ name: Schema.String.pipe(field(101, "GitHub App name.")),
23
+ }),
24
+ ).pipe(field(11, "GitHub App that created the check, such as GitHub Actions.")),
25
+ check_suite: Schema.NullOr(Schema.Struct({ id: Long.pipe(field(102, "Check suite ID.")) })).pipe(
26
+ field(12, "Check suite the check run belongs to."),
27
+ ),
28
+ output: Schema.Struct({
29
+ title: Schema.NullOr(Schema.String).pipe(field(103, "Output title.")),
30
+ summary: Schema.NullOr(Schema.String).pipe(field(104, "Output summary in Markdown.")),
31
+ }).pipe(field(13, "Output the check reported.")),
32
+ external_id: Schema.NullOr(Schema.String).pipe(field(14, "ID the app gave the check.")),
33
+ details_url: Schema.NullOr(Schema.String).pipe(field(15, "Details page from the app.")),
34
+ html_url: Schema.NullOr(Schema.String).pipe(field(16, "Check run page on GitHub.")),
35
+ })
36
+ .annotate({
37
+ description:
38
+ "Check runs, such as GitHub Actions jobs. Polled for default-branch commits; webhooks cover all branches.",
39
+ })
40
+ .pipe(Iceberg.identifier("id"));
41
+
42
+ export type CheckRun = Schema.Schema.Type<typeof CheckRunSchema>;
43
+
44
+ export const CheckRunObjectSchema = CheckRunSchema.mapFields((fields) =>
45
+ Struct.omit(fields, ["version", "repository_id"]),
46
+ );
47
+
48
+ export type CheckRunObject = Schema.Schema.Type<typeof CheckRunObjectSchema>;
@@ -0,0 +1,31 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Text, Timestamp, field, user, version } from "./shared";
5
+
6
+ export const CommitStatusSchema = Schema.Struct({
7
+ id: Long.pipe(field(1, "Unique status ID. Each new status of a context gets a new ID.")),
8
+ version: version(2, "status"),
9
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the status.")),
10
+ repository_id: Long.pipe(field(4, "ID of the repository the status belongs to.")),
11
+ sha: Schema.String.pipe(field(5, "SHA of the commit the status is on.")),
12
+ state: Schema.String.pipe(field(6, "State: error, failure, pending, or success.")),
13
+ context: Schema.String.pipe(field(7, "Label that tells the status apart, such as ci/build.")),
14
+ description: Text.pipe(field(8, "Short description. Empty when not set.")),
15
+ target_url: Schema.NullOr(Schema.String).pipe(field(9, "Link the status points to.")),
16
+ creator: Schema.NullOr(user(100)).pipe(field(10, "Account that created the status.")),
17
+ created_at: Timestamp.pipe(field(11, "Time the status was created.")),
18
+ })
19
+ .annotate({
20
+ description: "Commit statuses. Polled for default-branch commits; webhooks cover all branches.",
21
+ })
22
+ .pipe(Iceberg.identifier("id"));
23
+
24
+ export type CommitStatus = Schema.Schema.Type<typeof CommitStatusSchema>;
25
+
26
+ export const CommitStatusObjectSchema = CommitStatusSchema.mapFields((fields) => ({
27
+ ...Struct.omit(fields, ["version", "repository_id", "sha"]),
28
+ updated_at: Timestamp,
29
+ }));
30
+
31
+ export type CommitStatusObject = Schema.Schema.Type<typeof CommitStatusObjectSchema>;
@@ -0,0 +1,64 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, SchemaTransformation } from "effect";
3
+
4
+ import { Long, Timestamp, field, list, user } from "./shared";
5
+
6
+ export const gitActor = (baseId: number) =>
7
+ Schema.Struct({
8
+ name: Schema.String.pipe(field(baseId, "Name in the commit.")),
9
+ date: Timestamp.pipe(field(baseId + 1, "Time in the commit.")),
10
+ });
11
+
12
+ /**
13
+ * The GitHub account of a commit's author or committer. GitHub sends `null` or
14
+ * `{}` when the email matches no account, and both become `null`.
15
+ */
16
+ export const account = (baseId: number) =>
17
+ Schema.NullOr(Schema.Union([user(baseId), Schema.Struct({})])).pipe(
18
+ Schema.decodeTo(
19
+ Schema.NullOr(Schema.toType(user(baseId))),
20
+ SchemaTransformation.transform({
21
+ decode: (value) => (value !== null && "id" in value ? value : null),
22
+ encode: (value) => value,
23
+ }),
24
+ ),
25
+ );
26
+
27
+ export const CommitSchema = Schema.Struct({
28
+ key: Schema.String.pipe(field(1, "Repository ID and SHA, such as `1406396726:9eb3a7d`.")),
29
+ version: Schema.Date.pipe(field(2, "Commit time. A commit never changes.")),
30
+ repository_id: Long.pipe(field(3, "ID of the repository the commit is in.")),
31
+ sha: Schema.String.pipe(field(4, "Commit SHA.")),
32
+ node_id: Schema.String.pipe(field(5, "GraphQL node ID of the commit.")),
33
+ message: Schema.String.pipe(field(6, "Commit message.")),
34
+ author: gitActor(100).pipe(field(7, "Author name and time from the commit.")),
35
+ committer: gitActor(102).pipe(field(8, "Committer name and time from the commit.")),
36
+ author_user: account(104).pipe(field(9, "GitHub account of the author.")),
37
+ committer_user: account(107).pipe(field(10, "GitHub account of the committer.")),
38
+ parents: list(110, Schema.String).pipe(field(11, "SHAs of the parent commits.")),
39
+ verified: Schema.Boolean.pipe(field(12, "Whether GitHub verified the commit signature.")),
40
+ html_url: Schema.String.pipe(field(13, "Commit page on GitHub.")),
41
+ })
42
+ .annotate({
43
+ description: "Commits on the default branch of the installation's repositories.",
44
+ })
45
+ .pipe(Iceberg.identifier("key"));
46
+
47
+ export type Commit = Schema.Schema.Type<typeof CommitSchema>;
48
+
49
+ export const CommitObjectSchema = Schema.Struct({
50
+ sha: Schema.String,
51
+ node_id: Schema.String,
52
+ commit: Schema.Struct({
53
+ author: gitActor(100),
54
+ committer: gitActor(102),
55
+ message: Schema.String,
56
+ verification: Schema.optionalKey(Schema.Struct({ verified: Schema.Boolean })),
57
+ }),
58
+ author: account(104),
59
+ committer: account(107),
60
+ parents: Schema.Array(Schema.Struct({ sha: Schema.String })),
61
+ html_url: Schema.String,
62
+ });
63
+
64
+ export type CommitObject = Schema.Schema.Type<typeof CommitObjectSchema>;
@@ -0,0 +1,139 @@
1
+ import { Schema, Struct } from "effect";
2
+
3
+ import { IssueCommentObjectSchema } from "./issue-comments";
4
+ import { IssueObjectSchema } from "./issues";
5
+ import { PullRequestReviewCommentObjectSchema } from "./pull-request-review-comments";
6
+ import { PullRequestObjectSchema } from "./pull-requests";
7
+ import { ReleaseObjectSchema } from "./releases";
8
+ import { RepositoryObjectSchema } from "./repositories";
9
+ import { Long, ObjectRefSchema, Timestamp } from "./shared";
10
+ import { WorkflowRunObjectSchema } from "./workflow-runs";
11
+
12
+ /**
13
+ * The webhook route passes the payload on as it is. GitHub puts the event name
14
+ * in a header, so each resource decodes its own event.
15
+ */
16
+ export const WebhookPayloadSchema = Schema.Record(Schema.String, Schema.Unknown);
17
+
18
+ export type WebhookPayload = Schema.Schema.Type<typeof WebhookPayloadSchema>;
19
+
20
+ export const InstallationEventSchema = Schema.Struct({
21
+ installation: Schema.optional(Schema.Struct({ id: Schema.Number })),
22
+ });
23
+
24
+ /** For handlers that read the API again. */
25
+ const RepositoryNameSchema = Schema.Struct({ id: Long, full_name: Schema.String });
26
+
27
+ /** A transferred issue no longer exists in its old repository. */
28
+ export const IssueRemovedEventSchema = Schema.Struct({
29
+ action: Schema.Literals(["deleted", "transferred"]),
30
+ issue: ObjectRefSchema,
31
+ });
32
+
33
+ export const IssuesEventSchema = Schema.Union([
34
+ IssueRemovedEventSchema,
35
+ Schema.Struct({
36
+ action: Schema.String,
37
+ repository: RepositoryNameSchema,
38
+ issue: IssueObjectSchema,
39
+ }),
40
+ ]);
41
+
42
+ export const IssueCommentDeletedEventSchema = Schema.Struct({
43
+ action: Schema.Literal("deleted"),
44
+ comment: ObjectRefSchema,
45
+ });
46
+
47
+ export const IssueCommentEventSchema = Schema.Union([
48
+ IssueCommentDeletedEventSchema,
49
+ Schema.Struct({
50
+ action: Schema.String,
51
+ repository: ObjectRefSchema,
52
+ comment: IssueCommentObjectSchema,
53
+ }),
54
+ ]);
55
+
56
+ export const PullRequestReviewCommentDeletedEventSchema = Schema.Struct({
57
+ action: Schema.Literal("deleted"),
58
+ comment: ObjectRefSchema,
59
+ });
60
+
61
+ export const PullRequestReviewCommentEventSchema = Schema.Union([
62
+ PullRequestReviewCommentDeletedEventSchema,
63
+ Schema.Struct({
64
+ action: Schema.String,
65
+ repository: ObjectRefSchema,
66
+ comment: PullRequestReviewCommentObjectSchema,
67
+ }),
68
+ ]);
69
+
70
+ export const PullRequestEventSchema = Schema.Struct({
71
+ repository: RepositoryNameSchema,
72
+ pull_request: PullRequestObjectSchema,
73
+ });
74
+
75
+ export const RepositoryDeletedEventSchema = Schema.Struct({
76
+ action: Schema.Literal("deleted"),
77
+ repository: ObjectRefSchema,
78
+ });
79
+
80
+ export const RepositoryEventSchema = Schema.Union([
81
+ RepositoryDeletedEventSchema,
82
+ Schema.Struct({ action: Schema.String, repository: RepositoryObjectSchema }),
83
+ ]);
84
+
85
+ export const ReleaseDeletedEventSchema = Schema.Struct({
86
+ action: Schema.Literal("deleted"),
87
+ release: ObjectRefSchema,
88
+ });
89
+
90
+ export const ReleaseEventSchema = Schema.Union([
91
+ ReleaseDeletedEventSchema,
92
+ Schema.Struct({
93
+ action: Schema.String,
94
+ repository: ObjectRefSchema,
95
+ release: ReleaseObjectSchema,
96
+ }),
97
+ ]);
98
+
99
+ export const WorkflowRunEventSchema = Schema.Struct({
100
+ repository: ObjectRefSchema,
101
+ workflow_run: WorkflowRunObjectSchema,
102
+ });
103
+
104
+ export const PushEventSchema = Schema.Struct({
105
+ ref: Schema.String,
106
+ before: Schema.String,
107
+ after: Schema.String,
108
+ repository: RepositoryNameSchema.mapFields(Struct.assign({ default_branch: Schema.String })),
109
+ });
110
+
111
+ export const PullRequestReviewEventSchema = Schema.Struct({
112
+ repository: RepositoryNameSchema,
113
+ pull_request: Schema.Struct({ number: Long }),
114
+ review: ObjectRefSchema,
115
+ });
116
+
117
+ export const PullRequestCommitsEventSchema = Schema.Struct({
118
+ action: Schema.String,
119
+ changes: Schema.optionalKey(Schema.Struct({ base: Schema.optionalKey(Schema.Unknown) })),
120
+ repository: RepositoryNameSchema,
121
+ pull_request: Schema.Struct({ number: Long, updated_at: Timestamp }),
122
+ });
123
+
124
+ export const CheckRunEventSchema = Schema.Struct({
125
+ repository: RepositoryNameSchema,
126
+ check_run: ObjectRefSchema,
127
+ });
128
+
129
+ export const WorkflowJobEventSchema = Schema.Struct({
130
+ repository: RepositoryNameSchema,
131
+ workflow_job: ObjectRefSchema,
132
+ });
133
+
134
+ /** The status payload is flat. */
135
+ export const StatusEventSchema = Schema.Struct({
136
+ id: Long,
137
+ sha: Schema.String,
138
+ repository: RepositoryNameSchema,
139
+ });
@@ -0,0 +1,38 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Text, Timestamp, deleted, field, user, version } from "./shared";
5
+
6
+ export const IssueCommentSchema = Schema.Struct({
7
+ id: Long.pipe(field(1, "Unique comment ID.")),
8
+ version: version(2, "comment"),
9
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the comment.")),
10
+ repository_id: Long.pipe(field(4, "ID of the repository the comment belongs to.")),
11
+ issue_number: Long.pipe(
12
+ field(5, "Number of the issue or pull request the comment is on, in its repository."),
13
+ ),
14
+ user: Schema.NullOr(user(100)).pipe(field(6, "Account that wrote the comment.")),
15
+ author_association: Schema.String.pipe(
16
+ field(7, "Author's relation to the repository, such as OWNER or CONTRIBUTOR."),
17
+ ),
18
+ body: Text.pipe(field(8, "Comment in Markdown. Empty when not set.")),
19
+ created_at: Timestamp.pipe(field(9, "Time the comment was written.")),
20
+ html_url: Schema.String.pipe(field(10, "Comment on GitHub.")),
21
+ _deleted: deleted(11, "comment"),
22
+ })
23
+ .annotate({
24
+ description:
25
+ "Comments on issues and pull requests. Pull request review comments are not included.",
26
+ })
27
+ .pipe(Iceberg.identifier("id"));
28
+
29
+ export type IssueComment = Schema.Schema.Type<typeof IssueCommentSchema>;
30
+
31
+ export const IssueCommentObjectSchema = IssueCommentSchema.mapFields((fields) => ({
32
+ ...Struct.omit(fields, ["version", "repository_id", "issue_number", "_deleted"]),
33
+ updated_at: Timestamp,
34
+ // The list has no issue number, only this URL, which ends in it.
35
+ issue_url: Schema.String.check(Schema.isPattern(/\/issues\/\d+$/)),
36
+ }));
37
+
38
+ export type IssueCommentObject = Schema.Schema.Type<typeof IssueCommentObjectSchema>;
@@ -0,0 +1,62 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import {
5
+ Long,
6
+ Text,
7
+ Timestamp,
8
+ deleted,
9
+ field,
10
+ label,
11
+ list,
12
+ milestone,
13
+ optionalList,
14
+ user,
15
+ version,
16
+ } from "./shared";
17
+
18
+ export const IssueSchema = Schema.Struct({
19
+ id: Long.pipe(field(1, "Unique issue ID.")),
20
+ version: version(2, "issue"),
21
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the issue.")),
22
+ repository_id: Long.pipe(field(4, "ID of the repository the issue belongs to.")),
23
+ number: Long.pipe(field(5, "Issue number in the repository.")),
24
+ title: Schema.String.pipe(field(6, "Issue title.")),
25
+ body: Text.pipe(field(7, "Issue description in Markdown. Empty when not set.")),
26
+ state: Schema.String.pipe(field(8, "State: open or closed.")),
27
+ state_reason: Schema.NullOr(Schema.String).pipe(
28
+ field(9, "Why the issue was closed or reopened, such as completed or not_planned."),
29
+ ),
30
+ locked: Schema.Boolean.pipe(field(10, "Whether the conversation is locked.")),
31
+ user: Schema.NullOr(user(100)).pipe(field(11, "Account that opened the issue.")),
32
+ author_association: Schema.String.pipe(
33
+ field(12, "Author's relation to the repository, such as OWNER or CONTRIBUTOR."),
34
+ ),
35
+ labels: list(103, label(104)).pipe(field(13, "Labels on the issue.")),
36
+ assignees: list(106, user(107)).pipe(field(14, "Accounts assigned to the issue.")),
37
+ milestone: Schema.NullOr(milestone(110)).pipe(field(15, "Milestone of the issue.")),
38
+ comments: Long.pipe(field(16, "Number of comments.")),
39
+ created_at: Timestamp.pipe(field(17, "Time the issue was opened.")),
40
+ closed_at: Schema.NullOr(Timestamp).pipe(
41
+ field(18, "Time the issue was closed. Null while it is open."),
42
+ ),
43
+ html_url: Schema.String.pipe(field(19, "Issue page on GitHub.")),
44
+ _deleted: deleted(20, "issue"),
45
+ })
46
+ .annotate({
47
+ description: "Issues in the installation's repositories. Pull requests are not included.",
48
+ })
49
+ .pipe(Iceberg.identifier("id"));
50
+
51
+ export type Issue = Schema.Schema.Type<typeof IssueSchema>;
52
+
53
+ export const IssueObjectSchema = IssueSchema.mapFields((fields) => ({
54
+ ...Struct.omit(fields, ["version", "repository_id", "labels", "assignees", "_deleted"]),
55
+ updated_at: Timestamp,
56
+ labels: optionalList(label(104)),
57
+ assignees: optionalList(user(107)),
58
+ // Set on pull requests, which the issues list also returns.
59
+ pull_request: Schema.optionalKey(Schema.Unknown),
60
+ }));
61
+
62
+ export type IssueObject = Schema.Schema.Type<typeof IssueObjectSchema>;
@@ -0,0 +1,28 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema } from "effect";
3
+
4
+ import { account, gitActor } from "./commits";
5
+ import { Long, field } from "./shared";
6
+
7
+ export const PullRequestCommitSchema = Schema.Struct({
8
+ key: Schema.String.pipe(
9
+ field(1, "Repository ID, pull request number, and SHA, such as `1406396726:3:9eb3a7d`."),
10
+ ),
11
+ version: Schema.Date.pipe(field(2, "Time GitHub last updated the pull request.")),
12
+ repository_id: Long.pipe(field(3, "ID of the repository the pull request belongs to.")),
13
+ pull_request_number: Long.pipe(field(4, "Pull request number in the repository.")),
14
+ sha: Schema.String.pipe(field(5, "Commit SHA.")),
15
+ message: Schema.String.pipe(field(6, "Commit message.")),
16
+ author: gitActor(100).pipe(field(7, "Author name and time from the commit.")),
17
+ committer: gitActor(102).pipe(field(8, "Committer name and time from the commit.")),
18
+ author_user: account(104).pipe(field(9, "GitHub account of the author.")),
19
+ committer_user: account(107).pipe(field(10, "GitHub account of the committer.")),
20
+ html_url: Schema.String.pipe(field(11, "Commit page on GitHub.")),
21
+ })
22
+ .annotate({
23
+ description:
24
+ "Commits in pull requests, up to 250 per pull request. Commits removed by a force push stay.",
25
+ })
26
+ .pipe(Iceberg.identifier("key"));
27
+
28
+ export type PullRequestCommit = Schema.Schema.Type<typeof PullRequestCommitSchema>;
@@ -0,0 +1,67 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Timestamp, deleted, field, user, version } from "./shared";
5
+
6
+ export const PullRequestReviewCommentSchema = Schema.Struct({
7
+ id: Long.pipe(field(1, "Unique review comment ID.")),
8
+ version: version(2, "review comment"),
9
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the review comment.")),
10
+ repository_id: Long.pipe(field(4, "ID of the repository the comment belongs to.")),
11
+ pull_request_number: Long.pipe(
12
+ field(5, "Number of the pull request the comment is on, in its repository."),
13
+ ),
14
+ pull_request_review_id: Schema.NullOr(Long).pipe(
15
+ field(6, "ID of the review the comment belongs to."),
16
+ ),
17
+ in_reply_to_id: Schema.optionalKey(Long).pipe(field(7, "ID of the comment this one replies to.")),
18
+ user: Schema.NullOr(user(100)).pipe(field(8, "Account that wrote the comment.")),
19
+ author_association: Schema.String.pipe(
20
+ field(9, "Author's relation to the repository, such as OWNER or CONTRIBUTOR."),
21
+ ),
22
+ body: Schema.String.pipe(field(10, "Comment in Markdown.")),
23
+ path: Schema.String.pipe(field(11, "Path of the file the comment is on.")),
24
+ commit_id: Schema.String.pipe(field(12, "SHA of the commit the comment is on now.")),
25
+ original_commit_id: Schema.String.pipe(
26
+ field(13, "SHA of the commit the comment was written on."),
27
+ ),
28
+ diff_hunk: Schema.String.pipe(field(14, "Part of the diff the comment is on.")),
29
+ // GitHub sends null for a comment on a line that is no longer in the diff.
30
+ line: Schema.optionalKey(Schema.NullOr(Long)).pipe(
31
+ field(15, "Last line of the commented range in the current diff."),
32
+ ),
33
+ original_line: Schema.optionalKey(Schema.NullOr(Long)).pipe(
34
+ field(16, "Last line of the commented range in the original diff."),
35
+ ),
36
+ start_line: Schema.optionalKey(Schema.NullOr(Long)).pipe(
37
+ field(17, "First line of a multi-line comment."),
38
+ ),
39
+ side: Schema.optionalKey(Schema.NullOr(Schema.String)).pipe(
40
+ field(18, "Side of the diff: LEFT or RIGHT."),
41
+ ),
42
+ subject_type: Schema.optionalKey(Schema.String).pipe(
43
+ field(19, "What the comment is on: line or file."),
44
+ ),
45
+ created_at: Timestamp.pipe(field(20, "Time the comment was written.")),
46
+ html_url: Schema.String.pipe(field(21, "Comment on GitHub.")),
47
+ _deleted: deleted(22, "review comment"),
48
+ })
49
+ .annotate({
50
+ description: "Review comments on pull request diffs.",
51
+ })
52
+ .pipe(Iceberg.identifier("id"));
53
+
54
+ export type PullRequestReviewComment = Schema.Schema.Type<typeof PullRequestReviewCommentSchema>;
55
+
56
+ export const PullRequestReviewCommentObjectSchema = PullRequestReviewCommentSchema.mapFields(
57
+ (fields) => ({
58
+ ...Struct.omit(fields, ["version", "repository_id", "pull_request_number", "_deleted"]),
59
+ updated_at: Timestamp,
60
+ // The list has no pull request number, only this URL, which ends in it.
61
+ pull_request_url: Schema.String.check(Schema.isPattern(/\/pulls\/\d+$/)),
62
+ }),
63
+ );
64
+
65
+ export type PullRequestReviewCommentObject = Schema.Schema.Type<
66
+ typeof PullRequestReviewCommentObjectSchema
67
+ >;
@@ -0,0 +1,37 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Timestamp, field, readVersion, user } from "./shared";
5
+
6
+ export const PullRequestReviewSchema = Schema.Struct({
7
+ id: Long.pipe(field(1, "Unique review ID.")),
8
+ version: readVersion(2, "review"),
9
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the review.")),
10
+ repository_id: Long.pipe(field(4, "ID of the repository the review belongs to.")),
11
+ pull_request_number: Long.pipe(
12
+ field(5, "Number of the pull request the review is on, in its repository."),
13
+ ),
14
+ user: Schema.NullOr(user(100)).pipe(field(6, "Account that wrote the review.")),
15
+ author_association: Schema.String.pipe(
16
+ field(7, "Author's relation to the repository, such as OWNER or CONTRIBUTOR."),
17
+ ),
18
+ state: Schema.String.pipe(
19
+ field(8, "State, such as APPROVED, CHANGES_REQUESTED, COMMENTED, or DISMISSED."),
20
+ ),
21
+ body: Schema.String.pipe(field(9, "Review summary in Markdown.")),
22
+ commit_id: Schema.NullOr(Schema.String).pipe(field(10, "SHA of the commit the review is on.")),
23
+ submitted_at: Schema.optionalKey(Timestamp).pipe(field(11, "Time the review was submitted.")),
24
+ html_url: Schema.String.pipe(field(12, "Review on GitHub.")),
25
+ })
26
+ .annotate({
27
+ description: "Reviews on pull requests. Pending reviews are only visible to their author.",
28
+ })
29
+ .pipe(Iceberg.identifier("id"));
30
+
31
+ export type PullRequestReview = Schema.Schema.Type<typeof PullRequestReviewSchema>;
32
+
33
+ export const PullRequestReviewObjectSchema = PullRequestReviewSchema.mapFields((fields) =>
34
+ Struct.omit(fields, ["version", "repository_id", "pull_request_number"]),
35
+ );
36
+
37
+ export type PullRequestReviewObject = Schema.Schema.Type<typeof PullRequestReviewObjectSchema>;
@@ -0,0 +1,75 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import {
5
+ Long,
6
+ Text,
7
+ Timestamp,
8
+ field,
9
+ label,
10
+ list,
11
+ milestone,
12
+ optionalList,
13
+ user,
14
+ version,
15
+ } from "./shared";
16
+
17
+ const branch = (baseId: number) =>
18
+ Schema.Struct({
19
+ ref: Schema.String.pipe(field(baseId, "Branch name.")),
20
+ sha: Schema.String.pipe(field(baseId + 1, "Commit SHA.")),
21
+ label: Schema.String.pipe(field(baseId + 2, "Owner and branch, such as octocat:main.")),
22
+ });
23
+
24
+ export const PullRequestSchema = Schema.Struct({
25
+ id: Long.pipe(field(1, "Unique pull request ID. Not the ID of its issue.")),
26
+ version: version(2, "pull request"),
27
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the pull request.")),
28
+ repository_id: Long.pipe(field(4, "ID of the repository the pull request belongs to.")),
29
+ number: Long.pipe(field(5, "Pull request number in the repository.")),
30
+ title: Schema.String.pipe(field(6, "Pull request title.")),
31
+ body: Text.pipe(field(7, "Pull request description in Markdown. Empty when not set.")),
32
+ state: Schema.String.pipe(field(8, "State: open or closed. Merged pull requests are closed.")),
33
+ draft: Schema.optionalKey(Schema.Boolean).pipe(field(9, "Whether the pull request is a draft.")),
34
+ locked: Schema.Boolean.pipe(field(10, "Whether the conversation is locked.")),
35
+ user: Schema.NullOr(user(100)).pipe(field(11, "Account that opened the pull request.")),
36
+ author_association: Schema.String.pipe(
37
+ field(12, "Author's relation to the repository, such as OWNER or CONTRIBUTOR."),
38
+ ),
39
+ labels: list(103, label(104)).pipe(field(13, "Labels on the pull request.")),
40
+ assignees: list(106, user(107)).pipe(field(14, "Accounts assigned to the pull request.")),
41
+ requested_reviewers: list(110, user(111)).pipe(
42
+ field(15, "Accounts asked to review that have not reviewed yet."),
43
+ ),
44
+ milestone: Schema.NullOr(milestone(114)).pipe(field(16, "Milestone of the pull request.")),
45
+ head: branch(117).pipe(field(17, "Branch the changes come from.")),
46
+ base: branch(120).pipe(field(18, "Branch the changes merge into.")),
47
+ created_at: Timestamp.pipe(field(19, "Time the pull request was opened.")),
48
+ closed_at: Schema.NullOr(Timestamp).pipe(
49
+ field(20, "Time the pull request was closed. Null while it is open."),
50
+ ),
51
+ merged_at: Schema.NullOr(Timestamp).pipe(field(21, "Time the pull request was merged.")),
52
+ html_url: Schema.String.pipe(field(22, "Pull request page on GitHub.")),
53
+ })
54
+ .annotate({
55
+ description: "Pull requests in the installation's repositories.",
56
+ })
57
+ .pipe(Iceberg.identifier("id"));
58
+
59
+ export type PullRequest = Schema.Schema.Type<typeof PullRequestSchema>;
60
+
61
+ export const PullRequestObjectSchema = PullRequestSchema.mapFields((fields) => ({
62
+ ...Struct.omit(fields, [
63
+ "version",
64
+ "repository_id",
65
+ "labels",
66
+ "assignees",
67
+ "requested_reviewers",
68
+ ]),
69
+ updated_at: Timestamp,
70
+ labels: optionalList(label(104)),
71
+ assignees: optionalList(user(107)),
72
+ requested_reviewers: optionalList(user(111)),
73
+ }));
74
+
75
+ export type PullRequestObject = Schema.Schema.Type<typeof PullRequestObjectSchema>;
@@ -0,0 +1,53 @@
1
+ import { Iceberg } from "@useairfoil/connector-kit";
2
+ import { Schema, Struct } from "effect";
3
+
4
+ import { Long, Text, Timestamp, deleted, field, list, user, version } from "./shared";
5
+
6
+ const asset = (baseId: number) =>
7
+ Schema.Struct({
8
+ id: Long.pipe(field(baseId, "Asset ID.")),
9
+ name: Schema.String.pipe(field(baseId + 1, "File name.")),
10
+ label: Schema.NullOr(Schema.String).pipe(field(baseId + 2, "Label shown instead of the name.")),
11
+ state: Schema.String.pipe(field(baseId + 3, "State: uploaded or open.")),
12
+ content_type: Schema.String.pipe(field(baseId + 4, "Media type of the file.")),
13
+ size: Long.pipe(field(baseId + 5, "Size in bytes.")),
14
+ download_count: Long.pipe(
15
+ field(baseId + 6, "Number of downloads when the release last changed."),
16
+ ),
17
+ created_at: Timestamp.pipe(field(baseId + 7, "Time the asset was uploaded.")),
18
+ updated_at: Timestamp.pipe(field(baseId + 8, "Time the asset last changed.")),
19
+ browser_download_url: Schema.String.pipe(field(baseId + 9, "Download link.")),
20
+ });
21
+
22
+ export const ReleaseSchema = Schema.Struct({
23
+ id: Long.pipe(field(1, "Unique release ID.")),
24
+ version: version(2, "release"),
25
+ node_id: Schema.String.pipe(field(3, "GraphQL node ID of the release.")),
26
+ repository_id: Long.pipe(field(4, "ID of the repository the release belongs to.")),
27
+ tag_name: Schema.String.pipe(field(5, "Tag of the release.")),
28
+ target_commitish: Schema.String.pipe(field(6, "Branch or commit the tag was created from.")),
29
+ name: Text.pipe(field(7, "Release title. Empty when not set.")),
30
+ body: Text.pipe(field(8, "Release notes in Markdown. Empty when not set.")),
31
+ draft: Schema.Boolean.pipe(field(9, "Whether the release is a draft.")),
32
+ prerelease: Schema.Boolean.pipe(field(10, "Whether the release is a pre-release.")),
33
+ author: user(100).pipe(field(11, "Account that created the release.")),
34
+ assets: list(103, asset(104)).pipe(field(12, "Files attached to the release.")),
35
+ created_at: Timestamp.pipe(field(13, "Time the release was created.")),
36
+ published_at: Schema.NullOr(Timestamp).pipe(field(14, "Time the release was published.")),
37
+ html_url: Schema.String.pipe(field(15, "Release page on GitHub.")),
38
+ _deleted: deleted(16, "release"),
39
+ })
40
+ .annotate({
41
+ description: "Releases in the installation's repositories, with their assets.",
42
+ })
43
+ .pipe(Iceberg.identifier("id"));
44
+
45
+ export type Release = Schema.Schema.Type<typeof ReleaseSchema>;
46
+
47
+ export const ReleaseObjectSchema = ReleaseSchema.mapFields((fields) => ({
48
+ ...Struct.omit(fields, ["version", "repository_id", "_deleted"]),
49
+ // Not always set, according to the API schema.
50
+ updated_at: Schema.optionalKey(Schema.NullOr(Timestamp)),
51
+ }));
52
+
53
+ export type ReleaseObject = Schema.Schema.Type<typeof ReleaseObjectSchema>;