@backstage/plugin-catalog-import 0.13.4-next.2 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/alpha.d.ts +1 -1
- package/dist/alpha.esm.js +2 -2
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api/AzureDevops.esm.js.map +1 -1
- package/dist/api/AzureRepoApiClient.esm.js.map +1 -1
- package/dist/api/CatalogImportApi.esm.js.map +1 -1
- package/dist/api/CatalogImportClient.esm.js.map +1 -1
- package/dist/api/GitHub.esm.js.map +1 -1
- package/dist/components/Buttons/index.esm.js +1 -1
- package/dist/components/Buttons/index.esm.js.map +1 -1
- package/dist/components/DefaultImportPage/DefaultImportPage.esm.js.map +1 -1
- package/dist/components/EntityListComponent/EntityListComponent.esm.js.map +1 -1
- package/dist/components/ImportInfoCard/ImportInfoCard.esm.js.map +1 -1
- package/dist/components/ImportPage/ImportPage.esm.js.map +1 -1
- package/dist/components/ImportStepper/ImportStepper.esm.js +1 -1
- package/dist/components/ImportStepper/ImportStepper.esm.js.map +1 -1
- package/dist/components/ImportStepper/defaults.esm.js.map +1 -1
- package/dist/components/StepFinishImportLocation/StepFinishImportLocation.esm.js.map +1 -1
- package/dist/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/AutocompleteTextField.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreparePullRequestForm.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js.map +1 -1
- package/dist/components/StepPrepareSelectLocations/StepPrepareSelectLocations.esm.js.map +1 -1
- package/dist/components/StepReviewLocation/StepReviewLocation.esm.js.map +1 -1
- package/dist/components/helpers.esm.js.map +1 -1
- package/dist/components/useImportState.esm.js.map +1 -1
- package/dist/hooks/useCatalogFilename.esm.js.map +1 -1
- package/dist/package.json.esm.js +1 -1
- package/dist/plugin.esm.js +2 -2
- package/dist/plugin.esm.js.map +1 -1
- package/dist/translation.esm.js.map +1 -1
- package/package.json +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-import
|
|
2
2
|
|
|
3
|
+
## 0.13.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e4ddf22: Internal update to align with new blueprint parameter naming in the new frontend system.
|
|
8
|
+
- f2f133c: Internal update to use the new variant of `ApiBlueprint`.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/core-components@0.17.5
|
|
11
|
+
- @backstage/frontend-plugin-api@0.11.0
|
|
12
|
+
- @backstage/core-compat-api@0.5.0
|
|
13
|
+
- @backstage/plugin-catalog-react@1.20.0
|
|
14
|
+
- @backstage/catalog-client@1.11.0
|
|
15
|
+
|
|
3
16
|
## 0.13.4-next.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/alpha.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ declare const catalogImportTranslationRef: _backstage_core_plugin_api_alpha.Tran
|
|
|
74
74
|
}>;
|
|
75
75
|
|
|
76
76
|
/** @alpha */
|
|
77
|
-
declare const _default: _backstage_frontend_plugin_api.
|
|
77
|
+
declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin<{
|
|
78
78
|
importPage: _backstage_frontend_plugin_api.RouteRef<undefined>;
|
|
79
79
|
}, {}, {
|
|
80
80
|
"api:catalog-import": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { configApiRef, fetchApiRef, discoveryApiRef } from '@backstage/core-plugin-api';
|
|
3
3
|
import { convertLegacyRouteRef, compatWrapper } from '@backstage/core-compat-api';
|
|
4
4
|
import { PageBlueprint, ApiBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
5
|
-
import {
|
|
5
|
+
import { scmIntegrationsApiRef, scmAuthApiRef } from '@backstage/integration-react';
|
|
6
6
|
import { catalogImportApiRef } from './api/CatalogImportApi.esm.js';
|
|
7
7
|
import { CatalogImportClient } from './api/CatalogImportClient.esm.js';
|
|
8
8
|
import { rootRouteRef } from './plugin.esm.js';
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nexport * from './translation';\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n path: '/catalog-import',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/ImportPage').then(m =>\n compatWrapper(<m.ImportPage />),\n ),\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'catalog-import',\n info: { packageJson: () => import('../package.json') },\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: convertLegacyRouteRef(rootRouteRef),\n },\n});\n\nexport { catalogImportTranslationRef } from './translation';\n"],"names":[],"mappings":";;;;;;;;;;;AA0CA,MAAM,iBAAA,GAAoB,cAAc,
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nexport * from './translation';\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n path: '/catalog-import',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/ImportPage').then(m =>\n compatWrapper(<m.ImportPage />),\n ),\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'catalog-import',\n info: { packageJson: () => import('../package.json') },\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: convertLegacyRouteRef(rootRouteRef),\n },\n});\n\nexport { catalogImportTranslationRef } from './translation';\n"],"names":[],"mappings":";;;;;;;;;;;AA0CA,MAAM,iBAAA,GAAoB,cAAc,IAAA,CAAK;AAAA,EAC3C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,iBAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,MAAA,EAAQ,MACN,OAAO,sCAAyB,CAAA,CAAE,IAAA;AAAA,MAAK,OACrC,aAAA,iBAAc,GAAA,CAAC,CAAA,CAAE,UAAA,EAAF,EAAa,CAAE;AAAA;AAChC;AAEN,CAAC,CAAA;AAED,MAAM,gBAAA,GAAmB,aAAa,IAAA,CAAK;AAAA,EACzC,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,mBAAA;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,YAAA,EAAc,eAAA;AAAA,MACd,UAAA,EAAY,aAAA;AAAA,MACZ,QAAA,EAAU,WAAA;AAAA,MACV,kBAAA,EAAoB,qBAAA;AAAA,MACpB,UAAA,EAAY,aAAA;AAAA,MACZ,SAAA,EAAW;AAAA,KACb;AAAA,IACA,SAAS,CAAC;AAAA,MACR,YAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,MACA,kBAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF,KACE,IAAI,mBAAA,CAAoB;AAAA,MACtB,YAAA;AAAA,MACA,UAAA;AAAA,MACA,kBAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACD;AAAA,GACJ;AACL,CAAC,CAAA;AAGD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,gBAAA;AAAA,EACV,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAA,EAAE;AAAA,EACrD,UAAA,EAAY,CAAC,gBAAA,EAAkB,iBAAiB,CAAA;AAAA,EAChD,MAAA,EAAQ;AAAA,IACN,UAAA,EAAY,sBAAsB,YAAY;AAAA;AAElD,CAAC,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureDevops.esm.js","sources":["../../src/api/AzureDevops.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { createAzurePullRequest } from './AzureRepoApiClient';\n\nexport interface AzureRepoParts {\n tenantUrl: string;\n repoName: string;\n project: string;\n}\n\nexport function parseAzureUrl(repoUrl: string): AzureRepoParts {\n const { org, repo, project, host } = parseRepoUrl(repoUrl);\n if (!org || !repo || !project) {\n throw new Error(\n 'Invalid AzureDevops Repository. Please use a valid repository url and try again ',\n );\n }\n const tenantUrl = `https://${host}/${org}`;\n\n return { tenantUrl, repoName: repo, project: project };\n}\n\nexport async function submitAzurePrToRepo(\n options: {\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n },\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n) {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n const { tenantUrl, repoName, project } = parseAzureUrl(repositoryUrl);\n const result = await createAzurePullRequest({\n token,\n fileContent,\n title,\n description: body,\n project,\n repository: repoName,\n branchName,\n tenantUrl,\n fileName,\n });\n const catalogLocation = `${result.repository.webUrl}?path=/${fileName}`;\n const prLocation = `${result.repository.webUrl}/pullrequest/${result.pullRequestId}`;\n return {\n link: prLocation!,\n location: catalogLocation,\n };\n}\n\nexport function parseRepoUrl(sourceUrl: string) {\n const url = new URL(sourceUrl);\n\n let host = url.host;\n let org;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n org = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n org = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n host = `${host}/${parts[1]}`;\n org = parts[2];\n project = parts[3];\n repo = parts[5];\n }\n\n return { host, org, project, repo };\n}\n"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"AzureDevops.esm.js","sources":["../../src/api/AzureDevops.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { createAzurePullRequest } from './AzureRepoApiClient';\n\nexport interface AzureRepoParts {\n tenantUrl: string;\n repoName: string;\n project: string;\n}\n\nexport function parseAzureUrl(repoUrl: string): AzureRepoParts {\n const { org, repo, project, host } = parseRepoUrl(repoUrl);\n if (!org || !repo || !project) {\n throw new Error(\n 'Invalid AzureDevops Repository. Please use a valid repository url and try again ',\n );\n }\n const tenantUrl = `https://${host}/${org}`;\n\n return { tenantUrl, repoName: repo, project: project };\n}\n\nexport async function submitAzurePrToRepo(\n options: {\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n },\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n) {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n const { tenantUrl, repoName, project } = parseAzureUrl(repositoryUrl);\n const result = await createAzurePullRequest({\n token,\n fileContent,\n title,\n description: body,\n project,\n repository: repoName,\n branchName,\n tenantUrl,\n fileName,\n });\n const catalogLocation = `${result.repository.webUrl}?path=/${fileName}`;\n const prLocation = `${result.repository.webUrl}/pullrequest/${result.pullRequestId}`;\n return {\n link: prLocation!,\n location: catalogLocation,\n };\n}\n\nexport function parseRepoUrl(sourceUrl: string) {\n const url = new URL(sourceUrl);\n\n let host = url.host;\n let org;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n org = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n org = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n host = `${host}/${parts[1]}`;\n org = parts[2];\n project = parts[3];\n repo = parts[5];\n }\n\n return { host, org, project, repo };\n}\n"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,OAAA,EAAiC;AAC7D,EAAA,MAAM,EAAE,GAAA,EAAK,IAAA,EAAM,SAAS,IAAA,EAAK,GAAI,aAAa,OAAO,CAAA;AACzD,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,IAAA,IAAQ,CAAC,OAAA,EAAS;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,SAAA,GAAY,CAAA,QAAA,EAAW,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAExC,EAAA,OAAO,EAAE,SAAA,EAAW,QAAA,EAAU,IAAA,EAAM,OAAA,EAAiB;AACvD;AAEA,eAAsB,mBAAA,CACpB,OAAA,EAMA,UAAA,EACA,SAAA,EACA;AACA,EAAA,MAAM,EAAE,aAAA,EAAe,WAAA,EAAa,KAAA,EAAO,MAAK,GAAI,OAAA;AAEpD,EAAA,MAAM,UAAA,GAAa,cAAc,SAAS,CAAA;AAC1C,EAAA,MAAM,QAAA,GAAW,mBAAmB,SAAS,CAAA;AAE7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AA,OAAA,GAAU,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,EAC1B,CAAA,MAAA,IAAW,KAAA,CAAM,CAAC,CAAA,KAAM,MAAA,EAAQ;AAC9B,IAAA,GAAA,GAAM,MAAM,CAAC,CAAA;AACb,IAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,IAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,EAChB,CAAA,MAAA,IAAW,KAAA,CAAM,CAAC,CAAA,KAAM,MAAA,EAAQ;AAC9B,IAAA,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAC1B,IAAA,GAAA,GAAM,MAAM,CAAC,CAAA;AACb,IAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,IAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,EAChB;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,GAAA,EAAK,OAAA,EAAS,IAAA,EAAK;AACpC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureRepoApiClient.esm.js","sources":["../../src/api/AzureRepoApiClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface AzurePrOptions {\n tenantUrl: string;\n title: string;\n project: string;\n branchName: string;\n repository: string;\n token: string;\n fileContent: string;\n fileName: string;\n description: string;\n}\n\nexport interface CreateAzurePr {\n sourceRefName: string;\n targetRefName: string;\n title: string;\n description: string;\n}\n\nexport interface AzureRepo {\n id: string;\n name: string;\n defaultBranch: string;\n}\n\nexport interface AzureRef {\n name: string;\n objectId: string;\n}\n\ninterface RefQueryResult {\n value: AzureRef[];\n}\n\nexport interface AzureCommit {\n comment: string;\n\n changes: {\n changeType: string;\n item: {\n path: string;\n };\n newContent: {\n content: string;\n contentType: 'rawtext';\n };\n }[];\n}\n\nexport interface AzureRefUpdate {\n repositoryId: string;\n name: string;\n oldObjectId: string;\n newObjectId: string;\n}\n\nexport interface AzurePushResult {\n refUpdates: AzureRefUpdate[];\n}\n\nexport interface AzurePush {\n refUpdates: {\n name: string;\n oldObjectId: string;\n }[];\n commits: AzureCommit[];\n}\n\nexport interface AzurePrResult {\n pullRequestId: string;\n repository: {\n name: string;\n webUrl: string;\n };\n}\n\nconst apiVersions = '6.0';\n\nexport interface RepoApiClientOptions {\n project: string;\n tenantUrl: string;\n}\n\nexport interface NewBranchOptions {\n fileContent: string;\n fileName: string;\n title: string;\n branchName: string;\n repoName: string;\n sourceBranch: AzureRef;\n}\n\nexport interface CreatePrOptions {\n repoName: string;\n sourceName: string;\n targetName: string;\n description: string;\n title: string;\n}\n\nexport class RepoApiClient {\n private createEndpoint = (\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n ) => {\n const url = new URL(\n `${this._options.tenantUrl}/${this._options.project}/_apis/git/repositories`,\n );\n url.pathname += path;\n\n url.searchParams.set('api-version', version);\n Object.entries(queryParams ?? {}).forEach(([key, value]) =>\n url.searchParams.set(key, value),\n );\n return url.toString();\n };\n\n constructor(private _options: RepoApiClientOptions) {}\n\n private async get<T>(\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version, queryParams);\n const result = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n private async post<T>(\n path: string,\n version: string,\n payload: unknown,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version);\n const result = await fetch(endpoint, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n async getRepository(\n repositoryName: string,\n token: string,\n ): Promise<AzureRepo> {\n return this.get(`/${repositoryName}`, apiVersions, undefined, token);\n }\n\n async getDefaultBranch(repo: AzureRepo, token: string): Promise<AzureRef> {\n const filter = repo.defaultBranch.replace('refs/', '');\n const result: RefQueryResult = await this.get(\n `/${repo.name}/refs`,\n apiVersions,\n { filter },\n token,\n );\n if (!result.value?.length) {\n return Promise.reject(\n new Error(`The requested ref '${filter}' was not found`),\n );\n }\n return result.value[0];\n }\n\n async pushNewBranch(\n options: NewBranchOptions,\n token: string,\n ): Promise<AzureRefUpdate> {\n const { sourceBranch, repoName } = options;\n const push: AzurePush = {\n refUpdates: [\n {\n name: `refs/heads/${options.branchName}`,\n oldObjectId: sourceBranch.objectId,\n },\n ],\n commits: [\n {\n comment: options.title,\n changes: [\n {\n changeType: 'add',\n item: {\n path: `/${options.fileName}`,\n },\n newContent: {\n content: options.fileContent,\n contentType: 'rawtext',\n },\n },\n ],\n },\n ],\n };\n const result = await this.post<AzurePushResult>(\n `/${repoName}/pushes`,\n apiVersions,\n push,\n token,\n );\n return result.refUpdates[0];\n }\n\n async createPullRequest(\n options: CreatePrOptions,\n token: string,\n ): Promise<AzurePrResult> {\n const { repoName, sourceName, targetName } = options;\n const payload: CreateAzurePr = {\n title: options.title,\n description: options.description,\n sourceRefName: sourceName,\n targetRefName: targetName,\n };\n\n return await this.post<AzurePrResult>(\n `/${repoName}/pullrequests`,\n apiVersions,\n payload,\n token,\n );\n }\n}\n\nexport async function createAzurePullRequest(\n options: AzurePrOptions,\n client: RepoApiClient | undefined = undefined,\n): Promise<AzurePrResult> {\n const {\n title,\n repository,\n token,\n fileContent,\n fileName,\n branchName,\n description,\n } = options;\n const actualClient = client ?? new RepoApiClient(options);\n const repo = await actualClient.getRepository(repository, token);\n const defaultBranch = await actualClient.getDefaultBranch(repo, token);\n const branchOptions: NewBranchOptions = {\n title: title,\n repoName: repo.name,\n sourceBranch: defaultBranch,\n branchName: branchName,\n fileContent: fileContent,\n fileName: fileName,\n };\n const refUpdate = await actualClient.pushNewBranch(branchOptions, token);\n const prOptions: CreatePrOptions = {\n title,\n description,\n repoName: repo.name,\n sourceName: refUpdate.name,\n targetName: defaultBranch.name,\n };\n return actualClient.createPullRequest(prOptions, token);\n}\n"],"names":[],"mappings":"AA4FA,MAAM,WAAc,GAAA,KAAA;AAwBb,MAAM,aAAc,CAAA;AAAA,EAkBzB,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAAA;AAAiC,EAjB7C,cAAiB,GAAA,CACvB,IACA,EAAA,OAAA,EACA,cAAkD,KAC/C,CAAA,KAAA;AACH,IAAA,MAAM,MAAM,IAAI,GAAA;AAAA,MACd,GAAG,IAAK,CAAA,QAAA,CAAS,SAAS,CAAI,CAAA,EAAA,IAAA,CAAK,SAAS,OAAO,CAAA,uBAAA;AAAA,KACrD;AACA,IAAA,GAAA,CAAI,QAAY,IAAA,IAAA;AAEhB,IAAI,GAAA,CAAA,YAAA,CAAa,GAAI,CAAA,aAAA,EAAe,OAAO,CAAA;AAC3C,IAAA,MAAA,CAAO,OAAQ,CAAA,WAAA,IAAe,EAAE,CAAE,CAAA,OAAA;AAAA,MAAQ,CAAC,CAAC,GAAK,EAAA,KAAK,MACpD,GAAI,CAAA,YAAA,CAAa,GAAI,CAAA,GAAA,EAAK,KAAK;AAAA,KACjC;AACA,IAAA,OAAO,IAAI,QAAS,EAAA;AAAA,GACtB;AAAA,EAIA,MAAc,GACZ,CAAA,IAAA,EACA,OACA,EAAA,WAAA,GAAkD,QAClD,KACY,EAAA;AACZ,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,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U,IAAK,CAAA,IAAA;AAAA,IACf,YAAc,EAAA,aAAA;AAAA,IACd,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,aAAA,CAAc,eAAe,KAAK,CAAA;AACvE,EAAA,MAAM,SAA6B,GAAA;AAAA,IACjC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAU,IAAK,CAAA,IAAA;AAAA,IACf,YAAY,SAAU,CAAA,IAAA;AAAA,IACtB,YAAY,aAAc,CAAA;AAAA,GAC5B;AACA,EAAO,OAAA,YAAA,CAAa,iBAAkB,CAAA,SAAA,EAAW,KAAK,CAAA;AACxD;;;;"}
|
|
1
|
+
{"version":3,"file":"AzureRepoApiClient.esm.js","sources":["../../src/api/AzureRepoApiClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface AzurePrOptions {\n tenantUrl: string;\n title: string;\n project: string;\n branchName: string;\n repository: string;\n token: string;\n fileContent: string;\n fileName: string;\n description: string;\n}\n\nexport interface CreateAzurePr {\n sourceRefName: string;\n targetRefName: string;\n title: string;\n description: string;\n}\n\nexport interface AzureRepo {\n id: string;\n name: string;\n defaultBranch: string;\n}\n\nexport interface AzureRef {\n name: string;\n objectId: string;\n}\n\ninterface RefQueryResult {\n value: AzureRef[];\n}\n\nexport interface AzureCommit {\n comment: string;\n\n changes: {\n changeType: string;\n item: {\n path: string;\n };\n newContent: {\n content: string;\n contentType: 'rawtext';\n };\n }[];\n}\n\nexport interface AzureRefUpdate {\n repositoryId: string;\n name: string;\n oldObjectId: string;\n newObjectId: string;\n}\n\nexport interface AzurePushResult {\n refUpdates: AzureRefUpdate[];\n}\n\nexport interface AzurePush {\n refUpdates: {\n name: string;\n oldObjectId: string;\n }[];\n commits: AzureCommit[];\n}\n\nexport interface AzurePrResult {\n pullRequestId: string;\n repository: {\n name: string;\n webUrl: string;\n };\n}\n\nconst apiVersions = '6.0';\n\nexport interface RepoApiClientOptions {\n project: string;\n tenantUrl: string;\n}\n\nexport interface NewBranchOptions {\n fileContent: string;\n fileName: string;\n title: string;\n branchName: string;\n repoName: string;\n sourceBranch: AzureRef;\n}\n\nexport interface CreatePrOptions {\n repoName: string;\n sourceName: string;\n targetName: string;\n description: string;\n title: string;\n}\n\nexport class RepoApiClient {\n private createEndpoint = (\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n ) => {\n const url = new URL(\n `${this._options.tenantUrl}/${this._options.project}/_apis/git/repositories`,\n );\n url.pathname += path;\n\n url.searchParams.set('api-version', version);\n Object.entries(queryParams ?? {}).forEach(([key, value]) =>\n url.searchParams.set(key, value),\n );\n return url.toString();\n };\n\n constructor(private _options: RepoApiClientOptions) {}\n\n private async get<T>(\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version, queryParams);\n const result = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n private async post<T>(\n path: string,\n version: string,\n payload: unknown,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version);\n const result = await fetch(endpoint, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n async getRepository(\n repositoryName: string,\n token: string,\n ): Promise<AzureRepo> {\n return this.get(`/${repositoryName}`, apiVersions, undefined, token);\n }\n\n async getDefaultBranch(repo: AzureRepo, token: string): Promise<AzureRef> {\n const filter = repo.defaultBranch.replace('refs/', '');\n const result: RefQueryResult = await this.get(\n `/${repo.name}/refs`,\n apiVersions,\n { filter },\n token,\n );\n if (!result.value?.length) {\n return Promise.reject(\n new Error(`The requested ref '${filter}' was not found`),\n );\n }\n return result.value[0];\n }\n\n async pushNewBranch(\n options: NewBranchOptions,\n token: string,\n ): Promise<AzureRefUpdate> {\n const { sourceBranch, repoName } = options;\n const push: AzurePush = {\n refUpdates: [\n {\n name: `refs/heads/${options.branchName}`,\n oldObjectId: sourceBranch.objectId,\n },\n ],\n commits: [\n {\n comment: options.title,\n changes: [\n {\n changeType: 'add',\n item: {\n path: `/${options.fileName}`,\n },\n newContent: {\n content: options.fileContent,\n contentType: 'rawtext',\n },\n },\n ],\n },\n ],\n };\n const result = await this.post<AzurePushResult>(\n `/${repoName}/pushes`,\n apiVersions,\n push,\n token,\n );\n return result.refUpdates[0];\n }\n\n async createPullRequest(\n options: CreatePrOptions,\n token: string,\n ): Promise<AzurePrResult> {\n const { repoName, sourceName, targetName } = options;\n const payload: CreateAzurePr = {\n title: options.title,\n description: options.description,\n sourceRefName: sourceName,\n targetRefName: targetName,\n };\n\n return await this.post<AzurePrResult>(\n `/${repoName}/pullrequests`,\n apiVersions,\n payload,\n token,\n );\n }\n}\n\nexport async function createAzurePullRequest(\n options: AzurePrOptions,\n client: RepoApiClient | undefined = undefined,\n): Promise<AzurePrResult> {\n const {\n title,\n repository,\n token,\n fileContent,\n fileName,\n branchName,\n description,\n } = options;\n const actualClient = client ?? new RepoApiClient(options);\n const repo = await actualClient.getRepository(repository, token);\n const defaultBranch = await actualClient.getDefaultBranch(repo, token);\n const branchOptions: NewBranchOptions = {\n title: title,\n repoName: repo.name,\n sourceBranch: defaultBranch,\n branchName: branchName,\n fileContent: fileContent,\n fileName: fileName,\n };\n const refUpdate = await actualClient.pushNewBranch(branchOptions, token);\n const prOptions: CreatePrOptions = {\n title,\n description,\n repoName: repo.name,\n sourceName: refUpdate.name,\n targetName: defaultBranch.name,\n };\n return actualClient.createPullRequest(prOptions, token);\n}\n"],"names":[],"mappings":"AA4FA,MAAM,WAAA,GAAc,KAAA;AAwBb,MAAM,aAAA,CAAc;AAAA,EAkBzB,YAAoB,QAAA,EAAgC;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAAA,EAAiC;AAAA,EAjB7C,cAAA,GAAiB,CACvB,IAAA,EACA,OAAA,EACA,cAAkD,MAAA,KAC/C;AACH,IAAA,MAAM,MAAM,IAAI,GAAA;AAAA,MACd,GAAG,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA,CAAA,EAAI,IAAA,CAAK,SAAS,OAAO,CAAA,uBAAA;AAAA,KACrD;AACA,IAAA,GAAA,CAAI,QAAA,IAAY,IAAA;AAEhB,IAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,aAAA,EAAe,OAAO,CAAA;AAC3C,IAAA,MAAA,CAAO,OAAA,CAAQ,WAAA,IAAe,EAAE,CAAA,CAAE,OAAA;AAAA,MAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,MACpD,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,GAAA,EAAK,KAAK;AAAA,KACjC;AACA,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB,CAAA;AAAA,EAIA,MAAc,GAAA,CACZ,IAAA,EACA,OAAA,EACA,WAAA,GAAkD,QAClD,KAAA,EACY;AACZ,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,cAAA,CAAe,IAAA,EAAM,SAAS,WAAW,CAAA;AAC/D,IAAA,MAAM,MAAA,GAAS,MAAM,KAAA,CAAM,QAAA,EAAU;AAAA,MACnC,OAAA,EAAS;AAAA,QACP,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA;AAChC,KACD,CAAA;AACD,IAAA,IAAI,CAAC,O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AA;AACvE,EAAA,MAAM,SAAA,GAA6B;AAAA,IACjC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAU,IAAA,CAAK,IAAA;AAAA,IACf,YAAY,SAAA,CAAU,IAAA;AAAA,IACtB,YAAY,aAAA,CAAc;AAAA,GAC5B;AACA,EAAA,OAAO,YAAA,CAAa,iBAAA,CAAkB,SAAA,EAAW,KAAK,CAAA;AACxD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogImportApi.esm.js","sources":["../../src/api/CatalogImportApi.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\n/**\n * Utility API reference for the {@link CatalogImportApi}.\n *\n * @public\n */\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n});\n\n/**\n * Result of the analysis.\n *\n * @public\n */\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\n/**\n * API for driving catalog imports.\n *\n * @public\n */\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"CatalogImportApi.esm.js","sources":["../../src/api/CatalogImportApi.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\n/**\n * Utility API reference for the {@link CatalogImportApi}.\n *\n * @public\n */\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n});\n\n/**\n * Result of the analysis.\n *\n * @public\n */\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\n/**\n * API for driving catalog imports.\n *\n * @public\n */\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,sBAAsB,YAAA,CAA+B;AAAA,EAChE,EAAA,EAAI;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport YAML from 'yaml';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const parseData = YAML.parseAllDocuments(fileContent);\n\n for (const document of parseData) {\n const validationResponse = await this.catalogApi.validateEntity(\n document.toJS(),\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;;AAqCO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAOT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,OAAQ,CAAA,UAAA;AAC1B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AACxB,IAAA,IAAA,CAAK,qBAAqB,OAAQ,CAAA,kBAAA;AAClC,IAAA,IAAA,CAAK,aAAa,OAAQ,CAAA,UAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AAAA;AAC3B,EAEA,MAAM,WAAW,GAAqC,EAAA;AACpD,IAAA,IACE,IAAI,GAAI,CAAA,GAAG,EAAE,QAAS,CAAA,KAAA,CAAM,UAAU,CACtC,IAAA,IAAI,GAAI,CAAA,GAAG,EAAE,YAAa,CAAA,GAAA,CAAI,MAAM,CAAG,EAAA,KAAA,CAAM,SAAS,CACtD,EAAA;AACA,MAAA,MAAM,QAAW,GAAA,MAAM,IAAK,CAAA,UAAA,CAAW,WAAY,CAAA;AAAA,QACjD,IAAM,EAAA,KAAA;AAAA,QACN,MAAQ,EAAA,GAAA;AAAA,QACR,MAAQ,EAAA;AAAA,OACT,CAAA;AAED,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,WAAA;AAAA,QACN,SAAW,EAAA;AAAA,UACT;AAAA,YACE,QAAQ,QAAS,CAAA,MAA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AEX;;;;"}
|
|
1
|
+
{"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport YAML from 'yaml';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const parseData = YAML.parseAllDocuments(fileContent);\n\n for (const document of parseData) {\n const validationResponse = await this.catalogApi.validateEntity(\n document.toJS(),\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;;AAqCO,MAAM,mBAAA,CAAgD;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAAA,EAOT;AACD,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,qBAAqB,OAAA,CAAQ,kBAAA;AAClC,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,WAAW,GAAA,EAAqC;AACpD,IAAA,IACE,IAAI,GAAA,CAAI,GAAG,EAAE,QAAA,CAAS,KAAA,CAAM,UAAU,CAAA,IACtC,IAAI,GAAA,CAAI,GAAG,EAAE,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG,KAAA,CAAM,SAAS,CAAA,EACtD;AACA,MAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,UAAA,CAAW,WAAA,CAAY;AAAA,QACjD,IAAA,EAAM,KAAA;AAAA,QACN,MAAA,EAAQ,GAAA;AAAA,QACR,MAAA,EAAQ;AAAA,OACT,CAAA;A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R,CAAA,8DAAA,EAAiE,QAAA,CAAS,MAAM,CAAA,EAAA,EAAK,SAAS,UAAU,CAAA;AAAA,OAC1G;AAAA,IACF;AAEA,IAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,IAAA,EAAK;AACpC,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHub.esm.js","sources":["../../src/api/GitHub.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { Base64 } from 'js-base64';\n\nexport interface GitHubOptions {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GithubIntegrationConfig;\n}\nexport const getGithubIntegrationConfig = (\n scmIntegrationsApi: ScmIntegrationRegistry,\n location: string,\n) => {\n const integration = scmIntegrationsApi.github.byUrl(location);\n if (!integration) {\n return undefined;\n }\n\n const { name: repo, owner } = parseGitUrl(location);\n return {\n repo,\n owner,\n githubIntegrationConfig: integration.config,\n };\n};\n\nexport async function submitGitHubPrToRepo(\n options: GitHubOptions,\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n): Promise<{ link: string; location: string }> {\n const {\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n } = options;\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const repoData = await octo.repos\n .get({\n owner,\n repo,\n })\n .catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n\n const parentRef = await octo.git\n .getRef({\n owner,\n repo,\n ref: `heads/${repoData.data.default_branch}`,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\"Couldn't fetch default branch data\", e),\n );\n });\n\n await octo.git\n .createRef({\n owner,\n repo,\n ref: `refs/heads/${branchName}`,\n sha: parentRef.data.object.sha,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a new branch with name '${branchName}'`,\n e,\n ),\n );\n });\n\n await octo.repos\n .createOrUpdateFileContents({\n owner,\n repo,\n path: fileName,\n message: title,\n content: Base64.encode(fileContent),\n branch: branchName,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a commit with ${fileName} file added`,\n e,\n ),\n );\n });\n\n const pullRequestResponse = await octo.pulls\n .create({\n owner,\n repo,\n title,\n head: branchName,\n body,\n base: repoData.data.default_branch,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a pull request for ${branchName} branch`,\n e,\n ),\n );\n });\n\n return {\n link: pullRequestResponse.data.html_url,\n location: `https://${githubIntegrationConfig.host}/${owner}/${repo}/blob/${repoData.data.default_branch}/${fileName}`,\n };\n}\n\nfunction formatHttpErrorMessage(\n message: string,\n error: { status: number; message: string },\n) {\n return `${message}, received http response status code ${error.status}: ${error.message}`;\n}\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"GitHub.esm.js","sources":["../../src/api/GitHub.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { Base64 } from 'js-base64';\n\nexport interface GitHubOptions {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GithubIntegrationConfig;\n}\nexport const getGithubIntegrationConfig = (\n scmIntegrationsApi: ScmIntegrationRegistry,\n location: string,\n) => {\n const integration = scmIntegrationsApi.github.byUrl(location);\n if (!integration) {\n return undefined;\n }\n\n const { name: repo, owner } = parseGitUrl(location);\n return {\n repo,\n owner,\n githubIntegrationConfig: integration.config,\n };\n};\n\nexport async function submitGitHubPrToRepo(\n options: GitHubOptions,\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n): Promise<{ link: string; location: string }> {\n const {\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n } = options;\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const repoData = await octo.repos\n .get({\n owner,\n repo,\n })\n .catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n\n const parentRef = await octo.git\n .getRef({\n owner,\n repo,\n ref: `heads/${repoData.data.default_branch}`,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\"Couldn't fetch default branch data\", e),\n );\n });\n\n await octo.git\n .createRef({\n owner,\n repo,\n ref: `refs/heads/${branchName}`,\n sha: parentRef.data.object.sha,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a new branch with name '${branchName}'`,\n e,\n ),\n );\n });\n\n await octo.repos\n .createOrUpdateFileContents({\n owner,\n repo,\n path: fileName,\n message: title,\n content: Base64.encode(fileContent),\n branch: branchName,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a commit with ${fileName} file added`,\n e,\n ),\n );\n });\n\n const pullRequestResponse = await octo.pulls\n .create({\n owner,\n repo,\n title,\n head: branchName,\n body,\n base: repoData.data.default_branch,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a pull request for ${branchName} branch`,\n e,\n ),\n );\n });\n\n return {\n link: pullRequestResponse.data.html_url,\n location: `https://${githubIntegrationConfig.host}/${owner}/${repo}/blob/${repoData.data.default_branch}/${fileName}`,\n };\n}\n\nfunction formatHttpErrorMessage(\n message: string,\n error: { status: number; message: string },\n) {\n return `${message}, received http response status code ${error.status}: ${error.message}`;\n}\n"],"names":[],"mappings":";;;;;AAqDA,eAAsB,oBAAA,CACpB,OAAA,EACA,UAAA,EACA,SAAA,EAC6C;AAC7C,EAAA,MAAM;AAAA,IACJ,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,MAAM,WAAW,cAAA,CAAe;AAAA,IAChD,GAAA,EAAK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,MAAM,MAAM,CAAA,EAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AACzF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { LinkButton } from '@backstage/core-components';
|
|
3
3
|
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import Button from '@material-ui/core/Button';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/Buttons/index.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LinkButton } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ComponentProps } from 'react';\n\nimport { catalogImportTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles(theme => ({\n wrapper: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n position: 'relative',\n },\n buttonProgress: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n marginTop: -12,\n marginLeft: -12,\n },\n button: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n },\n}));\n\nexport const NextButton = (\n props: ComponentProps<typeof Button> & { loading?: boolean },\n) => {\n const { loading, ...buttonProps } = props;\n const classes = useStyles();\n\n return (\n <div className={classes.wrapper}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n {...buttonProps}\n disabled={props.disabled || props.loading}\n />\n {props.loading && (\n <CircularProgress size=\"1.5rem\" className={classes.buttonProgress} />\n )}\n {props.loading}\n </div>\n );\n};\n\nexport const BackButton = (props: ComponentProps<typeof Button>) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const classes = useStyles();\n\n return (\n <Button variant=\"outlined\" className={classes.button} {...props}>\n {props.children || t('buttons.back')}\n </Button>\n );\n};\n\nexport const ViewComponentButton = (\n props: ComponentProps<typeof LinkButton>,\n) => {\n const classes = useStyles();\n\n return (\n <LinkButton\n color=\"primary\"\n variant=\"contained\"\n className={classes.button}\n {...props}\n >\n {props.children}\n </LinkButton>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,SAAA,GAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/Buttons/index.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LinkButton } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ComponentProps } from 'react';\n\nimport { catalogImportTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles(theme => ({\n wrapper: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n position: 'relative',\n },\n buttonProgress: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n marginTop: -12,\n marginLeft: -12,\n },\n button: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n },\n}));\n\nexport const NextButton = (\n props: ComponentProps<typeof Button> & { loading?: boolean },\n) => {\n const { loading, ...buttonProps } = props;\n const classes = useStyles();\n\n return (\n <div className={classes.wrapper}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n {...buttonProps}\n disabled={props.disabled || props.loading}\n />\n {props.loading && (\n <CircularProgress size=\"1.5rem\" className={classes.buttonProgress} />\n )}\n {props.loading}\n </div>\n );\n};\n\nexport const BackButton = (props: ComponentProps<typeof Button>) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const classes = useStyles();\n\n return (\n <Button variant=\"outlined\" className={classes.button} {...props}>\n {props.children || t('buttons.back')}\n </Button>\n );\n};\n\nexport const ViewComponentButton = (\n props: ComponentProps<typeof LinkButton>,\n) => {\n const classes = useStyles();\n\n return (\n <LinkButton\n color=\"primary\"\n variant=\"contained\"\n className={classes.button}\n {...props}\n >\n {props.children}\n </LinkButton>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,OAAA,EAAS;AAAA,IACP,SAAA,EAAW,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC5B,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,QAAA,EAAU,UAAA;AAAA,IACV,GAAA,EAAK,KAAA;AAAA,IACL,IAAA,EAAM,KAAA;AAAA,IACN,SAAA,EAAW,GAAA;AAAA,IACX,UAAA,EAAY;AAAA,GACd;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,SAAA,EAAW,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC;AAAA;AAEhC,CAAA,CAAE,CAAA;AAEK,MAAM,UAAA,GAAa,CACxB,KAAA,KACG;AACH,EAAA,MAAM,EA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EJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultImportPage.esm.js","sources":["../../../src/components/DefaultImportPage/DefaultImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Grid from '@material-ui/core/Grid';\nimport { useTheme } from '@material-ui/core/styles';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\n\nimport { catalogImportTranslationRef } from '../../translation';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\n/**\n * The default catalog import page.\n *\n * @public\n */\nexport const DefaultImportPage = () => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const theme = useTheme();\n const configApi = useApi(configApiRef);\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const contentItems = [\n <Grid key={0} item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>,\n\n <Grid key={1} item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>,\n ];\n\n return (\n <Page themeId=\"home\">\n <Header title={t('defaultImportPage.headerTitle')} />\n <Content>\n <ContentHeader\n title={t('defaultImportPage.contentHeaderTitle', { appTitle })}\n >\n <SupportButton>\n {t('defaultImportPage.supportTitle', { appTitle })}\n </SupportButton>\n </ContentHeader>\n\n <Grid container spacing={2}>\n {isMobile ? contentItems : contentItems.reverse()}\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,EAAE,CAAA,
|
|
1
|
+
{"version":3,"file":"DefaultImportPage.esm.js","sources":["../../../src/components/DefaultImportPage/DefaultImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Grid from '@material-ui/core/Grid';\nimport { useTheme } from '@material-ui/core/styles';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\n\nimport { catalogImportTranslationRef } from '../../translation';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\n/**\n * The default catalog import page.\n *\n * @public\n */\nexport const DefaultImportPage = () => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const theme = useTheme();\n const configApi = useApi(configApiRef);\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const contentItems = [\n <Grid key={0} item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>,\n\n <Grid key={1} item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>,\n ];\n\n return (\n <Page themeId=\"home\">\n <Header title={t('defaultImportPage.headerTitle')} />\n <Content>\n <ContentHeader\n title={t('defaultImportPage.contentHeaderTitle', { appTitle })}\n >\n <SupportButton>\n {t('defaultImportPage.supportTitle', { appTitle })}\n </SupportButton>\n </ContentHeader>\n\n <Grid container spacing={2}>\n {isMobile ? contentItems : contentItems.reverse()}\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,QAAQ,QAAA,EAAS;AACvB,EAAA,MAAM,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,WAAW,aAAA,CAAc,KAAA,CAAM,WAAA,CAAY,IAAA,CAAK,IAAI,CAAC,CAAA;AAC3D,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,iBAAA,CAAkB,WAAW,CAAA,IAAK,WAAA;AAE7D,EAAA,MAAM,YAAA,GAAe;AAAA,oBACnB,GAAA,CAAC,IAAA,EAAA,EAAa,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EAAI,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,GAAG,EAAA,EAAI,CAAA,EAC3C,QAAA,kBAAA,GAAA,CAAC,cAAA,EAAA,EAAe,KADP,CAEX,CAAA;AAAA,oBAEA,GAAA,CAAC,IAAA,EAAA,EAAa,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EAAI,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,GAAG,EAAA,EAAI,CAAA,EAC3C,QAAA,kBAAA,GAAA,CAAC,aAAA,EAAA,EAAc,KADN,CAEX;AAAA,GACF;AAEA,EAAA,uBACE,IAAA,CAAC,IAAA,EAAA,EAAK,OAAA,EAAQ,MAAA,EACZ,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAO,KAAA,EAAO,CAAA,CAAE,+BAA+B,CAAA,EAAG,CAAA;AAAA,yBAClD,OAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,aAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO,CAAA,CAAE,sCAAA,EAAwC,EAAE,UAAU,CAAA;AAAA,UAE7D,8BAAC,aAAA,EAAA,EACE,QAAA,EAAA,CAAA,CAAE,kCAAkC,EAAE,QAAA,EAAU,CAAA,EACnD;AAAA;AAAA,OACF;AAAA,sBAEA,GAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAS,IAAA,EAAC,OAAA,EAAS,GACtB,QAAA,EAAA,QAAA,GAAW,YAAA,GAAe,YAAA,CAAa,OAAA,EAAQ,EAClD;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListComponent.esm.js","sources":["../../../src/components/EntityListComponent/EntityListComponent.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefLink,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport Collapse from '@material-ui/core/Collapse';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { ReactElement, Fragment, useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\n/**\n * Props for {@link EntityListComponent}.\n *\n * @public\n */\nexport interface EntityListComponentProps {\n locations: Array<{\n target: string;\n entities: (Entity | CompoundEntityRef)[];\n }>;\n locationListItemIcon: (target: string) => ReactElement;\n collapsed?: boolean;\n firstListItem?: ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n}\n\n/**\n * Shows a result list of entities.\n *\n * @public\n */\nexport const EntityListComponent = (props: EntityListComponentProps) => {\n const {\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n } = props;\n\n const classes = useStyles();\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const [expandedUrls, setExpandedUrls] = useState<string[]>([]);\n\n const handleClick = (url: string) => {\n setExpandedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n function sortEntities(entities: Array<CompoundEntityRef | Entity>) {\n return entities.sort((a, b) =>\n entityPresentationApi\n .forEntity(stringifyEntityRef(a))\n .snapshot.entityRef.localeCompare(\n entityPresentationApi.forEntity(stringifyEntityRef(b)).snapshot\n .entityRef,\n ),\n );\n }\n\n return (\n <List>\n {firstListItem}\n {locations.map(r => (\n <Fragment key={r.target}>\n <ListItem\n dense\n button={Boolean(onItemClick) as any}\n onClick={() => onItemClick?.(r.target)}\n >\n <ListItemIcon>{locationListItemIcon(r.target)}</ListItemIcon>\n\n <ListItemText\n primary={r.target}\n secondary={`Entities: ${r.entities.length}`}\n />\n\n {collapsed && (\n <ListItemSecondaryAction>\n <IconButton edge=\"end\" onClick={() => handleClick(r.target)}>\n {expandedUrls.includes(r.target) ? (\n <ExpandLessIcon />\n ) : (\n <ExpandMoreIcon />\n )}\n </IconButton>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n\n <Collapse\n in={!collapsed || expandedUrls.includes(r.target)}\n timeout=\"auto\"\n unmountOnExit\n >\n <List component=\"div\" disablePadding dense>\n {sortEntities(r.entities).map(entity => {\n return (\n <ListItem\n key={stringifyEntityRef(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemText\n primary={<EntityDisplayName entityRef={entity} />}\n />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </Fragment>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,SAAA,GAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"EntityListComponent.esm.js","sources":["../../../src/components/EntityListComponent/EntityListComponent.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefLink,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport Collapse from '@material-ui/core/Collapse';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { ReactElement, Fragment, useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\n/**\n * Props for {@link EntityListComponent}.\n *\n * @public\n */\nexport interface EntityListComponentProps {\n locations: Array<{\n target: string;\n entities: (Entity | CompoundEntityRef)[];\n }>;\n locationListItemIcon: (target: string) => ReactElement;\n collapsed?: boolean;\n firstListItem?: ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n}\n\n/**\n * Shows a result list of entities.\n *\n * @public\n */\nexport const EntityListComponent = (props: EntityListComponentProps) => {\n const {\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n } = props;\n\n const classes = useStyles();\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const [expandedUrls, setExpandedUrls] = useState<string[]>([]);\n\n const handleClick = (url: string) => {\n setExpandedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n function sortEntities(entities: Array<CompoundEntityRef | Entity>) {\n return entities.sort((a, b) =>\n entityPresentationApi\n .forEntity(stringifyEntityRef(a))\n .snapshot.entityRef.localeCompare(\n entityPresentationApi.forEntity(stringifyEntityRef(b)).snapshot\n .entityRef,\n ),\n );\n }\n\n return (\n <List>\n {firstListItem}\n {locations.map(r => (\n <Fragment key={r.target}>\n <ListItem\n dense\n button={Boolean(onItemClick) as any}\n onClick={() => onItemClick?.(r.target)}\n >\n <ListItemIcon>{locationListItemIcon(r.target)}</ListItemIcon>\n\n <ListItemText\n primary={r.target}\n secondary={`Entities: ${r.entities.length}`}\n />\n\n {collapsed && (\n <ListItemSecondaryAction>\n <IconButton edge=\"end\" onClick={() => handleClick(r.target)}>\n {expandedUrls.includes(r.target) ? (\n <ExpandLessIcon />\n ) : (\n <ExpandMoreIcon />\n )}\n </IconButton>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n\n <Collapse\n in={!collapsed || expandedUrls.includes(r.target)}\n timeout=\"auto\"\n unmountOnExit\n >\n <List component=\"div\" disablePadding dense>\n {sortEntities(r.entities).map(entity => {\n return (\n <ListItem\n key={stringifyEntityRef(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemText\n primary={<EntityDisplayName entityRef={entity} />}\n />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </Fragment>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,MAAA,EAAQ;AAAA,IACN,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC;AAAA;AAEhC,CAAA,CAAE,CAAA;AAwBK,MAAM,mBAAA,GAAsB,CAAC,KAAA,KAAoC;AACtE,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,SAAA,GAAY,KAAA;AAAA,IACZ,oBAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAA,GAAY;AAAA,GACd,GAAI,KAAA;AAEJ,EAAA,MAAM,UAAU,SAAA,EAAU;AAC1B,EAAA,MAAM,qBAAA,GAAwB,OAAO,wBAAwB,CAAA;AAC7D,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAA,CAAmB,EAAE,CAAA;AAE7D,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,KAAgB;AACnC,IAAA,eAAA;AAAA,MAAgB,CAAA,IAAA,KACd,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,CAAK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../src/components/ImportInfoCard/ImportInfoCard.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\n\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title={t('importInfoCard.title')}\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: t('importInfoCard.deepLinkTitle'),\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.linkDescription', { appTitle })}\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.fileLinkTitle')}\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.fileLinkDescription', { appTitle })}\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.githubIntegration.title')}\n <Chip\n label={t('importInfoCard.githubIntegration.label')}\n variant=\"outlined\"\n size=\"small\"\n style={{ marginLeft: 8, marginBottom: 0 }}\n />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.exampleDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.preparePullRequestDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ImportInfoCard.esm.js","sources":["../../../src/components/ImportInfoCard/ImportInfoCard.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\n\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title={t('importInfoCard.title')}\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: t('importInfoCard.deepLinkTitle'),\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.linkDescription', { appTitle })}\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.fileLinkTitle')}\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.fileLinkDescription', { appTitle })}\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.githubIntegration.title')}\n <Chip\n label={t('importInfoCard.githubIntegration.label')}\n variant=\"outlined\"\n size=\"small\"\n style={{ marginLeft: 8, marginBottom: 0 }}\n />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.exampleDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.preparePullRequestDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyCO,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA+B;AAC5D,EAAA,MAAM;AAAA,IACJ,kBAAA,GAAqB,sEAAA;AAAA,IACrB,oBAAA,GAAuB;AAAA,GACzB,GAAI,KAAA;AAEJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,iBAAA,CAAkB,WAAW,CAAA,IAAK,WAAA;AAC7D,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM,oBAAA,GAAuB,SAAA,CAAU,GAAA,CAAI,qBAAqB,CAAA;AAEhE,EAAA,MAAM,kBAAkB,kBAAA,EAAmB;AAE3C,EAAA,uBACE,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,sBAAsB,CAAA;AAAA,MAC/B,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAA,EAAK;AAAA,MACxC,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,EAAE,8BAA8B,CAAA;AAAA,QACvC,IAAA,EAAM;AAAA,OACR;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAA,EAAA,EAA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;AAAA,4BACjC,GAAA,CAAC,UAAM,QAAA,EAAA,oBAAA,EAAqB;AAAA,WAAA,EAC9B,CAAA;AAAA,8BACC,UAAA,EAAA,EAAW,OAAA,EAAQ,SAAQ,SAAA,EAAS,IAAA,EAClC,YAAE,mCAAA,EAAqC;AAAA,YACtC,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH,CAAA;AAAA,UACC,gBAAA,CAAiB,sCAChB,GAAA,CAAC,UAAA,EAAA,EAAW,SAAQ,OAAA,EAAQ,SAAA,EAAS,IAAA,EAClC,QAAA,EAAA,CAAA,CAAE,8CAAA,EAAgD;AAAA,YACjD,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportPage.esm.js","sources":["../../../src/components/ImportPage/ImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useOutlet } from 'react-router-dom';\nimport { DefaultImportPage } from '../DefaultImportPage';\n\n/**\n * The whole catalog import page.\n *\n * @public\n */\nexport const ImportPage = () => {\n const outlet = useOutlet();\n\n return outlet || <DefaultImportPage />;\n};\n"],"names":[],"mappings":";;;;AAwBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"ImportPage.esm.js","sources":["../../../src/components/ImportPage/ImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useOutlet } from 'react-router-dom';\nimport { DefaultImportPage } from '../DefaultImportPage';\n\n/**\n * The whole catalog import page.\n *\n * @public\n */\nexport const ImportPage = () => {\n const outlet = useOutlet();\n\n return outlet || <DefaultImportPage />;\n};\n"],"names":[],"mappings":";;;;AAwBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,EAAA,OAAO,MAAA,wBAAW,iBAAA,EAAA,EAAkB,CAAA;AACtC;;;;"}
|
|
@@ -14,7 +14,7 @@ import 'git-url-parse';
|
|
|
14
14
|
import '@octokit/rest';
|
|
15
15
|
import 'js-base64';
|
|
16
16
|
import { useImportState } from '../useImportState.esm.js';
|
|
17
|
-
import {
|
|
17
|
+
import { defaultGenerateStepper, defaultStepper } from './defaults.esm.js';
|
|
18
18
|
|
|
19
19
|
const useStyles = makeStyles(() => ({
|
|
20
20
|
stepperRoot: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { catalogImportTranslationRef } from '@backstage/plugin-catalog-import/alpha';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useMemo } from 'react';\n\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n t: TranslationFunction<typeof catalogImportTranslationRef.T>,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper, t),\n [generateStepper, state.activeFlow, t],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,
|
|
1
|
+
{"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { catalogImportTranslationRef } from '@backstage/plugin-catalog-import/alpha';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useMemo } from 'react';\n\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n t: TranslationFunction<typeof catalogImportTranslationRef.T>,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper, t),\n [generateStepper, state.activeFlow, t],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,WAAA,EAAa;AAAA,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