@useairfoil/producer-github 0.0.1 → 0.0.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 (60) hide show
  1. package/LICENSE.txt +201 -0
  2. package/README.md +116 -0
  3. package/dist/index.d.mts +1939 -0
  4. package/dist/index.mjs +3 -0
  5. package/dist/main.d.mts +1 -0
  6. package/dist/main.mjs +700 -0
  7. package/dist/main.mjs.map +1 -0
  8. package/dist/manifest.d.mts +56 -0
  9. package/dist/manifest.mjs +137 -0
  10. package/dist/manifest.mjs.map +1 -0
  11. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  12. package/dist/src-DKDUc00e.mjs +1563 -0
  13. package/dist/src-DKDUc00e.mjs.map +1 -0
  14. package/package.json +46 -8
  15. package/src/client/auth.ts +113 -0
  16. package/src/client/client.ts +192 -0
  17. package/src/client/constants.ts +4 -0
  18. package/src/connector.ts +97 -0
  19. package/src/create-table.ts +10 -0
  20. package/src/demo/changes.ts +420 -0
  21. package/src/demo/index.ts +59 -0
  22. package/src/demo/setup.ts +34 -0
  23. package/src/demo/shared.ts +101 -0
  24. package/src/index.ts +13 -0
  25. package/src/main.ts +28 -0
  26. package/src/manifest.ts +45 -0
  27. package/src/resources/check-runs.ts +72 -0
  28. package/src/resources/commit-statuses.ts +84 -0
  29. package/src/resources/commits.ts +101 -0
  30. package/src/resources/issue-comments.ts +75 -0
  31. package/src/resources/issues.ts +78 -0
  32. package/src/resources/pull-request-commits.ts +91 -0
  33. package/src/resources/pull-request-review-comments.ts +78 -0
  34. package/src/resources/pull-request-reviews.ts +76 -0
  35. package/src/resources/pull-requests.ts +79 -0
  36. package/src/resources/releases.ts +74 -0
  37. package/src/resources/repositories.ts +101 -0
  38. package/src/resources/shared.ts +480 -0
  39. package/src/resources/workflow-jobs.ts +73 -0
  40. package/src/resources/workflow-runs.ts +70 -0
  41. package/src/sandbox.ts +35 -0
  42. package/src/schemas/check-runs.ts +72 -0
  43. package/src/schemas/commit-statuses.ts +51 -0
  44. package/src/schemas/commits.ts +80 -0
  45. package/src/schemas/events.ts +139 -0
  46. package/src/schemas/issue-comments.ts +48 -0
  47. package/src/schemas/issues.ts +76 -0
  48. package/src/schemas/pull-request-commits.ts +42 -0
  49. package/src/schemas/pull-request-review-comments.ts +85 -0
  50. package/src/schemas/pull-request-reviews.ts +53 -0
  51. package/src/schemas/pull-requests.ts +95 -0
  52. package/src/schemas/releases.ts +70 -0
  53. package/src/schemas/repositories.ts +73 -0
  54. package/src/schemas/shared.ts +76 -0
  55. package/src/schemas/workflow-jobs.ts +78 -0
  56. package/src/schemas/workflow-runs.ts +72 -0
  57. package/src/start.ts +47 -0
  58. package/src/tables.ts +31 -0
  59. package/src/webhook/route.ts +46 -0
  60. package/src/webhook/signature.ts +20 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { C as auth_exports, S as client_exports, _ as IssueObjectSchema, b as IssueCommentSchema, d as RepositoryObjectSchema, f as RepositorySchema, h as PullRequestSchema, i as webhookPath, m as PullRequestObjectSchema, n as connector_exports, v as IssueSchema, y as IssueCommentObjectSchema } from "./src-DKDUc00e.mjs";
2
+ import { manifest } from "./manifest.mjs";
3
+ export { auth_exports as GitHubAuth, client_exports as GitHubClient, connector_exports as GitHubConnector, IssueCommentObjectSchema, IssueCommentSchema, IssueObjectSchema, IssueSchema, PullRequestObjectSchema, PullRequestSchema, RepositoryObjectSchema, RepositorySchema, manifest, webhookPath };
@@ -0,0 +1 @@
1
+ export {}
package/dist/main.mjs ADDED
@@ -0,0 +1,700 @@
1
+ #!/usr/bin/env node
2
+ import { a as WorkflowJobSchema, b as IssueCommentSchema, c as CommitStatusSchema, f as RepositorySchema, g as PullRequestReviewCommentSchema, h as PullRequestSchema, l as CommitSchema, o as PullRequestReviewSchema, p as ReleaseSchema, r as layerConfig, s as PullRequestCommitSchema, t as GitHubConnector, u as WorkflowRunSchema, v as IssueSchema, x as CheckRunSchema } from "./src-DKDUc00e.mjs";
3
+ import { GitHubConfigDef } from "./manifest.mjs";
4
+ import { ConnectorApp, Demo, Ingestor, RuntimeConfig, StateStore, Telemetry } from "@useairfoil/connector-kit";
5
+ import { Config, Duration, Effect, Layer, Logger, Schema } from "effect";
6
+ import { FetchHttpClient } from "effect/http";
7
+ import { NodeRuntime, NodeServices } from "@effect/platform-node";
8
+ import { Command } from "effect/cli";
9
+ import { PgClient } from "@effect/sql-pg";
10
+ //#region package.json
11
+ var version = "0.0.3";
12
+ //#endregion
13
+ //#region src/tables.ts
14
+ const tableSchemas = {
15
+ repositories: RepositorySchema,
16
+ issues: IssueSchema,
17
+ pull_requests: PullRequestSchema,
18
+ issue_comments: IssueCommentSchema,
19
+ pull_request_reviews: PullRequestReviewSchema,
20
+ pull_request_review_comments: PullRequestReviewCommentSchema,
21
+ pull_request_commits: PullRequestCommitSchema,
22
+ commits: CommitSchema,
23
+ check_runs: CheckRunSchema,
24
+ commit_statuses: CommitStatusSchema,
25
+ workflow_runs: WorkflowRunSchema,
26
+ workflow_jobs: WorkflowJobSchema,
27
+ releases: ReleaseSchema
28
+ };
29
+ //#endregion
30
+ //#region src/create-table.ts
31
+ const createTableCommand = ConnectorApp.makeCreateTableCommand(tableSchemas);
32
+ const setupCommand = ConnectorApp.makeSetupCommand(tableSchemas).pipe(Command.provide(RuntimeConfig.layerHosted()));
33
+ //#endregion
34
+ //#region src/demo/shared.ts
35
+ const day = Duration.toMillis(Duration.days(1));
36
+ const minute = Duration.toMillis(Duration.minutes(1));
37
+ const org = "acme-labs";
38
+ const owner = {
39
+ id: 91000000n,
40
+ login: org,
41
+ type: "Organization"
42
+ };
43
+ const people = [
44
+ "mara-ellis",
45
+ "dkowalski",
46
+ "jin-park",
47
+ "sofia-rojas",
48
+ "tbrennan",
49
+ "amir-haddad",
50
+ "lucy-chen",
51
+ "oscar-mendez",
52
+ "priya-nair",
53
+ "felix-weber",
54
+ "nadia-kova",
55
+ "ben-ortiz"
56
+ ].map((login, k) => ({
57
+ id: BigInt(5e7 + k),
58
+ login,
59
+ type: "User"
60
+ }));
61
+ const actionsBot = {
62
+ id: 41898282n,
63
+ login: "github-actions[bot]",
64
+ type: "Bot"
65
+ };
66
+ const repositories = [
67
+ {
68
+ name: "api",
69
+ language: "Go",
70
+ topics: ["api", "backend"],
71
+ description: "Public REST API"
72
+ },
73
+ {
74
+ name: "web",
75
+ language: "TypeScript",
76
+ topics: ["frontend", "react"],
77
+ description: "Web app"
78
+ },
79
+ {
80
+ name: "mobile",
81
+ language: "Kotlin",
82
+ topics: ["android"],
83
+ description: "Android app"
84
+ },
85
+ {
86
+ name: "infra",
87
+ language: "HCL",
88
+ topics: ["terraform"],
89
+ description: "Cloud infrastructure"
90
+ },
91
+ {
92
+ name: "docs",
93
+ language: "MDX",
94
+ topics: ["documentation"],
95
+ description: "Product docs"
96
+ },
97
+ {
98
+ name: "sdk-js",
99
+ language: "TypeScript",
100
+ topics: ["sdk"],
101
+ description: "JavaScript SDK"
102
+ }
103
+ ];
104
+ const repositoryId = (r) => BigInt(7e8 + r);
105
+ const labels = [
106
+ {
107
+ id: 6100000001n,
108
+ name: "bug"
109
+ },
110
+ {
111
+ id: 6100000002n,
112
+ name: "enhancement"
113
+ },
114
+ {
115
+ id: 6100000003n,
116
+ name: "documentation"
117
+ },
118
+ {
119
+ id: 6100000004n,
120
+ name: "good first issue"
121
+ }
122
+ ];
123
+ const verbs = [
124
+ "Fix",
125
+ "Add",
126
+ "Improve",
127
+ "Update",
128
+ "Remove",
129
+ "Refactor",
130
+ "Support"
131
+ ];
132
+ const paths = [
133
+ "src/server.ts",
134
+ "src/client.ts",
135
+ "src/routes/users.ts",
136
+ "src/lib/cache.ts",
137
+ "README.md"
138
+ ];
139
+ const nodeId = (prefix, id) => `${prefix}_kwDO${id.toString(16).toUpperCase()}`;
140
+ const urlOf = (repo) => `https://github.com/${org}/${repo.name}`;
141
+ /** Date helpers for one run. `at` keeps a time from going past now. */
142
+ const clock = ({ faker, now }) => {
143
+ const at = (time) => new Date(Math.min(time, now.getTime()));
144
+ const later = (from, min, max) => at(from.getTime() + faker.number.int({
145
+ min,
146
+ max
147
+ }));
148
+ return {
149
+ at,
150
+ later
151
+ };
152
+ };
153
+ //#endregion
154
+ //#region src/demo/changes.ts
155
+ /**
156
+ * One group is one change in a repository: an issue, the pull request that
157
+ * fixes it, and its CI.
158
+ */
159
+ const changeRows = (index, context) => {
160
+ const { faker, now } = context;
161
+ const { at, later } = clock(context);
162
+ const rows = {
163
+ issues: [],
164
+ pull_requests: [],
165
+ issue_comments: [],
166
+ pull_request_reviews: [],
167
+ pull_request_review_comments: [],
168
+ pull_request_commits: [],
169
+ commits: [],
170
+ check_runs: [],
171
+ commit_statuses: [],
172
+ workflow_runs: [],
173
+ workflow_jobs: [],
174
+ releases: []
175
+ };
176
+ const r = index % repositories.length;
177
+ const repo = repositories[r] ?? repositories[0];
178
+ const repoId = repositoryId(r);
179
+ const round = Math.floor(index / repositories.length);
180
+ const issueNumber = BigInt(round * 2 + 1);
181
+ const prNumber = BigInt(round * 2 + 2);
182
+ const id = BigInt(index);
183
+ const author = faker.helpers.arrayElement(people);
184
+ const reviewer = faker.helpers.arrayElement(people.filter((person) => person !== author));
185
+ const association = (account) => account.type === "Bot" ? "NONE" : "MEMBER";
186
+ const title = `${faker.helpers.arrayElement(verbs)} ${faker.hacker.adjective()} ${faker.hacker.noun()} handling`;
187
+ const label = faker.helpers.arrayElement(labels);
188
+ const opened = at(now.getTime() - faker.number.int({
189
+ min: day,
190
+ max: 600 * day
191
+ }));
192
+ const comment = (issueNumber, n, created) => {
193
+ const commentId = 1800000000n + id * 10n + BigInt(n);
194
+ const user = faker.helpers.arrayElement(people);
195
+ return {
196
+ id: commentId,
197
+ version: created,
198
+ node_id: nodeId("IC", commentId),
199
+ repository_id: repoId,
200
+ issue_number: issueNumber,
201
+ user,
202
+ author_association: association(user),
203
+ body: faker.helpers.arrayElement([
204
+ "I can reproduce this on the latest release.",
205
+ "Thanks for the report. Looking into it.",
206
+ "This should be fixed once the pull request lands.",
207
+ "Can we add a test for this case?",
208
+ "LGTM, thanks!"
209
+ ]),
210
+ created_at: created,
211
+ html_url: `${urlOf(repo)}/issues/${issueNumber}#issuecomment-${commentId}`
212
+ };
213
+ };
214
+ const fixed = faker.datatype.boolean({ probability: .75 });
215
+ const issueComments = Array.from({ length: faker.number.int({ max: 3 }) }, (_, n) => comment(issueNumber, n, later(opened, minute, 5 * day)));
216
+ rows.issue_comments.push(...issueComments);
217
+ const branch = `${author.login.split("-")[0]}/${title.toLowerCase().split(" ").slice(1, 3).join("-")}`;
218
+ const prOpened = later(opened, 60 * minute, 7 * day);
219
+ const prState = faker.helpers.weightedArrayElement([
220
+ {
221
+ weight: 70,
222
+ value: "merged"
223
+ },
224
+ {
225
+ weight: 10,
226
+ value: "closed"
227
+ },
228
+ {
229
+ weight: 20,
230
+ value: "open"
231
+ }
232
+ ]);
233
+ const baseSha = faker.git.commitSha();
234
+ let committed = prOpened;
235
+ const shas = Array.from({ length: faker.number.int({
236
+ min: 1,
237
+ max: 4
238
+ }) }, (_, n) => {
239
+ committed = later(committed, 10 * minute, day);
240
+ return {
241
+ sha: faker.git.commitSha(),
242
+ message: n === 0 ? title : faker.git.commitMessage(),
243
+ at: committed
244
+ };
245
+ });
246
+ const headSha = shas.at(-1)?.sha ?? baseSha;
247
+ const reviewed = later(committed, 30 * minute, 2 * day);
248
+ const closedAt = prState === "open" ? null : later(reviewed, 10 * minute, day);
249
+ const mergedAt = prState === "merged" ? closedAt : null;
250
+ const prComments = Array.from({ length: faker.number.int({ max: 2 }) }, (_, n) => comment(prNumber, 5 + n, later(prOpened, minute, 2 * day)));
251
+ rows.issue_comments.push(...prComments);
252
+ const prUpdated = new Date(Math.max(closedAt?.getTime() ?? 0, reviewed.getTime(), ...prComments.map((row) => row.created_at.getTime())));
253
+ const prId = 1500000000n + id;
254
+ rows.pull_requests.push({
255
+ id: prId,
256
+ version: prUpdated,
257
+ node_id: nodeId("PR", prId),
258
+ repository_id: repoId,
259
+ number: prNumber,
260
+ title,
261
+ body: `Fixes #${issueNumber}.\n\n${faker.hacker.phrase()}`,
262
+ state: prState === "open" ? "open" : "closed",
263
+ draft: prState === "open" && faker.datatype.boolean({ probability: .2 }),
264
+ locked: false,
265
+ user: author,
266
+ author_association: "MEMBER",
267
+ labels: [label],
268
+ assignees: [author],
269
+ requested_reviewers: prState === "open" ? [reviewer] : [],
270
+ milestone: null,
271
+ head: {
272
+ ref: branch,
273
+ sha: headSha,
274
+ label: `${org}:${branch}`
275
+ },
276
+ base: {
277
+ ref: "main",
278
+ sha: baseSha,
279
+ label: `${org}:main`
280
+ },
281
+ created_at: prOpened,
282
+ closed_at: closedAt,
283
+ merged_at: mergedAt,
284
+ html_url: `${urlOf(repo)}/pull/${prNumber}`
285
+ });
286
+ for (const commit of shas) rows.pull_request_commits.push({
287
+ key: `${repoId}:${prNumber}:${commit.sha}`,
288
+ version: prUpdated,
289
+ repository_id: repoId,
290
+ pull_request_number: prNumber,
291
+ sha: commit.sha,
292
+ message: commit.message,
293
+ author: {
294
+ name: author.login,
295
+ date: commit.at
296
+ },
297
+ committer: {
298
+ name: author.login,
299
+ date: commit.at
300
+ },
301
+ author_user: author,
302
+ committer_user: author,
303
+ html_url: `${urlOf(repo)}/commit/${commit.sha}`
304
+ });
305
+ const reviewState = faker.helpers.weightedArrayElement([
306
+ {
307
+ weight: 70,
308
+ value: "APPROVED"
309
+ },
310
+ {
311
+ weight: 20,
312
+ value: "CHANGES_REQUESTED"
313
+ },
314
+ {
315
+ weight: 10,
316
+ value: "COMMENTED"
317
+ }
318
+ ]);
319
+ if (prState !== "open" || faker.datatype.boolean({ probability: .5 })) {
320
+ const reviewId = 2400000000n + id;
321
+ rows.pull_request_reviews.push({
322
+ id: reviewId,
323
+ version: now,
324
+ node_id: nodeId("PRR", reviewId),
325
+ repository_id: repoId,
326
+ pull_request_number: prNumber,
327
+ user: reviewer,
328
+ author_association: "MEMBER",
329
+ state: reviewState,
330
+ body: reviewState === "APPROVED" ? "" : "A few small things before this lands.",
331
+ commit_id: headSha,
332
+ submitted_at: reviewed,
333
+ html_url: `${urlOf(repo)}/pull/${prNumber}#pullrequestreview-${reviewId}`
334
+ });
335
+ if (reviewState !== "APPROVED") {
336
+ const line = BigInt(faker.number.int({
337
+ min: 5,
338
+ max: 200
339
+ }));
340
+ const reviewCommentId = 2900000000n + id;
341
+ rows.pull_request_review_comments.push({
342
+ id: reviewCommentId,
343
+ version: reviewed,
344
+ node_id: nodeId("PRRC", reviewCommentId),
345
+ repository_id: repoId,
346
+ pull_request_number: prNumber,
347
+ pull_request_review_id: reviewId,
348
+ user: reviewer,
349
+ author_association: "MEMBER",
350
+ body: faker.helpers.arrayElement([
351
+ "Could this return early instead?",
352
+ "Nit: this name is a bit unclear.",
353
+ "We should handle the error here."
354
+ ]),
355
+ path: faker.helpers.arrayElement(paths),
356
+ commit_id: headSha,
357
+ original_commit_id: headSha,
358
+ diff_hunk: `@@ -${line},6 +${line},8 @@`,
359
+ line,
360
+ original_line: line,
361
+ start_line: null,
362
+ side: "RIGHT",
363
+ subject_type: "line",
364
+ created_at: reviewed,
365
+ html_url: `${urlOf(repo)}/pull/${prNumber}#discussion_r${reviewCommentId}`
366
+ });
367
+ }
368
+ }
369
+ const ciPassed = faker.datatype.boolean({ probability: .85 });
370
+ const runId = 9000000000n + id;
371
+ const runStarted = later(committed, 1e4, minute);
372
+ const workflowId = 60000000n + BigInt(r);
373
+ rows.workflow_runs.push({
374
+ id: runId,
375
+ version: later(runStarted, 2 * minute, 15 * minute),
376
+ node_id: nodeId("WFR", runId),
377
+ repository_id: repoId,
378
+ workflow_id: workflowId,
379
+ name: "CI",
380
+ display_title: title,
381
+ path: ".github/workflows/ci.yml",
382
+ event: "pull_request",
383
+ status: "completed",
384
+ conclusion: ciPassed ? "success" : "failure",
385
+ head_branch: branch,
386
+ head_sha: headSha,
387
+ run_number: BigInt(round + 1),
388
+ run_attempt: 1n,
389
+ check_suite_id: 30000000000n + id,
390
+ actor: author,
391
+ triggering_actor: author,
392
+ pull_requests: [{
393
+ id: prId,
394
+ number: prNumber
395
+ }],
396
+ created_at: runStarted,
397
+ run_started_at: runStarted,
398
+ html_url: `${urlOf(repo)}/actions/runs/${runId}`
399
+ });
400
+ ["build", "test"].forEach((name, j) => {
401
+ const jobId = 25000000000n + id * 2n + BigInt(j);
402
+ const started = later(runStarted, 5e3, minute);
403
+ const completed = later(started, minute, 10 * minute);
404
+ const conclusion = ciPassed || name === "build" ? "success" : "failure";
405
+ rows.workflow_jobs.push({
406
+ id: jobId,
407
+ version: now,
408
+ node_id: nodeId("CR", jobId),
409
+ repository_id: repoId,
410
+ run_id: runId,
411
+ run_attempt: 1n,
412
+ workflow_name: "CI",
413
+ name,
414
+ head_sha: headSha,
415
+ head_branch: branch,
416
+ status: "completed",
417
+ conclusion,
418
+ created_at: runStarted,
419
+ started_at: started,
420
+ completed_at: completed,
421
+ runner_name: `GitHub Actions ${faker.number.int({
422
+ min: 1,
423
+ max: 99
424
+ })}`,
425
+ labels: ["ubuntu-latest"],
426
+ steps: [
427
+ "Set up job",
428
+ "Checkout",
429
+ `Run ${name}`,
430
+ "Complete job"
431
+ ].map((step, s) => ({
432
+ number: BigInt(s + 1),
433
+ name: step,
434
+ status: "completed",
435
+ conclusion: s === 2 ? conclusion : "success",
436
+ started_at: started,
437
+ completed_at: completed
438
+ })),
439
+ html_url: `${urlOf(repo)}/actions/runs/${runId}/job/${jobId}`
440
+ });
441
+ rows.check_runs.push({
442
+ id: jobId,
443
+ version: now,
444
+ node_id: nodeId("CR", jobId),
445
+ repository_id: repoId,
446
+ head_sha: headSha,
447
+ name,
448
+ status: "completed",
449
+ conclusion,
450
+ started_at: started,
451
+ completed_at: completed,
452
+ app: {
453
+ id: 15368n,
454
+ name: "GitHub Actions"
455
+ },
456
+ check_suite: { id: 30000000000n + id },
457
+ output: {
458
+ title: null,
459
+ summary: null
460
+ },
461
+ external_id: null,
462
+ details_url: `${urlOf(repo)}/actions/runs/${runId}/job/${jobId}`,
463
+ html_url: `${urlOf(repo)}/actions/runs/${runId}/job/${jobId}`
464
+ });
465
+ });
466
+ if (mergedAt) {
467
+ const sha = faker.git.commitSha();
468
+ rows.commits.push({
469
+ key: `${repoId}:${sha}`,
470
+ version: mergedAt,
471
+ repository_id: repoId,
472
+ sha,
473
+ node_id: nodeId("C", 3000000000n + id),
474
+ message: `${title} (#${prNumber})`,
475
+ author: {
476
+ name: author.login,
477
+ date: mergedAt
478
+ },
479
+ committer: {
480
+ name: "GitHub",
481
+ date: mergedAt
482
+ },
483
+ author_user: author,
484
+ committer_user: {
485
+ id: 19864447n,
486
+ login: "web-flow",
487
+ type: "User"
488
+ },
489
+ parents: [baseSha],
490
+ verified: true,
491
+ html_url: `${urlOf(repo)}/commit/${sha}`
492
+ });
493
+ const statusId = 3500000000n + id;
494
+ const deployed = faker.datatype.boolean({ probability: .95 });
495
+ rows.commit_statuses.push({
496
+ id: statusId,
497
+ version: later(mergedAt, minute, 10 * minute),
498
+ node_id: nodeId("SC", statusId),
499
+ repository_id: repoId,
500
+ sha,
501
+ state: deployed ? "success" : "failure",
502
+ context: "deploy/production",
503
+ description: deployed ? "Deployed to production" : "Deploy failed",
504
+ target_url: `https://deploy.example.com/${repo.name}/${sha.slice(0, 7)}`,
505
+ creator: actionsBot,
506
+ created_at: later(mergedAt, minute, 10 * minute)
507
+ });
508
+ }
509
+ const issueClosed = fixed && mergedAt ? mergedAt : null;
510
+ const issueId = 1200000000n + id;
511
+ rows.issues.push({
512
+ id: issueId,
513
+ version: new Date(Math.max(opened.getTime(), issueClosed?.getTime() ?? 0, ...issueComments.map((row) => row.created_at.getTime()))),
514
+ node_id: nodeId("I", issueId),
515
+ repository_id: repoId,
516
+ number: issueNumber,
517
+ title,
518
+ body: `${faker.hacker.phrase()}\n\nSteps to reproduce are in the thread.`,
519
+ state: issueClosed ? "closed" : "open",
520
+ state_reason: issueClosed ? "completed" : null,
521
+ locked: false,
522
+ user: faker.helpers.arrayElement(people),
523
+ author_association: "MEMBER",
524
+ labels: [label],
525
+ assignees: [author],
526
+ milestone: null,
527
+ comments: BigInt(issueComments.length),
528
+ created_at: opened,
529
+ closed_at: issueClosed,
530
+ html_url: `${urlOf(repo)}/issues/${issueNumber}`
531
+ });
532
+ if (round % 5 === 4 && mergedAt) {
533
+ const releaseId = 4000000000n + id;
534
+ const tag = `v1.${Math.floor(round / 5)}.0`;
535
+ rows.releases.push({
536
+ id: releaseId,
537
+ version: mergedAt,
538
+ node_id: nodeId("RE", releaseId),
539
+ repository_id: repoId,
540
+ tag_name: tag,
541
+ target_commitish: "main",
542
+ name: tag,
543
+ body: `## What's changed\n\n- ${title} (#${prNumber})`,
544
+ draft: false,
545
+ prerelease: false,
546
+ author,
547
+ assets: [],
548
+ created_at: mergedAt,
549
+ published_at: mergedAt,
550
+ html_url: `${urlOf(repo)}/releases/tag/${tag}`
551
+ });
552
+ }
553
+ return rows;
554
+ };
555
+ //#endregion
556
+ //#region src/demo/setup.ts
557
+ /** The repositories, written once before any change. */
558
+ const setupRows = ({ now }) => {
559
+ const created = /* @__PURE__ */ new Date(now.getTime() - 900 * day);
560
+ return { repositories: repositories.map((repo, r) => ({
561
+ id: repositoryId(r),
562
+ version: now,
563
+ node_id: nodeId("R", repositoryId(r)),
564
+ name: repo.name,
565
+ full_name: `${org}/${repo.name}`,
566
+ owner,
567
+ private: repo.name !== "sdk-js" && repo.name !== "docs",
568
+ visibility: repo.name === "sdk-js" || repo.name === "docs" ? "public" : "private",
569
+ description: repo.description,
570
+ fork: false,
571
+ archived: false,
572
+ disabled: false,
573
+ default_branch: "main",
574
+ language: repo.language,
575
+ topics: [...repo.topics],
576
+ html_url: urlOf(repo),
577
+ created_at: new Date(created.getTime() + r * 30 * day),
578
+ _deleted: false
579
+ })) };
580
+ };
581
+ //#endregion
582
+ //#region src/demo/index.ts
583
+ const demo = Demo.define({
584
+ name: "producer-github",
585
+ setup: {
586
+ tables: [Demo.table({
587
+ name: "repositories",
588
+ rowSchema: RepositorySchema,
589
+ version: "version"
590
+ })],
591
+ rows: setupRows
592
+ },
593
+ group: {
594
+ tables: [
595
+ Demo.table({
596
+ name: "issues",
597
+ rowSchema: IssueSchema,
598
+ version: "version"
599
+ }),
600
+ Demo.table({
601
+ name: "pull_requests",
602
+ rowSchema: PullRequestSchema,
603
+ version: "version"
604
+ }),
605
+ Demo.table({
606
+ name: "issue_comments",
607
+ rowSchema: IssueCommentSchema,
608
+ version: "version"
609
+ }),
610
+ Demo.table({
611
+ name: "pull_request_reviews",
612
+ rowSchema: PullRequestReviewSchema,
613
+ version: "version"
614
+ }),
615
+ Demo.table({
616
+ name: "pull_request_review_comments",
617
+ rowSchema: PullRequestReviewCommentSchema,
618
+ version: "version"
619
+ }),
620
+ Demo.table({
621
+ name: "pull_request_commits",
622
+ rowSchema: PullRequestCommitSchema,
623
+ version: "version"
624
+ }),
625
+ Demo.table({
626
+ name: "commits",
627
+ rowSchema: CommitSchema,
628
+ version: "version"
629
+ }),
630
+ Demo.table({
631
+ name: "check_runs",
632
+ rowSchema: CheckRunSchema,
633
+ version: "version"
634
+ }),
635
+ Demo.table({
636
+ name: "commit_statuses",
637
+ rowSchema: CommitStatusSchema,
638
+ version: "version"
639
+ }),
640
+ Demo.table({
641
+ name: "workflow_runs",
642
+ rowSchema: WorkflowRunSchema,
643
+ version: "version"
644
+ }),
645
+ Demo.table({
646
+ name: "workflow_jobs",
647
+ rowSchema: WorkflowJobSchema,
648
+ version: "version"
649
+ }),
650
+ Demo.table({
651
+ name: "releases",
652
+ rowSchema: ReleaseSchema,
653
+ version: "version"
654
+ })
655
+ ],
656
+ rows: changeRows
657
+ }
658
+ });
659
+ const demoCommand = ConnectorApp.makeDemoCommand(demo).pipe(Command.provide(RuntimeConfig.layerHosted()));
660
+ //#endregion
661
+ //#region src/sandbox.ts
662
+ const ConnectorLayer$1 = layerConfig(GitHubConfigDef.config);
663
+ const TelemetryLayer$1 = Layer.mergeAll(Telemetry.layerOtlp(), Telemetry.layerMetricsConsoleDump());
664
+ const sandboxCommand = Command.make("sandbox", {}, () => Effect.gen(function* () {
665
+ const port = yield* RuntimeConfig.httpPort;
666
+ const entrypoint = yield* GitHubConnector;
667
+ return yield* ConnectorApp.start(entrypoint, { port });
668
+ }).pipe(Effect.annotateLogs({ component: "github" }), Effect.provide(Layer.mergeAll(StateStore.layerMemory, Ingestor.layerConsole, ConnectorLayer$1, Logger.layer([Logger.consolePretty()]), TelemetryLayer$1)))).pipe(Command.withDescription("Run the connector locally and log ingested data"));
669
+ //#endregion
670
+ //#region src/start.ts
671
+ const ConnectorLayer = layerConfig(GitHubConfigDef.config);
672
+ const TelemetryLayer = Telemetry.layerOtlp();
673
+ const PostgresLayer = PgClient.layerConfig({
674
+ url: Config.schema(Schema.Redacted(Schema.NonEmptyString), RuntimeConfig.PlatformRuntimeKey.postgresConnectionString),
675
+ maxConnections: Config.succeed(2),
676
+ connectTimeout: Config.succeed("5 seconds"),
677
+ applicationName: Config.succeed("airfoil-producer-github")
678
+ });
679
+ const StateStoreLayer = StateStore.layerSql().pipe(Layer.provide(PostgresLayer));
680
+ const startCommand = Command.make("start", {}, () => Effect.gen(function* () {
681
+ const port = yield* RuntimeConfig.httpPort;
682
+ const entrypoint = yield* GitHubConnector;
683
+ return yield* ConnectorApp.start(entrypoint, { port }).pipe(Effect.provide(Ingestor.layerArrowFlightConfig(entrypoint)));
684
+ }).pipe(Effect.annotateLogs({ component: "github" }), Effect.provide(Layer.mergeAll(StateStoreLayer, ConnectorLayer, Logger.layer([Logger.consolePretty()]), TelemetryLayer)), Effect.provide(RuntimeConfig.layerHosted()))).pipe(Command.withDescription("Run the connector"));
685
+ //#endregion
686
+ //#region src/main.ts
687
+ const BootstrapLayer = Layer.mergeAll(FetchHttpClient.layer, NodeServices.layer);
688
+ const program = Command.make("producer-github", {}, () => Effect.void).pipe(Command.withSubcommands([
689
+ setupCommand,
690
+ startCommand,
691
+ sandboxCommand,
692
+ createTableCommand,
693
+ demoCommand
694
+ ]));
695
+ const cli = Command.run(program, { version });
696
+ NodeRuntime.runMain(cli.pipe(Effect.provide(BootstrapLayer), Effect.scoped));
697
+ //#endregion
698
+ export {};
699
+
700
+ //# sourceMappingURL=main.mjs.map