@red-hat-developer-hub/backstage-plugin-bulk-import-backend 5.1.1 → 5.2.0
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 +6 -0
- package/dist/catalog/catalogHttpClient.cjs.js +11 -6
- package/dist/catalog/catalogHttpClient.cjs.js.map +1 -1
- package/dist/catalog/catalogUtils.cjs.js.map +1 -1
- package/dist/generated/openapidocument.cjs.js +29 -2
- package/dist/generated/openapidocument.cjs.js.map +1 -1
- package/dist/service/handlers/import/bulkImports.cjs.js +14 -5
- package/dist/service/handlers/import/bulkImports.cjs.js.map +1 -1
- package/dist/service/handlers/import/importStatus.cjs.js.map +1 -1
- package/dist/service/handlers/repository/repositories.cjs.js +1 -1
- package/dist/service/handlers/repository/repositories.cjs.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
### Dependencies
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- be29a84: Introduced a new response key 'source' in the GET /imports endpoint to indicate from which source the import originated from ('config', 'location', 'integration'). In case of duplicates, it returns first source it finds in order 'config', 'location', 'integration'.
|
|
8
|
+
|
|
3
9
|
## 5.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -52,12 +52,14 @@ class CatalogHttpClient {
|
|
|
52
52
|
pageNumber,
|
|
53
53
|
pageSize
|
|
54
54
|
);
|
|
55
|
-
const result = /* @__PURE__ */ new
|
|
55
|
+
const result = /* @__PURE__ */ new Map();
|
|
56
56
|
for (const l of byId.locations) {
|
|
57
|
-
result.
|
|
57
|
+
if (!result.has(l.target)) {
|
|
58
|
+
result.set(l.target, l);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
return {
|
|
60
|
-
|
|
62
|
+
uniqueCatalogUrlLocations: result,
|
|
61
63
|
totalCount: byId.totalCount
|
|
62
64
|
};
|
|
63
65
|
}
|
|
@@ -95,7 +97,8 @@ class CatalogHttpClient {
|
|
|
95
97
|
).map((location) => {
|
|
96
98
|
return {
|
|
97
99
|
id: location.data?.id,
|
|
98
|
-
target: location.data.target
|
|
100
|
+
target: location.data.target,
|
|
101
|
+
source: "location"
|
|
99
102
|
};
|
|
100
103
|
});
|
|
101
104
|
const filtered = catalogUtils.filterLocations(res, search);
|
|
@@ -109,7 +112,8 @@ class CatalogHttpClient {
|
|
|
109
112
|
const target = location.getString("target");
|
|
110
113
|
return {
|
|
111
114
|
id: `app-config-location--${target}`,
|
|
112
|
-
target
|
|
115
|
+
target,
|
|
116
|
+
source: "config"
|
|
113
117
|
};
|
|
114
118
|
});
|
|
115
119
|
const filtered = catalogUtils.filterLocations(res, search);
|
|
@@ -137,7 +141,8 @@ class CatalogHttpClient {
|
|
|
137
141
|
).map((location) => {
|
|
138
142
|
return {
|
|
139
143
|
id: location.metadata.uid,
|
|
140
|
-
target: location.spec.target
|
|
144
|
+
target: location.spec.target,
|
|
145
|
+
source: "integration"
|
|
141
146
|
};
|
|
142
147
|
});
|
|
143
148
|
const filtered = catalogUtils.filterLocations(res, search);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogHttpClient.cjs.js","sources":["../../src/catalog/catalogHttpClient.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\nimport type {\n AuthService,\n DiscoveryService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { LocationEntity } from '@backstage/catalog-model';\nimport type { Config } from '@backstage/config';\n\nimport fetch from 'node-fetch';\n\nimport { getTokenForPlugin, logErrorIfNeeded } from '../helpers';\nimport { filterLocations, getCatalogUrl } from './catalogUtils';\n\nexport class CatalogHttpClient {\n private readonly logger: LoggerService;\n private readonly config: Config;\n private readonly discovery: DiscoveryService;\n private readonly auth: AuthService;\n private readonly catalogApi: CatalogApi;\n\n constructor(deps: {\n logger: LoggerService;\n config: Config;\n discovery: DiscoveryService;\n auth: AuthService;\n catalogApi: CatalogApi;\n }) {\n this.logger = deps.logger;\n this.config = deps.config;\n this.discovery = deps.discovery;\n this.auth = deps.auth;\n this.catalogApi = deps.catalogApi;\n }\n\n // Wrapper for https://backstage.io/docs/features/software-catalog/software-catalog-api/#post-analyze-location\n async analyzeLocation(repoUrl: string): Promise<any[]> {\n this.logger.debug(`Forwarding request to analyze location: ${repoUrl}`);\n const response = await fetch(\n `${await this.discovery.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'POST',\n body: JSON.stringify({\n location: {\n type: 'github',\n target: repoUrl,\n },\n }),\n },\n );\n return (await response.json()).generateEntities ?? [];\n }\n\n async listCatalogUrlLocations(\n search?: string,\n pageNumber?: number,\n pageSize?: number,\n ): Promise<{ targetUrls: string[]; totalCount?: number }> {\n const byId = await this.listCatalogUrlLocationsById(\n search,\n pageNumber,\n pageSize,\n );\n const result = new Set<string>();\n for (const l of byId.locations) {\n result.add(l.target);\n }\n return {\n targetUrls: Array.from(result.values()),\n totalCount: byId.totalCount,\n };\n }\n\n async listCatalogUrlLocationsById(\n search?: string,\n pageNumber?: number,\n pageSize?: number,\n ): Promise<{\n locations: { id?: string; target: string }[];\n totalCount?: number;\n }> {\n const result = await Promise.all([\n this.listCatalogUrlLocationsFromConfig(search),\n this.listCatalogUrlLocationsByIdFromLocationsEndpoint(search),\n this.listCatalogUrlLocationEntitiesById(search, pageNumber, pageSize),\n ]);\n const locations = result.flatMap(u => u.locations);\n // we might have duplicate elements here\n const totalCount = result\n .map(l => l.totalCount ?? 0)\n .reduce((accumulator, currentValue) => accumulator + currentValue, 0);\n return {\n locations,\n totalCount,\n };\n }\n\n async listCatalogUrlLocationsByIdFromLocationsEndpoint(\n search?: string,\n ): Promise<{\n locations: { id?: string; target: string }[];\n totalCount?: number;\n }> {\n const url = `${await this.discovery.getBaseUrl('catalog')}/locations`;\n const response = await fetch(url, {\n headers: {\n Accept: 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'GET',\n });\n const locations = (await response.json()) as {\n data: { id: string; target: string; type: string };\n }[];\n if (!Array.isArray(locations)) {\n return { locations: [] };\n }\n const res = locations\n .filter(\n location => location.data?.target && location.data?.type === 'url',\n )\n .map(location => {\n return {\n id: location.data?.id,\n target: location.data.target,\n };\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n listCatalogUrlLocationsFromConfig(search?: string): {\n locations: { id?: string; target: string }[];\n totalCount?: number;\n } {\n const locationConfigs =\n this.config.getOptionalConfigArray('catalog.locations') ?? [];\n const res = locationConfigs\n .filter(\n location =>\n location.getOptionalString('target') &&\n location.getOptionalString('type') === 'url',\n )\n .map(location => {\n const target = location.getString('target');\n return {\n id: `app-config-location--${target}`,\n target,\n };\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n async listCatalogUrlLocationEntitiesById(\n search?: string,\n _pageNumber?: number,\n _pageSize?: number,\n ): Promise<{\n locations: { id?: string; target: string }[];\n totalCount?: number;\n }> {\n const result = await this.catalogApi.getEntities(\n {\n filter: {\n kind: 'Location',\n },\n // There is no query parameter to find entities with target URLs containing a string.\n // The existing filter does an exact matching. That's why we are retrieving this hard-coded high number of Locations.\n limit: 9999,\n offset: 0,\n order: { field: 'metadata.name', order: 'desc' },\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n const locations = (result?.items ?? []) as LocationEntity[];\n const res = locations\n .filter(\n location => location.spec?.target && location.spec?.type === 'url',\n )\n .map(location => {\n return {\n id: location.metadata.uid,\n target: location.spec.target!,\n };\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n /**\n * verifyLocationExistence checks for the existence of the Location target.\n * Under the hood, it attempts to read the target URL and will return false if the target could not be found\n * and even if there is already a Location row in the database.\n * @param repoCatalogUrl\n */\n async verifyLocationExistence(repoCatalogUrl: string): Promise<boolean> {\n try {\n const result = await this.catalogApi.addLocation(\n {\n type: 'url',\n target: repoCatalogUrl,\n dryRun: true,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n // The `result.exists` field is only filled in dryRun mode\n return result.exists as boolean;\n } catch (error: any) {\n if (error.message?.includes('NotFoundError')) {\n return false;\n }\n throw error;\n }\n }\n\n async hasEntityInCatalog(entityName: string) {\n return this.catalogApi\n .queryEntities(\n {\n filter: {\n 'metadata.name': entityName,\n },\n limit: 1,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n )\n .then(resp => resp.items?.length > 0);\n }\n\n async possiblyCreateLocation(repoCatalogUrl: string) {\n try {\n await this.catalogApi.addLocation(\n {\n type: 'url',\n target: repoCatalogUrl,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n } catch (error: any) {\n if (!error.message?.includes('ConflictError')) {\n throw error;\n }\n // Location already exists, which is fine\n }\n }\n\n async deleteCatalogLocationById(locationId: string): Promise<void> {\n try {\n const url = `${await this.discovery.getBaseUrl(\n 'catalog',\n )}/locations/${locationId}`;\n await fetch(url, {\n headers: {\n Accept: 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'DELETE',\n });\n } catch (error: any) {\n logErrorIfNeeded(\n this.logger,\n `Could not delete location ${locationId}`,\n error,\n );\n }\n }\n\n async deleteCatalogLocationEntityById(locationUid: string): Promise<void> {\n await this.catalogApi.removeEntityByUid(locationUid, {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n });\n }\n\n async findLocationEntitiesByRepoUrl(repoUrl: string, defaultBranch?: string) {\n return this.findLocationEntitiesByTargetUrl(\n getCatalogUrl(this.config, repoUrl, defaultBranch),\n );\n }\n\n async findLocationEntitiesByTargetUrl(targetUrl: string, limit?: number) {\n return this.catalogApi\n .queryEntities(\n {\n filter: [\n { kind: 'Location', 'spec.type': 'url', 'spec.target': targetUrl },\n ],\n fields: ['metadata.namespace', 'metadata.name', 'metadata.uid'],\n limit,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n )\n .then(resp => resp.items);\n }\n\n async refreshLocationByRepoUrl(repoUrl: string, defaultBranch?: string) {\n const promises: Promise<void>[] = [];\n this.findLocationEntitiesByRepoUrl(repoUrl, defaultBranch).then(\n entities => {\n const nbEntities = entities.length;\n if (nbEntities === 0) {\n this.logger.debug(`No Location Entity found for repo: ${repoUrl}`);\n return;\n }\n this.logger.debug(\n `Refreshing ${nbEntities} Location(s) for repo: ${repoUrl}`,\n );\n entities.forEach(ent =>\n promises.push(\n this.refreshEntity(\n 'location',\n ent.metadata.name,\n ent.metadata.namespace,\n ),\n ),\n );\n },\n );\n await Promise.all(promises);\n }\n\n async refreshEntity(\n kind: string,\n name: string,\n namespace: string = 'default',\n ) {\n const entityRef = `${kind}:${namespace}/${name}`;\n this.logger.debug(`Refreshing entityRef: ${entityRef}`);\n await this.catalogApi.refreshEntity(entityRef, {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n });\n }\n}\n"],"names":["fetch","getTokenForPlugin","filterLocations","logErrorIfNeeded","getCatalogUrl"],"mappings":";;;;;;;;;;;AA8BO,MAAM,iBAAkB,CAAA;AAAA,EACZ,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA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AA,MAC7C,KAAO,EAAA,MAAMA,sBAAkB,CAAA,IAAA,CAAK,MAAM,SAAS;AAAA,KACpD,CAAA;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"catalogHttpClient.cjs.js","sources":["../../src/catalog/catalogHttpClient.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\nimport type {\n AuthService,\n DiscoveryService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { LocationEntity } from '@backstage/catalog-model';\nimport type { Config } from '@backstage/config';\n\nimport fetch from 'node-fetch';\n\nimport { getTokenForPlugin, logErrorIfNeeded } from '../helpers';\nimport { filterLocations, getCatalogUrl } from './catalogUtils';\nimport { CatalogLocation } from './types';\n\nexport class CatalogHttpClient {\n private readonly logger: LoggerService;\n private readonly config: Config;\n private readonly discovery: DiscoveryService;\n private readonly auth: AuthService;\n private readonly catalogApi: CatalogApi;\n\n constructor(deps: {\n logger: LoggerService;\n config: Config;\n discovery: DiscoveryService;\n auth: AuthService;\n catalogApi: CatalogApi;\n }) {\n this.logger = deps.logger;\n this.config = deps.config;\n this.discovery = deps.discovery;\n this.auth = deps.auth;\n this.catalogApi = deps.catalogApi;\n }\n\n // Wrapper for https://backstage.io/docs/features/software-catalog/software-catalog-api/#post-analyze-location\n async analyzeLocation(repoUrl: string): Promise<any[]> {\n this.logger.debug(`Forwarding request to analyze location: ${repoUrl}`);\n const response = await fetch(\n `${await this.discovery.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'POST',\n body: JSON.stringify({\n location: {\n type: 'github',\n target: repoUrl,\n },\n }),\n },\n );\n return (await response.json()).generateEntities ?? [];\n }\n\n async listCatalogUrlLocations(\n search?: string,\n pageNumber?: number,\n pageSize?: number,\n ): Promise<{\n uniqueCatalogUrlLocations: Map<string, CatalogLocation>;\n totalCount?: number;\n }> {\n // byId order: config, locations, other\n const byId = await this.listCatalogUrlLocationsById(\n search,\n pageNumber,\n pageSize,\n );\n const result = new Map<string, CatalogLocation>();\n\n for (const l of byId.locations) {\n if (!result.has(l.target)) {\n result.set(l.target, l);\n }\n }\n return {\n uniqueCatalogUrlLocations: result,\n totalCount: byId.totalCount,\n };\n }\n\n async listCatalogUrlLocationsById(\n search?: string,\n pageNumber?: number,\n pageSize?: number,\n ): Promise<{\n locations: CatalogLocation[];\n totalCount?: number;\n }> {\n const result = await Promise.all([\n this.listCatalogUrlLocationsFromConfig(search),\n this.listCatalogUrlLocationsByIdFromLocationsEndpoint(search),\n this.listCatalogUrlLocationEntitiesById(search, pageNumber, pageSize),\n ]);\n const locations = result.flatMap(u => u.locations);\n // we might have duplicate elements here\n const totalCount = result\n .map(l => l.totalCount ?? 0)\n .reduce((accumulator, currentValue) => accumulator + currentValue, 0);\n return {\n locations,\n totalCount,\n };\n }\n\n async listCatalogUrlLocationsByIdFromLocationsEndpoint(\n search?: string,\n ): Promise<{\n locations: CatalogLocation[];\n totalCount?: number;\n }> {\n const url = `${await this.discovery.getBaseUrl('catalog')}/locations`;\n const response = await fetch(url, {\n headers: {\n Accept: 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'GET',\n });\n const locations = (await response.json()) as {\n data: { id: string; target: string; type: string };\n }[];\n if (!Array.isArray(locations)) {\n return { locations: [] };\n }\n const res = locations\n .filter(\n location => location.data?.target && location.data?.type === 'url',\n )\n .map(location => {\n return {\n id: location.data?.id,\n target: location.data.target,\n source: 'location',\n } as CatalogLocation;\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n listCatalogUrlLocationsFromConfig(search?: string): {\n locations: CatalogLocation[];\n totalCount?: number;\n } {\n const locationConfigs =\n this.config.getOptionalConfigArray('catalog.locations') ?? [];\n const res = locationConfigs\n .filter(\n location =>\n location.getOptionalString('target') &&\n location.getOptionalString('type') === 'url',\n )\n .map(location => {\n const target = location.getString('target');\n return {\n id: `app-config-location--${target}`,\n target,\n source: 'config',\n } as CatalogLocation;\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n async listCatalogUrlLocationEntitiesById(\n search?: string,\n _pageNumber?: number,\n _pageSize?: number,\n ): Promise<{\n locations: CatalogLocation[];\n totalCount?: number;\n }> {\n const result = await this.catalogApi.getEntities(\n {\n filter: {\n kind: 'Location',\n },\n // There is no query parameter to find entities with target URLs containing a string.\n // The existing filter does an exact matching. That's why we are retrieving this hard-coded high number of Locations.\n limit: 9999,\n offset: 0,\n order: { field: 'metadata.name', order: 'desc' },\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n const locations = (result?.items ?? []) as LocationEntity[];\n const res = locations\n .filter(\n location => location.spec?.target && location.spec?.type === 'url',\n )\n .map(location => {\n return {\n id: location.metadata.uid,\n target: location.spec.target!,\n source: 'integration',\n } as CatalogLocation;\n });\n const filtered = filterLocations(res, search);\n return { locations: filtered, totalCount: filtered.length };\n }\n\n /**\n * verifyLocationExistence checks for the existence of the Location target.\n * Under the hood, it attempts to read the target URL and will return false if the target could not be found\n * and even if there is already a Location row in the database.\n * @param repoCatalogUrl\n */\n async verifyLocationExistence(repoCatalogUrl: string): Promise<boolean> {\n try {\n const result = await this.catalogApi.addLocation(\n {\n type: 'url',\n target: repoCatalogUrl,\n dryRun: true,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n // The `result.exists` field is only filled in dryRun mode\n return result.exists as boolean;\n } catch (error: any) {\n if (error.message?.includes('NotFoundError')) {\n return false;\n }\n throw error;\n }\n }\n\n async hasEntityInCatalog(entityName: string) {\n return this.catalogApi\n .queryEntities(\n {\n filter: {\n 'metadata.name': entityName,\n },\n limit: 1,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n )\n .then(resp => resp.items?.length > 0);\n }\n\n async possiblyCreateLocation(repoCatalogUrl: string) {\n try {\n await this.catalogApi.addLocation(\n {\n type: 'url',\n target: repoCatalogUrl,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n );\n } catch (error: any) {\n if (!error.message?.includes('ConflictError')) {\n throw error;\n }\n // Location already exists, which is fine\n }\n }\n\n async deleteCatalogLocationById(locationId: string): Promise<void> {\n try {\n const url = `${await this.discovery.getBaseUrl(\n 'catalog',\n )}/locations/${locationId}`;\n await fetch(url, {\n headers: {\n Accept: 'application/json',\n Authorization: `Bearer ${await getTokenForPlugin(\n this.auth,\n 'catalog',\n )}`,\n },\n method: 'DELETE',\n });\n } catch (error: any) {\n logErrorIfNeeded(\n this.logger,\n `Could not delete location ${locationId}`,\n error,\n );\n }\n }\n\n async deleteCatalogLocationEntityById(locationUid: string): Promise<void> {\n await this.catalogApi.removeEntityByUid(locationUid, {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n });\n }\n\n async findLocationEntitiesByRepoUrl(repoUrl: string, defaultBranch?: string) {\n return this.findLocationEntitiesByTargetUrl(\n getCatalogUrl(this.config, repoUrl, defaultBranch),\n );\n }\n\n async findLocationEntitiesByTargetUrl(targetUrl: string, limit?: number) {\n return this.catalogApi\n .queryEntities(\n {\n filter: [\n { kind: 'Location', 'spec.type': 'url', 'spec.target': targetUrl },\n ],\n fields: ['metadata.namespace', 'metadata.name', 'metadata.uid'],\n limit,\n },\n {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n },\n )\n .then(resp => resp.items);\n }\n\n async refreshLocationByRepoUrl(repoUrl: string, defaultBranch?: string) {\n const promises: Promise<void>[] = [];\n this.findLocationEntitiesByRepoUrl(repoUrl, defaultBranch).then(\n entities => {\n const nbEntities = entities.length;\n if (nbEntities === 0) {\n this.logger.debug(`No Location Entity found for repo: ${repoUrl}`);\n return;\n }\n this.logger.debug(\n `Refreshing ${nbEntities} Location(s) for repo: ${repoUrl}`,\n );\n entities.forEach(ent =>\n promises.push(\n this.refreshEntity(\n 'location',\n ent.metadata.name,\n ent.metadata.namespace,\n ),\n ),\n );\n },\n );\n await Promise.all(promises);\n }\n\n async refreshEntity(\n kind: string,\n name: string,\n namespace: string = 'default',\n ) {\n const entityRef = `${kind}:${namespace}/${name}`;\n this.logger.debug(`Refreshing entityRef: ${entityRef}`);\n await this.catalogApi.refreshEntity(entityRef, {\n token: await getTokenForPlugin(this.auth, 'catalog'),\n });\n }\n}\n"],"names":["fetch","getTokenForPlugin","filterLocations","logErrorIfNeeded","getCatalogUrl"],"mappings":";;;;;;;;;;;AA+BO,MAAM,iBAAkB,CAAA;AAAA,EACZ,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EAEjB,YAAY,IAMT,EAAA;AACD,IAAA,IAAA,CAAK,SAAS,IAAK,CAAA,MAAA;AACnB,IAAA,IAAA,CAAK,SAAS,IAAK,CAAA,MAAA;AACnB,IAAA,IAAA,CAAK,YAAY,IAAK,CAAA,SAAA;AACtB,IAAA,IAAA,CAAK,OAAO,IAAK,CAAA,IAAA;AACjB,IAAA,IAAA,CAAK,aAAa,IAAK,CAAA,UAAA;AAAA;AACzB;AAAA,EAGA,MAAM,gBAAgB,OAAiC,EAAA;AACrD,IAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAA2C,wCAAA,EAAA,OAAO,CAAE,CAAA,CAAA;AACtE,IAAA,MAAM,WAAW,MAAMA,sBAAA;AAAA,MACrB,GAAG,MAAM,IAAA,CAAK,SAAU,CAAA,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AAS,CAAA,MAAA;AAC5B,QAAA,IAAI,eAAe,CAAG,EAAA;AACpB,UAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAAsC,mCAAA,EAAA,OAAO,CAAE,CAAA,CAAA;AACjE,UAAA;AAAA;AAEF,QAAA,IAAA,CAAK,MAAO,CAAA,KAAA;AAAA,UACV,CAAA,WAAA,EAAc,UAAU,CAAA,uBAAA,EAA0B,OAAO,CAAA;AAAA,SAC3D;AACA,QAAS,QAAA,CAAA,OAAA;AAAA,UAAQ,SACf,QAAS,CAAA,IAAA;AAAA,YACP,IAAK,CAAA,aAAA;AAAA,cACH,UAAA;AAAA,cACA,IAAI,QAAS,CAAA,IAAA;AAAA,cACb,IAAI,QAAS,CAAA;AAAA;AACf;AACF,SACF;AAAA;AACF,KACF;AACA,IAAM,MAAA,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA;AAC5B,EAEA,MAAM,aAAA,CACJ,IACA,EAAA,IAAA,EACA,YAAoB,SACpB,EAAA;AACA,IAAA,MAAM,YAAY,CAAG,EAAA,IAAI,CAAI,CAAA,EAAA,SAAS,IAAI,IAAI,CAAA,CAAA;AAC9C,IAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAAyB,sBAAA,EAAA,SAAS,CAAE,CAAA,CAAA;AACtD,IAAM,MAAA,IAAA,CAAK,UAAW,CAAA,aAAA,CAAc,SAAW,EAAA;AAAA,MAC7C,KAAO,EAAA,MAAMA,sBAAkB,CAAA,IAAA,CAAK,MAAM,SAAS;AAAA,KACpD,CAAA;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogUtils.cjs.js","sources":["../../src/catalog/catalogUtils.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\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nexport function getCatalogFilename(config: Config): string {\n return (\n config.getOptionalString('catalog.import.entityFilename') ??\n 'catalog-info.yaml'\n );\n}\n\nexport function getBranchName(config: Config): string {\n return (\n config.getOptionalString('catalog.import.pullRequestBranchName') ??\n 'backstage-integration'\n );\n}\n\nexport function getCatalogUrl(\n config: Config,\n repoUrl: string,\n defaultBranch: string = 'main',\n): string {\n return `${repoUrl}/blob/${defaultBranch}/${getCatalogFilename(config)}`;\n}\n\nexport function filterLocations(\n res:
|
|
1
|
+
{"version":3,"file":"catalogUtils.cjs.js","sources":["../../src/catalog/catalogUtils.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\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nimport { CatalogLocation } from './types';\n\nexport function getCatalogFilename(config: Config): string {\n return (\n config.getOptionalString('catalog.import.entityFilename') ??\n 'catalog-info.yaml'\n );\n}\n\nexport function getBranchName(config: Config): string {\n return (\n config.getOptionalString('catalog.import.pullRequestBranchName') ??\n 'backstage-integration'\n );\n}\n\nexport function getCatalogUrl(\n config: Config,\n repoUrl: string,\n defaultBranch: string = 'main',\n): string {\n return `${repoUrl}/blob/${defaultBranch}/${getCatalogFilename(config)}`;\n}\n\nexport function filterLocations(\n res: CatalogLocation[],\n search: string | undefined,\n) {\n return search\n ? res.filter(loc => {\n const split = loc.target.split('/blob/');\n if (split.length < 2) {\n return false;\n }\n const repoUrl = split[0];\n const gitUrl = gitUrlParse(repoUrl);\n return gitUrl.name.toLowerCase().includes(search.toLowerCase());\n })\n : res;\n}\n"],"names":["gitUrlParse"],"mappings":";;;;;;;;AAsBO,SAAS,mBAAmB,MAAwB,EAAA;AACzD,EACE,OAAA,MAAA,CAAO,iBAAkB,CAAA,+BAA+B,CACxD,IAAA,mBAAA;AAEJ;AAEO,SAAS,cAAc,MAAwB,EAAA;AACpD,EACE,OAAA,MAAA,CAAO,iBAAkB,CAAA,sCAAsC,CAC/D,IAAA,uBAAA;AAEJ;AAEO,SAAS,aACd,CAAA,MAAA,EACA,OACA,EAAA,aAAA,GAAwB,MAChB,EAAA;AACR,EAAA,OAAO,GAAG,OAAO,CAAA,MAAA,EAAS,aAAa,CAAI,CAAA,EAAA,kBAAA,CAAmB,MAAM,CAAC,CAAA,CAAA;AACvE;AAEgB,SAAA,eAAA,CACd,KACA,MACA,EAAA;AACA,EAAO,OAAA,MAAA,GACH,GAAI,CAAA,MAAA,CAAO,CAAO,GAAA,KAAA;AAChB,IAAA,MAAM,KAAQ,GAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,QAAQ,CAAA;AACvC,IAAI,IAAA,KAAA,CAAM,SAAS,CAAG,EAAA;AACpB,MAAO,OAAA,KAAA;AAAA;AAET,IAAM,MAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACvB,IAAM,MAAA,MAAA,GAASA,6BAAY,OAAO,CAAA;AAClC,IAAA,OAAO,OAAO,IAAK,CAAA,WAAA,GAAc,QAAS,CAAA,MAAA,CAAO,aAAa,CAAA;AAAA,GAC/D,CACD,GAAA,GAAA;AACN;;;;;;;"}
|
|
@@ -303,7 +303,7 @@ const OPENAPI = `
|
|
|
303
303
|
{
|
|
304
304
|
"type": "array",
|
|
305
305
|
"items": {
|
|
306
|
-
"$ref": "#/components/schemas/
|
|
306
|
+
"$ref": "#/components/schemas/SourceImport"
|
|
307
307
|
}
|
|
308
308
|
},
|
|
309
309
|
{
|
|
@@ -734,7 +734,7 @@ const OPENAPI = `
|
|
|
734
734
|
"imports": {
|
|
735
735
|
"type": "array",
|
|
736
736
|
"items": {
|
|
737
|
-
"$ref": "#/components/schemas/
|
|
737
|
+
"$ref": "#/components/schemas/SourceImport"
|
|
738
738
|
}
|
|
739
739
|
},
|
|
740
740
|
"errors": {
|
|
@@ -817,6 +817,33 @@ const OPENAPI = `
|
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
819
|
},
|
|
820
|
+
"SourceImport": {
|
|
821
|
+
"title": "Import Job with source it originates from",
|
|
822
|
+
"allOf": [
|
|
823
|
+
{
|
|
824
|
+
"$ref": "#/components/schemas/Import"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
"type": "object",
|
|
828
|
+
"properties": {
|
|
829
|
+
"source": {
|
|
830
|
+
"$ref": "#/components/schemas/Source"
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
]
|
|
835
|
+
},
|
|
836
|
+
"Source": {
|
|
837
|
+
"type": "string",
|
|
838
|
+
"nullable": true,
|
|
839
|
+
"description": "Import Source:\\n * 'config' - Import from static catalog location configuration in 'app-config'\\n * 'location' - Import of user registered entities using locations endpoint\\n * 'integration' - Import using a GitHub integration\\n * null - Import source is unknown\\n",
|
|
840
|
+
"enum": [
|
|
841
|
+
"config",
|
|
842
|
+
"location",
|
|
843
|
+
"integration",
|
|
844
|
+
null
|
|
845
|
+
]
|
|
846
|
+
},
|
|
820
847
|
"ImportRequest": {
|
|
821
848
|
"title": "Import Job request",
|
|
822
849
|
"type": "object",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapidocument.cjs.js","sources":["../../src/generated/openapidocument.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\n// eslint-disable\n// prettier-ignore\nconst OPENAPI = `\n{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"version\": \"1.0\",\n \"title\": \"Bulk Import Backend\",\n \"description\": \"The Bulk Import Backend APIs allow users to bulk import repositories into the Backstage catalog from remote sources such as Git.\"\n },\n \"servers\": [\n {\n \"url\": \"{protocol}://{host}:{port}/{basePath}\",\n \"variables\": {\n \"protocol\": {\n \"enum\": [\n \"http\",\n \"https\"\n ],\n \"default\": \"http\"\n },\n \"host\": {\n \"default\": \"localhost\"\n },\n \"port\": {\n \"default\": \"7007\"\n },\n \"basePath\": {\n \"default\": \"api/bulk-import\"\n }\n }\n }\n ],\n \"paths\": {\n \"/ping\": {\n \"get\": {\n \"operationId\": \"ping\",\n \"summary\": \"Check the health of the Bulk Import backend router\",\n \"tags\": [\n \"Management\"\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"The backend router for the Bulk Import backend is up and running\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"enum\": [\n \"ok\"\n ]\n }\n }\n },\n \"example\": {\n \"status\": \"ok\"\n }\n }\n }\n }\n }\n }\n },\n \"/organizations\": {\n \"get\": {\n \"operationId\": \"findAllOrganizations\",\n \"summary\": \"Fetch Organizations accessible by Backstage Github Integrations\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Organization\"\n ],\n \"parameters\": [\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Organization list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/OrganizationList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleOrgs\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Organization is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/OrganizationList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/orgListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/organizations/{organizationName}/repositories\": {\n \"get\": {\n \"operationId\": \"findRepositoriesByOrganization\",\n \"summary\": \"Fetch Repositories in the specified GitHub organization, provided it is accessible by any of the configured GitHub Integrations.\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Organization\"\n ],\n \"parameters\": [\n {\n \"in\": \"path\",\n \"name\": \"organizationName\",\n \"description\": \"Organization name\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"checkImportStatus\",\n \"description\": \"whether to return import status. Note that this might incur a performance penalty because the import status is computed for each repository.\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Org Repository list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleRepos\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Org Repository is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/repositoryListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/repositories\": {\n \"get\": {\n \"operationId\": \"findAllRepositories\",\n \"summary\": \"Fetch Organization Repositories accessible by Backstage Github Integrations\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Repository\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"checkImportStatus\",\n \"description\": \"whether to return import status. Note that this might incur a performance penalty because the import status is computed for each repository.\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Repository list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleRepos\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no repository is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/repositoryListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/imports\": {\n \"get\": {\n \"operationId\": \"findAllImports\",\n \"summary\": \"Fetch Import Jobs\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"$ref\": \"#/components/parameters/apiVersionHeaderParam\"\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParamDeprecated\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParamDeprecated\"\n },\n {\n \"$ref\": \"#/components/parameters/pageQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizeQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Import Job list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"oneOf\": [\n {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Import\"\n }\n },\n {\n \"$ref\": \"#/components/schemas/ImportJobListV2\"\n }\n ]\n },\n \"examples\": {\n \"twoImports\": {\n \"$ref\": \"#/components/examples/twoImports\"\n },\n \"multipleImportJobsV2\": {\n \"$ref\": \"#/components/examples/multipleImportJobsV2\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Import Job is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"oneOf\": [\n {\n \"type\": \"string\",\n \"description\": \"Generic error\"\n },\n {\n \"$ref\": \"#/components/schemas/ImportJobListV2\"\n }\n ]\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/importJobListErrors\"\n }\n }\n }\n }\n }\n }\n },\n \"post\": {\n \"operationId\": \"createImportJobs\",\n \"summary\": \"Submit Import Jobs\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"dryRun\",\n \"description\": \"whether to perform a dry-run to check if entity name collisions would occur in the catalog\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n }\n ],\n \"requestBody\": {\n \"description\": \"List of Import jobs to create\",\n \"required\": true,\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/ImportRequest\"\n }\n },\n \"examples\": {\n \"multipleImportRequests\": {\n \"$ref\": \"#/components/examples/multipleImportRequests\"\n }\n }\n }\n }\n },\n \"responses\": {\n \"202\": {\n \"description\": \"Import Jobs request was submitted successfully to the API. Check the status in each item of the response body list to see their individual status.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Import\"\n }\n },\n \"examples\": {\n \"twoImports\": {\n \"$ref\": \"#/components/examples/twoImportJobs\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/import/by-repo\": {\n \"get\": {\n \"operationId\": \"findImportStatusByRepo\",\n \"summary\": \"Get Import Status by repository\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"repo\",\n \"description\": \"the full URL to the repo\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"defaultBranch\",\n \"description\": \"the name of the default branch\",\n \"schema\": {\n \"type\": \"string\",\n \"default\": \"main\"\n }\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Import Job status was determined successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Import\"\n },\n \"examples\": {\n \"singleImportStatusForRepo\": {\n \"$ref\": \"#/components/examples/singleImportStatusForRepo\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error\"\n }\n }\n },\n \"delete\": {\n \"operationId\": \"deleteImportByRepo\",\n \"summary\": \"Delete Import by repository\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"repo\",\n \"description\": \"the full URL to the repo\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"defaultBranch\",\n \"description\": \"the name of the default branch\",\n \"schema\": {\n \"type\": \"string\",\n \"default\": \"main\"\n }\n }\n ],\n \"responses\": {\n \"204\": {\n \"description\": \"Import Job was successfully delete with no errors\"\n },\n \"500\": {\n \"description\": \"Generic error\"\n }\n }\n }\n }\n },\n \"components\": {\n \"parameters\": {\n \"apiVersionHeaderParam\": {\n \"in\": \"header\",\n \"name\": \"api-version\",\n \"description\": \"API version.\\\\n\\\\n## Changelog\\\\n\\\\n### v1 (default)\\\\nInitial version\\\\n#### Deprecations\\\\n* GET /imports\\\\n * Deprecation of 'pagePerIntegration' and 'sizePerIntegration' query parameters and introduction of new 'page' and 'size' parameters\\\\n * 'page' takes precedence over 'pagePerIntegration' if both are passed\\\\n * 'size' takes precedence over 'sizePerIntegration' if both are passed\\\\n\\\\n### v2\\\\n#### Breaking changes\\\\n* GET /imports\\\\n * Query parameters:\\\\n * 'pagePerIntegration' is ignored in favor of 'page'\\\\n * 'sizePerIntegration' is ignored in favor of 'size'\\\\n * Response structure changed to include pagination info: instead of returning a simple list of Imports, the response is now an object containing the following fields:\\\\n * 'imports': the list of Imports\\\\n * 'page': the page requested\\\\n * 'size': the requested number of Imports requested per page\\\\n * 'totalCount': the total count of Imports\\\\n\",\n \"schema\": {\n \"type\": \"string\",\n \"enum\": [\n \"v1\",\n \"v2\"\n ],\n \"default\": \"v1\"\n }\n },\n \"pagePerIntegrationQueryParam\": {\n \"in\": \"query\",\n \"name\": \"pagePerIntegration\",\n \"description\": \"the page number for each Integration\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizePerIntegrationQueryParam\": {\n \"in\": \"query\",\n \"name\": \"sizePerIntegration\",\n \"description\": \"the number of items per Integration to return per page\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n },\n \"pagePerIntegrationQueryParamDeprecated\": {\n \"in\": \"query\",\n \"name\": \"pagePerIntegration\",\n \"description\": \"the page number for each Integration. **Deprecated**. Use the 'page' query parameter instead.\",\n \"deprecated\": true,\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizePerIntegrationQueryParamDeprecated\": {\n \"in\": \"query\",\n \"name\": \"sizePerIntegration\",\n \"description\": \"the number of items per Integration to return per page. **Deprecated**. Use the 'size' query parameter instead.\",\n \"deprecated\": true,\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n },\n \"searchQueryParam\": {\n \"in\": \"query\",\n \"name\": \"search\",\n \"description\": \"returns only the items that match the search string\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n \"pageQueryParam\": {\n \"in\": \"query\",\n \"name\": \"page\",\n \"description\": \"the requested page number\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizeQueryParam\": {\n \"in\": \"query\",\n \"name\": \"size\",\n \"description\": \"the number of items to return per page\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n }\n },\n \"schemas\": {\n \"OrganizationList\": {\n \"title\": \"Organization List\",\n \"type\": \"object\",\n \"properties\": {\n \"organizations\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Organization\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"pagePerIntegration\": {\n \"type\": \"integer\"\n },\n \"sizePerIntegration\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Organization\": {\n \"title\": \"Organization\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"unique identifier\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"organization name\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"organization description\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"organization URL\"\n },\n \"totalRepoCount\": {\n \"type\": \"number\",\n \"description\": \"total number of repositories in this Organization\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"RepositoryList\": {\n \"title\": \"Repository List\",\n \"type\": \"object\",\n \"properties\": {\n \"repositories\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Repository\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"pagePerIntegration\": {\n \"type\": \"integer\"\n },\n \"sizePerIntegration\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Repository\": {\n \"title\": \"Repository\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"unique identifier\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"repository name\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"repository URL\"\n },\n \"organization\": {\n \"type\": \"string\",\n \"description\": \"organization which the repository is part of\"\n },\n \"importStatus\": {\n \"$ref\": \"#/components/schemas/ImportStatus\"\n },\n \"defaultBranch\": {\n \"type\": \"string\",\n \"description\": \"default branch\"\n },\n \"lastUpdate\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"ApprovalTool\": {\n \"type\": \"string\",\n \"enum\": [\n \"GIT\",\n \"SERVICENOW\"\n ]\n },\n \"ImportStatus\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Import Job status\",\n \"enum\": [\n \"ADDED\",\n \"WAIT_PR_APPROVAL\",\n \"PR_ERROR\",\n null\n ]\n },\n \"ImportJobListV2\": {\n \"title\": \"Import Job List\",\n \"type\": \"object\",\n \"properties\": {\n \"imports\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Import\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"page\": {\n \"type\": \"integer\"\n },\n \"size\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Import\": {\n \"title\": \"Import Job\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/ImportStatus\"\n },\n \"catalogEntityName\": {\n \"type\": \"string\",\n \"description\": \"Specified entity name in the catalog. Filled only in response for dry-run import requests.\"\n },\n \"lastUpdate\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"approvalTool\": {\n \"$ref\": \"#/components/schemas/ApprovalTool\"\n },\n \"repository\": {\n \"$ref\": \"#/components/schemas/Repository\"\n },\n \"github\": {\n \"type\": \"object\",\n \"description\": \"GitHub details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"pullRequest\": {\n \"type\": \"object\",\n \"properties\": {\n \"url\": {\n \"type\": \"string\",\n \"description\": \"URL of the Pull Request\"\n },\n \"number\": {\n \"type\": \"number\",\n \"description\": \"Pull Request number\"\n },\n \"title\": {\n \"type\": \"string\",\n \"description\": \"title of the Pull Request\"\n },\n \"body\": {\n \"type\": \"string\",\n \"description\": \"body of the Pull Request\"\n },\n \"catalogInfoContent\": {\n \"type\": \"string\",\n \"description\": \"content of the catalog-info.yaml as fetched from the Pull Request.\"\n }\n }\n }\n }\n }\n }\n },\n \"ImportRequest\": {\n \"title\": \"Import Job request\",\n \"type\": \"object\",\n \"required\": [\n \"repository\"\n ],\n \"properties\": {\n \"approvalTool\": {\n \"$ref\": \"#/components/schemas/ApprovalTool\"\n },\n \"catalogEntityName\": {\n \"type\": \"string\",\n \"description\": \"Expected Entity name in the catalog. Relevant only if the 'dryRun' query parameter is set to 'true'.\"\n },\n \"codeOwnersFileAsEntityOwner\": {\n \"type\": \"boolean\",\n \"description\": \"Whether the CODEOWNERS file will be used as entity owner. Only relevant for dry-run requests. If set to 'false', the corresponding dry-run check will be skipped.\"\n },\n \"repository\": {\n \"type\": \"object\",\n \"required\": [\n \"url\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"repository name\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"repository URL\"\n },\n \"organization\": {\n \"type\": \"string\",\n \"description\": \"organization which the repository is part of\"\n },\n \"defaultBranch\": {\n \"type\": \"string\",\n \"description\": \"default branch\"\n }\n }\n },\n \"catalogInfoContent\": {\n \"type\": \"string\",\n \"description\": \"content of the catalog-info.yaml to include in the import Pull Request.\"\n },\n \"github\": {\n \"type\": \"object\",\n \"description\": \"GitHub details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"pullRequest\": {\n \"type\": \"object\",\n \"description\": \"Pull Request details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"description\": \"title of the Pull Request\"\n },\n \"body\": {\n \"type\": \"string\",\n \"description\": \"body of the Pull Request\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"securitySchemes\": {\n \"BearerAuth\": {\n \"type\": \"http\",\n \"scheme\": \"bearer\",\n \"bearerFormat\": \"JWT\",\n \"description\": \"Backstage Permissions Framework JWT\"\n }\n },\n \"examples\": {\n \"multipleOrgs\": {\n \"summary\": \"Multiple organizations\",\n \"value\": {\n \"errors\": [],\n \"organizations\": [\n {\n \"id\": \"unique-org-id-1\",\n \"name\": \"pet-org\",\n \"url\": \"https://github.com/pet-org\",\n \"description\": \"A great Pet Org\",\n \"totalRepoCount\": 10\n },\n {\n \"id\": \"unique-org-id-2\",\n \"name\": \"org-zero\",\n \"url\": \"https://ghe.example.com/org-zero\",\n \"totalRepoCount\": 0\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"org-one\",\n \"url\": \"https://ghe.example.com/org-one\",\n \"description\": \"Org One description\",\n \"totalRepoCount\": 1234\n }\n ]\n }\n },\n \"orgListErrors\": {\n \"summary\": \"Errors when listing organizations\",\n \"value\": {\n \"errors\": [\n \"Github App with ID 2 failed spectacularly\"\n ],\n \"organizations\": []\n }\n },\n \"multipleRepos\": {\n \"summary\": \"Multiple repositories\",\n \"value\": {\n \"errors\": [],\n \"repositories\": [\n {\n \"id\": \"unique-id-1\",\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\",\n \"importStatus\": \"WAIT_PR_APPROVAL\",\n \"defaultBranch\": \"main\"\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"project-zero\",\n \"url\": \"https://ghe.example.com/my-other-org/project-zero\",\n \"organization\": \"my-other-org\",\n \"importStatus\": \"PR_REJECTED\",\n \"defaultBranch\": \"dev\"\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"project-one\",\n \"defaultBranch\": \"trunk\",\n \"url\": \"https://ghe.example.com/my-other-org-2/project-one\",\n \"organization\": \"my-other-org-2\"\n }\n ]\n }\n },\n \"repositoryListErrors\": {\n \"summary\": \"Errors when listing repositories\",\n \"value\": {\n \"errors\": [\n \"Github App with ID 2 failed spectacularly\"\n ],\n \"repositories\": []\n }\n },\n \"twoImports\": {\n \"summary\": \"Two import job requests (V1)\",\n \"value\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n },\n \"multipleImportJobsV2\": {\n \"summary\": \"Two import job requests (V2)\",\n \"value\": {\n \"errors\": [],\n \"page\": 1,\n \"size\": 2,\n \"totalCount\": 10,\n \"imports\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n }\n },\n \"importJobListErrors\": {\n \"summary\": \"Errors when listing import jobs\",\n \"value\": {\n \"errors\": [\n \"Github App with ID xyz-123 failed spectacularly\"\n ],\n \"imports\": []\n }\n },\n \"twoImportJobs\": {\n \"summary\": \"Two import jobs\",\n \"value\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n },\n \"singleImportStatusForRepo\": {\n \"summary\": \"Single import job status for given repo\",\n \"value\": {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n }\n },\n \"multipleImportRequests\": {\n \"summary\": \"Multiple import requests\",\n \"value\": [\n {\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\",\n \"defaultBranch\": \"main\"\n },\n \"github\": {\n \"pullRequest\": {\n \"title\": \"Add default catalog-info.yaml to import to Red Hat Developer Hub\"\n }\n }\n },\n {\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"project-zero\",\n \"url\": \"https://ghe.example.com/my-other-org/project-zero\",\n \"organization\": \"my-other-org\",\n \"defaultBranch\": \"dev\"\n },\n \"github\": {\n \"pullRequest\": {\n \"title\": \"Add custom catalog-info.yaml to import to Red Hat Developer Hub\",\n \"body\": \"This pull request adds a **Backstage entity metadata file** to this repository so that the component can be added to the Red Hat Developer Hub software catalog.\\\\n\\\\nAfter this pull request is merged, the component will become available.\\\\n\\\\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\"\n }\n },\n \"catalogInfoContent\": \"apiVersion: backstage.io/v1alpha1\\\\nkind: Component\\\\nmetadata:\\\\n name: project-zero\\\\n annotations:\\\\n github.com/project-slug: my-other-org/project-zero\\\\n acme.com/custom-annotation: my-value\\\\nspec:\\\\n type: other\\\\n lifecycle: unknown\\\\n owner: my-other-org\"\n }\n ]\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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AA0oCH,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,OAAO;;;;"}
|
|
1
|
+
{"version":3,"file":"openapidocument.cjs.js","sources":["../../src/generated/openapidocument.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\n// eslint-disable\n// prettier-ignore\nconst OPENAPI = `\n{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"version\": \"1.0\",\n \"title\": \"Bulk Import Backend\",\n \"description\": \"The Bulk Import Backend APIs allow users to bulk import repositories into the Backstage catalog from remote sources such as Git.\"\n },\n \"servers\": [\n {\n \"url\": \"{protocol}://{host}:{port}/{basePath}\",\n \"variables\": {\n \"protocol\": {\n \"enum\": [\n \"http\",\n \"https\"\n ],\n \"default\": \"http\"\n },\n \"host\": {\n \"default\": \"localhost\"\n },\n \"port\": {\n \"default\": \"7007\"\n },\n \"basePath\": {\n \"default\": \"api/bulk-import\"\n }\n }\n }\n ],\n \"paths\": {\n \"/ping\": {\n \"get\": {\n \"operationId\": \"ping\",\n \"summary\": \"Check the health of the Bulk Import backend router\",\n \"tags\": [\n \"Management\"\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"The backend router for the Bulk Import backend is up and running\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"enum\": [\n \"ok\"\n ]\n }\n }\n },\n \"example\": {\n \"status\": \"ok\"\n }\n }\n }\n }\n }\n }\n },\n \"/organizations\": {\n \"get\": {\n \"operationId\": \"findAllOrganizations\",\n \"summary\": \"Fetch Organizations accessible by Backstage Github Integrations\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Organization\"\n ],\n \"parameters\": [\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Organization list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/OrganizationList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleOrgs\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Organization is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/OrganizationList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/orgListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/organizations/{organizationName}/repositories\": {\n \"get\": {\n \"operationId\": \"findRepositoriesByOrganization\",\n \"summary\": \"Fetch Repositories in the specified GitHub organization, provided it is accessible by any of the configured GitHub Integrations.\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Organization\"\n ],\n \"parameters\": [\n {\n \"in\": \"path\",\n \"name\": \"organizationName\",\n \"description\": \"Organization name\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"checkImportStatus\",\n \"description\": \"whether to return import status. Note that this might incur a performance penalty because the import status is computed for each repository.\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Org Repository list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleRepos\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Org Repository is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/repositoryListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/repositories\": {\n \"get\": {\n \"operationId\": \"findAllRepositories\",\n \"summary\": \"Fetch Organization Repositories accessible by Backstage Github Integrations\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Repository\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"checkImportStatus\",\n \"description\": \"whether to return import status. Note that this might incur a performance penalty because the import status is computed for each repository.\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Repository list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"multipleRepos\": {\n \"$ref\": \"#/components/examples/multipleRepos\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no repository is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/RepositoryList\"\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/repositoryListErrors\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/imports\": {\n \"get\": {\n \"operationId\": \"findAllImports\",\n \"summary\": \"Fetch Import Jobs\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"$ref\": \"#/components/parameters/apiVersionHeaderParam\"\n },\n {\n \"$ref\": \"#/components/parameters/pagePerIntegrationQueryParamDeprecated\"\n },\n {\n \"$ref\": \"#/components/parameters/sizePerIntegrationQueryParamDeprecated\"\n },\n {\n \"$ref\": \"#/components/parameters/pageQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/sizeQueryParam\"\n },\n {\n \"$ref\": \"#/components/parameters/searchQueryParam\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Import Job list was fetched successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"oneOf\": [\n {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/SourceImport\"\n }\n },\n {\n \"$ref\": \"#/components/schemas/ImportJobListV2\"\n }\n ]\n },\n \"examples\": {\n \"twoImports\": {\n \"$ref\": \"#/components/examples/twoImports\"\n },\n \"multipleImportJobsV2\": {\n \"$ref\": \"#/components/examples/multipleImportJobsV2\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error when there are errors and no Import Job is returned\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"oneOf\": [\n {\n \"type\": \"string\",\n \"description\": \"Generic error\"\n },\n {\n \"$ref\": \"#/components/schemas/ImportJobListV2\"\n }\n ]\n },\n \"examples\": {\n \"repositoryListErrors\": {\n \"$ref\": \"#/components/examples/importJobListErrors\"\n }\n }\n }\n }\n }\n }\n },\n \"post\": {\n \"operationId\": \"createImportJobs\",\n \"summary\": \"Submit Import Jobs\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"dryRun\",\n \"description\": \"whether to perform a dry-run to check if entity name collisions would occur in the catalog\",\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": \"false\"\n }\n }\n ],\n \"requestBody\": {\n \"description\": \"List of Import jobs to create\",\n \"required\": true,\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/ImportRequest\"\n }\n },\n \"examples\": {\n \"multipleImportRequests\": {\n \"$ref\": \"#/components/examples/multipleImportRequests\"\n }\n }\n }\n }\n },\n \"responses\": {\n \"202\": {\n \"description\": \"Import Jobs request was submitted successfully to the API. Check the status in each item of the response body list to see their individual status.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Import\"\n }\n },\n \"examples\": {\n \"twoImports\": {\n \"$ref\": \"#/components/examples/twoImportJobs\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"/import/by-repo\": {\n \"get\": {\n \"operationId\": \"findImportStatusByRepo\",\n \"summary\": \"Get Import Status by repository\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"repo\",\n \"description\": \"the full URL to the repo\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"defaultBranch\",\n \"description\": \"the name of the default branch\",\n \"schema\": {\n \"type\": \"string\",\n \"default\": \"main\"\n }\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Import Job status was determined successfully with no errors\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Import\"\n },\n \"examples\": {\n \"singleImportStatusForRepo\": {\n \"$ref\": \"#/components/examples/singleImportStatusForRepo\"\n }\n }\n }\n }\n },\n \"500\": {\n \"description\": \"Generic error\"\n }\n }\n },\n \"delete\": {\n \"operationId\": \"deleteImportByRepo\",\n \"summary\": \"Delete Import by repository\",\n \"security\": [\n {\n \"BearerAuth\": []\n }\n ],\n \"tags\": [\n \"Import\"\n ],\n \"parameters\": [\n {\n \"in\": \"query\",\n \"name\": \"repo\",\n \"description\": \"the full URL to the repo\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"in\": \"query\",\n \"name\": \"defaultBranch\",\n \"description\": \"the name of the default branch\",\n \"schema\": {\n \"type\": \"string\",\n \"default\": \"main\"\n }\n }\n ],\n \"responses\": {\n \"204\": {\n \"description\": \"Import Job was successfully delete with no errors\"\n },\n \"500\": {\n \"description\": \"Generic error\"\n }\n }\n }\n }\n },\n \"components\": {\n \"parameters\": {\n \"apiVersionHeaderParam\": {\n \"in\": \"header\",\n \"name\": \"api-version\",\n \"description\": \"API version.\\\\n\\\\n## Changelog\\\\n\\\\n### v1 (default)\\\\nInitial version\\\\n#### Deprecations\\\\n* GET /imports\\\\n * Deprecation of 'pagePerIntegration' and 'sizePerIntegration' query parameters and introduction of new 'page' and 'size' parameters\\\\n * 'page' takes precedence over 'pagePerIntegration' if both are passed\\\\n * 'size' takes precedence over 'sizePerIntegration' if both are passed\\\\n\\\\n### v2\\\\n#### Breaking changes\\\\n* GET /imports\\\\n * Query parameters:\\\\n * 'pagePerIntegration' is ignored in favor of 'page'\\\\n * 'sizePerIntegration' is ignored in favor of 'size'\\\\n * Response structure changed to include pagination info: instead of returning a simple list of Imports, the response is now an object containing the following fields:\\\\n * 'imports': the list of Imports\\\\n * 'page': the page requested\\\\n * 'size': the requested number of Imports requested per page\\\\n * 'totalCount': the total count of Imports\\\\n\",\n \"schema\": {\n \"type\": \"string\",\n \"enum\": [\n \"v1\",\n \"v2\"\n ],\n \"default\": \"v1\"\n }\n },\n \"pagePerIntegrationQueryParam\": {\n \"in\": \"query\",\n \"name\": \"pagePerIntegration\",\n \"description\": \"the page number for each Integration\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizePerIntegrationQueryParam\": {\n \"in\": \"query\",\n \"name\": \"sizePerIntegration\",\n \"description\": \"the number of items per Integration to return per page\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n },\n \"pagePerIntegrationQueryParamDeprecated\": {\n \"in\": \"query\",\n \"name\": \"pagePerIntegration\",\n \"description\": \"the page number for each Integration. **Deprecated**. Use the 'page' query parameter instead.\",\n \"deprecated\": true,\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizePerIntegrationQueryParamDeprecated\": {\n \"in\": \"query\",\n \"name\": \"sizePerIntegration\",\n \"description\": \"the number of items per Integration to return per page. **Deprecated**. Use the 'size' query parameter instead.\",\n \"deprecated\": true,\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n },\n \"searchQueryParam\": {\n \"in\": \"query\",\n \"name\": \"search\",\n \"description\": \"returns only the items that match the search string\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n \"pageQueryParam\": {\n \"in\": \"query\",\n \"name\": \"page\",\n \"description\": \"the requested page number\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"sizeQueryParam\": {\n \"in\": \"query\",\n \"name\": \"size\",\n \"description\": \"the number of items to return per page\",\n \"schema\": {\n \"type\": \"integer\",\n \"default\": 20\n }\n }\n },\n \"schemas\": {\n \"OrganizationList\": {\n \"title\": \"Organization List\",\n \"type\": \"object\",\n \"properties\": {\n \"organizations\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Organization\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"pagePerIntegration\": {\n \"type\": \"integer\"\n },\n \"sizePerIntegration\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Organization\": {\n \"title\": \"Organization\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"unique identifier\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"organization name\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"organization description\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"organization URL\"\n },\n \"totalRepoCount\": {\n \"type\": \"number\",\n \"description\": \"total number of repositories in this Organization\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"RepositoryList\": {\n \"title\": \"Repository List\",\n \"type\": \"object\",\n \"properties\": {\n \"repositories\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Repository\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"pagePerIntegration\": {\n \"type\": \"integer\"\n },\n \"sizePerIntegration\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Repository\": {\n \"title\": \"Repository\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"unique identifier\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"repository name\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"repository URL\"\n },\n \"organization\": {\n \"type\": \"string\",\n \"description\": \"organization which the repository is part of\"\n },\n \"importStatus\": {\n \"$ref\": \"#/components/schemas/ImportStatus\"\n },\n \"defaultBranch\": {\n \"type\": \"string\",\n \"description\": \"default branch\"\n },\n \"lastUpdate\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"ApprovalTool\": {\n \"type\": \"string\",\n \"enum\": [\n \"GIT\",\n \"SERVICENOW\"\n ]\n },\n \"ImportStatus\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Import Job status\",\n \"enum\": [\n \"ADDED\",\n \"WAIT_PR_APPROVAL\",\n \"PR_ERROR\",\n null\n ]\n },\n \"ImportJobListV2\": {\n \"title\": \"Import Job List\",\n \"type\": \"object\",\n \"properties\": {\n \"imports\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/SourceImport\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"totalCount\": {\n \"type\": \"integer\"\n },\n \"page\": {\n \"type\": \"integer\"\n },\n \"size\": {\n \"type\": \"integer\"\n }\n }\n },\n \"Import\": {\n \"title\": \"Import Job\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/ImportStatus\"\n },\n \"catalogEntityName\": {\n \"type\": \"string\",\n \"description\": \"Specified entity name in the catalog. Filled only in response for dry-run import requests.\"\n },\n \"lastUpdate\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"approvalTool\": {\n \"$ref\": \"#/components/schemas/ApprovalTool\"\n },\n \"repository\": {\n \"$ref\": \"#/components/schemas/Repository\"\n },\n \"github\": {\n \"type\": \"object\",\n \"description\": \"GitHub details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"pullRequest\": {\n \"type\": \"object\",\n \"properties\": {\n \"url\": {\n \"type\": \"string\",\n \"description\": \"URL of the Pull Request\"\n },\n \"number\": {\n \"type\": \"number\",\n \"description\": \"Pull Request number\"\n },\n \"title\": {\n \"type\": \"string\",\n \"description\": \"title of the Pull Request\"\n },\n \"body\": {\n \"type\": \"string\",\n \"description\": \"body of the Pull Request\"\n },\n \"catalogInfoContent\": {\n \"type\": \"string\",\n \"description\": \"content of the catalog-info.yaml as fetched from the Pull Request.\"\n }\n }\n }\n }\n }\n }\n },\n \"SourceImport\": {\n \"title\": \"Import Job with source it originates from\",\n \"allOf\": [\n {\n \"$ref\": \"#/components/schemas/Import\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"source\": {\n \"$ref\": \"#/components/schemas/Source\"\n }\n }\n }\n ]\n },\n \"Source\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Import Source:\\\\n * 'config' - Import from static catalog location configuration in 'app-config'\\\\n * 'location' - Import of user registered entities using locations endpoint\\\\n * 'integration' - Import using a GitHub integration\\\\n * null - Import source is unknown\\\\n\",\n \"enum\": [\n \"config\",\n \"location\",\n \"integration\",\n null\n ]\n },\n \"ImportRequest\": {\n \"title\": \"Import Job request\",\n \"type\": \"object\",\n \"required\": [\n \"repository\"\n ],\n \"properties\": {\n \"approvalTool\": {\n \"$ref\": \"#/components/schemas/ApprovalTool\"\n },\n \"catalogEntityName\": {\n \"type\": \"string\",\n \"description\": \"Expected Entity name in the catalog. Relevant only if the 'dryRun' query parameter is set to 'true'.\"\n },\n \"codeOwnersFileAsEntityOwner\": {\n \"type\": \"boolean\",\n \"description\": \"Whether the CODEOWNERS file will be used as entity owner. Only relevant for dry-run requests. If set to 'false', the corresponding dry-run check will be skipped.\"\n },\n \"repository\": {\n \"type\": \"object\",\n \"required\": [\n \"url\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"repository name\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"repository URL\"\n },\n \"organization\": {\n \"type\": \"string\",\n \"description\": \"organization which the repository is part of\"\n },\n \"defaultBranch\": {\n \"type\": \"string\",\n \"description\": \"default branch\"\n }\n }\n },\n \"catalogInfoContent\": {\n \"type\": \"string\",\n \"description\": \"content of the catalog-info.yaml to include in the import Pull Request.\"\n },\n \"github\": {\n \"type\": \"object\",\n \"description\": \"GitHub details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"pullRequest\": {\n \"type\": \"object\",\n \"description\": \"Pull Request details. Applicable if approvalTool is git.\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"description\": \"title of the Pull Request\"\n },\n \"body\": {\n \"type\": \"string\",\n \"description\": \"body of the Pull Request\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"securitySchemes\": {\n \"BearerAuth\": {\n \"type\": \"http\",\n \"scheme\": \"bearer\",\n \"bearerFormat\": \"JWT\",\n \"description\": \"Backstage Permissions Framework JWT\"\n }\n },\n \"examples\": {\n \"multipleOrgs\": {\n \"summary\": \"Multiple organizations\",\n \"value\": {\n \"errors\": [],\n \"organizations\": [\n {\n \"id\": \"unique-org-id-1\",\n \"name\": \"pet-org\",\n \"url\": \"https://github.com/pet-org\",\n \"description\": \"A great Pet Org\",\n \"totalRepoCount\": 10\n },\n {\n \"id\": \"unique-org-id-2\",\n \"name\": \"org-zero\",\n \"url\": \"https://ghe.example.com/org-zero\",\n \"totalRepoCount\": 0\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"org-one\",\n \"url\": \"https://ghe.example.com/org-one\",\n \"description\": \"Org One description\",\n \"totalRepoCount\": 1234\n }\n ]\n }\n },\n \"orgListErrors\": {\n \"summary\": \"Errors when listing organizations\",\n \"value\": {\n \"errors\": [\n \"Github App with ID 2 failed spectacularly\"\n ],\n \"organizations\": []\n }\n },\n \"multipleRepos\": {\n \"summary\": \"Multiple repositories\",\n \"value\": {\n \"errors\": [],\n \"repositories\": [\n {\n \"id\": \"unique-id-1\",\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\",\n \"importStatus\": \"WAIT_PR_APPROVAL\",\n \"defaultBranch\": \"main\"\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"project-zero\",\n \"url\": \"https://ghe.example.com/my-other-org/project-zero\",\n \"organization\": \"my-other-org\",\n \"importStatus\": \"PR_REJECTED\",\n \"defaultBranch\": \"dev\"\n },\n {\n \"id\": \"unique-id-2\",\n \"name\": \"project-one\",\n \"defaultBranch\": \"trunk\",\n \"url\": \"https://ghe.example.com/my-other-org-2/project-one\",\n \"organization\": \"my-other-org-2\"\n }\n ]\n }\n },\n \"repositoryListErrors\": {\n \"summary\": \"Errors when listing repositories\",\n \"value\": {\n \"errors\": [\n \"Github App with ID 2 failed spectacularly\"\n ],\n \"repositories\": []\n }\n },\n \"twoImports\": {\n \"summary\": \"Two import job requests (V1)\",\n \"value\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n },\n \"multipleImportJobsV2\": {\n \"summary\": \"Two import job requests (V2)\",\n \"value\": {\n \"errors\": [],\n \"page\": 1,\n \"size\": 2,\n \"totalCount\": 10,\n \"imports\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n }\n },\n \"importJobListErrors\": {\n \"summary\": \"Errors when listing import jobs\",\n \"value\": {\n \"errors\": [\n \"Github App with ID xyz-123 failed spectacularly\"\n ],\n \"imports\": []\n }\n },\n \"twoImportJobs\": {\n \"summary\": \"Two import jobs\",\n \"value\": [\n {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n },\n {\n \"id\": \"bulk-import-id-2\",\n \"status\": \"PR_REJECTED\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app-test\",\n \"url\": \"https://github.com/my-org/pet-app-test\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app-test/pull/10\",\n \"number\": 10\n }\n }\n }\n ]\n },\n \"singleImportStatusForRepo\": {\n \"summary\": \"Single import job status for given repo\",\n \"value\": {\n \"id\": \"bulk-import-id-1\",\n \"status\": \"WAIT_PR_APPROVAL\",\n \"errors\": [],\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\"\n },\n \"github\": {\n \"pullRequest\": {\n \"url\": \"https://github.com/my-org/pet-app/pull/1\",\n \"number\": 1\n }\n }\n }\n },\n \"multipleImportRequests\": {\n \"summary\": \"Multiple import requests\",\n \"value\": [\n {\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"pet-app\",\n \"url\": \"https://github.com/my-org/pet-app\",\n \"organization\": \"my-org\",\n \"defaultBranch\": \"main\"\n },\n \"github\": {\n \"pullRequest\": {\n \"title\": \"Add default catalog-info.yaml to import to Red Hat Developer Hub\"\n }\n }\n },\n {\n \"approvalTool\": \"GIT\",\n \"repository\": {\n \"name\": \"project-zero\",\n \"url\": \"https://ghe.example.com/my-other-org/project-zero\",\n \"organization\": \"my-other-org\",\n \"defaultBranch\": \"dev\"\n },\n \"github\": {\n \"pullRequest\": {\n \"title\": \"Add custom catalog-info.yaml to import to Red Hat Developer Hub\",\n \"body\": \"This pull request adds a **Backstage entity metadata file** to this repository so that the component can be added to the Red Hat Developer Hub software catalog.\\\\n\\\\nAfter this pull request is merged, the component will become available.\\\\n\\\\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\"\n }\n },\n \"catalogInfoContent\": \"apiVersion: backstage.io/v1alpha1\\\\nkind: Component\\\\nmetadata:\\\\n name: project-zero\\\\n annotations:\\\\n github.com/project-slug: my-other-org/project-zero\\\\n acme.com/custom-annotation: my-value\\\\nspec:\\\\n type: other\\\\n lifecycle: unknown\\\\n owner: my-other-org\"\n }\n ]\n }\n }\n }\n}`\nexport const openApiDocument = JSON.parse(OPENAPI);\n"],"names":[],"mappings":";;AAkBA,MAAM,OAAU,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AAqqCH,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,OAAO;;;;"}
|
|
@@ -40,27 +40,29 @@ async function findAllImports(deps, requestHeaders, queryParams) {
|
|
|
40
40
|
search,
|
|
41
41
|
pageNumber,
|
|
42
42
|
pageSize
|
|
43
|
-
)).
|
|
43
|
+
)).uniqueCatalogUrlLocations;
|
|
44
44
|
const defaultBranchByRepoUrl = await resolveReposDefaultBranches(
|
|
45
45
|
deps.logger,
|
|
46
46
|
deps.githubApiService,
|
|
47
|
-
allLocations,
|
|
47
|
+
allLocations.keys(),
|
|
48
48
|
catalogFilename
|
|
49
49
|
);
|
|
50
50
|
const importCandidates = findImportCandidates(
|
|
51
|
-
allLocations,
|
|
51
|
+
allLocations.keys(),
|
|
52
52
|
defaultBranchByRepoUrl,
|
|
53
53
|
catalogFilename
|
|
54
54
|
);
|
|
55
55
|
const importsReachableFromGHIntegrations = await deps.githubApiService.filterLocationsAccessibleFromIntegrations(
|
|
56
56
|
importCandidates
|
|
57
57
|
);
|
|
58
|
+
const repoUrlToLocation = /* @__PURE__ */ new Map();
|
|
58
59
|
const importStatusPromises = [];
|
|
59
60
|
for (const loc of importsReachableFromGHIntegrations) {
|
|
60
61
|
const repoUrl = repoUrlFromLocation(loc);
|
|
61
62
|
if (!repoUrl) {
|
|
62
63
|
continue;
|
|
63
64
|
}
|
|
65
|
+
repoUrlToLocation.set(repoUrl, loc);
|
|
64
66
|
importStatusPromises.push(
|
|
65
67
|
findImportStatusByRepo(
|
|
66
68
|
deps,
|
|
@@ -71,7 +73,14 @@ async function findAllImports(deps, requestHeaders, queryParams) {
|
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
75
|
const result = await Promise.all(importStatusPromises);
|
|
74
|
-
const imports = result.filter((res) => res.responseBody).map((res) => res.responseBody)
|
|
76
|
+
const imports = result.filter((res) => res.responseBody).map((res) => res.responseBody).map((res) => {
|
|
77
|
+
const key = res?.repository?.url;
|
|
78
|
+
const location = key ? repoUrlToLocation.get(key) : void 0;
|
|
79
|
+
return {
|
|
80
|
+
...res,
|
|
81
|
+
source: location ? allLocations.get(location)?.source : void 0
|
|
82
|
+
};
|
|
83
|
+
});
|
|
75
84
|
sortImports(imports);
|
|
76
85
|
const paginated = pagination.paginateArray(imports, pageNumber, pageSize);
|
|
77
86
|
if (apiVersion === "v1") {
|
|
@@ -445,7 +454,7 @@ async function findImportStatusByRepo(deps, repoUrl, defaultBranch, includeCatal
|
|
|
445
454
|
}
|
|
446
455
|
);
|
|
447
456
|
if (!openImportPr.prUrl) {
|
|
448
|
-
const catalogLocations = (await deps.catalogHttpClient.listCatalogUrlLocations()).
|
|
457
|
+
const catalogLocations = (await deps.catalogHttpClient.listCatalogUrlLocations()).uniqueCatalogUrlLocations.keys();
|
|
449
458
|
const catalogUrl = catalogUtils.getCatalogUrl(deps.config, repoUrl, defaultBranch);
|
|
450
459
|
let exists = false;
|
|
451
460
|
for (const loc of catalogLocations) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulkImports.cjs.js","sources":["../../../../src/service/handlers/import/bulkImports.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\nimport type { AuthService, LoggerService } from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport type { CatalogInfoGenerator } from '../../../catalog/catalogInfoGenerator';\nimport {\n getCatalogFilename,\n getCatalogUrl,\n} from '../../../catalog/catalogUtils';\nimport type { Components, Paths } from '../../../generated/openapi';\nimport type { GithubApiService } from '../../../github';\nimport { logErrorIfNeeded, paginateArray } from '../../../helpers';\nimport {\n DefaultPageNumber,\n DefaultPageSize,\n type HandlerResponse,\n} from '../handlers';\n\ntype CreateImportDryRunStatus =\n | 'CATALOG_ENTITY_CONFLICT'\n | 'CATALOG_INFO_FILE_EXISTS_IN_REPO'\n | 'CODEOWNERS_FILE_NOT_FOUND_IN_REPO'\n | 'REPO_EMPTY';\n\ntype FindAllImportsResponse =\n | Components.Schemas.Import[]\n | Components.Schemas.ImportJobListV2;\n\nfunction sortImports(imports: Components.Schemas.Import[]) {\n imports.sort((a, b) => {\n if (a.repository?.name === undefined && b.repository?.name === undefined) {\n return 0;\n }\n if (a.repository?.name === undefined) {\n return -1;\n }\n if (b.repository?.name === undefined) {\n return 1;\n }\n return a.repository.name.localeCompare(b.repository.name);\n });\n}\n\nexport async function findAllImports(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n requestHeaders?: {\n apiVersion?: Paths.FindAllImports.Parameters.ApiVersion;\n },\n queryParams?: {\n search?: string;\n pageNumber?: number;\n pageSize?: number;\n },\n): Promise<HandlerResponse<FindAllImportsResponse>> {\n const apiVersion = requestHeaders?.apiVersion ?? 'v1';\n const search = queryParams?.search;\n const pageNumber = queryParams?.pageNumber ?? DefaultPageNumber;\n const pageSize = queryParams?.pageSize ?? DefaultPageSize;\n\n deps.logger.debug(\n `Getting all bulk import jobs (apiVersion=${apiVersion}, search=${search}, page=${pageNumber}, size=${pageSize})..`,\n );\n\n const catalogFilename = getCatalogFilename(deps.config);\n\n const allLocations = (\n await deps.catalogHttpClient.listCatalogUrlLocations(\n search,\n pageNumber,\n pageSize,\n )\n ).targetUrls;\n\n // resolve default branches for each unique repo URL from GH,\n // because we cannot easily determine that from the location target URL.\n // It can be 'main' or something more convoluted like 'our/awesome/main'.\n const defaultBranchByRepoUrl = await resolveReposDefaultBranches(\n deps.logger,\n deps.githubApiService,\n allLocations,\n catalogFilename,\n );\n\n // filter out locations that do not match what we are expecting, i.e.:\n // an URL to a catalog-info YAML file at the root of the repo\n const importCandidates = findImportCandidates(\n allLocations,\n defaultBranchByRepoUrl,\n catalogFilename,\n );\n\n // Keep only repos that are accessible from the configured GH integrations\n const importsReachableFromGHIntegrations =\n await deps.githubApiService.filterLocationsAccessibleFromIntegrations(\n importCandidates,\n );\n\n // now fetch the import statuses in different promises\n const importStatusPromises: Promise<\n HandlerResponse<Components.Schemas.Import>\n >[] = [];\n for (const loc of importsReachableFromGHIntegrations) {\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n\n importStatusPromises.push(\n findImportStatusByRepo(\n deps,\n repoUrl,\n defaultBranchByRepoUrl.get(repoUrl),\n false,\n ),\n );\n }\n\n const result = await Promise.all(importStatusPromises);\n const imports = result\n .filter(res => res.responseBody)\n .map(res => res.responseBody!);\n\n // sorting the output to make it deterministic and easy to navigate in the UI\n sortImports(imports);\n\n const paginated = paginateArray(imports, pageNumber, pageSize);\n if (apiVersion === 'v1') {\n return {\n statusCode: 200,\n responseBody: paginated.result,\n };\n }\n return {\n statusCode: 200,\n responseBody: {\n imports: paginated.result,\n totalCount: paginated.totalCount,\n page: pageNumber,\n size: pageSize,\n },\n };\n}\n\nasync function resolveReposDefaultBranches(\n logger: LoggerService,\n githubApiService: GithubApiService,\n allLocations: string[],\n catalogFilename: string,\n) {\n const defaultBranchByRepoUrlPromises: Promise<{\n repoUrl: string;\n defaultBranch?: string;\n }>[] = [];\n for (const loc of allLocations) {\n // loc has the following format: https://github.com/<org>/<repo>/blob/<default-branch>/catalog-info.yaml\n // but it can have a more convoluted format like 'https://github.com/janus-idp/backstage-plugins/blob/main/plugins/scaffolder-annotator-action/examples/templates/01-scaffolder-template.yaml'\n // if registered manually from the 'Register existing component' feature in Backstage.\n if (!loc.endsWith(catalogFilename)) {\n logger.debug(\n `Ignored location ${loc} because it does not point to a file named ${catalogFilename}`,\n );\n continue;\n }\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n defaultBranchByRepoUrlPromises.push(\n githubApiService\n .getRepositoryFromIntegrations(repoUrl)\n .then(resp => {\n return { repoUrl, defaultBranch: resp?.repository?.default_branch };\n })\n .catch((err: any) => {\n logErrorIfNeeded(\n logger,\n `Ignored repo ${repoUrl} due to an error while fetching details from GitHub`,\n err,\n );\n return {\n repoUrl,\n defaultBranch: undefined,\n };\n }),\n );\n }\n const defaultBranchesResponses = await Promise.all(\n defaultBranchByRepoUrlPromises,\n );\n return new Map(\n defaultBranchesResponses\n .flat()\n .filter(r => r.defaultBranch)\n .map(r => [r.repoUrl, r.defaultBranch!]),\n );\n}\n\nfunction repoUrlFromLocation(loc: string) {\n const split = loc.split('/blob/');\n if (split.length < 2) {\n return undefined;\n }\n return split[0];\n}\n\nfunction findImportCandidates(\n allLocations: string[],\n defaultBranchByRepoUrl: Map<string, string>,\n catalogFilename: string,\n) {\n const filteredLocations: string[] = [];\n for (const loc of allLocations) {\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n\n const defaultBranch = defaultBranchByRepoUrl.get(repoUrl);\n if (!defaultBranch) {\n continue;\n }\n if (loc !== `${repoUrl}/blob/${defaultBranch}/${catalogFilename}`) {\n // Because users can use the \"Register existing component\" workflow to register a Location\n // using any file path in the repo, we consider a repository as an Import Location only\n // if it is at the root of the repository, because that is what the import PR ultimately does.\n continue;\n }\n filteredLocations.push(loc);\n }\n return filteredLocations;\n}\n\nasync function createPR(\n githubApiService: GithubApiService,\n logger: LoggerService,\n req: Components.Schemas.ImportRequest,\n gitUrl: gitUrlParse.GitUrl,\n catalogInfoGenerator: CatalogInfoGenerator,\n config: Config,\n) {\n const appTitle =\n config.getOptionalString('app.title') ?? 'Red Hat Developer Hub';\n const appBaseUrl = config.getString('app.baseUrl');\n const catalogFileName = getCatalogFilename(config);\n return await githubApiService.submitPrToRepo(logger, {\n repoUrl: req.repository.url,\n gitUrl: gitUrl,\n defaultBranch: req.repository.defaultBranch,\n catalogInfoContent:\n req.catalogInfoContent ??\n (await catalogInfoGenerator.generateDefaultCatalogInfoContent(\n req.repository.url,\n )),\n prTitle: req.github?.pullRequest?.title ?? `Add ${catalogFileName}`,\n prBody:\n req.github?.pullRequest?.body ??\n `\nThis pull request adds a **Backstage entity metadata file** to this repository so that the component can be added to a Backstage application.\n\nAfter this pull request is merged, the component will become available in the [${appTitle} software catalog](${appBaseUrl}).\n\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\n`,\n });\n}\n\nasync function handleAddedReposFromCreateImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n importRequests: Components.Schemas.ImportRequest[],\n) {\n const result: Components.Schemas.Import[] = [];\n\n for (const req of importRequests) {\n // Check if repo is already imported\n const repoCatalogUrl = getCatalogUrl(\n deps.config,\n req.repository.url,\n req.repository.defaultBranch,\n );\n const hasLocation = await deps.catalogHttpClient.verifyLocationExistence(\n repoCatalogUrl,\n );\n if (!hasLocation) {\n continue;\n }\n const hasCatalogInfoFileInRepo = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: getCatalogFilename(deps.config),\n });\n if (!hasCatalogInfoFileInRepo) {\n continue;\n }\n\n const ghRepo = await deps.githubApiService.getRepositoryFromIntegrations(\n req.repository.url,\n );\n\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n req.repository.url,\n req.repository.defaultBranch,\n );\n\n const gitUrl = gitUrlParse(req.repository.url);\n result.push({\n status: 'ADDED',\n lastUpdate: ghRepo?.repository?.updated_at ?? undefined,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n });\n }\n return result;\n}\n\nasync function handlePrCreationRequest(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n req: Components.Schemas.ImportRequest,\n gitUrl: gitUrlParse.GitUrl,\n): Promise<Components.Schemas.Import> {\n const repoCatalogUrl = getCatalogUrl(\n deps.config,\n req.repository.url,\n req.repository.defaultBranch,\n );\n const prToRepo = await createPR(\n deps.githubApiService,\n deps.logger,\n req,\n gitUrl,\n deps.catalogInfoGenerator,\n deps.config,\n );\n if (prToRepo.errors && prToRepo.errors.length > 0) {\n return {\n errors: prToRepo.errors,\n status: 'PR_ERROR',\n repository: req.repository,\n };\n }\n if (prToRepo.prUrl) {\n deps.logger.debug(`Created new PR from request: ${prToRepo.prUrl}`);\n }\n\n // Create Location\n await deps.catalogHttpClient.possiblyCreateLocation(repoCatalogUrl);\n\n if (prToRepo.hasChanges === false) {\n deps.logger.debug(\n `No bulk import PR created on ${req.repository.url} since its default branch (${req.repository.defaultBranch}) already contains a catalog-info file`,\n );\n\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n req.repository.url,\n req.repository.defaultBranch,\n );\n return {\n status: 'ADDED',\n lastUpdate: prToRepo.lastUpdate,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n };\n }\n\n return {\n errors: prToRepo.errors,\n status: 'WAIT_PR_APPROVAL',\n lastUpdate: prToRepo.lastUpdate,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n github: {\n pullRequest: {\n url: prToRepo.prUrl,\n number: prToRepo.prNumber,\n },\n },\n };\n}\n\nexport async function createImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n reqParams: {\n importRequests: Paths.CreateImportJobs.RequestBody;\n dryRun?: boolean;\n },\n): Promise<\n HandlerResponse<Components.Schemas.Import[] | { errors: string[] }>\n> {\n const dryRun = reqParams.dryRun ?? false;\n const importRequests = reqParams.importRequests;\n deps.logger.debug(\n `Handling request to import ${importRequests?.length} repo(s) (dryRun=${dryRun})..`,\n );\n\n if (importRequests.length === 0) {\n deps.logger.debug('Missing import requests from request body');\n return {\n statusCode: 400,\n responseBody: [],\n };\n }\n\n if (dryRun) {\n return {\n statusCode: 202,\n responseBody: await dryRunCreateImportJobs(deps, importRequests),\n };\n }\n\n const result: Components.Schemas.Import[] = [];\n\n const addedRepos = await handleAddedReposFromCreateImportJobs(\n deps,\n importRequests,\n );\n result.push(...addedRepos);\n const addedReposMap = new Map(\n addedRepos.map(res => [res.repository?.url, res]),\n );\n const remainingRequests = importRequests.filter(\n req => !addedReposMap.has(req.repository.url),\n );\n\n for (const req of remainingRequests) {\n const gitUrl = gitUrlParse(req.repository.url);\n\n // Create PR\n try {\n result.push(await handlePrCreationRequest(deps, req, gitUrl));\n } catch (error: any) {\n result.push({\n errors: [error.message],\n status: 'PR_ERROR',\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n } as Components.Schemas.Import);\n }\n }\n\n sortImports(result);\n\n return {\n statusCode: 202,\n responseBody: result,\n };\n}\n\nasync function dryRunCreateImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n importRequests: Paths.CreateImportJobs.RequestBody,\n) {\n const result: Components.Schemas.Import[] = [];\n for (const req of importRequests) {\n const gitUrl = gitUrlParse(req.repository.url);\n\n const dryRunChecks = await performDryRunChecks(deps, req);\n if (dryRunChecks.errors?.length > 0) {\n deps.logger.warn(\n `Errors while performing dry-run checks: ${dryRunChecks.errors}`,\n );\n }\n result.push({\n errors: dryRunChecks.dryRunStatuses,\n catalogEntityName: req.catalogEntityName,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n });\n }\n return result;\n}\n\nasync function performDryRunChecks(\n deps: {\n logger: LoggerService;\n auth: AuthService;\n catalogApi: CatalogApi;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n req: Components.Schemas.ImportRequest,\n): Promise<{ dryRunStatuses: CreateImportDryRunStatus[]; errors: string[] }> {\n const checkCatalog = async (\n catalogEntityName: string,\n ): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const hasEntity = await deps.catalogHttpClient.hasEntityInCatalog(\n catalogEntityName,\n );\n if (hasEntity) {\n return { dryRunStatuses: ['CATALOG_ENTITY_CONFLICT'] };\n }\n return {};\n };\n\n const checkEmptyRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const empty = await deps.githubApiService.isRepoEmpty({\n repoUrl: req.repository.url,\n });\n if (empty) {\n return {\n dryRunStatuses: ['REPO_EMPTY'],\n };\n }\n return {};\n };\n\n const checkCatalogInfoPresenceInRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const exists = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: getCatalogFilename(deps.config),\n });\n if (exists) {\n return {\n dryRunStatuses: ['CATALOG_INFO_FILE_EXISTS_IN_REPO'],\n };\n }\n return {};\n };\n\n const checkCodeOwnersFileInRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const exists = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: '.github/CODEOWNERS',\n });\n if (!exists) {\n return {\n dryRunStatuses: ['CODEOWNERS_FILE_NOT_FOUND_IN_REPO'],\n };\n }\n return {};\n };\n\n const dryRunStatuses: CreateImportDryRunStatus[] = [];\n const errors: string[] = [];\n const allChecksFn = [checkEmptyRepo(), checkCatalogInfoPresenceInRepo()];\n if (req.catalogEntityName?.trim()) {\n allChecksFn.push(checkCatalog(req.catalogEntityName));\n }\n if (req.codeOwnersFileAsEntityOwner) {\n allChecksFn.push(checkCodeOwnersFileInRepo());\n }\n const allChecks = await Promise.all(allChecksFn);\n allChecks.flat().forEach(res => {\n if (res.dryRunStatuses) {\n dryRunStatuses.push(...res.dryRunStatuses);\n }\n if (res.errors) {\n errors.push(...res.errors);\n }\n });\n\n dryRunStatuses.sort((a, b) => a.localeCompare(b));\n\n return {\n dryRunStatuses,\n errors,\n };\n}\n\nexport async function findImportStatusByRepo(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n defaultBranch?: string,\n includeCatalogInfoContent?: boolean,\n): Promise<HandlerResponse<Components.Schemas.Import>> {\n deps.logger.debug(`Getting bulk import job status for ${repoUrl}..`);\n\n const gitUrl = gitUrlParse(repoUrl);\n\n const errors: string[] = [];\n const result = {\n id: repoUrl,\n repository: {\n url: repoUrl,\n name: gitUrl.name,\n organization: gitUrl.organization,\n id: `${gitUrl.organization}/${gitUrl.name}`,\n defaultBranch,\n },\n approvalTool: 'GIT',\n status: null,\n } as Components.Schemas.Import;\n try {\n // Check to see if there are any PR\n const openImportPr = await deps.githubApiService.findImportOpenPr(\n deps.logger,\n {\n repoUrl: repoUrl,\n includeCatalogInfoContent,\n },\n );\n if (!openImportPr.prUrl) {\n const catalogLocations = (\n await deps.catalogHttpClient.listCatalogUrlLocations()\n ).targetUrls;\n const catalogUrl = getCatalogUrl(deps.config, repoUrl, defaultBranch);\n let exists = false;\n for (const loc of catalogLocations) {\n if (loc === catalogUrl) {\n exists = true;\n break;\n }\n }\n if (\n exists &&\n (await deps.githubApiService.hasFileInRepo({\n repoUrl,\n defaultBranch,\n fileName: getCatalogFilename(deps.config),\n }))\n ) {\n result.status = 'ADDED';\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n repoUrl,\n defaultBranch,\n );\n }\n // No import PR => let's determine last update from the repository\n const ghRepo = await deps.githubApiService.getRepositoryFromIntegrations(\n repoUrl,\n );\n result.lastUpdate = ghRepo.repository?.updated_at ?? undefined;\n return {\n statusCode: 200,\n responseBody: result,\n };\n }\n result.status = 'WAIT_PR_APPROVAL';\n result.github = {\n pullRequest: {\n number: openImportPr.prNum,\n url: openImportPr.prUrl,\n title: openImportPr.prTitle,\n body: openImportPr.prBody,\n catalogInfoContent: openImportPr.prCatalogInfoContent,\n },\n };\n result.lastUpdate = openImportPr.lastUpdate;\n } catch (error: any) {\n errors.push(error.message);\n result.errors = errors;\n if (error.message?.includes('Not Found')) {\n return {\n statusCode: 404,\n responseBody: result,\n };\n }\n result.status = 'PR_ERROR';\n }\n\n return {\n statusCode: 200,\n responseBody: result,\n };\n}\n\nexport async function deleteImportByRepo(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n defaultBranch?: string,\n): Promise<HandlerResponse<void>> {\n deps.logger.debug(`Deleting bulk import job status for ${repoUrl}..`);\n\n // Check to see if there are any PR\n const openImportPr = await deps.githubApiService.findImportOpenPr(\n deps.logger,\n {\n repoUrl: repoUrl,\n },\n );\n const gitUrl = gitUrlParse(repoUrl);\n if (openImportPr.prUrl) {\n // Close PR\n const appTitle =\n deps.config.getOptionalString('app.title') ?? 'Red Hat Developer Hub';\n const appBaseUrl = deps.config.getString('app.baseUrl');\n await deps.githubApiService.closeImportPR(deps.logger, {\n repoUrl,\n gitUrl,\n comment: `Closing PR upon request for bulk import deletion. This request was created from [${appTitle}](${appBaseUrl}).`,\n });\n }\n // Also delete the import branch, so that it is not outdated if we try later to import the repo again\n await deps.githubApiService.deleteImportBranch({\n repoUrl,\n gitUrl,\n });\n // Remove Location from catalog\n const catalogUrl = getCatalogUrl(deps.config, repoUrl, defaultBranch);\n const findLocationFrom = (list: { id?: string; target: string }[]) => {\n for (const loc of list) {\n if (loc.target === catalogUrl) {\n return loc.id;\n }\n }\n return undefined;\n };\n\n const locationId = findLocationFrom(\n (\n await deps.catalogHttpClient.listCatalogUrlLocationsByIdFromLocationsEndpoint()\n ).locations,\n );\n if (locationId) {\n await deps.catalogHttpClient.deleteCatalogLocationById(locationId);\n }\n\n return {\n statusCode: 204,\n responseBody: undefined,\n };\n}\n"],"names":["DefaultPageNumber","DefaultPageSize","getCatalogFilename","paginateArray","logErrorIfNeeded","getCatalogUrl","gitUrlParse"],"mappings":";;;;;;;;;;;;;;;AA+CA,SAAS,YAAY,OAAsC,EAAA;AACzD,EAAQ,OAAA,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA;AACrB,IAAA,IAAI,EAAE,UAAY,EAAA,IAAA,KAAS,UAAa,CAAE,CAAA,UAAA,EAAY,SAAS,KAAW,CAAA,EAAA;AACxE,MAAO,OAAA,CAAA;AAAA;AAET,IAAI,IAAA,CAAA,CAAE,UAAY,EAAA,IAAA,KAAS,KAAW,CAAA,EAAA;AACpC,MAAO,OAAA,CAAA,CAAA;AAAA;AAET,IAAI,IAAA,CAAA,CAAE,UAAY,EAAA,IAAA,KAAS,KAAW,CAAA,EAAA;AACpC,MAAO,OAAA,CAAA;AAAA;AAET,IAA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CAAA,SAAA,CAAU,aAAa,CAAA;AACtD,IAAA,MAAM,IAAK,CAAA,gBAAA,CAAiB,aAAc,CAAA,IAAA,CAAK,MAAQ,EAAA;AAAA,MACrD,OAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAS,EAAA,CAAA,iFAAA,EAAoF,QAAQ,CAAA,EAAA,EAAK,UAAU,CAAA,EAAA;AAAA,KACrH,CAAA;AAAA;AAGH,EAAM,MAAA,IAAA,CAAK,iBAAiB,kBAAmB,CAAA;AAAA,IAC7C,OAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,UAAa,GAAAD,0BAAA,CAAc,IAAK,CAAA,MAAA,EAAQ,SAAS,aAAa,CAAA;AACpE,EAAM,MAAA,gBAAA,GAAmB,CAAC,IAA4C,KAAA;AACpE,IAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACtB,MAAI,IAAA,GAAA,CAAI,WAAW,UAAY,EAAA;AAC7B,QAAA,OAAO,GAAI,CAAA,EAAA;AAAA;AACb;AAEF,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,UAAa,GAAA,gBAAA;AAAA,IAAA,CAEf,MAAM,IAAA,CAAK,iBAAkB,CAAA,gDAAA,EAC7B,EAAA;AAAA,GACJ;AACA,EAAA,IAAI,UAAY,EAAA;AACd,IAAM,MAAA,IAAA,CAAK,iBAAkB,CAAA,yBAAA,CAA0B,UAAU,CAAA;AAAA;AAGnE,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,GAAA;AAAA,IACZ,YAAc,EAAA,KAAA;AAAA,GAChB;AACF;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"bulkImports.cjs.js","sources":["../../../../src/service/handlers/import/bulkImports.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\nimport type { AuthService, LoggerService } from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport type { CatalogInfoGenerator } from '../../../catalog/catalogInfoGenerator';\nimport {\n getCatalogFilename,\n getCatalogUrl,\n} from '../../../catalog/catalogUtils';\nimport type { Components, Paths } from '../../../generated/openapi';\nimport type { GithubApiService } from '../../../github';\nimport { logErrorIfNeeded, paginateArray } from '../../../helpers';\nimport {\n DefaultPageNumber,\n DefaultPageSize,\n type HandlerResponse,\n} from '../handlers';\n\ntype CreateImportDryRunStatus =\n | 'CATALOG_ENTITY_CONFLICT'\n | 'CATALOG_INFO_FILE_EXISTS_IN_REPO'\n | 'CODEOWNERS_FILE_NOT_FOUND_IN_REPO'\n | 'REPO_EMPTY';\n\ntype FindAllImportsResponse =\n | Components.Schemas.Import[]\n | Components.Schemas.ImportJobListV2;\n\nfunction sortImports(imports: Components.Schemas.Import[]) {\n imports.sort((a, b) => {\n if (a.repository?.name === undefined && b.repository?.name === undefined) {\n return 0;\n }\n if (a.repository?.name === undefined) {\n return -1;\n }\n if (b.repository?.name === undefined) {\n return 1;\n }\n return a.repository.name.localeCompare(b.repository.name);\n });\n}\n\nexport async function findAllImports(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n requestHeaders?: {\n apiVersion?: Paths.FindAllImports.Parameters.ApiVersion;\n },\n queryParams?: {\n search?: string;\n pageNumber?: number;\n pageSize?: number;\n },\n): Promise<HandlerResponse<FindAllImportsResponse>> {\n const apiVersion = requestHeaders?.apiVersion ?? 'v1';\n const search = queryParams?.search;\n const pageNumber = queryParams?.pageNumber ?? DefaultPageNumber;\n const pageSize = queryParams?.pageSize ?? DefaultPageSize;\n\n deps.logger.debug(\n `Getting all bulk import jobs (apiVersion=${apiVersion}, search=${search}, page=${pageNumber}, size=${pageSize})..`,\n );\n\n const catalogFilename = getCatalogFilename(deps.config);\n\n const allLocations = (\n await deps.catalogHttpClient.listCatalogUrlLocations(\n search,\n pageNumber,\n pageSize,\n )\n ).uniqueCatalogUrlLocations;\n\n // resolve default branches for each unique repo URL from GH,\n // because we cannot easily determine that from the location target URL.\n // It can be 'main' or something more convoluted like 'our/awesome/main'.\n const defaultBranchByRepoUrl = await resolveReposDefaultBranches(\n deps.logger,\n deps.githubApiService,\n allLocations.keys(),\n catalogFilename,\n );\n\n // filter out locations that do not match what we are expecting, i.e.:\n // an URL to a catalog-info YAML file at the root of the repo\n const importCandidates = findImportCandidates(\n allLocations.keys(),\n defaultBranchByRepoUrl,\n catalogFilename,\n );\n\n // Keep only repos that are accessible from the configured GH integrations\n const importsReachableFromGHIntegrations =\n await deps.githubApiService.filterLocationsAccessibleFromIntegrations(\n importCandidates,\n );\n\n const repoUrlToLocation = new Map<string, string>();\n\n // now fetch the import statuses in different promises\n const importStatusPromises: Promise<\n HandlerResponse<Components.Schemas.Import>\n >[] = [];\n for (const loc of importsReachableFromGHIntegrations) {\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n repoUrlToLocation.set(repoUrl, loc);\n\n importStatusPromises.push(\n findImportStatusByRepo(\n deps,\n repoUrl,\n defaultBranchByRepoUrl.get(repoUrl),\n false,\n ),\n );\n }\n\n const result = await Promise.all(importStatusPromises);\n const imports = result\n .filter(res => res.responseBody)\n .map(res => res.responseBody!)\n .map(res => {\n const key = res?.repository?.url;\n const location = key ? repoUrlToLocation.get(key) : undefined;\n return {\n ...res,\n source: location ? allLocations.get(location)?.source : undefined,\n };\n });\n\n // sorting the output to make it deterministic and easy to navigate in the UI\n sortImports(imports);\n\n const paginated = paginateArray(imports, pageNumber, pageSize);\n if (apiVersion === 'v1') {\n return {\n statusCode: 200,\n responseBody: paginated.result,\n };\n }\n return {\n statusCode: 200,\n responseBody: {\n imports: paginated.result,\n totalCount: paginated.totalCount,\n page: pageNumber,\n size: pageSize,\n },\n };\n}\n\nasync function resolveReposDefaultBranches(\n logger: LoggerService,\n githubApiService: GithubApiService,\n allLocations: Iterable<string>,\n catalogFilename: string,\n) {\n const defaultBranchByRepoUrlPromises: Promise<{\n repoUrl: string;\n defaultBranch?: string;\n }>[] = [];\n for (const loc of allLocations) {\n // loc has the following format: https://github.com/<org>/<repo>/blob/<default-branch>/catalog-info.yaml\n // but it can have a more convoluted format like 'https://github.com/janus-idp/backstage-plugins/blob/main/plugins/scaffolder-annotator-action/examples/templates/01-scaffolder-template.yaml'\n // if registered manually from the 'Register existing component' feature in Backstage.\n if (!loc.endsWith(catalogFilename)) {\n logger.debug(\n `Ignored location ${loc} because it does not point to a file named ${catalogFilename}`,\n );\n continue;\n }\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n defaultBranchByRepoUrlPromises.push(\n githubApiService\n .getRepositoryFromIntegrations(repoUrl)\n .then(resp => {\n return { repoUrl, defaultBranch: resp?.repository?.default_branch };\n })\n .catch((err: any) => {\n logErrorIfNeeded(\n logger,\n `Ignored repo ${repoUrl} due to an error while fetching details from GitHub`,\n err,\n );\n return {\n repoUrl,\n defaultBranch: undefined,\n };\n }),\n );\n }\n const defaultBranchesResponses = await Promise.all(\n defaultBranchByRepoUrlPromises,\n );\n return new Map(\n defaultBranchesResponses\n .flat()\n .filter(r => r.defaultBranch)\n .map(r => [r.repoUrl, r.defaultBranch!]),\n );\n}\n\nfunction repoUrlFromLocation(loc: string) {\n const split = loc.split('/blob/');\n if (split.length < 2) {\n return undefined;\n }\n return split[0];\n}\n\nfunction findImportCandidates(\n allLocations: Iterable<string>,\n defaultBranchByRepoUrl: Map<string, string>,\n catalogFilename: string,\n) {\n const filteredLocations: string[] = [];\n for (const loc of allLocations) {\n const repoUrl = repoUrlFromLocation(loc);\n if (!repoUrl) {\n continue;\n }\n\n const defaultBranch = defaultBranchByRepoUrl.get(repoUrl);\n if (!defaultBranch) {\n continue;\n }\n if (loc !== `${repoUrl}/blob/${defaultBranch}/${catalogFilename}`) {\n // Because users can use the \"Register existing component\" workflow to register a Location\n // using any file path in the repo, we consider a repository as an Import Location only\n // if it is at the root of the repository, because that is what the import PR ultimately does.\n continue;\n }\n filteredLocations.push(loc);\n }\n return filteredLocations;\n}\n\nasync function createPR(\n githubApiService: GithubApiService,\n logger: LoggerService,\n req: Components.Schemas.ImportRequest,\n gitUrl: gitUrlParse.GitUrl,\n catalogInfoGenerator: CatalogInfoGenerator,\n config: Config,\n) {\n const appTitle =\n config.getOptionalString('app.title') ?? 'Red Hat Developer Hub';\n const appBaseUrl = config.getString('app.baseUrl');\n const catalogFileName = getCatalogFilename(config);\n return await githubApiService.submitPrToRepo(logger, {\n repoUrl: req.repository.url,\n gitUrl: gitUrl,\n defaultBranch: req.repository.defaultBranch,\n catalogInfoContent:\n req.catalogInfoContent ??\n (await catalogInfoGenerator.generateDefaultCatalogInfoContent(\n req.repository.url,\n )),\n prTitle: req.github?.pullRequest?.title ?? `Add ${catalogFileName}`,\n prBody:\n req.github?.pullRequest?.body ??\n `\nThis pull request adds a **Backstage entity metadata file** to this repository so that the component can be added to a Backstage application.\n\nAfter this pull request is merged, the component will become available in the [${appTitle} software catalog](${appBaseUrl}).\n\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\n`,\n });\n}\n\nasync function handleAddedReposFromCreateImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n importRequests: Components.Schemas.ImportRequest[],\n) {\n const result: Components.Schemas.Import[] = [];\n\n for (const req of importRequests) {\n // Check if repo is already imported\n const repoCatalogUrl = getCatalogUrl(\n deps.config,\n req.repository.url,\n req.repository.defaultBranch,\n );\n const hasLocation = await deps.catalogHttpClient.verifyLocationExistence(\n repoCatalogUrl,\n );\n if (!hasLocation) {\n continue;\n }\n const hasCatalogInfoFileInRepo = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: getCatalogFilename(deps.config),\n });\n if (!hasCatalogInfoFileInRepo) {\n continue;\n }\n\n const ghRepo = await deps.githubApiService.getRepositoryFromIntegrations(\n req.repository.url,\n );\n\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n req.repository.url,\n req.repository.defaultBranch,\n );\n\n const gitUrl = gitUrlParse(req.repository.url);\n result.push({\n status: 'ADDED',\n lastUpdate: ghRepo?.repository?.updated_at ?? undefined,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n });\n }\n return result;\n}\n\nasync function handlePrCreationRequest(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n req: Components.Schemas.ImportRequest,\n gitUrl: gitUrlParse.GitUrl,\n): Promise<Components.Schemas.Import> {\n const repoCatalogUrl = getCatalogUrl(\n deps.config,\n req.repository.url,\n req.repository.defaultBranch,\n );\n const prToRepo = await createPR(\n deps.githubApiService,\n deps.logger,\n req,\n gitUrl,\n deps.catalogInfoGenerator,\n deps.config,\n );\n if (prToRepo.errors && prToRepo.errors.length > 0) {\n return {\n errors: prToRepo.errors,\n status: 'PR_ERROR',\n repository: req.repository,\n };\n }\n if (prToRepo.prUrl) {\n deps.logger.debug(`Created new PR from request: ${prToRepo.prUrl}`);\n }\n\n // Create Location\n await deps.catalogHttpClient.possiblyCreateLocation(repoCatalogUrl);\n\n if (prToRepo.hasChanges === false) {\n deps.logger.debug(\n `No bulk import PR created on ${req.repository.url} since its default branch (${req.repository.defaultBranch}) already contains a catalog-info file`,\n );\n\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n req.repository.url,\n req.repository.defaultBranch,\n );\n return {\n status: 'ADDED',\n lastUpdate: prToRepo.lastUpdate,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n };\n }\n\n return {\n errors: prToRepo.errors,\n status: 'WAIT_PR_APPROVAL',\n lastUpdate: prToRepo.lastUpdate,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n github: {\n pullRequest: {\n url: prToRepo.prUrl,\n number: prToRepo.prNumber,\n },\n },\n };\n}\n\nexport async function createImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n reqParams: {\n importRequests: Paths.CreateImportJobs.RequestBody;\n dryRun?: boolean;\n },\n): Promise<\n HandlerResponse<Components.Schemas.Import[] | { errors: string[] }>\n> {\n const dryRun = reqParams.dryRun ?? false;\n const importRequests = reqParams.importRequests;\n deps.logger.debug(\n `Handling request to import ${importRequests?.length} repo(s) (dryRun=${dryRun})..`,\n );\n\n if (importRequests.length === 0) {\n deps.logger.debug('Missing import requests from request body');\n return {\n statusCode: 400,\n responseBody: [],\n };\n }\n\n if (dryRun) {\n return {\n statusCode: 202,\n responseBody: await dryRunCreateImportJobs(deps, importRequests),\n };\n }\n\n const result: Components.Schemas.Import[] = [];\n\n const addedRepos = await handleAddedReposFromCreateImportJobs(\n deps,\n importRequests,\n );\n result.push(...addedRepos);\n const addedReposMap = new Map(\n addedRepos.map(res => [res.repository?.url, res]),\n );\n const remainingRequests = importRequests.filter(\n req => !addedReposMap.has(req.repository.url),\n );\n\n for (const req of remainingRequests) {\n const gitUrl = gitUrlParse(req.repository.url);\n\n // Create PR\n try {\n result.push(await handlePrCreationRequest(deps, req, gitUrl));\n } catch (error: any) {\n result.push({\n errors: [error.message],\n status: 'PR_ERROR',\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n } as Components.Schemas.Import);\n }\n }\n\n sortImports(result);\n\n return {\n statusCode: 202,\n responseBody: result,\n };\n}\n\nasync function dryRunCreateImportJobs(\n deps: {\n logger: LoggerService;\n config: Config;\n auth: AuthService;\n catalogApi: CatalogApi;\n githubApiService: GithubApiService;\n catalogInfoGenerator: CatalogInfoGenerator;\n catalogHttpClient: CatalogHttpClient;\n },\n importRequests: Paths.CreateImportJobs.RequestBody,\n) {\n const result: Components.Schemas.Import[] = [];\n for (const req of importRequests) {\n const gitUrl = gitUrlParse(req.repository.url);\n\n const dryRunChecks = await performDryRunChecks(deps, req);\n if (dryRunChecks.errors?.length > 0) {\n deps.logger.warn(\n `Errors while performing dry-run checks: ${dryRunChecks.errors}`,\n );\n }\n result.push({\n errors: dryRunChecks.dryRunStatuses,\n catalogEntityName: req.catalogEntityName,\n repository: {\n url: req.repository.url,\n name: gitUrl.name,\n organization: gitUrl.organization,\n },\n });\n }\n return result;\n}\n\nasync function performDryRunChecks(\n deps: {\n logger: LoggerService;\n auth: AuthService;\n catalogApi: CatalogApi;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n req: Components.Schemas.ImportRequest,\n): Promise<{ dryRunStatuses: CreateImportDryRunStatus[]; errors: string[] }> {\n const checkCatalog = async (\n catalogEntityName: string,\n ): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const hasEntity = await deps.catalogHttpClient.hasEntityInCatalog(\n catalogEntityName,\n );\n if (hasEntity) {\n return { dryRunStatuses: ['CATALOG_ENTITY_CONFLICT'] };\n }\n return {};\n };\n\n const checkEmptyRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const empty = await deps.githubApiService.isRepoEmpty({\n repoUrl: req.repository.url,\n });\n if (empty) {\n return {\n dryRunStatuses: ['REPO_EMPTY'],\n };\n }\n return {};\n };\n\n const checkCatalogInfoPresenceInRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const exists = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: getCatalogFilename(deps.config),\n });\n if (exists) {\n return {\n dryRunStatuses: ['CATALOG_INFO_FILE_EXISTS_IN_REPO'],\n };\n }\n return {};\n };\n\n const checkCodeOwnersFileInRepo = async (): Promise<{\n dryRunStatuses?: CreateImportDryRunStatus[];\n errors?: string[];\n }> => {\n const exists = await deps.githubApiService.hasFileInRepo({\n repoUrl: req.repository.url,\n defaultBranch: req.repository.defaultBranch,\n fileName: '.github/CODEOWNERS',\n });\n if (!exists) {\n return {\n dryRunStatuses: ['CODEOWNERS_FILE_NOT_FOUND_IN_REPO'],\n };\n }\n return {};\n };\n\n const dryRunStatuses: CreateImportDryRunStatus[] = [];\n const errors: string[] = [];\n const allChecksFn = [checkEmptyRepo(), checkCatalogInfoPresenceInRepo()];\n if (req.catalogEntityName?.trim()) {\n allChecksFn.push(checkCatalog(req.catalogEntityName));\n }\n if (req.codeOwnersFileAsEntityOwner) {\n allChecksFn.push(checkCodeOwnersFileInRepo());\n }\n const allChecks = await Promise.all(allChecksFn);\n allChecks.flat().forEach(res => {\n if (res.dryRunStatuses) {\n dryRunStatuses.push(...res.dryRunStatuses);\n }\n if (res.errors) {\n errors.push(...res.errors);\n }\n });\n\n dryRunStatuses.sort((a, b) => a.localeCompare(b));\n\n return {\n dryRunStatuses,\n errors,\n };\n}\n\nexport async function findImportStatusByRepo(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n defaultBranch?: string,\n includeCatalogInfoContent?: boolean,\n): Promise<HandlerResponse<Components.Schemas.Import>> {\n deps.logger.debug(`Getting bulk import job status for ${repoUrl}..`);\n\n const gitUrl = gitUrlParse(repoUrl);\n\n const errors: string[] = [];\n const result = {\n id: repoUrl,\n repository: {\n url: repoUrl,\n name: gitUrl.name,\n organization: gitUrl.organization,\n id: `${gitUrl.organization}/${gitUrl.name}`,\n defaultBranch,\n },\n approvalTool: 'GIT',\n status: null,\n } as Components.Schemas.Import;\n try {\n // Check to see if there are any PR\n const openImportPr = await deps.githubApiService.findImportOpenPr(\n deps.logger,\n {\n repoUrl: repoUrl,\n includeCatalogInfoContent,\n },\n );\n if (!openImportPr.prUrl) {\n const catalogLocations = (\n await deps.catalogHttpClient.listCatalogUrlLocations()\n ).uniqueCatalogUrlLocations.keys();\n\n const catalogUrl = getCatalogUrl(deps.config, repoUrl, defaultBranch);\n let exists = false;\n for (const loc of catalogLocations) {\n if (loc === catalogUrl) {\n exists = true;\n break;\n }\n }\n if (\n exists &&\n (await deps.githubApiService.hasFileInRepo({\n repoUrl,\n defaultBranch,\n fileName: getCatalogFilename(deps.config),\n }))\n ) {\n result.status = 'ADDED';\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n repoUrl,\n defaultBranch,\n );\n }\n // No import PR => let's determine last update from the repository\n const ghRepo = await deps.githubApiService.getRepositoryFromIntegrations(\n repoUrl,\n );\n result.lastUpdate = ghRepo.repository?.updated_at ?? undefined;\n return {\n statusCode: 200,\n responseBody: result,\n };\n }\n result.status = 'WAIT_PR_APPROVAL';\n result.github = {\n pullRequest: {\n number: openImportPr.prNum,\n url: openImportPr.prUrl,\n title: openImportPr.prTitle,\n body: openImportPr.prBody,\n catalogInfoContent: openImportPr.prCatalogInfoContent,\n },\n };\n result.lastUpdate = openImportPr.lastUpdate;\n } catch (error: any) {\n errors.push(error.message);\n result.errors = errors;\n if (error.message?.includes('Not Found')) {\n return {\n statusCode: 404,\n responseBody: result,\n };\n }\n result.status = 'PR_ERROR';\n }\n\n return {\n statusCode: 200,\n responseBody: result,\n };\n}\n\nexport async function deleteImportByRepo(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n defaultBranch?: string,\n): Promise<HandlerResponse<void>> {\n deps.logger.debug(`Deleting bulk import job status for ${repoUrl}..`);\n\n // Check to see if there are any PR\n const openImportPr = await deps.githubApiService.findImportOpenPr(\n deps.logger,\n {\n repoUrl: repoUrl,\n },\n );\n const gitUrl = gitUrlParse(repoUrl);\n if (openImportPr.prUrl) {\n // Close PR\n const appTitle =\n deps.config.getOptionalString('app.title') ?? 'Red Hat Developer Hub';\n const appBaseUrl = deps.config.getString('app.baseUrl');\n await deps.githubApiService.closeImportPR(deps.logger, {\n repoUrl,\n gitUrl,\n comment: `Closing PR upon request for bulk import deletion. This request was created from [${appTitle}](${appBaseUrl}).`,\n });\n }\n // Also delete the import branch, so that it is not outdated if we try later to import the repo again\n await deps.githubApiService.deleteImportBranch({\n repoUrl,\n gitUrl,\n });\n // Remove Location from catalog\n const catalogUrl = getCatalogUrl(deps.config, repoUrl, defaultBranch);\n const findLocationFrom = (list: { id?: string; target: string }[]) => {\n for (const loc of list) {\n if (loc.target === catalogUrl) {\n return loc.id;\n }\n }\n return undefined;\n };\n\n const locationId = findLocationFrom(\n (\n await deps.catalogHttpClient.listCatalogUrlLocationsByIdFromLocationsEndpoint()\n ).locations,\n );\n if (locationId) {\n await deps.catalogHttpClient.deleteCatalogLocationById(locationId);\n }\n\n return {\n statusCode: 204,\n responseBody: undefined,\n };\n}\n"],"names":["DefaultPageNumber","DefaultPageSize","getCatalogFilename","paginateArray","logErrorIfNeeded","getCatalogUrl","gitUrlParse"],"mappings":";;;;;;;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BAAmB,CAAA;AAAA,IAC7C,OAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,UAAa,GAAAD,0BAAA,CAAc,IAAK,CAAA,MAAA,EAAQ,SAAS,aAAa,CAAA;AACpE,EAAM,MAAA,gBAAA,GAAmB,CAAC,IAA4C,KAAA;AACpE,IAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACtB,MAAI,IAAA,GAAA,CAAI,WAAW,UAAY,EAAA;AAC7B,QAAA,OAAO,GAAI,CAAA,EAAA;AAAA;AACb;AAEF,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,UAAa,GAAA,gBAAA;AAAA,IAAA,CAEf,MAAM,IAAA,CAAK,iBAAkB,CAAA,gDAAA,EAC7B,EAAA;AAAA,GACJ;AACA,EAAA,IAAI,UAAY,EAAA;AACd,IAAM,MAAA,IAAA,CAAK,iBAAkB,CAAA,yBAAA,CAA0B,UAAU,CAAA;AAAA;AAGnE,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,GAAA;AAAA,IACZ,YAAc,EAAA,KAAA;AAAA,GAChB;AACF;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importStatus.cjs.js","sources":["../../../../src/service/handlers/import/importStatus.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\nimport type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport {\n getCatalogFilename,\n getCatalogUrl,\n} from '../../../catalog/catalogUtils';\nimport type { Components } from '../../../generated/openapi';\nimport type { GithubApiService } from '../../../github';\n\nexport async function getImportStatusFromLocations(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n catalogUrlLocations: string
|
|
1
|
+
{"version":3,"file":"importStatus.cjs.js","sources":["../../../../src/service/handlers/import/importStatus.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\nimport type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport {\n getCatalogFilename,\n getCatalogUrl,\n} from '../../../catalog/catalogUtils';\nimport type { Components } from '../../../generated/openapi';\nimport type { GithubApiService } from '../../../github';\n\nexport async function getImportStatusFromLocations(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n catalogUrlLocations: Iterable<string>,\n defaultBranch?: string,\n): Promise<{\n status: Components.Schemas.ImportStatus;\n lastUpdate?: string;\n} | null> {\n return getImportStatusWithCheckerFn(\n deps,\n repoUrl,\n async (catalogUrl: string) => {\n for (const loc of catalogUrlLocations) {\n if (catalogUrl === loc) {\n return true;\n }\n }\n return false;\n },\n defaultBranch,\n );\n}\n\nasync function getImportStatusWithCheckerFn(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n repoUrl: string,\n catalogExistenceCheckFn: (catalogUrl: string) => Promise<boolean>,\n defaultBranch?: string,\n): Promise<{\n status: Components.Schemas.ImportStatus;\n lastUpdate?: string;\n} | null> {\n // Check to see if there are any PR\n const openImportPr = await deps.githubApiService.findImportOpenPr(\n deps.logger,\n {\n repoUrl,\n },\n );\n if (!openImportPr.prUrl) {\n const existsInCatalog = await catalogExistenceCheckFn(\n getCatalogUrl(deps.config, repoUrl, defaultBranch),\n );\n const existsInRepo = await deps.githubApiService.hasFileInRepo({\n repoUrl,\n defaultBranch,\n fileName: getCatalogFilename(deps.config),\n });\n if (existsInCatalog && existsInRepo) {\n // Force a refresh of the Location, so that the entities from the catalog-info.yaml can show up quickly (not guaranteed however).\n await deps.catalogHttpClient.refreshLocationByRepoUrl(\n repoUrl,\n defaultBranch,\n );\n return { status: 'ADDED' };\n }\n return null;\n }\n return { status: 'WAIT_PR_APPROVAL', lastUpdate: openImportPr.lastUpdate };\n}\n"],"names":["getCatalogUrl","getCatalogFilename"],"mappings":";;;;AA2BA,eAAsB,4BACpB,CAAA,IAAA,EAMA,OACA,EAAA,mBAAA,EACA,aAIQ,EAAA;AACR,EAAO,OAAA,4BAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAO,UAAuB,KAAA;AAC5B,MAAA,KAAA,MAAW,OAAO,mBAAqB,EAAA;AACrC,QAAA,IAAI,eAAe,GAAK,EAAA;AACtB,UAAO,OAAA,IAAA;AAAA;AACT;AAEF,MAAO,OAAA,KAAA;AAAA,KACT;AAAA,IACA;AAAA,GACF;AACF;AAEA,eAAe,4BACb,CAAA,IAAA,EAMA,OACA,EAAA,uBAAA,EACA,aAIQ,EAAA;AAER,EAAM,MAAA,YAAA,GAAe,MAAM,IAAA,CAAK,gBAAiB,CAAA,gBAAA;AAAA,IAC/C,IAAK,CAAA,MAAA;AAAA,IACL;AAAA,MACE;AAAA;AACF,GACF;AACA,EAAI,IAAA,CAAC,aAAa,KAAO,EAAA;AACvB,IAAA,MAAM,kBAAkB,MAAM,uBAAA;AAAA,MAC5BA,0BAAc,CAAA,IAAA,CAAK,MAAQ,EAAA,OAAA,EAAS,aAAa;AAAA,KACnD;AACA,IAAA,MAAM,YAAe,GAAA,MAAM,IAAK,CAAA,gBAAA,CAAiB,aAAc,CAAA;AAAA,MAC7D,OAAA;AAAA,MACA,aAAA;AAAA,MACA,QAAA,EAAUC,+BAAmB,CAAA,IAAA,CAAK,MAAM;AAAA,KACzC,CAAA;AACD,IAAA,IAAI,mBAAmB,YAAc,EAAA;AAEnC,MAAA,MAAM,KAAK,iBAAkB,CAAA,wBAAA;AAAA,QAC3B,OAAA;AAAA,QACA;AAAA,OACF;AACA,MAAO,OAAA,EAAE,QAAQ,OAAQ,EAAA;AAAA;AAE3B,IAAO,OAAA,IAAA;AAAA;AAET,EAAA,OAAO,EAAE,MAAA,EAAQ,kBAAoB,EAAA,UAAA,EAAY,aAAa,UAAW,EAAA;AAC3E;;;;"}
|
|
@@ -53,7 +53,7 @@ async function formatResponse(deps, allReposAccessible, checkStatus) {
|
|
|
53
53
|
}
|
|
54
54
|
let catalogLocations = [];
|
|
55
55
|
if (checkStatus) {
|
|
56
|
-
catalogLocations = (await deps.catalogHttpClient.listCatalogUrlLocations()).
|
|
56
|
+
catalogLocations = (await deps.catalogHttpClient.listCatalogUrlLocations()).uniqueCatalogUrlLocations.keys();
|
|
57
57
|
}
|
|
58
58
|
const repoList = [];
|
|
59
59
|
for (const repo of allReposAccessible.repositories) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositories.cjs.js","sources":["../../../../src/service/handlers/repository/repositories.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\nimport type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport type { Components } from '../../../generated/openapi';\nimport type {\n GithubApiService,\n GithubRepositoryResponse,\n} from '../../../github';\nimport {\n DefaultPageNumber,\n DefaultPageSize,\n type HandlerResponse,\n} from '../handlers';\nimport { getImportStatusFromLocations } from '../import';\n\nexport async function findAllRepositories(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n reqParams?: {\n search?: string;\n checkStatus?: boolean;\n pageNumber?: number;\n pageSize?: number;\n },\n): Promise<HandlerResponse<Components.Schemas.RepositoryList>> {\n const search = reqParams?.search;\n const checkStatus = reqParams?.checkStatus ?? false;\n const pageNumber = reqParams?.pageNumber ?? DefaultPageNumber;\n const pageSize = reqParams?.pageSize ?? DefaultPageSize;\n deps.logger.debug(\n `Getting all repositories - (search,page,size)=('${\n search ?? ''\n }',${pageNumber},${pageSize})..`,\n );\n return deps.githubApiService\n .getRepositoriesFromIntegrations(search, pageNumber, pageSize)\n .then(response => formatResponse(deps, response, checkStatus));\n}\n\nexport async function findRepositoriesByOrganization(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n orgName: string,\n search?: string,\n checkStatus: boolean = false,\n pageNumber: number = DefaultPageNumber,\n pageSize: number = DefaultPageSize,\n): Promise<HandlerResponse<Components.Schemas.RepositoryList>> {\n deps.logger.debug(\n `Getting all repositories for org \"${orgName}\" - (search,page,size)=(${search},${pageNumber},${pageSize})..`,\n );\n return deps.githubApiService\n .getOrgRepositoriesFromIntegrations(orgName, search, pageNumber, pageSize)\n .then(response => formatResponse(deps, response, checkStatus));\n}\n\nfunction sortRepos(repoList: Components.Schemas.Repository[]) {\n // sorting the output to make it deterministic and easy to navigate in the UI\n repoList.sort((a, b) => {\n if (a.name === undefined && b.name === undefined) {\n return 0;\n }\n if (a.name === undefined) {\n return -1;\n }\n if (b.name === undefined) {\n return 1;\n }\n return a.name.localeCompare(b.name);\n });\n}\n\ntype ImportStatus =\n | { status: Components.Schemas.ImportStatus; lastUpdate?: string }\n | null\n | undefined;\n\nasync function formatResponse(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n allReposAccessible: GithubRepositoryResponse,\n checkStatus: boolean,\n) {\n const errorList =\n allReposAccessible.errors\n ?.map(err => err.error?.message)\n ?.filter(msg => msg) ?? [];\n if (allReposAccessible.repositories?.length === 0 && errorList.length > 0) {\n return {\n statusCode: 500,\n responseBody: {\n errors: errorList,\n },\n };\n }\n\n let catalogLocations: string
|
|
1
|
+
{"version":3,"file":"repositories.cjs.js","sources":["../../../../src/service/handlers/repository/repositories.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\nimport type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport gitUrlParse from 'git-url-parse';\n\nimport { CatalogHttpClient } from '../../../catalog/catalogHttpClient';\nimport type { Components } from '../../../generated/openapi';\nimport type {\n GithubApiService,\n GithubRepositoryResponse,\n} from '../../../github';\nimport {\n DefaultPageNumber,\n DefaultPageSize,\n type HandlerResponse,\n} from '../handlers';\nimport { getImportStatusFromLocations } from '../import';\n\nexport async function findAllRepositories(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n reqParams?: {\n search?: string;\n checkStatus?: boolean;\n pageNumber?: number;\n pageSize?: number;\n },\n): Promise<HandlerResponse<Components.Schemas.RepositoryList>> {\n const search = reqParams?.search;\n const checkStatus = reqParams?.checkStatus ?? false;\n const pageNumber = reqParams?.pageNumber ?? DefaultPageNumber;\n const pageSize = reqParams?.pageSize ?? DefaultPageSize;\n deps.logger.debug(\n `Getting all repositories - (search,page,size)=('${\n search ?? ''\n }',${pageNumber},${pageSize})..`,\n );\n return deps.githubApiService\n .getRepositoriesFromIntegrations(search, pageNumber, pageSize)\n .then(response => formatResponse(deps, response, checkStatus));\n}\n\nexport async function findRepositoriesByOrganization(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n orgName: string,\n search?: string,\n checkStatus: boolean = false,\n pageNumber: number = DefaultPageNumber,\n pageSize: number = DefaultPageSize,\n): Promise<HandlerResponse<Components.Schemas.RepositoryList>> {\n deps.logger.debug(\n `Getting all repositories for org \"${orgName}\" - (search,page,size)=(${search},${pageNumber},${pageSize})..`,\n );\n return deps.githubApiService\n .getOrgRepositoriesFromIntegrations(orgName, search, pageNumber, pageSize)\n .then(response => formatResponse(deps, response, checkStatus));\n}\n\nfunction sortRepos(repoList: Components.Schemas.Repository[]) {\n // sorting the output to make it deterministic and easy to navigate in the UI\n repoList.sort((a, b) => {\n if (a.name === undefined && b.name === undefined) {\n return 0;\n }\n if (a.name === undefined) {\n return -1;\n }\n if (b.name === undefined) {\n return 1;\n }\n return a.name.localeCompare(b.name);\n });\n}\n\ntype ImportStatus =\n | { status: Components.Schemas.ImportStatus; lastUpdate?: string }\n | null\n | undefined;\n\nasync function formatResponse(\n deps: {\n logger: LoggerService;\n config: Config;\n githubApiService: GithubApiService;\n catalogHttpClient: CatalogHttpClient;\n },\n allReposAccessible: GithubRepositoryResponse,\n checkStatus: boolean,\n) {\n const errorList =\n allReposAccessible.errors\n ?.map(err => err.error?.message)\n ?.filter(msg => msg) ?? [];\n if (allReposAccessible.repositories?.length === 0 && errorList.length > 0) {\n return {\n statusCode: 500,\n responseBody: {\n errors: errorList,\n },\n };\n }\n\n let catalogLocations: Iterable<string> = [];\n if (checkStatus) {\n catalogLocations = (\n await deps.catalogHttpClient.listCatalogUrlLocations()\n ).uniqueCatalogUrlLocations.keys();\n }\n const repoList: Components.Schemas.Repository[] = [];\n for (const repo of allReposAccessible.repositories) {\n const gitUrl = gitUrlParse(repo.html_url);\n const errors: string[] = [];\n let importStatus: ImportStatus;\n if (checkStatus) {\n importStatus = await getImportStatusFromLocations(\n deps,\n repo.html_url,\n catalogLocations,\n repo.default_branch,\n ).catch((error: any) => {\n errors.push(error.message);\n return undefined;\n });\n }\n const repoUpdatedAt = repo.updated_at ?? undefined;\n repoList.push({\n id: `${gitUrl.organization}/${repo.name}`,\n name: repo.name,\n organization: gitUrl.organization,\n url: repo.html_url,\n defaultBranch: repo.default_branch,\n importStatus: importStatus?.status,\n lastUpdate: importStatus?.lastUpdate ?? repoUpdatedAt,\n errors: errors,\n });\n }\n\n sortRepos(repoList);\n\n return {\n statusCode: 200,\n responseBody: {\n errors: errorList,\n repositories: repoList,\n totalCount: allReposAccessible.totalCount,\n },\n };\n}\n"],"names":["DefaultPageNumber","DefaultPageSize","gitUrlParse","importStatus","getImportStatusFromLocations"],"mappings":";;;;;;;;;;;;;AAkCsB,eAAA,mBAAA,CACpB,MAMA,SAM6D,EAAA;AAC7D,EAAA,MAAM,SAAS,SAAW,EAAA,MAAA;AAC1B,EAAM,MAAA,WAAA,GAAc,WAAW,WAAe,IAAA,KAAA;AAC9C,EAAM,MAAA,UAAA,GAAa,WAAW,UAAc,IAAAA,0BAAA;AAC5C,EAAM,MAAA,QAAA,GAAW,WAAW,QAAY,IAAAC,wBAAA;AACxC,EAAA,IAAA,CAAK,MAAO,CAAA,KAAA;AAAA,IAC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