import * as react_jsx_runtime from 'react/jsx-runtime'; import * as _backstage_core_plugin_api from '@backstage/core-plugin-api'; import { DiscoveryApi, FetchApi, ConfigApi } from '@backstage/core-plugin-api'; import { Entity, CompoundEntityRef } from '@backstage/catalog-model'; import { ReactElement, ComponentProps, ReactNode } from 'react'; import { InfoCardVariants } from '@backstage/core-components'; import { TranslationFunction } from '@backstage/core-plugin-api/alpha'; import { catalogImportTranslationRef as catalogImportTranslationRef$1 } from '@backstage/plugin-catalog-import/alpha'; import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api'; import { TextFieldProps } from '@material-ui/core/TextField/TextField'; import { FieldErrors, Controller, UseFormProps, SubmitHandler, UseFormReturn, NestedValue } from 'react-hook-form'; import { CatalogApi } from '@backstage/catalog-client'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { ScmAuthApi } from '@backstage/integration-react'; /** * A plugin that helps the user in importing projects and YAML files into the * catalog. * * @public */ declare const catalogImportPlugin: _backstage_core_plugin_api.BackstagePlugin<{ importPage: _backstage_core_plugin_api.RouteRef; }, {}>; /** * The page for importing projects and YAML files into the catalog. * * @public */ declare const CatalogImportPage: () => react_jsx_runtime.JSX.Element; /** * The default catalog import page. * * @public */ declare const DefaultImportPage: () => react_jsx_runtime.JSX.Element; /** * Props for {@link EntityListComponent}. * * @public */ interface EntityListComponentProps { locations: Array<{ target: string; entities: (Entity | CompoundEntityRef)[]; }>; locationListItemIcon: (target: string) => ReactElement; collapsed?: boolean; firstListItem?: ReactElement; onItemClick?: (target: string) => void; withLinks?: boolean; } /** * Shows a result list of entities. * * @public */ declare const EntityListComponent: (props: EntityListComponentProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link ImportInfoCard}. * * @public */ interface ImportInfoCardProps { exampleLocationUrl?: string; exampleRepositoryUrl?: string; } /** * Shows information about the import process. * * @public */ declare const ImportInfoCard: (props: ImportInfoCardProps) => react_jsx_runtime.JSX.Element; type RecursivePartial = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial[] : T[P] extends object ? RecursivePartial : T[P]; }; type PartialEntity = RecursivePartial; /** * Utility API reference for the {@link CatalogImportApi}. * * @public */ declare const catalogImportApiRef: _backstage_frontend_plugin_api.ApiRef; /** * Result of the analysis. * * @public */ type AnalyzeResult = { type: 'locations'; locations: Array<{ target: string; exists?: boolean; entities: CompoundEntityRef[]; }>; } | { type: 'repository'; url: string; integrationType: string; generatedEntities: PartialEntity[]; }; /** * API for driving catalog imports. * * @public */ interface CatalogImportApi { analyzeUrl(url: string): Promise; preparePullRequest?(): Promise<{ title: string; body: string; }>; submitPullRequest(options: { repositoryUrl: string; fileContent: string; title: string; body: string; }): Promise<{ link: string; location: string; }>; } /** * The default implementation of the {@link CatalogImportApi}. * * @public */ declare class CatalogImportClient implements CatalogImportApi { private readonly discoveryApi; private readonly fetchApi; private readonly scmAuthApi; private readonly scmIntegrationsApi; private readonly catalogApi; private readonly configApi; constructor(options: { discoveryApi: DiscoveryApi; scmAuthApi: ScmAuthApi; fetchApi: FetchApi; scmIntegrationsApi: ScmIntegrationRegistry; catalogApi: CatalogApi; configApi: ConfigApi; }); analyzeUrl(url: string): Promise; preparePullRequest(): Promise<{ title: string; body: string; }>; submitPullRequest(options: { repositoryUrl: string; fileContent: string; title: string; body: string; }): Promise<{ link: string; location: string; }>; private analyzeLocation; } /** * The configuration of the stepper. * * @public */ type ImportFlows = 'unknown' | 'single-location' | 'multiple-locations' | 'no-location'; /** * Result of the prepare state. * * @public */ type PrepareResult = { type: 'locations'; locations: Array<{ exists?: boolean; target: string; entities: CompoundEntityRef[]; }>; } | { type: 'repository'; url: string; integrationType: string; pullRequest: { url: string; }; locations: Array<{ target: string; entities: CompoundEntityRef[]; }>; }; type ReviewResult = { type: 'locations'; locations: Array<{ target: string; entities: Entity[]; }>; refreshed: Array<{ target: string; }>; } | { type: 'repository'; url: string; integrationType: string; pullRequest: { url: string; }; locations: Array<{ target: string; entities: Entity[]; }>; }; type onAnalysisFn = (flow: ImportFlows, url: string, result: AnalyzeResult, opts?: { prepareResult?: PrepareResult; }) => void; type onPrepareFn = (result: PrepareResult, opts?: { notRepeatable?: boolean; }) => void; type onReviewFn = (result: ReviewResult) => void; type State = { activeState: 'analyze'; onAnalysis: onAnalysisFn; } | { activeState: 'prepare'; analyzeResult: AnalyzeResult; prepareResult?: PrepareResult; onPrepare: onPrepareFn; } | { activeState: 'review'; analyzeResult: AnalyzeResult; prepareResult: PrepareResult; onReview: onReviewFn; } | { activeState: 'finish'; analyzeResult: AnalyzeResult; prepareResult: PrepareResult; reviewResult: ReviewResult; }; type ImportState = State & { activeFlow: ImportFlows; activeStepNumber: number; analysisUrl?: string; onGoBack?: () => void; onReset: () => void; }; type StepperApis = { catalogImportApi: CatalogImportApi; }; type StepConfiguration = { stepLabel: ReactElement; content: ReactElement; }; /** * Defines the details of the stepper. * * @public */ interface StepperProvider { analyze: (s: Extract, opts: { apis: StepperApis; t: TranslationFunction; }) => StepConfiguration; prepare: (s: Extract, opts: { apis: StepperApis; t: TranslationFunction; }) => StepConfiguration; review: (s: Extract, opts: { apis: StepperApis; t: TranslationFunction; }) => StepConfiguration; finish: (s: Extract, opts: { apis: StepperApis; t: TranslationFunction; }) => StepConfiguration; } /** * The default stepper generation function. * * Override this function to customize the import flow. Each flow should at * least override the prepare operation. * * @param flow - the name of the active flow * @param defaults - the default steps * @param t - the translation function * @public */ declare function defaultGenerateStepper(flow: ImportFlows, defaults: StepperProvider, t: TranslationFunction): StepperProvider; /** * Props for {@link ImportStepper}. * * @public */ interface ImportStepperProps { initialUrl?: string; generateStepper?: (flow: ImportFlows, defaults: StepperProvider, t: TranslationFunction) => StepperProvider; variant?: InfoCardVariants; } /** * The stepper that holds the different import stages. * * @public */ declare const ImportStepper: (props: ImportStepperProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link StepInitAnalyzeUrl}. * * @public */ interface StepInitAnalyzeUrlProps { onAnalysis: (flow: ImportFlows, url: string, result: AnalyzeResult, opts?: { prepareResult?: PrepareResult; }) => void; disablePullRequest?: boolean; analysisUrl?: string; exampleLocationUrl?: string; } /** * A form that lets the user input a url and analyze it for existing locations or potential entities. * * @param onAnalysis - is called when the analysis was successful * @param analysisUrl - a url that can be used as a default value * @param disablePullRequest - if true, repositories without entities will abort the wizard * @public */ declare const StepInitAnalyzeUrl: (props: StepInitAnalyzeUrlProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link AutocompleteTextField}. * * @public */ interface AutocompleteTextFieldProps { name: TFieldValue; options: string[]; required?: boolean; errors?: FieldErrors; rules?: ComponentProps['rules']; loading?: boolean; loadingText?: string; helperText?: ReactNode; errorHelperText?: string; textFieldProps?: Omit; } /** * An autocompletion text field for the catalog import flows. * * @public */ declare const AutocompleteTextField: (props: AutocompleteTextFieldProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link PreparePullRequestForm}. * * @public */ type PreparePullRequestFormProps> = Pick, 'defaultValues'> & { onSubmit: SubmitHandler; render: (props: Pick, 'formState' | 'register' | 'control' | 'setValue'> & { values: TFieldValues; }) => ReactNode; }; /** * A form wrapper that creates a form that is used to prepare a pull request. It * hosts the form logic. * * @param defaultValues - the default values of the form * @param onSubmit - a callback that is executed when the form is submitted * (initiated by a button of type="submit") * @param render - render the form elements * @public */ declare const PreparePullRequestForm: >(props: PreparePullRequestFormProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link PreviewCatalogInfoComponent}. * * @public */ interface PreviewCatalogInfoComponentProps { repositoryUrl: string; entities: Entity[]; classes?: { card?: string; cardContent?: string; }; } /** * Previews information about an entity to create. * * @public */ declare const PreviewCatalogInfoComponent: (props: PreviewCatalogInfoComponentProps) => react_jsx_runtime.JSX.Element; /** * Props for {@link PreviewPullRequestComponent}. * * @public */ interface PreviewPullRequestComponentProps { title: string; description: string; classes?: { card?: string; cardContent?: string; }; } /** * Previews a pull request. * * @public */ declare const PreviewPullRequestComponent: (props: PreviewPullRequestComponentProps) => react_jsx_runtime.JSX.Element; type FormData = { title: string; body: string; componentName: string; owner: string; useCodeowners: boolean; }; /** * Helper for unpacking NestedValue into the underlying type. * * @public * @deprecated This is a copy of the type from react-hook-form, and will be removed in a future release */ type UnpackNestedValue = T extends NestedValue ? U : T extends Date | FileList | File | Blob ? T : T extends object ? { [K in keyof T]: UnpackNestedValue; } : T; /** * Props for {@link StepPrepareCreatePullRequest}. * * @public */ interface StepPrepareCreatePullRequestProps { analyzeResult: Extract; onPrepare: (result: PrepareResult, opts?: { notRepeatable?: boolean; }) => void; onGoBack?: () => void; renderFormFields: (props: Pick, 'register' | 'setValue' | 'formState'> & { values: UnpackNestedValue; groups: string[]; groupsLoading: boolean; }) => ReactNode; } /** * Prepares a pull request. * * @public */ declare const StepPrepareCreatePullRequest: (props: StepPrepareCreatePullRequestProps) => react_jsx_runtime.JSX.Element; /** @public */ declare const catalogImportTranslationRef: _backstage_frontend_plugin_api.TranslationRef<"catalog-import", { readonly "buttons.back": "Back"; readonly "defaultImportPage.headerTitle": "Register an existing component"; readonly "defaultImportPage.contentHeaderTitle": "Start tracking your component in {{appTitle}}"; readonly "defaultImportPage.supportTitle": "Start tracking your component in {{appTitle}} by adding it to the software catalog."; readonly "importInfoCard.title": "Register an existing component"; readonly "importInfoCard.deepLinkTitle": "Learn more about the Software Catalog"; readonly "importInfoCard.linkDescription": "Enter the URL to your source code repository to add it to {{appTitle}}."; readonly "importInfoCard.fileLinkTitle": "Link to an existing entity file"; readonly "importInfoCard.examplePrefix": "Example: "; readonly "importInfoCard.fileLinkDescription": "The wizard analyzes the file, previews the entities, and adds them to the {{appTitle}} catalog."; readonly "importInfoCard.exampleDescription": "The wizard discovers all {{catalogFilename}} files in the repository, previews the entities, and adds them to the {{appTitle}} catalog."; readonly "importInfoCard.preparePullRequestDescription": "If no entities are found, the wizard will prepare a Pull Request that adds an example {{catalogFilename}} and prepares the {{appTitle}} catalog to load all entities as soon as the Pull Request is merged."; readonly "importInfoCard.githubIntegration.label": "GitHub only"; readonly "importInfoCard.githubIntegration.title": "Link to a repository"; readonly "importStepper.finish.title": "Finish"; readonly "importStepper.singleLocation.title": "Select Locations"; readonly "importStepper.singleLocation.description": "Discovered Locations: 1"; readonly "importStepper.multipleLocations.title": "Select Locations"; readonly "importStepper.multipleLocations.description": "Discovered Locations: {{length, number}}"; readonly "importStepper.noLocation.title": "Create Pull Request"; readonly "importStepper.noLocation.createPr.detailsTitle": "Pull Request Details"; readonly "importStepper.noLocation.createPr.titleLabel": "Pull Request Title"; readonly "importStepper.noLocation.createPr.titlePlaceholder": "Add Backstage catalog entity descriptor files"; readonly "importStepper.noLocation.createPr.bodyLabel": "Pull Request Body"; readonly "importStepper.noLocation.createPr.bodyPlaceholder": "A describing text with Markdown support"; readonly "importStepper.noLocation.createPr.configurationTitle": "Entity Configuration"; readonly "importStepper.noLocation.createPr.componentNameLabel": "Name of the created component"; readonly "importStepper.noLocation.createPr.componentNamePlaceholder": "my-component"; readonly "importStepper.noLocation.createPr.ownerLoadingText": "Loading groups…"; readonly "importStepper.noLocation.createPr.ownerHelperText": "Select an owner from the list or enter a reference to a Group or a User"; readonly "importStepper.noLocation.createPr.ownerErrorHelperText": "required value"; readonly "importStepper.noLocation.createPr.ownerLabel": "Entity Owner"; readonly "importStepper.noLocation.createPr.ownerPlaceholder": "my-group"; readonly "importStepper.noLocation.createPr.codeownersHelperText": "WARNING: This may fail if no CODEOWNERS file is found at the target location."; readonly "importStepper.analyze.title": "Select URL"; readonly "importStepper.prepare.title": "Import Actions"; readonly "importStepper.prepare.description": "Optional"; readonly "importStepper.review.title": "Review"; readonly "stepFinishImportLocation.repository.title": "The following Pull Request has been opened: "; readonly "stepFinishImportLocation.repository.description": "Your entities will be imported as soon as the Pull Request is merged."; readonly "stepFinishImportLocation.locations.new": "The following entities have been added to the catalog:"; readonly "stepFinishImportLocation.locations.backButtonText": "Register another"; readonly "stepFinishImportLocation.locations.existing": "A refresh was triggered for the following locations:"; readonly "stepFinishImportLocation.locations.viewButtonText": "View Component"; readonly "stepFinishImportLocation.backButtonText": "Register another"; readonly "stepInitAnalyzeUrl.error.default": "Received unknown analysis result of type {{type}}. Please contact the support team."; readonly "stepInitAnalyzeUrl.error.url": "Must start with http:// or https://."; readonly "stepInitAnalyzeUrl.error.repository": "Couldn't generate entities for your repository"; readonly "stepInitAnalyzeUrl.error.locations": "There are no entities at this location"; readonly "stepInitAnalyzeUrl.urlHelperText": "Enter the full path to your entity file to start tracking your component"; readonly "stepInitAnalyzeUrl.nextButtonText": "Analyze"; readonly "stepPrepareCreatePullRequest.description": "You entered a link to a {{integrationType}} repository but a {{catalogFilename}} could not be found. Use this form to open a Pull Request that creates one."; readonly "stepPrepareCreatePullRequest.nextButtonText": "Create PR"; readonly "stepPrepareCreatePullRequest.previewPr.title": "Preview Pull Request"; readonly "stepPrepareCreatePullRequest.previewPr.subheader": "Create a new Pull Request"; readonly "stepPrepareCreatePullRequest.previewCatalogInfo.title": "Preview Entities"; readonly "stepPrepareSelectLocations.locations.description": "Select one or more locations that are present in your git repository:"; readonly "stepPrepareSelectLocations.locations.selectAll": "Select All"; readonly "stepPrepareSelectLocations.nextButtonText": "Review"; readonly "stepPrepareSelectLocations.existingLocations.description": "These locations already exist in the catalog:"; readonly "stepReviewLocation.refresh": "Refresh"; readonly "stepReviewLocation.import": "Import"; readonly "stepReviewLocation.catalog.new": "The following entities will be added to the catalog:"; readonly "stepReviewLocation.catalog.exists": "The following locations already exist in the catalog:"; readonly "stepReviewLocation.prepareResult.title": "The following Pull Request has been opened: "; readonly "stepReviewLocation.prepareResult.description": "You can already import the location and {{appTitle}} will fetch the entities as soon as the Pull Request is merged."; }>; export { AutocompleteTextField, CatalogImportClient, CatalogImportPage, DefaultImportPage, EntityListComponent, ImportInfoCard, ImportStepper, PreparePullRequestForm, PreviewCatalogInfoComponent, PreviewPullRequestComponent, StepInitAnalyzeUrl, StepPrepareCreatePullRequest, catalogImportApiRef, catalogImportPlugin, catalogImportTranslationRef, defaultGenerateStepper, catalogImportPlugin as plugin }; export type { AnalyzeResult, AutocompleteTextFieldProps, CatalogImportApi, EntityListComponentProps, ImportFlows, ImportInfoCardProps, ImportState, ImportStepperProps, PreparePullRequestFormProps, PrepareResult, PreviewCatalogInfoComponentProps, PreviewPullRequestComponentProps, StepInitAnalyzeUrlProps, StepPrepareCreatePullRequestProps, UnpackNestedValue };