MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / listGitLabRepositories

Function listGitLabRepositories

apps/web/src/lib/integrations/gitlab-service.ts:154–204  ·  view source on GitHub ↗
(
  owner: Owner,
  integrationId: string,
  forceRefresh: boolean = false
)

Source from the content-addressed store, hash-verified

152
153 return integration || null;
154}
155
156/**
157 * Resolve a GitLab credential through the private-key holding token service.
158 */
159function requireAvailableGitLabCredential(
160 result: GitLabCredentialBrokerResult,
161 expectedInstanceUrl: string
162): string {
163 if (result.status === 'available') {
164 if (result.instanceUrl !== expectedInstanceUrl) {
165 throw new TRPCError({
166 code: 'UNAUTHORIZED',
167 message: 'GitLab integration changed while resolving credentials',
168 });
169 }
170 return result.token;
171 }
172
173 switch (result.status) {
174 case 'invalid_request':
175 throw new TRPCError({ code: 'BAD_REQUEST', message: 'Invalid GitLab credential request' });
176 case 'not_connected':
177 throw new TRPCError({ code: 'NOT_FOUND', message: 'GitLab integration not found' });
178 case 'reconnect_required':
179 throw new TRPCError({
180 code: 'UNAUTHORIZED',
181 message: 'GitLab integration must be reconnected',
182 });
183 case 'temporarily_unavailable':
184 throw new TRPCError({
185 code: 'SERVICE_UNAVAILABLE',
186 message: 'GitLab credentials are temporarily unavailable',
187 });
188 }
189}
190
191export async function getValidGitLabToken(
192 integration: PlatformIntegration,
193 actor: GitLabCredentialActor
194): Promise<string> {
195 const metadata = requireMetadataRecord(integration.metadata);
196 const expectedInstanceUrl = normalizeInstanceUrl(
197 readOptionalMetadataString(metadata, 'gitlab_instance_url')
198 );
199 return requireAvailableGitLabCredential(
200 await fetchGitLabCredential(actor, {
201 credential: 'integration',
202 integrationId: integration.id,
203 }),
204 expectedInstanceUrl
205 );
206}
207

Callers

nothing calls this directly

Calls 6

fetchGitLabProjectsFunction · 0.90
getValidGitLabTokenFunction · 0.85
normalizeInstanceUrlFunction · 0.85
limitMethod · 0.65

Tested by

no test coverage detected