@@ -4,7 +4,7 @@ import type { Container } from './container';
44import type { Account } from './git/models/author' ;
55import type { DefaultBranch } from './git/models/defaultBranch' ;
66import type { Issue } from './git/models/issue' ;
7- import type { IssueOrPullRequest } from './git/models/issueOrPullRequest' ;
7+ import type { IssueOrPullRequest , IssueOrPullRequestType } from './git/models/issueOrPullRequest' ;
88import type { PullRequest } from './git/models/pullRequest' ;
99import type { RepositoryMetadata } from './git/models/repositoryMetadata' ;
1010import type { HostingIntegration , IntegrationBase , ResourceDescriptor } from './plus/integrations/integration' ;
@@ -111,6 +111,7 @@ export class CacheProvider implements Disposable {
111111
112112 getIssueOrPullRequest (
113113 id : string ,
114+ type : IssueOrPullRequestType | undefined ,
114115 resource : ResourceDescriptor ,
115116 integration : IntegrationBase | undefined ,
116117 cacheable : Cacheable < IssueOrPullRequest > ,
@@ -119,11 +120,11 @@ export class CacheProvider implements Disposable {
119120 const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
120121
121122 if ( resource == null ) {
122- return this . get ( 'issuesOrPrsById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
123+ return this . get ( 'issuesOrPrsById' , `id:${ id } :${ key } : ${ type ?? 'unknown' } ` , etag , cacheable , options ) ;
123124 }
124125 return this . get (
125126 'issuesOrPrsByIdAndRepo' ,
126- `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` ,
127+ `id:${ id } :${ key } :${ type ?? 'unknown' } : ${ JSON . stringify ( resource ) } }` ,
127128 etag ,
128129 cacheable ,
129130 options ,
@@ -140,11 +141,17 @@ export class CacheProvider implements Disposable {
140141 const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
141142
142143 if ( resource == null ) {
143- return this . get ( 'issuesById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
144+ return this . get (
145+ 'issuesById' ,
146+ `id:${ id } :${ key } :${ 'issue' satisfies IssueOrPullRequestType } ` ,
147+ etag ,
148+ cacheable ,
149+ options ,
150+ ) ;
144151 }
145152 return this . get (
146153 'issuesByIdAndResource' ,
147- `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` ,
154+ `id:${ id } :${ key } :${ 'issue' satisfies IssueOrPullRequestType } : ${ JSON . stringify ( resource ) } }` ,
148155 etag ,
149156 cacheable ,
150157 options ,
@@ -161,9 +168,21 @@ export class CacheProvider implements Disposable {
161168 const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
162169
163170 if ( resource == null ) {
164- return this . get ( 'prsById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
171+ return this . get (
172+ 'prsById' ,
173+ `id:${ id } :${ key } :${ 'pullrequest' satisfies IssueOrPullRequestType } ` ,
174+ etag ,
175+ cacheable ,
176+ options ,
177+ ) ;
165178 }
166- return this . get ( 'prsById' , `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` , etag , cacheable , options ) ;
179+ return this . get (
180+ 'prsById' ,
181+ `id:${ id } :${ key } :${ 'pullrequest' satisfies IssueOrPullRequestType } :${ JSON . stringify ( resource ) } }` ,
182+ etag ,
183+ cacheable ,
184+ options ,
185+ ) ;
167186 }
168187
169188 getPullRequestForBranch (
@@ -264,7 +283,12 @@ export class CacheProvider implements Disposable {
264283 if ( isPromise ( item . value ) ) {
265284 void item . value . then ( v => {
266285 if ( v != null ) {
267- this . set ( 'issuesOrPrsById' , `id:${ v . id } :${ key } ` , v , etag ) ;
286+ this . set (
287+ 'issuesOrPrsById' ,
288+ `id:${ v . id } :${ key } :${ 'pullrequest' satisfies IssueOrPullRequestType } ` ,
289+ v ,
290+ etag ,
291+ ) ;
268292 }
269293 } ) ;
270294 }
0 commit comments