11import { assert , describe , it , vi } from "@effect/vitest" ;
2- import type { OrchestrationProjectShell , ProjectId } from "@t3tools/contracts" ;
2+ import {
3+ SourceControlProviderKind ,
4+ type OrchestrationProjectShell ,
5+ type ProjectId ,
6+ } from "@t3tools/contracts" ;
37import * as Effect from "effect/Effect" ;
48import * as Layer from "effect/Layer" ;
59import * as Option from "effect/Option" ;
610
711import * as ProjectService from "../project/ProjectService.ts" ;
812import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts" ;
9- import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi" ;
13+ import * as GitHubRequestPolicy from "@t3tools/source-control-github/server/GitHubRequestPolicy" ;
14+ import * as GitHubIssueGraphQl from "./gitHubIssueGraphQl.fork.ts" ;
1015import * as GitHubCredentials from "@t3tools/source-control-github/server/GitHubCredentials" ;
1116import * as GitHubIssueService from "./GitHubIssueService.ts" ;
1217
@@ -32,7 +37,7 @@ function project(input: {
3237 remoteName : "origin" ,
3338 remoteUrl : `https://${ host } /${ repository } .git` ,
3439 } ,
35- provider : input . provider ?? "github" ,
40+ provider : SourceControlProviderKind . make ( input . provider ?? "github" ) ,
3641 displayName : repository ,
3742 owner,
3843 name,
@@ -85,12 +90,12 @@ const issueIdAnswer = (id: string) =>
8590
8691function makeService (
8792 projects : ReadonlyArray < OrchestrationProjectShell > ,
88- graphql : GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] ,
93+ graphql : GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] ,
8994) {
9095 return GitHubIssueService . make . pipe (
9196 Effect . provide (
9297 Layer . mergeAll (
93- Layer . mock ( GitHubApi . GitHubApi ) ( { graphql } ) ,
98+ Layer . mock ( GitHubIssueGraphQl . GitHubIssueGraphQl ) ( { graphql } ) ,
9499 Layer . mock ( ProjectService . ProjectService ) ( {
95100 listShells : ( ) => Effect . succeed ( projects ) ,
96101 getShell : ( projectId ) =>
@@ -108,7 +113,7 @@ function makeService(
108113describe ( "GitHubIssueService" , ( ) => {
109114 it . effect ( "composes the search qualifiers while discovering only GitHub projects" , ( ) =>
110115 Effect . gen ( function * ( ) {
111- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
116+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
112117 searchAnswer ( [ issueRow ( 2 ) , issueRow ( 1 ) ] ) ,
113118 ) ;
114119 const service = yield * makeService (
@@ -141,7 +146,9 @@ describe("GitHubIssueService", () => {
141146
142147 it . effect ( "sends sort:updated-desc when no user query is present" , ( ) =>
143148 Effect . gen ( function * ( ) {
144- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) => searchAnswer ( [ ] ) ) ;
149+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
150+ searchAnswer ( [ ] ) ,
151+ ) ;
145152 const service = yield * makeService (
146153 [ project ( { id : "p1" , title : "web" , workspaceRoot : "/web" } ) ] ,
147154 graphql ,
@@ -156,7 +163,9 @@ describe("GitHubIssueService", () => {
156163
157164 it . effect ( "routes Enterprise repositories to their host" , ( ) =>
158165 Effect . gen ( function * ( ) {
159- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) => searchAnswer ( [ ] ) ) ;
166+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
167+ searchAnswer ( [ ] ) ,
168+ ) ;
160169 const service = yield * makeService (
161170 [
162171 project ( {
@@ -181,7 +190,7 @@ describe("GitHubIssueService", () => {
181190
182191 it . effect ( "applies project filtering before repository de-duplication" , ( ) =>
183192 Effect . gen ( function * ( ) {
184- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
193+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
185194 searchAnswer ( [ issueRow ( 7 ) ] ) ,
186195 ) ;
187196 const service = yield * makeService (
@@ -199,7 +208,7 @@ describe("GitHubIssueService", () => {
199208
200209 it . effect ( "sorts mixed timezone offsets by instant and limits globally" , ( ) =>
201210 Effect . gen ( function * ( ) {
202- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( call ) =>
211+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( call ) =>
203212 Effect . succeed (
204213 JSON . stringify ( {
205214 data : {
@@ -232,7 +241,7 @@ describe("GitHubIssueService", () => {
232241
233242 it . effect ( "marks a per-repository overflow as truncated" , ( ) =>
234243 Effect . gen ( function * ( ) {
235- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
244+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
236245 searchAnswer ( [ issueRow ( 3 ) , issueRow ( 2 ) , issueRow ( 1 ) ] ) ,
237246 ) ;
238247 const service = yield * makeService (
@@ -247,7 +256,7 @@ describe("GitHubIssueService", () => {
247256
248257 it . effect ( "carries each row's true comment count from the search answer" , ( ) =>
249258 Effect . gen ( function * ( ) {
250- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
259+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
251260 searchAnswer ( [ issueRow ( 5 ) , { ...issueRow ( 6 ) , comments : { totalCount : 12 } } ] ) ,
252261 ) ;
253262 const service = yield * makeService (
@@ -264,10 +273,10 @@ describe("GitHubIssueService", () => {
264273
265274 it . effect ( "keeps healthy rows when one host is unauthenticated" , ( ) =>
266275 Effect . gen ( function * ( ) {
267- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( call ) =>
276+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( call ) =>
268277 call . host === "ghe.acme.dev"
269278 ? Effect . fail (
270- new GitHubApi . GitHubApiAuthenticationError ( {
279+ new GitHubRequestPolicy . GitHubApiAuthenticationError ( {
271280 host : call . host ,
272281 operation : "listIssues" ,
273282 } ) ,
@@ -299,9 +308,9 @@ describe("GitHubIssueService", () => {
299308
300309 it . effect ( "returns project errors when every repository fails" , ( ) =>
301310 Effect . gen ( function * ( ) {
302- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
311+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
303312 Effect . fail (
304- new GitHubApi . GitHubApiAuthenticationError ( {
313+ new GitHubRequestPolicy . GitHubApiAuthenticationError ( {
305314 host : "github.com" ,
306315 operation : "listIssues" ,
307316 } ) ,
@@ -319,7 +328,7 @@ describe("GitHubIssueService", () => {
319328
320329 it . effect ( "degrades malformed repository output" , ( ) =>
321330 Effect . gen ( function * ( ) {
322- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
331+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
323332 Effect . succeed ( "not-json" ) ,
324333 ) ;
325334 const service = yield * makeService (
@@ -334,7 +343,7 @@ describe("GitHubIssueService", () => {
334343
335344 it . effect ( "fails the whole read when the host has no credential at all" , ( ) =>
336345 Effect . gen ( function * ( ) {
337- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
346+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
338347 Effect . fail ( new GitHubCredentials . GitHubCliMissingError ( { host : "github.com" } ) ) ,
339348 ) ;
340349 const service = yield * makeService (
@@ -348,7 +357,7 @@ describe("GitHubIssueService", () => {
348357
349358 it . effect ( "uses the selected project to read an issue from another repository" , ( ) =>
350359 Effect . gen ( function * ( ) {
351- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
360+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
352361 issueAnswer ( {
353362 ...issueRow ( 42 ) ,
354363 body : "Cross-repository issue" ,
@@ -376,7 +385,7 @@ describe("GitHubIssueService", () => {
376385 Effect . gen ( function * ( ) {
377386 // The read window is the newest 100 comments; totalCount says how many exist in full.
378387 const nodes = Array . from ( { length : 100 } , ( _ , index ) => commentNode ( index + 2 ) ) ;
379- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
388+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
380389 issueAnswer ( {
381390 ...issueRow ( 42 ) ,
382391 body : "Body" ,
@@ -403,7 +412,7 @@ describe("GitHubIssueService", () => {
403412
404413 it . effect ( "loads issue detail and normalizes comment count" , ( ) =>
405414 Effect . gen ( function * ( ) {
406- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
415+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
407416 issueAnswer ( {
408417 ...issueRow ( 42 ) ,
409418 body : "Visible issue body" ,
@@ -440,7 +449,7 @@ describe("GitHubIssueService", () => {
440449
441450 it . effect ( "closes with a reason and reopens without one" , ( ) =>
442451 Effect . gen ( function * ( ) {
443- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( call ) =>
452+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( call ) =>
444453 String ( call . query ) . includes ( "closeIssue" )
445454 ? Effect . succeed ( JSON . stringify ( { data : { closeIssue : { issue : { id : "node-1" } } } } ) )
446455 : String ( call . query ) . includes ( "reopenIssue" )
@@ -472,9 +481,9 @@ describe("GitHubIssueService", () => {
472481
473482 it . effect ( "reports an unauthenticated close with the host to log in to" , ( ) =>
474483 Effect . gen ( function * ( ) {
475- const graphql = vi . fn < GitHubApi . GitHubApi [ "Service" ] [ "graphql" ] > ( ( ) =>
484+ const graphql = vi . fn < GitHubIssueGraphQl . GitHubIssueGraphQl [ "Service" ] [ "graphql" ] > ( ( ) =>
476485 Effect . fail (
477- new GitHubApi . GitHubApiAuthenticationError ( {
486+ new GitHubRequestPolicy . GitHubApiAuthenticationError ( {
478487 host : "ghe.acme.dev" ,
479488 operation : "closeIssueId" ,
480489 } ) ,
0 commit comments