( owner: Owner, integrationId: string, projectPath: string // e.g., "group/project" or project ID )
| 208 | export async function getValidGitLabProjectAccessToken( |
| 209 | integration: PlatformIntegration, |
| 210 | projectId: string | number, |
| 211 | actor: GitLabCredentialActor |
| 212 | ): Promise<string> { |
| 213 | const metadata = requireMetadataRecord(integration.metadata); |
| 214 | const expectedInstanceUrl = normalizeInstanceUrl( |
| 215 | readOptionalMetadataString(metadata, 'gitlab_instance_url') |
| 216 | ); |
| 217 | return requireAvailableGitLabCredential( |
| 218 | await fetchGitLabCredential(actor, { |
| 219 | credential: 'project-exact', |
| 220 | integrationId: integration.id, |
| 221 | projectId: requireGitLabProjectId(projectId), |
| 222 | }), |
| 223 | expectedInstanceUrl |
| 224 | ); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * List repositories accessible by a GitLab integration |
| 229 | * Returns cached repositories by default, fetches fresh from GitLab when forceRefresh is true |
| 230 | */ |
| 231 | export async function listGitLabRepositories( |
| 232 | owner: Owner, |
| 233 | integrationId: string, |
| 234 | actor: GitLabCredentialActor, |
| 235 | forceRefresh: boolean = false |
| 236 | ) { |
| 237 | const ownershipCondition = |
| 238 | owner.type === 'user' |
| 239 | ? eq(platform_integrations.owned_by_user_id, owner.id) |
| 240 | : eq(platform_integrations.owned_by_organization_id, owner.id); |
| 241 | |
| 242 | const [integration] = await db |
| 243 | .select() |
| 244 | .from(platform_integrations) |
| 245 | .where( |
| 246 | and( |
| 247 | eq(platform_integrations.id, integrationId), |
| 248 | ownershipCondition, |
| 249 | eq(platform_integrations.platform, PLATFORM.GITLAB) |
| 250 | ) |
| 251 | ) |
| 252 | .limit(1); |
| 253 | |
| 254 | if (!integration) { |
nothing calls this directly
no test coverage detected