import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api'; import { LoggerService, SchedulerServiceTaskRunner, SchedulerService, SchedulerServiceTaskScheduleDefinition } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { CatalogProcessor, LocationSpec, CatalogProcessorEmit, EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-node'; import { EventsService } from '@backstage/plugin-events-node'; import { UserEntity, GroupEntity } from '@backstage/catalog-model'; import { GitLabIntegrationConfig } from '@backstage/integration'; /** * Registers the GitlabDiscoveryEntityProvider with the catalog processing extension point. * * @public */ declare const catalogModuleGitlabDiscoveryEntityProvider: _backstage_backend_plugin_api.BackendFeature; /** * Extracts repositories out of an GitLab instance. * @public */ declare class GitLabDiscoveryProcessor implements CatalogProcessor { private readonly integrations; private readonly logger; private readonly cache; private readonly skipReposWithoutExactFileMatch; private readonly skipForkedRepos; private readonly includeArchivedRepos; static fromConfig(config: Config, options: { logger: LoggerService; skipReposWithoutExactFileMatch?: boolean; skipForkedRepos?: boolean; includeArchivedRepos?: boolean; }): GitLabDiscoveryProcessor; private constructor(); getProcessorName(): string; readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise; private getCacheKey; } /** * Discovers catalog files located in your GitLab instance. * The provider will search your GitLab instance's projects and register catalog files matching the configured path * as Location entity and via following processing steps add all contained catalog entities. * This can be useful as an alternative to static locations or manually adding things to the catalog. * * @public */ declare class GitlabDiscoveryEntityProvider implements EntityProvider { private readonly config; private readonly integration; private readonly logger; private readonly scheduleFn; private connection?; private readonly events?; private readonly gitLabClient; static fromConfig(config: Config, options: { logger: LoggerService; events?: EventsService; schedule?: SchedulerServiceTaskRunner; scheduler?: SchedulerService; }): GitlabDiscoveryEntityProvider[]; /** * Constructs a GitlabDiscoveryEntityProvider instance. * * @param options - Configuration options including config, integration, logger, and taskRunner. */ private constructor(); getProviderName(): string; connect(connection: EntityProviderConnection): Promise; /** * Creates a scheduled task runner for refreshing the entity provider. * * @param taskRunner - The task runner instance. * @returns The scheduled function. */ private createScheduleFn; /** * Performs a full scan on the GitLab instance searching for locations to be ingested * * @param logger - The logger instance for logging. */ refresh(logger: LoggerService): Promise; /** * Determine the location on GitLab to be ingested. * Uses GitLab's search API to find projects matching provided configuration. * * @returns A list of location to be ingested */ private searchEntities; /** * Determine the location on GitLab to be ingested base on configured groups and filters. * * @returns A list of location to be ingested */ private getEntities; /** * Deduplicate a list of projects based on their id. * * @param projects - a list of projects to be deduplicated * @returns a list of projects with unique id */ private deduplicateProjects; /** * Retrieve a list of projects that match configuration. * * @param group - a full path of a GitLab group, can be empty * @returns An array of project to be processed and the number of project scanned */ private getProjectsToProcess; private createLocationSpecFromParams; private createLocationSpec; /** * Handles the "gitlab.push" event. * * @param event - The push event payload. */ private onRepoPush; /** * Gets files matching the specified commit action and catalog file name. * * @param event - The push event payload. * @param action - The action type ('added', 'removed', or 'modified'). * @param catalogFile - The catalog file name. * @returns An array of file paths. */ private getFilesMatchingConfig; /** * Creates Backstage location specs for committed files. * * @param project - The GitLab project information. * @param addedFiles - The array of added file paths. * @returns An array of location specs. */ private createLocationSpecCommitedFiles; /** * Converts a target URL to a LocationSpec object. * * @param target - The target URL to be converted. * @returns The LocationSpec object representing the URL. */ private toLocationSpec; private toDeferredEntities; private isProjectCompliant; private shouldProcessProject; private isGroupCompliant; } /** * Representation of a GitLab user in the GitLab API * * @public */ type GitLabUser = { id: number; username: string; email?: string; name: string; state: string; web_url: string; avatar_url: string; groups?: GitLabGroup[]; group_saml_identity?: GitLabGroupSamlIdentity; is_using_seat?: boolean; }; /** * @public */ type GitLabGroupSamlIdentity = { extern_uid: string; }; /** * Representation of a GitLab group in the GitLab API * * @public */ type GitLabGroup = { id: number; name: string; full_path: string; description?: string; visibility?: string; parent_id?: number; }; /** * The configuration parameters for the GitlabProvider * * @public */ type GitlabProviderConfig = { /** * Identifies one of the hosts set up in the integrations */ host: string; /** * Required for gitlab.com when `orgEnabled: true`. * Optional for self managed. Must not end with slash. * Accepts only groups under the provided path (which will be stripped) */ group: string; /** * If true, the provider will only ingest users that are part of the configured group. */ restrictUsersToGroup?: boolean; /** * ??? */ id: string; /** * The name of the branch to be used, to discover catalog files. */ branch?: string; /** * If no `branch` is configured and there is no default branch defined at the project as well, this fallback is used * to discover catalog files. * Defaults to: `master` */ fallbackBranch: string; /** * Defaults to `catalog-info.yaml` */ catalogFile: string; /** * Filters found projects based on provided patter. * Defaults to `[\s\S]*`, which means to not filter anything */ projectPattern: RegExp; /** * Filters found users based on provided patter. * Defaults to `[\s\S]*`, which means to not filter anything */ userPattern: RegExp; /** * Filters found groups based on provided patterns. * Defaults to `[\s\S]*`, which means to not filter anything * */ groupPattern: RegExp | RegExp[]; /** * If true, the provider will also add inherited (ascendant) users to the ingested groups. * See: https://docs.gitlab.com/ee/api/graphql/reference/#groupmemberrelation * * @deprecated Use the `relations` array to configure group membership relations instead. **/ allowInherited?: boolean; /** * If true, use the GitLab search API to find projects locations. */ useSearch?: boolean; /** * Specifies the types of group membership relations that should be included when ingesting data. * * The following values are valid: * - 'DIRECT': Direct members of the group. This is the default relation and is always included. * - 'INHERITED': Members inherited from parent (ascendant) groups. * - 'DESCENDANTS': Members from child (descendant) groups. * - 'SHARED_FROM_GROUPS': Members shared from other groups. * * See: https://docs.gitlab.com/ee/api/graphql/reference/#groupmemberrelation * * If the `relations` array is provided in the app-config.yaml, it should contain any combination of the above values. * The 'DIRECT' relation is automatically included and cannot be excluded, even if not specified. * Example configuration: * * ```yaml * catalog: * providers: * gitlab: * development: * relations: * - INHERITED * - DESCENDANTS * - SHARED_FROM_GROUPS * ``` */ relations?: string[]; orgEnabled?: boolean; schedule?: SchedulerServiceTaskScheduleDefinition; /** * If the project is a fork, skip repository */ skipForkedRepos?: boolean; /** * If the project is archived, include repository */ includeArchivedRepos?: boolean; /** * List of repositories to exclude from discovery, should be the full path to the repository, e.g. `group/project` * Paths should not start or end with a slash. */ excludeRepos?: string[]; /** * If true, users without a seat will be included in the catalog. * Group/Application Access Tokens are still filtered out but you might find service accounts or other users without a seat. * Defaults to `false` */ includeUsersWithoutSeat?: boolean; /** * If true, the membership parameter is set to true in the GitLab API request. * See: https://docs.gitlab.com/api/projects/#list-projects */ membership?: boolean; /** * Optional comma separated list of topics to filter projects by, as specified in the GitLab API documentation: * https://docs.gitlab.com/api/projects/#list-projects */ topics?: string; }; /** * Customize how group names are generated * * @public */ type GroupNameTransformer = (options: GroupNameTransformerOptions) => string; /** * The GroupTransformerOptions * * @public */ interface GroupNameTransformerOptions { group: GitLabGroup; providerConfig: GitlabProviderConfig; } /** * Customize the ingested User entity * * @public */ type UserTransformer = (options: UserTransformerOptions) => UserEntity; /** * The UserTransformerOptions * * @public */ interface UserTransformerOptions { user: GitLabUser; integrationConfig: GitLabIntegrationConfig; providerConfig: GitlabProviderConfig; groupNameTransformer: GroupNameTransformer; } /** * Customize the ingested Group entity * * @public */ type GroupTransformer = (options: GroupTransformerOptions) => GroupEntity[]; /** * The GroupTransformer options * * @public */ interface GroupTransformerOptions { groups: GitLabGroup[]; providerConfig: GitlabProviderConfig; groupNameTransformer: GroupNameTransformer; } /** * Discovers users and groups from a Gitlab instance. * @public */ declare class GitlabOrgDiscoveryEntityProvider implements EntityProvider { private readonly config; private readonly integration; private readonly logger; private readonly events?; private readonly scheduleFn; private connection?; private userTransformer; private groupEntitiesTransformer; private groupNameTransformer; private readonly gitLabClient; private readonly groupPatterns; static fromConfig(config: Config, options: { logger: LoggerService; events?: EventsService; schedule?: SchedulerServiceTaskRunner; scheduler?: SchedulerService; userTransformer?: UserTransformer; groupEntitiesTransformer?: GroupTransformer; groupNameTransformer?: GroupNameTransformer; }): GitlabOrgDiscoveryEntityProvider[]; private constructor(); getProviderName(): string; connect(connection: EntityProviderConnection): Promise; private createScheduleFn; private refresh; private onGroupChange; private onGroupEdit; private onUserChange; private onMembershipChange; private shouldProcessGroup; private shouldProcessUser; private withLocations; private getRelations; } export { GitLabDiscoveryProcessor, GitlabDiscoveryEntityProvider, GitlabOrgDiscoveryEntityProvider, catalogModuleGitlabDiscoveryEntityProvider as default }; export type { GitLabGroup, GitLabGroupSamlIdentity, GitLabUser, GitlabProviderConfig, GroupNameTransformer, GroupNameTransformerOptions, GroupTransformer, GroupTransformerOptions, UserTransformer, UserTransformerOptions };