@backstage/plugin-catalog-backend 2.1.0 → 3.0.0-next.1
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 +48 -0
- package/config.d.ts +0 -14
- package/dist/index.d.ts +0 -1
- package/dist/processors/UrlReaderProcessor.cjs.js +6 -31
- package/dist/processors/UrlReaderProcessor.cjs.js.map +1 -1
- package/dist/service/CatalogBuilder.cjs.js +1 -1
- package/dist/service/CatalogBuilder.cjs.js.map +1 -1
- package/package.json +19 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 3.0.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/config@1.3.3-next.0
|
|
9
|
+
- @backstage/plugin-permission-common@0.9.1-next.0
|
|
10
|
+
- @backstage/plugin-permission-node@0.10.2-next.0
|
|
11
|
+
- @backstage/catalog-model@1.7.5-next.0
|
|
12
|
+
- @backstage/catalog-client@1.10.2-next.0
|
|
13
|
+
- @backstage/integration@1.17.1-next.1
|
|
14
|
+
- @backstage/backend-plugin-api@1.4.1-next.0
|
|
15
|
+
- @backstage/plugin-catalog-common@1.1.5-next.0
|
|
16
|
+
- @backstage/plugin-catalog-node@1.17.2-next.0
|
|
17
|
+
- @backstage/backend-openapi-utils@0.5.5-next.0
|
|
18
|
+
- @backstage/plugin-events-node@0.4.13-next.0
|
|
19
|
+
|
|
20
|
+
## 3.0.0-next.0
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- 2339363: **BREAKING:** The experimental `catalog.useUrlReadersSearch` configuration flag (introduced in v1.36) has been removed.
|
|
25
|
+
|
|
26
|
+
The `UrlReaderProcessor` now always uses the `search` method of `UrlReaders`. Built-in `UrlReaderService` implementations have been updated accordingly.
|
|
27
|
+
If you use custom `UrlReaderService` implementations, you need to adapt their `search` method to correctly handle both specific URLs and potential
|
|
28
|
+
search patterns (see changes on built-in readers [in the original PR](https://github.com/backstage/backstage/pull/28379/files#diff-68b0452f173ee54bdd40f7b5e047a9cb8bb59200425622c212c217b76dac1d1b)).
|
|
29
|
+
|
|
30
|
+
Previous behavior was to call the `search` method only if the parsed Git URL's filename contained a wildcard and use `readUrl` otherwise. Each `UrlReaderService` must implement this logic in the `search` method instead.
|
|
31
|
+
|
|
32
|
+
This allows each `UrlReaderService` implementation to check whether it's a search URL (that contains a wildcard pattern) or not using logic that is specific to each provider.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @backstage/integration@1.17.1-next.0
|
|
38
|
+
- @backstage/plugin-permission-node@0.10.1
|
|
39
|
+
- @backstage/backend-plugin-api@1.4.0
|
|
40
|
+
- @backstage/plugin-catalog-node@1.17.1
|
|
41
|
+
- @backstage/plugin-events-node@0.4.12
|
|
42
|
+
- @backstage/backend-openapi-utils@0.5.4
|
|
43
|
+
- @backstage/catalog-client@1.10.1
|
|
44
|
+
- @backstage/catalog-model@1.7.4
|
|
45
|
+
- @backstage/config@1.3.2
|
|
46
|
+
- @backstage/errors@1.2.7
|
|
47
|
+
- @backstage/types@1.2.1
|
|
48
|
+
- @backstage/plugin-catalog-common@1.1.4
|
|
49
|
+
- @backstage/plugin-permission-common@0.9.0
|
|
50
|
+
|
|
3
51
|
## 2.1.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
package/config.d.ts
CHANGED
|
@@ -218,19 +218,5 @@ export interface Config {
|
|
|
218
218
|
* housing catalog-info files.
|
|
219
219
|
*/
|
|
220
220
|
processingInterval?: HumanDuration | false;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Defines if the UrlReaderProcessor should always call the search method of the
|
|
224
|
-
* different UrlReaders.
|
|
225
|
-
*
|
|
226
|
-
* If set to false, the UrlReaderProcessor will use the legacy behavior that tries to
|
|
227
|
-
* parse a Git URL and calls search if there's wildcard patterns and readUrl otherwise.
|
|
228
|
-
*
|
|
229
|
-
* If set to true, the UrlReaderProcessor always call the search method and lets each UrlReader
|
|
230
|
-
* determine if it's a search pattern or not.
|
|
231
|
-
*
|
|
232
|
-
* This flag is temporary and will be enabled by default in future releases.
|
|
233
|
-
*/
|
|
234
|
-
useUrlReadersSearch?: boolean;
|
|
235
221
|
};
|
|
236
222
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -93,7 +93,6 @@ declare class UrlReaderProcessor implements CatalogProcessor {
|
|
|
93
93
|
constructor(options: {
|
|
94
94
|
reader: UrlReaderService;
|
|
95
95
|
logger: LoggerService;
|
|
96
|
-
config?: Config;
|
|
97
96
|
});
|
|
98
97
|
getProcessorName(): string;
|
|
99
98
|
readLocation(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser, cache: CatalogProcessorCache): Promise<boolean>;
|
|
@@ -2,30 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
var errors = require('@backstage/errors');
|
|
4
4
|
var limiterFactory = require('p-limit');
|
|
5
|
-
var parseGitUrl = require('git-url-parse');
|
|
6
5
|
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
7
6
|
|
|
8
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
8
|
|
|
10
9
|
var limiterFactory__default = /*#__PURE__*/_interopDefaultCompat(limiterFactory);
|
|
11
|
-
var parseGitUrl__default = /*#__PURE__*/_interopDefaultCompat(parseGitUrl);
|
|
12
10
|
|
|
13
11
|
const CACHE_KEY = "v1";
|
|
14
12
|
class UrlReaderProcessor {
|
|
15
13
|
constructor(options) {
|
|
16
14
|
this.options = options;
|
|
17
15
|
this.#limiter = limiterFactory__default.default(5);
|
|
18
|
-
this.#useUrlReadersSearch = this.options.config?.getOptionalBoolean("catalog.useUrlReadersSearch") || false;
|
|
19
|
-
if (!this.#useUrlReadersSearch) {
|
|
20
|
-
this.options.logger.warn(
|
|
21
|
-
"UrlReaderProcessor uses the legacy readUrl/search behavior which will be removed in a future release. Set catalog.useUrlReadersSearch to true to adopt the new behavior."
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
16
|
}
|
|
25
17
|
// This limiter is used for only consuming a limited number of read streams
|
|
26
18
|
// concurrently.
|
|
27
19
|
#limiter;
|
|
28
|
-
#useUrlReadersSearch;
|
|
29
20
|
getProcessorName() {
|
|
30
21
|
return "url-reader";
|
|
31
22
|
}
|
|
@@ -88,28 +79,12 @@ class UrlReaderProcessor {
|
|
|
88
79
|
return true;
|
|
89
80
|
}
|
|
90
81
|
async doRead(location, etag) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return { response: await Promise.all(output), etag: response.etag };
|
|
98
|
-
}
|
|
99
|
-
const { filepath } = parseGitUrl__default.default(location);
|
|
100
|
-
if (filepath?.match(/[*?]/)) {
|
|
101
|
-
const response = await this.options.reader.search(location, { etag });
|
|
102
|
-
const output = response.files.map(async (file) => ({
|
|
103
|
-
url: file.url,
|
|
104
|
-
data: await this.#limiter(file.content)
|
|
105
|
-
}));
|
|
106
|
-
return { response: await Promise.all(output), etag: response.etag };
|
|
107
|
-
}
|
|
108
|
-
const data = await this.options.reader.readUrl(location, { etag });
|
|
109
|
-
return {
|
|
110
|
-
response: [{ url: location, data: await data.buffer() }],
|
|
111
|
-
etag: data.etag
|
|
112
|
-
};
|
|
82
|
+
const response = await this.options.reader.search(location, { etag });
|
|
83
|
+
const output = response.files.map(async (file) => ({
|
|
84
|
+
url: file.url,
|
|
85
|
+
data: await this.#limiter(file.content)
|
|
86
|
+
}));
|
|
87
|
+
return { response: await Promise.all(output), etag: response.etag };
|
|
113
88
|
}
|
|
114
89
|
}
|
|
115
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlReaderProcessor.cjs.js","sources":["../../src/processors/UrlReaderProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\nimport { assertError } from '@backstage/errors';\nimport limiterFactory, { Limit } from 'p-limit';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport
|
|
1
|
+
{"version":3,"file":"UrlReaderProcessor.cjs.js","sources":["../../src/processors/UrlReaderProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\nimport { assertError } from '@backstage/errors';\nimport limiterFactory, { Limit } from 'p-limit';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n CatalogProcessor,\n CatalogProcessorCache,\n CatalogProcessorEmit,\n CatalogProcessorEntityResult,\n CatalogProcessorParser,\n CatalogProcessorResult,\n processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';\n\nconst CACHE_KEY = 'v1';\n\n// WARNING: If you change this type, you likely need to bump the CACHE_KEY as well\ntype CacheItem = {\n etag: string;\n value: {\n type: 'entity';\n entity: Entity;\n location: LocationSpec;\n }[];\n};\n\n/** @public */\nexport class UrlReaderProcessor implements CatalogProcessor {\n // This limiter is used for only consuming a limited number of read streams\n // concurrently.\n #limiter: Limit;\n\n constructor(\n private readonly options: {\n reader: UrlReaderService;\n logger: LoggerService;\n },\n ) {\n this.#limiter = limiterFactory(5);\n }\n\n getProcessorName() {\n return 'url-reader';\n }\n\n async readLocation(\n location: LocationSpec,\n optional: boolean,\n emit: CatalogProcessorEmit,\n parser: CatalogProcessorParser,\n cache: CatalogProcessorCache,\n ): Promise<boolean> {\n if (location.type !== 'url') {\n return false;\n }\n\n const cacheItem = await cache.get<CacheItem>(CACHE_KEY);\n\n try {\n const { response, etag: newEtag } = await this.doRead(\n location.target,\n cacheItem?.etag,\n );\n\n if (response.length === 0 && !optional) {\n emit(\n processingResult.notFoundError(\n location,\n `Unable to read ${location.type}, no matching files found for ${location.target}`,\n ),\n );\n }\n\n const parseResults: CatalogProcessorResult[] = [];\n for (const item of response) {\n for await (const parseResult of parser({\n data: item.data,\n location: { type: location.type, target: item.url },\n })) {\n parseResults.push(parseResult);\n emit(parseResult);\n }\n }\n\n const isOnlyEntities = parseResults.every(r => r.type === 'entity');\n if (newEtag && isOnlyEntities) {\n await cache.set<CacheItem>(CACHE_KEY, {\n etag: newEtag,\n value: parseResults as CatalogProcessorEntityResult[],\n });\n }\n\n emit(processingResult.refresh(`${location.type}:${location.target}`));\n } catch (error) {\n assertError(error);\n const message = `Unable to read ${location.type}, ${error}`.substring(\n 0,\n 5000,\n );\n if (error.name === 'NotModifiedError' && cacheItem) {\n for (const parseResult of cacheItem.value) {\n emit(parseResult);\n }\n emit(processingResult.refresh(`${location.type}:${location.target}`));\n await cache.set(CACHE_KEY, cacheItem);\n } else if (error.name === 'NotFoundError') {\n if (!optional) {\n emit(processingResult.notFoundError(location, message));\n }\n } else {\n emit(processingResult.generalError(location, message));\n }\n }\n\n return true;\n }\n\n private async doRead(\n location: string,\n etag?: string,\n ): Promise<{ response: { data: Buffer; url: string }[]; etag?: string }> {\n const response = await this.options.reader.search(location, { etag });\n\n const output = response.files.map(async file => ({\n url: file.url,\n data: await this.#limiter(file.content),\n }));\n\n return { response: await Promise.all(output), etag: response.etag };\n }\n}\n"],"names":["limiterFactory","processingResult","assertError"],"mappings":";;;;;;;;;;AA+BA,MAAM,SAAY,GAAA,IAAA;AAaX,MAAM,kBAA+C,CAAA;AAAA,EAK1D,YACmB,OAIjB,EAAA;AAJiB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAKjB,IAAK,IAAA,CAAA,QAAA,GAAWA,gCAAe,CAAC,CAAA;AAAA;AAClC;AAAA;AAAA,EATA,QAAA;AAAA,EAWA,gBAAmB,GAAA;AACjB,IAAO,OAAA,YAAA;AAAA;AACT,EAEA,MAAM,YACJ,CAAA,QAAA,EACA,QACA,EAAA,IAAA,EACA,QACA,KACkB,EAAA;AAClB,IAAI,IAAA,QAAA,CAAS,SAAS,KAAO,EAAA;AAC3B,MAAO,OAAA,KAAA;AAAA;AAGT,IAAA,MAAM,SAAY,GAAA,MAAM,KAAM,CAAA,GAAA,CAAe,SAAS,CAAA;AAEtD,IAAI,IAAA;AACF,MAAA,MAAM,EAAE,QAAU,EAAA,IAAA,EAAM,OAAQ,EAAA,GAAI,MAAM,IAAK,CAAA,MAAA;AAAA,QAC7C,QAAS,CAAA,MAAA;AAAA,QACT,SAAW,EAAA;AAAA,OACb;AAEA,MAAA,IAAI,QAAS,CAAA,MAAA,KAAW,CAAK,IAAA,CAAC,QAAU,EAAA;AACtC,QAAA,IAAA;AAAA,UACEC,kCAAiB,CAAA,aAAA;AAAA,YACf,QAAA;AAAA,YACA,CAAkB,eAAA,EAAA,QAAA,CAAS,IAAI,CAAA,8BAAA,EAAiC,SAAS,MAAM,CAAA;AAAA;AACjF,SACF;AAAA;AAGF,MAAA,MAAM,eAAyC,EAAC;AAChD,MAAA,KAAA,MAAW,QAAQ,QAAU,EAAA;AAC3B,QAAA,WAAA,MAAiB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,OACtC,MAAA,IAAW,KAAM,CAAA,IAAA,KAAS,eAAiB,EAAA;AACzC,QAAA,IAAI,CAAC,QAAU,EAAA;AACb,UAAA,IAAA,CAAKA,kCAAiB,CAAA,aAAA,CAAc,QAAU,EAAA,OAAO,CAAC,CAAA;AAAA;AACxD,OACK,MAAA;AACL,QAAA,IAAA,CAAKA,kCAAiB,CAAA,YAAA,CAAa,QAAU,EAAA,OAAO,CAAC,CAAA;AAAA;AACvD;AAGF,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,MAAc,MACZ,CAAA,QAAA,EACA,IACuE,EAAA;AACvE,IAAM,MAAA,QAAA,GAAW,MAAM,IAAK,CAAA,OAAA,CAAQ,OAAO,MAAO,CAAA,QAAA,EAAU,EAAE,IAAA,EAAM,CAAA;AAEpE,IAAA,MAAM,MAAS,GAAA,QAAA,CAAS,KAAM,CAAA,GAAA,CAAI,OAAM,IAAS,MAAA;AAAA,MAC/C,KAAK,IAAK,CAAA,GAAA;AAAA,MACV,IAAM,EAAA,MAAM,IAAK,CAAA,QAAA,CAAS,KAAK,OAAO;AAAA,KACtC,CAAA,CAAA;AAEF,IAAO,OAAA,EAAE,UAAU,MAAM,OAAA,CAAQ,IAAI,MAAM,CAAA,EAAG,IAAM,EAAA,QAAA,CAAS,IAAK,EAAA;AAAA;AAEtE;;;;"}
|
|
@@ -228,7 +228,7 @@ class CatalogBuilder {
|
|
|
228
228
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
229
229
|
return [
|
|
230
230
|
new FileReaderProcessor.FileReaderProcessor(),
|
|
231
|
-
new UrlReaderProcessor.UrlReaderProcessor({ reader, logger
|
|
231
|
+
new UrlReaderProcessor.UrlReaderProcessor({ reader, logger }),
|
|
232
232
|
new AnnotateLocationEntityProcessor.AnnotateLocationEntityProcessor({ integrations })
|
|
233
233
|
];
|
|
234
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogBuilder.cjs.js","sources":["../../src/service/CatalogBuilder.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DefaultNamespaceEntityPolicy,\n Entity,\n EntityPolicies,\n EntityPolicy,\n FieldFormatEntityPolicy,\n makeValidator,\n NoForeignRootFieldsEntityPolicy,\n SchemaValidEntityPolicy,\n Validators,\n} from '@backstage/catalog-model';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { createHash } from 'crypto';\nimport { Router } from 'express';\nimport lodash from 'lodash';\n\nimport {\n AuditorService,\n AuthService,\n DatabaseService,\n HttpAuthService,\n LoggerService,\n PermissionsRegistryService,\n PermissionsService,\n RootConfigService,\n SchedulerService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport {\n catalogPermissions,\n RESOURCE_TYPE_CATALOG_ENTITY,\n} from '@backstage/plugin-catalog-common/alpha';\nimport {\n CatalogProcessor,\n CatalogProcessorParser,\n EntityProvider,\n LocationAnalyzer,\n PlaceholderResolver,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport { EventBroker, EventsService } from '@backstage/plugin-events-node';\nimport {\n Permission,\n PermissionAuthorizer,\n toPermissionEvaluator,\n} from '@backstage/plugin-permission-common';\nimport {\n createConditionTransformer,\n createPermissionIntegrationRouter,\n} from '@backstage/plugin-permission-node';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { DefaultCatalogDatabase } from '../database/DefaultCatalogDatabase';\nimport { DefaultProcessingDatabase } from '../database/DefaultProcessingDatabase';\nimport { DefaultProviderDatabase } from '../database/DefaultProviderDatabase';\nimport { applyDatabaseMigrations } from '../database/migrations';\nimport { DefaultCatalogRulesEnforcer } from '../ingestion/CatalogRules';\nimport { RepoLocationAnalyzer } from '../ingestion/LocationAnalyzer';\nimport { permissionRules as catalogPermissionRules } from '../permissions/rules';\nimport { CatalogProcessingEngine } from '../processing/types';\nimport {\n createRandomProcessingInterval,\n ProcessingIntervalFunction,\n} from '../processing/refresh';\nimport { connectEntityProviders } from '../processing/connectEntityProviders';\nimport { evictEntitiesFromOrphanedProviders } from '../processing/evictEntitiesFromOrphanedProviders';\nimport { DefaultCatalogProcessingEngine } from '../processing/DefaultCatalogProcessingEngine';\nimport { DefaultCatalogProcessingOrchestrator } from '../processing/DefaultCatalogProcessingOrchestrator';\nimport {\n AnnotateLocationEntityProcessor,\n BuiltinKindsEntityProcessor,\n FileReaderProcessor,\n PlaceholderProcessor,\n UrlReaderProcessor,\n} from '../processors';\nimport {\n jsonPlaceholderResolver,\n textPlaceholderResolver,\n yamlPlaceholderResolver,\n} from '../processors/PlaceholderProcessor';\nimport { ConfigLocationEntityProvider } from '../providers/ConfigLocationEntityProvider';\nimport { DefaultLocationStore } from '../providers/DefaultLocationStore';\nimport { DefaultStitcher } from '../stitching/DefaultStitcher';\nimport { defaultEntityDataParser } from '../util/parse';\nimport { AuthorizedEntitiesCatalog } from './AuthorizedEntitiesCatalog';\nimport { AuthorizedLocationAnalyzer } from './AuthorizedLocationAnalyzer';\nimport { AuthorizedLocationService } from './AuthorizedLocationService';\nimport { AuthorizedRefreshService } from './AuthorizedRefreshService';\nimport { createRouter } from './createRouter';\nimport { DefaultEntitiesCatalog } from './DefaultEntitiesCatalog';\nimport { DefaultLocationService } from './DefaultLocationService';\nimport { DefaultRefreshService } from './DefaultRefreshService';\nimport { entitiesResponseToObjects } from './response';\nimport {\n catalogEntityPermissionResourceRef,\n CatalogPermissionRuleInput,\n} from '@backstage/plugin-catalog-node/alpha';\n\nexport type CatalogEnvironment = {\n logger: LoggerService;\n database: DatabaseService;\n config: RootConfigService;\n reader: UrlReaderService;\n permissions: PermissionsService | PermissionAuthorizer;\n permissionsRegistry?: PermissionsRegistryService;\n scheduler?: SchedulerService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n auditor?: AuditorService;\n};\n\n/**\n * A builder that helps wire up all of the component parts of the catalog.\n *\n * The touch points where you can replace or extend behavior are as follows:\n *\n * - Entity policies can be added or replaced. These are automatically run\n * after the processors' pre-processing steps. All policies are given the\n * chance to inspect the entity, and all of them have to pass in order for\n * the entity to be considered valid from an overall point of view.\n * - Location analyzers can be added. These are responsible for analyzing\n * repositories when onboarding them into the catalog, by finding\n * catalog-info.yaml files and other artifacts that can help automatically\n * register or create catalog data on the user's behalf.\n * - Placeholder resolvers can be replaced or added. These run on the raw\n * structured data between the parsing and pre-processing steps, to replace\n * dollar-prefixed entries with their actual values (like $file).\n * - Field format validators can be replaced. These check the format of\n * individual core fields such as metadata.name, to ensure that they adhere\n * to certain rules.\n * - Processors can be added or replaced. These implement the functionality of\n * reading, parsing, validating, and processing the entity data before it is\n * persisted in the catalog.\n */\nexport class CatalogBuilder {\n private readonly env: CatalogEnvironment;\n private entityPolicies: EntityPolicy[];\n private entityPoliciesReplace: boolean;\n private placeholderResolvers: Record<string, PlaceholderResolver>;\n private fieldFormatValidators: Partial<Validators>;\n private entityProviders: EntityProvider[];\n private processors: CatalogProcessor[];\n private locationAnalyzers: ScmLocationAnalyzer[];\n private processorsReplace: boolean;\n private parser: CatalogProcessorParser | undefined;\n private onProcessingError?: (event: {\n unprocessedEntity: Entity;\n errors: Error[];\n }) => Promise<void> | void;\n private processingInterval: ProcessingIntervalFunction;\n private locationAnalyzer: LocationAnalyzer | undefined = undefined;\n private readonly permissions: Permission[];\n private readonly permissionRules: CatalogPermissionRuleInput[];\n private allowedLocationType: string[];\n private legacySingleProcessorValidation = false;\n private eventBroker?: EventBroker | EventsService;\n\n /**\n * Creates a catalog builder.\n */\n static create(env: CatalogEnvironment): CatalogBuilder {\n return new CatalogBuilder(env);\n }\n\n private constructor(env: CatalogEnvironment) {\n this.env = env;\n this.entityPolicies = [];\n this.entityPoliciesReplace = false;\n this.placeholderResolvers = {};\n this.fieldFormatValidators = {};\n this.entityProviders = [];\n this.processors = [];\n this.locationAnalyzers = [];\n this.processorsReplace = false;\n this.parser = undefined;\n this.permissions = [...catalogPermissions];\n this.permissionRules = Object.values(catalogPermissionRules);\n this.allowedLocationType = ['url'];\n\n this.processingInterval = CatalogBuilder.getDefaultProcessingInterval(\n env.config,\n );\n }\n\n /**\n * Adds policies that are used to validate entities between the pre-\n * processing and post-processing stages. All such policies must pass for the\n * entity to be considered valid.\n *\n * If what you want to do is to replace the rules for what format is allowed\n * in various core entity fields (such as metadata.name), you may want to use\n * {@link CatalogBuilder#setFieldFormatValidators} instead.\n *\n * @param policies - One or more policies\n */\n addEntityPolicy(\n ...policies: Array<EntityPolicy | Array<EntityPolicy>>\n ): CatalogBuilder {\n this.entityPolicies.push(...policies.flat());\n return this;\n }\n\n /**\n * Processing interval determines how often entities should be processed.\n * Seconds provided will be multiplied by 1.5\n * The default processing interval is 100-150 seconds.\n * setting this too low will potentially deplete request quotas to upstream services.\n */\n setProcessingIntervalSeconds(seconds: number): CatalogBuilder {\n this.processingInterval = createRandomProcessingInterval({\n minSeconds: seconds,\n maxSeconds: seconds * 1.5,\n });\n return this;\n }\n\n /**\n * Overwrites the default processing interval function used to spread\n * entity updates in the catalog.\n */\n setProcessingInterval(\n processingInterval: ProcessingIntervalFunction,\n ): CatalogBuilder {\n this.processingInterval = processingInterval;\n return this;\n }\n\n /**\n * Overwrites the default location analyzer.\n */\n setLocationAnalyzer(locationAnalyzer: LocationAnalyzer): CatalogBuilder {\n this.locationAnalyzer = locationAnalyzer;\n return this;\n }\n\n /**\n * Sets what policies to use for validation of entities between the pre-\n * processing and post-processing stages. All such policies must pass for the\n * entity to be considered valid.\n *\n * If what you want to do is to replace the rules for what format is allowed\n * in various core entity fields (such as metadata.name), you may want to use\n * {@link CatalogBuilder#setFieldFormatValidators} instead.\n *\n * This function replaces the default set of policies; use with care.\n *\n * @param policies - One or more policies\n */\n replaceEntityPolicies(policies: EntityPolicy[]): CatalogBuilder {\n this.entityPolicies = [...policies];\n this.entityPoliciesReplace = true;\n return this;\n }\n\n /**\n * Adds, or overwrites, a handler for placeholders (e.g. $file) in entity\n * definition files.\n *\n * @param key - The key that identifies the placeholder, e.g. \"file\"\n * @param resolver - The resolver that gets values for this placeholder\n */\n setPlaceholderResolver(\n key: string,\n resolver: PlaceholderResolver,\n ): CatalogBuilder {\n this.placeholderResolvers[key] = resolver;\n return this;\n }\n\n /**\n * Sets the validator function to use for one or more special fields of an\n * entity. This is useful if the default rules for formatting of fields are\n * not sufficient.\n *\n * This function has no effect if used together with\n * {@link CatalogBuilder#replaceEntityPolicies}.\n *\n * @param validators - The (subset of) validators to set\n */\n setFieldFormatValidators(validators: Partial<Validators>): CatalogBuilder {\n lodash.merge(this.fieldFormatValidators, validators);\n return this;\n }\n\n /**\n * Adds or replaces entity providers. These are responsible for bootstrapping\n * the list of entities out of original data sources. For example, there is\n * one entity source for the config locations, and one for the database\n * stored locations. If you ingest entities out of a third party system, you\n * may want to implement that in terms of an entity provider as well.\n *\n * @param providers - One or more entity providers\n */\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): CatalogBuilder {\n this.entityProviders.push(...providers.flat());\n return this;\n }\n\n /**\n * Adds entity processors. These are responsible for reading, parsing, and\n * processing entities before they are persisted in the catalog.\n *\n * @param processors - One or more processors\n */\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): CatalogBuilder {\n this.processors.push(...processors.flat());\n return this;\n }\n\n /**\n * Sets what entity processors to use. These are responsible for reading,\n * parsing, and processing entities before they are persisted in the catalog.\n *\n * This function replaces the default set of processors, consider using with\n * {@link CatalogBuilder#getDefaultProcessors}; use with care.\n *\n * @param processors - One or more processors\n */\n replaceProcessors(processors: CatalogProcessor[]): CatalogBuilder {\n this.processors = [...processors];\n this.processorsReplace = true;\n return this;\n }\n\n /**\n * Returns the default list of entity processors. These are responsible for reading,\n * parsing, and processing entities before they are persisted in the catalog. Changing\n * the order of processing can give more control to custom processors.\n *\n * Consider using with {@link CatalogBuilder#replaceProcessors}\n *\n */\n getDefaultProcessors(): CatalogProcessor[] {\n const { config, logger, reader } = this.env;\n const integrations = ScmIntegrations.fromConfig(config);\n\n return [\n new FileReaderProcessor(),\n new UrlReaderProcessor({ reader, logger, config }),\n new AnnotateLocationEntityProcessor({ integrations }),\n ];\n }\n\n /**\n * Adds Location Analyzers. These are responsible for analyzing\n * repositories when onboarding them into the catalog, by finding\n * catalog-info.yaml files and other artifacts that can help automatically\n * register or create catalog data on the user's behalf.\n *\n * @param locationAnalyzers - One or more location analyzers\n */\n addLocationAnalyzers(\n ...analyzers: Array<ScmLocationAnalyzer | Array<ScmLocationAnalyzer>>\n ): CatalogBuilder {\n this.locationAnalyzers.push(...analyzers.flat());\n return this;\n }\n\n /**\n * Sets up the catalog to use a custom parser for entity data.\n *\n * This is the function that gets called immediately after some raw entity\n * specification data has been read from a remote source, and needs to be\n * parsed and emitted as structured data.\n *\n * @param parser - The custom parser\n */\n setEntityDataParser(parser: CatalogProcessorParser): CatalogBuilder {\n this.parser = parser;\n return this;\n }\n\n /**\n * Adds additional permissions. See\n * {@link @backstage/plugin-permission-node#Permission}.\n *\n * @param permissions - Additional permissions\n */\n addPermissions(...permissions: Array<Permission | Array<Permission>>) {\n this.permissions.push(...permissions.flat());\n return this;\n }\n\n /**\n * Adds additional permission rules. Permission rules are used to evaluate\n * catalog resources against queries. See\n * {@link @backstage/plugin-permission-node#PermissionRule}.\n *\n * @param permissionRules - Additional permission rules\n */\n addPermissionRules(\n ...permissionRules: Array<\n CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>\n >\n ) {\n this.permissionRules.push(...permissionRules.flat());\n return this;\n }\n\n /**\n * Sets up the allowed location types from being registered via the location service.\n *\n * @param allowedLocationTypes - the allowed location types\n */\n setAllowedLocationTypes(allowedLocationTypes: string[]): CatalogBuilder {\n this.allowedLocationType = allowedLocationTypes;\n return this;\n }\n\n /**\n * Enables the legacy behaviour of canceling validation early whenever only a\n * single processor declares an entity kind to be valid.\n */\n useLegacySingleProcessorValidation(): this {\n this.legacySingleProcessorValidation = true;\n return this;\n }\n\n /**\n * Enables the publishing of events for conflicts in the DefaultProcessingDatabase\n */\n setEventBroker(broker: EventBroker | EventsService): CatalogBuilder {\n this.eventBroker = broker;\n return this;\n }\n\n /**\n * Wires up and returns all of the component parts of the catalog\n */\n async build(): Promise<{\n processingEngine: CatalogProcessingEngine;\n router: Router;\n }> {\n const {\n config,\n database,\n logger,\n permissions,\n scheduler,\n permissionsRegistry,\n auditor,\n auth,\n httpAuth,\n } = this.env;\n\n const disableRelationsCompatibility = config.getOptionalBoolean(\n 'catalog.disableRelationsCompatibility',\n );\n\n const policy = this.buildEntityPolicy();\n const processors = this.buildProcessors();\n const parser = this.parser || defaultEntityDataParser;\n\n const dbClient = await database.getClient();\n if (!database.migrations?.skip) {\n logger.info('Performing database migration');\n await applyDatabaseMigrations(dbClient);\n }\n\n const stitcher = DefaultStitcher.fromConfig(config, {\n knex: dbClient,\n logger,\n });\n\n const processingDatabase = new DefaultProcessingDatabase({\n database: dbClient,\n logger,\n refreshInterval: this.processingInterval,\n eventBroker: this.eventBroker,\n });\n const providerDatabase = new DefaultProviderDatabase({\n database: dbClient,\n logger,\n });\n const catalogDatabase = new DefaultCatalogDatabase({\n database: dbClient,\n logger,\n });\n const integrations = ScmIntegrations.fromConfig(config);\n const rulesEnforcer = DefaultCatalogRulesEnforcer.fromConfig(config);\n\n const unauthorizedEntitiesCatalog = new DefaultEntitiesCatalog({\n database: dbClient,\n logger,\n stitcher,\n disableRelationsCompatibility,\n });\n\n let permissionsService: PermissionsService;\n if ('authorizeConditional' in permissions) {\n permissionsService = permissions as PermissionsService;\n } else {\n logger.warn(\n 'PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions',\n );\n permissionsService = toPermissionEvaluator(permissions);\n }\n\n const orchestrator = new DefaultCatalogProcessingOrchestrator({\n processors,\n integrations,\n rulesEnforcer,\n logger,\n parser,\n policy,\n legacySingleProcessorValidation: this.legacySingleProcessorValidation,\n });\n\n const entitiesCatalog = new AuthorizedEntitiesCatalog(\n unauthorizedEntitiesCatalog,\n permissionsService,\n permissionsRegistry\n ? createConditionTransformer(\n permissionsRegistry.getPermissionRuleset(\n catalogEntityPermissionResourceRef,\n ),\n )\n : createConditionTransformer(this.permissionRules),\n );\n\n const getResources = async (resourceRefs: string[]) => {\n const { items } = await unauthorizedEntitiesCatalog.entitiesBatch({\n credentials: await auth.getOwnServiceCredentials(),\n entityRefs: resourceRefs,\n });\n\n return entitiesResponseToObjects(items).map(e => e || undefined);\n };\n\n let permissionIntegrationRouter:\n | ReturnType<typeof createPermissionIntegrationRouter>\n | undefined;\n if (permissionsRegistry) {\n permissionsRegistry.addResourceType({\n resourceRef: catalogEntityPermissionResourceRef,\n getResources,\n permissions: this.permissions,\n rules: this.permissionRules,\n });\n } else {\n permissionIntegrationRouter = createPermissionIntegrationRouter({\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n getResources,\n permissions: this.permissions,\n rules: this.permissionRules,\n });\n }\n\n const locationStore = new DefaultLocationStore(dbClient);\n const configLocationProvider = new ConfigLocationEntityProvider(config);\n const entityProviders = lodash.uniqBy(\n [...this.entityProviders, locationStore, configLocationProvider],\n provider => provider.getProviderName(),\n );\n\n const processingEngine = new DefaultCatalogProcessingEngine({\n config,\n scheduler,\n logger,\n knex: dbClient,\n processingDatabase,\n orchestrator,\n stitcher,\n createHash: () => createHash('sha1'),\n pollingIntervalMs: 1000,\n onProcessingError: event => {\n this.onProcessingError?.(event);\n },\n eventBroker: this.eventBroker,\n });\n\n const locationAnalyzer =\n this.locationAnalyzer ??\n new AuthorizedLocationAnalyzer(\n new RepoLocationAnalyzer(logger, integrations, this.locationAnalyzers),\n permissionsService,\n );\n const locationService = new AuthorizedLocationService(\n new DefaultLocationService(locationStore, orchestrator, {\n allowedLocationTypes: this.allowedLocationType,\n }),\n permissionsService,\n );\n const refreshService = new AuthorizedRefreshService(\n new DefaultRefreshService({ database: catalogDatabase }),\n permissionsService,\n );\n\n const router = await createRouter({\n entitiesCatalog,\n locationAnalyzer,\n locationService,\n orchestrator,\n refreshService,\n logger,\n config,\n permissionIntegrationRouter,\n auth,\n httpAuth,\n permissionsService,\n auditor,\n disableRelationsCompatibility,\n });\n\n if (\n config.getOptionalString('catalog.orphanProviderStrategy') === 'delete'\n ) {\n await evictEntitiesFromOrphanedProviders({\n db: providerDatabase,\n providers: entityProviders,\n logger,\n });\n }\n await connectEntityProviders(providerDatabase, entityProviders);\n\n return {\n processingEngine: {\n async start() {\n await processingEngine.start();\n await stitcher.start();\n },\n async stop() {\n await processingEngine.stop();\n await stitcher.stop();\n },\n },\n router,\n };\n }\n\n subscribe(options: {\n onProcessingError: (event: {\n unprocessedEntity: Entity;\n errors: Error[];\n }) => Promise<void> | void;\n }) {\n this.onProcessingError = options.onProcessingError;\n }\n\n private buildEntityPolicy(): EntityPolicy {\n const entityPolicies: EntityPolicy[] = this.entityPoliciesReplace\n ? [new SchemaValidEntityPolicy(), ...this.entityPolicies]\n : [\n new SchemaValidEntityPolicy(),\n new DefaultNamespaceEntityPolicy(),\n new NoForeignRootFieldsEntityPolicy(),\n new FieldFormatEntityPolicy(\n makeValidator(this.fieldFormatValidators),\n ),\n ...this.entityPolicies,\n ];\n\n return EntityPolicies.allOf(entityPolicies);\n }\n\n private buildProcessors(): CatalogProcessor[] {\n const { config, reader } = this.env;\n const integrations = ScmIntegrations.fromConfig(config);\n\n this.checkDeprecatedReaderProcessors();\n\n const placeholderResolvers: Record<string, PlaceholderResolver> = {\n json: jsonPlaceholderResolver,\n yaml: yamlPlaceholderResolver,\n text: textPlaceholderResolver,\n ...this.placeholderResolvers,\n };\n\n // The placeholder is always there no matter what\n const processors: CatalogProcessor[] = [\n new PlaceholderProcessor({\n resolvers: placeholderResolvers,\n reader,\n integrations,\n }),\n ];\n\n const builtinKindsEntityProcessor = new BuiltinKindsEntityProcessor();\n // If the user adds a processor named 'BuiltinKindsEntityProcessor',\n // skip inclusion of the catalog-backend version.\n if (\n !this.processors.some(\n processor =>\n processor.getProcessorName() ===\n builtinKindsEntityProcessor.getProcessorName(),\n )\n ) {\n processors.push(builtinKindsEntityProcessor);\n }\n\n const disableDefaultProcessors = config.getOptionalBoolean(\n 'catalog.disableDefaultProcessors',\n );\n\n // Add default processors if:\n // - processors have NOT been explicitly replaced\n // - and default processors are NOT disabled via config\n if (!this.processorsReplace && !disableDefaultProcessors) {\n processors.push(...this.getDefaultProcessors());\n }\n\n // Add the ones (if any) that the user added\n processors.push(...this.processors);\n\n this.checkMissingExternalProcessors(processors);\n\n return processors;\n }\n\n // TODO(Rugvip): These old processors are removed, for a while we'll be throwing\n // errors here to make sure people know where to move the config\n private checkDeprecatedReaderProcessors() {\n const pc = this.env.config.getOptionalConfig('catalog.processors');\n if (pc?.has('github')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.github, move to using integrations.github instead`,\n );\n }\n if (pc?.has('gitlabApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.gitlabApi, move to using integrations.gitlab instead`,\n );\n }\n if (pc?.has('bitbucketApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.bitbucketApi, move to using integrations.bitbucket instead`,\n );\n }\n if (pc?.has('azureApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.azureApi, move to using integrations.azure instead`,\n );\n }\n }\n\n // TODO(freben): This can be removed no sooner than June 2022, after adopters have had some time to adapt to the new package structure\n private checkMissingExternalProcessors(processors: CatalogProcessor[]) {\n const skipCheckVarName = 'BACKSTAGE_CATALOG_SKIP_MISSING_PROCESSORS_CHECK';\n if (process.env[skipCheckVarName]) {\n return;\n }\n\n const locationTypes = new Set(\n this.env.config\n .getOptionalConfigArray('catalog.locations')\n ?.map(l => l.getString('type')) ?? [],\n );\n const processorNames = new Set(processors.map(p => p.getProcessorName()));\n\n function check(\n locationType: string,\n processorName: string,\n installationUrl: string,\n ) {\n if (\n locationTypes.has(locationType) &&\n !processorNames.has(processorName)\n ) {\n throw new Error(\n [\n `Your config contains a \"catalog.locations\" entry of type ${locationType},`,\n `but does not have the corresponding catalog processor ${processorName} installed.`,\n `This processor used to be built into the catalog itself, but is now moved to an`,\n `external module that has to be installed manually. Please follow the installation`,\n `instructions at ${installationUrl} if you are using this ability, or remove the`,\n `location from your app config if you do not. You can also silence this check entirely`,\n `by setting the environment variable ${skipCheckVarName} to 'true'.`,\n ].join(' '),\n );\n }\n }\n\n check(\n 'aws-cloud-accounts',\n 'AwsOrganizationCloudAccountProcessor',\n 'https://backstage.io/docs/integrations',\n );\n check(\n 's3-discovery',\n 'AwsS3DiscoveryProcessor',\n 'https://backstage.io/docs/integrations/aws-s3/discovery',\n );\n check(\n 'azure-discovery',\n 'AzureDevOpsDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/azure/discovery',\n );\n check(\n 'bitbucket-discovery',\n 'BitbucketDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/bitbucket/discovery',\n );\n check(\n 'github-discovery',\n 'GithubDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/github/discovery',\n );\n check(\n 'github-org',\n 'GithubOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/github/org',\n );\n check(\n 'gitlab-discovery',\n 'GitLabDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/gitlab/discovery',\n );\n check(\n 'ldap-org',\n 'LdapOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/ldap/org',\n );\n check(\n 'microsoft-graph-org',\n 'MicrosoftGraphOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/azure/org',\n );\n }\n\n private static getDefaultProcessingInterval(\n config: Config,\n ): ProcessingIntervalFunction {\n const processingIntervalKey = 'catalog.processingInterval';\n\n if (!config.has(processingIntervalKey)) {\n return createRandomProcessingInterval({\n minSeconds: 100,\n maxSeconds: 150,\n });\n }\n\n if (!Boolean(config.get('catalog.processingInterval'))) {\n return () => {\n throw new Error(\n 'catalog.processingInterval is set to false, processing is disabled.',\n );\n };\n }\n\n const duration = readDurationFromConfig(config, {\n key: processingIntervalKey,\n });\n\n const seconds = Math.max(\n 1,\n Math.round(durationToMilliseconds(duration) / 1000),\n );\n\n return createRandomProcessingInterval({\n minSeconds: seconds,\n maxSeconds: seconds * 1.5,\n });\n }\n}\n"],"names":["catalogPermissions","catalogPermissionRules","createRandomProcessingInterval","lodash","ScmIntegrations","FileReaderProcessor","UrlReaderProcessor","AnnotateLocationEntityProcessor","defaultEntityDataParser","applyDatabaseMigrations","DefaultStitcher","DefaultProcessingDatabase","DefaultProviderDatabase","DefaultCatalogDatabase","DefaultCatalogRulesEnforcer","DefaultEntitiesCatalog","toPermissionEvaluator","DefaultCatalogProcessingOrchestrator","AuthorizedEntitiesCatalog","createConditionTransformer","catalogEntityPermissionResourceRef","entitiesResponseToObjects","createPermissionIntegrationRouter","RESOURCE_TYPE_CATALOG_ENTITY","DefaultLocationStore","ConfigLocationEntityProvider","DefaultCatalogProcessingEngine","createHash","AuthorizedLocationAnalyzer","RepoLocationAnalyzer","AuthorizedLocationService","DefaultLocationService","AuthorizedRefreshService","DefaultRefreshService","createRouter","evictEntitiesFromOrphanedProviders","connectEntityProviders","SchemaValidEntityPolicy","DefaultNamespaceEntityPolicy","NoForeignRootFieldsEntityPolicy","FieldFormatEntityPolicy","makeValidator","EntityPolicies","jsonPlaceholderResolver","yamlPlaceholderResolver","textPlaceholderResolver","PlaceholderProcessor","BuiltinKindsEntityProcessor","config","readDurationFromConfig","durationToMilliseconds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsJO,MAAM,cAAe,CAAA;AAAA,EACT,GAAA;AAAA,EACT,cAAA;AAAA,EACA,qBAAA;AAAA,E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wB,GAAA,4BAAA;AAE9B,IAAA,IAAI,CAACA,QAAA,CAAO,GAAI,CAAA,qBAAqB,CAAG,EAAA;AACtC,MAAA,OAAO9C,sCAA+B,CAAA;AAAA,QACpC,UAAY,EAAA,GAAA;AAAA,QACZ,UAAY,EAAA;AAAA,OACb,CAAA;AAAA;AAGH,IAAA,IAAI,CAAC,OAAQ,CAAA8C,QAAA,CAAO,GAAI,CAAA,4BAA4B,CAAC,CAAG,EAAA;AACtD,MAAA,OAAO,MAAM;AACX,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SACF;AAAA,OACF;AAAA;AAGF,IAAM,MAAA,QAAA,GAAWC,8BAAuBD,QAAQ,EAAA;AAAA,MAC9C,GAAK,EAAA;AAAA,KACN,CAAA;AAED,IAAA,MAAM,UAAU,IAAK,CAAA,GAAA;AAAA,MACnB,CAAA;AAAA,MACA,IAAK,CAAA,KAAA,CAAME,4BAAuB,CAAA,QAAQ,IAAI,GAAI;AAAA,KACpD;AAEA,IAAA,OAAOhD,sCAA+B,CAAA;AAAA,MACpC,UAAY,EAAA,OAAA;AAAA,MACZ,YAAY,OAAU,GAAA;AAAA,KACvB,CAAA;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"CatalogBuilder.cjs.js","sources":["../../src/service/CatalogBuilder.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DefaultNamespaceEntityPolicy,\n Entity,\n EntityPolicies,\n EntityPolicy,\n FieldFormatEntityPolicy,\n makeValidator,\n NoForeignRootFieldsEntityPolicy,\n SchemaValidEntityPolicy,\n Validators,\n} from '@backstage/catalog-model';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { createHash } from 'crypto';\nimport { Router } from 'express';\nimport lodash from 'lodash';\n\nimport {\n AuditorService,\n AuthService,\n DatabaseService,\n HttpAuthService,\n LoggerService,\n PermissionsRegistryService,\n PermissionsService,\n RootConfigService,\n SchedulerService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport {\n catalogPermissions,\n RESOURCE_TYPE_CATALOG_ENTITY,\n} from '@backstage/plugin-catalog-common/alpha';\nimport {\n CatalogProcessor,\n CatalogProcessorParser,\n EntityProvider,\n LocationAnalyzer,\n PlaceholderResolver,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport { EventBroker, EventsService } from '@backstage/plugin-events-node';\nimport {\n Permission,\n PermissionAuthorizer,\n toPermissionEvaluator,\n} from '@backstage/plugin-permission-common';\nimport {\n createConditionTransformer,\n createPermissionIntegrationRouter,\n} from '@backstage/plugin-permission-node';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { DefaultCatalogDatabase } from '../database/DefaultCatalogDatabase';\nimport { DefaultProcessingDatabase } from '../database/DefaultProcessingDatabase';\nimport { DefaultProviderDatabase } from '../database/DefaultProviderDatabase';\nimport { applyDatabaseMigrations } from '../database/migrations';\nimport { DefaultCatalogRulesEnforcer } from '../ingestion/CatalogRules';\nimport { RepoLocationAnalyzer } from '../ingestion/LocationAnalyzer';\nimport { permissionRules as catalogPermissionRules } from '../permissions/rules';\nimport { CatalogProcessingEngine } from '../processing/types';\nimport {\n createRandomProcessingInterval,\n ProcessingIntervalFunction,\n} from '../processing/refresh';\nimport { connectEntityProviders } from '../processing/connectEntityProviders';\nimport { evictEntitiesFromOrphanedProviders } from '../processing/evictEntitiesFromOrphanedProviders';\nimport { DefaultCatalogProcessingEngine } from '../processing/DefaultCatalogProcessingEngine';\nimport { DefaultCatalogProcessingOrchestrator } from '../processing/DefaultCatalogProcessingOrchestrator';\nimport {\n AnnotateLocationEntityProcessor,\n BuiltinKindsEntityProcessor,\n FileReaderProcessor,\n PlaceholderProcessor,\n UrlReaderProcessor,\n} from '../processors';\nimport {\n jsonPlaceholderResolver,\n textPlaceholderResolver,\n yamlPlaceholderResolver,\n} from '../processors/PlaceholderProcessor';\nimport { ConfigLocationEntityProvider } from '../providers/ConfigLocationEntityProvider';\nimport { DefaultLocationStore } from '../providers/DefaultLocationStore';\nimport { DefaultStitcher } from '../stitching/DefaultStitcher';\nimport { defaultEntityDataParser } from '../util/parse';\nimport { AuthorizedEntitiesCatalog } from './AuthorizedEntitiesCatalog';\nimport { AuthorizedLocationAnalyzer } from './AuthorizedLocationAnalyzer';\nimport { AuthorizedLocationService } from './AuthorizedLocationService';\nimport { AuthorizedRefreshService } from './AuthorizedRefreshService';\nimport { createRouter } from './createRouter';\nimport { DefaultEntitiesCatalog } from './DefaultEntitiesCatalog';\nimport { DefaultLocationService } from './DefaultLocationService';\nimport { DefaultRefreshService } from './DefaultRefreshService';\nimport { entitiesResponseToObjects } from './response';\nimport {\n catalogEntityPermissionResourceRef,\n CatalogPermissionRuleInput,\n} from '@backstage/plugin-catalog-node/alpha';\n\nexport type CatalogEnvironment = {\n logger: LoggerService;\n database: DatabaseService;\n config: RootConfigService;\n reader: UrlReaderService;\n permissions: PermissionsService | PermissionAuthorizer;\n permissionsRegistry?: PermissionsRegistryService;\n scheduler?: SchedulerService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n auditor?: AuditorService;\n};\n\n/**\n * A builder that helps wire up all of the component parts of the catalog.\n *\n * The touch points where you can replace or extend behavior are as follows:\n *\n * - Entity policies can be added or replaced. These are automatically run\n * after the processors' pre-processing steps. All policies are given the\n * chance to inspect the entity, and all of them have to pass in order for\n * the entity to be considered valid from an overall point of view.\n * - Location analyzers can be added. These are responsible for analyzing\n * repositories when onboarding them into the catalog, by finding\n * catalog-info.yaml files and other artifacts that can help automatically\n * register or create catalog data on the user's behalf.\n * - Placeholder resolvers can be replaced or added. These run on the raw\n * structured data between the parsing and pre-processing steps, to replace\n * dollar-prefixed entries with their actual values (like $file).\n * - Field format validators can be replaced. These check the format of\n * individual core fields such as metadata.name, to ensure that they adhere\n * to certain rules.\n * - Processors can be added or replaced. These implement the functionality of\n * reading, parsing, validating, and processing the entity data before it is\n * persisted in the catalog.\n */\nexport class CatalogBuilder {\n private readonly env: CatalogEnvironment;\n private entityPolicies: EntityPolicy[];\n private entityPoliciesReplace: boolean;\n private placeholderResolvers: Record<string, PlaceholderResolver>;\n private fieldFormatValidators: Partial<Validators>;\n private entityProviders: EntityProvider[];\n private processors: CatalogProcessor[];\n private locationAnalyzers: ScmLocationAnalyzer[];\n private processorsReplace: boolean;\n private parser: CatalogProcessorParser | undefined;\n private onProcessingError?: (event: {\n unprocessedEntity: Entity;\n errors: Error[];\n }) => Promise<void> | void;\n private processingInterval: ProcessingIntervalFunction;\n private locationAnalyzer: LocationAnalyzer | undefined = undefined;\n private readonly permissions: Permission[];\n private readonly permissionRules: CatalogPermissionRuleInput[];\n private allowedLocationType: string[];\n private legacySingleProcessorValidation = false;\n private eventBroker?: EventBroker | EventsService;\n\n /**\n * Creates a catalog builder.\n */\n static create(env: CatalogEnvironment): CatalogBuilder {\n return new CatalogBuilder(env);\n }\n\n private constructor(env: CatalogEnvironment) {\n this.env = env;\n this.entityPolicies = [];\n this.entityPoliciesReplace = false;\n this.placeholderResolvers = {};\n this.fieldFormatValidators = {};\n this.entityProviders = [];\n this.processors = [];\n this.locationAnalyzers = [];\n this.processorsReplace = false;\n this.parser = undefined;\n this.permissions = [...catalogPermissions];\n this.permissionRules = Object.values(catalogPermissionRules);\n this.allowedLocationType = ['url'];\n\n this.processingInterval = CatalogBuilder.getDefaultProcessingInterval(\n env.config,\n );\n }\n\n /**\n * Adds policies that are used to validate entities between the pre-\n * processing and post-processing stages. All such policies must pass for the\n * entity to be considered valid.\n *\n * If what you want to do is to replace the rules for what format is allowed\n * in various core entity fields (such as metadata.name), you may want to use\n * {@link CatalogBuilder#setFieldFormatValidators} instead.\n *\n * @param policies - One or more policies\n */\n addEntityPolicy(\n ...policies: Array<EntityPolicy | Array<EntityPolicy>>\n ): CatalogBuilder {\n this.entityPolicies.push(...policies.flat());\n return this;\n }\n\n /**\n * Processing interval determines how often entities should be processed.\n * Seconds provided will be multiplied by 1.5\n * The default processing interval is 100-150 seconds.\n * setting this too low will potentially deplete request quotas to upstream services.\n */\n setProcessingIntervalSeconds(seconds: number): CatalogBuilder {\n this.processingInterval = createRandomProcessingInterval({\n minSeconds: seconds,\n maxSeconds: seconds * 1.5,\n });\n return this;\n }\n\n /**\n * Overwrites the default processing interval function used to spread\n * entity updates in the catalog.\n */\n setProcessingInterval(\n processingInterval: ProcessingIntervalFunction,\n ): CatalogBuilder {\n this.processingInterval = processingInterval;\n return this;\n }\n\n /**\n * Overwrites the default location analyzer.\n */\n setLocationAnalyzer(locationAnalyzer: LocationAnalyzer): CatalogBuilder {\n this.locationAnalyzer = locationAnalyzer;\n return this;\n }\n\n /**\n * Sets what policies to use for validation of entities between the pre-\n * processing and post-processing stages. All such policies must pass for the\n * entity to be considered valid.\n *\n * If what you want to do is to replace the rules for what format is allowed\n * in various core entity fields (such as metadata.name), you may want to use\n * {@link CatalogBuilder#setFieldFormatValidators} instead.\n *\n * This function replaces the default set of policies; use with care.\n *\n * @param policies - One or more policies\n */\n replaceEntityPolicies(policies: EntityPolicy[]): CatalogBuilder {\n this.entityPolicies = [...policies];\n this.entityPoliciesReplace = true;\n return this;\n }\n\n /**\n * Adds, or overwrites, a handler for placeholders (e.g. $file) in entity\n * definition files.\n *\n * @param key - The key that identifies the placeholder, e.g. \"file\"\n * @param resolver - The resolver that gets values for this placeholder\n */\n setPlaceholderResolver(\n key: string,\n resolver: PlaceholderResolver,\n ): CatalogBuilder {\n this.placeholderResolvers[key] = resolver;\n return this;\n }\n\n /**\n * Sets the validator function to use for one or more special fields of an\n * entity. This is useful if the default rules for formatting of fields are\n * not sufficient.\n *\n * This function has no effect if used together with\n * {@link CatalogBuilder#replaceEntityPolicies}.\n *\n * @param validators - The (subset of) validators to set\n */\n setFieldFormatValidators(validators: Partial<Validators>): CatalogBuilder {\n lodash.merge(this.fieldFormatValidators, validators);\n return this;\n }\n\n /**\n * Adds or replaces entity providers. These are responsible for bootstrapping\n * the list of entities out of original data sources. For example, there is\n * one entity source for the config locations, and one for the database\n * stored locations. If you ingest entities out of a third party system, you\n * may want to implement that in terms of an entity provider as well.\n *\n * @param providers - One or more entity providers\n */\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): CatalogBuilder {\n this.entityProviders.push(...providers.flat());\n return this;\n }\n\n /**\n * Adds entity processors. These are responsible for reading, parsing, and\n * processing entities before they are persisted in the catalog.\n *\n * @param processors - One or more processors\n */\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): CatalogBuilder {\n this.processors.push(...processors.flat());\n return this;\n }\n\n /**\n * Sets what entity processors to use. These are responsible for reading,\n * parsing, and processing entities before they are persisted in the catalog.\n *\n * This function replaces the default set of processors, consider using with\n * {@link CatalogBuilder#getDefaultProcessors}; use with care.\n *\n * @param processors - One or more processors\n */\n replaceProcessors(processors: CatalogProcessor[]): CatalogBuilder {\n this.processors = [...processors];\n this.processorsReplace = true;\n return this;\n }\n\n /**\n * Returns the default list of entity processors. These are responsible for reading,\n * parsing, and processing entities before they are persisted in the catalog. Changing\n * the order of processing can give more control to custom processors.\n *\n * Consider using with {@link CatalogBuilder#replaceProcessors}\n *\n */\n getDefaultProcessors(): CatalogProcessor[] {\n const { config, logger, reader } = this.env;\n const integrations = ScmIntegrations.fromConfig(config);\n\n return [\n new FileReaderProcessor(),\n new UrlReaderProcessor({ reader, logger }),\n new AnnotateLocationEntityProcessor({ integrations }),\n ];\n }\n\n /**\n * Adds Location Analyzers. These are responsible for analyzing\n * repositories when onboarding them into the catalog, by finding\n * catalog-info.yaml files and other artifacts that can help automatically\n * register or create catalog data on the user's behalf.\n *\n * @param locationAnalyzers - One or more location analyzers\n */\n addLocationAnalyzers(\n ...analyzers: Array<ScmLocationAnalyzer | Array<ScmLocationAnalyzer>>\n ): CatalogBuilder {\n this.locationAnalyzers.push(...analyzers.flat());\n return this;\n }\n\n /**\n * Sets up the catalog to use a custom parser for entity data.\n *\n * This is the function that gets called immediately after some raw entity\n * specification data has been read from a remote source, and needs to be\n * parsed and emitted as structured data.\n *\n * @param parser - The custom parser\n */\n setEntityDataParser(parser: CatalogProcessorParser): CatalogBuilder {\n this.parser = parser;\n return this;\n }\n\n /**\n * Adds additional permissions. See\n * {@link @backstage/plugin-permission-node#Permission}.\n *\n * @param permissions - Additional permissions\n */\n addPermissions(...permissions: Array<Permission | Array<Permission>>) {\n this.permissions.push(...permissions.flat());\n return this;\n }\n\n /**\n * Adds additional permission rules. Permission rules are used to evaluate\n * catalog resources against queries. See\n * {@link @backstage/plugin-permission-node#PermissionRule}.\n *\n * @param permissionRules - Additional permission rules\n */\n addPermissionRules(\n ...permissionRules: Array<\n CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>\n >\n ) {\n this.permissionRules.push(...permissionRules.flat());\n return this;\n }\n\n /**\n * Sets up the allowed location types from being registered via the location service.\n *\n * @param allowedLocationTypes - the allowed location types\n */\n setAllowedLocationTypes(allowedLocationTypes: string[]): CatalogBuilder {\n this.allowedLocationType = allowedLocationTypes;\n return this;\n }\n\n /**\n * Enables the legacy behaviour of canceling validation early whenever only a\n * single processor declares an entity kind to be valid.\n */\n useLegacySingleProcessorValidation(): this {\n this.legacySingleProcessorValidation = true;\n return this;\n }\n\n /**\n * Enables the publishing of events for conflicts in the DefaultProcessingDatabase\n */\n setEventBroker(broker: EventBroker | EventsService): CatalogBuilder {\n this.eventBroker = broker;\n return this;\n }\n\n /**\n * Wires up and returns all of the component parts of the catalog\n */\n async build(): Promise<{\n processingEngine: CatalogProcessingEngine;\n router: Router;\n }> {\n const {\n config,\n database,\n logger,\n permissions,\n scheduler,\n permissionsRegistry,\n auditor,\n auth,\n httpAuth,\n } = this.env;\n\n const disableRelationsCompatibility = config.getOptionalBoolean(\n 'catalog.disableRelationsCompatibility',\n );\n\n const policy = this.buildEntityPolicy();\n const processors = this.buildProcessors();\n const parser = this.parser || defaultEntityDataParser;\n\n const dbClient = await database.getClient();\n if (!database.migrations?.skip) {\n logger.info('Performing database migration');\n await applyDatabaseMigrations(dbClient);\n }\n\n const stitcher = DefaultStitcher.fromConfig(config, {\n knex: dbClient,\n logger,\n });\n\n const processingDatabase = new DefaultProcessingDatabase({\n database: dbClient,\n logger,\n refreshInterval: this.processingInterval,\n eventBroker: this.eventBroker,\n });\n const providerDatabase = new DefaultProviderDatabase({\n database: dbClient,\n logger,\n });\n const catalogDatabase = new DefaultCatalogDatabase({\n database: dbClient,\n logger,\n });\n const integrations = ScmIntegrations.fromConfig(config);\n const rulesEnforcer = DefaultCatalogRulesEnforcer.fromConfig(config);\n\n const unauthorizedEntitiesCatalog = new DefaultEntitiesCatalog({\n database: dbClient,\n logger,\n stitcher,\n disableRelationsCompatibility,\n });\n\n let permissionsService: PermissionsService;\n if ('authorizeConditional' in permissions) {\n permissionsService = permissions as PermissionsService;\n } else {\n logger.warn(\n 'PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions',\n );\n permissionsService = toPermissionEvaluator(permissions);\n }\n\n const orchestrator = new DefaultCatalogProcessingOrchestrator({\n processors,\n integrations,\n rulesEnforcer,\n logger,\n parser,\n policy,\n legacySingleProcessorValidation: this.legacySingleProcessorValidation,\n });\n\n const entitiesCatalog = new AuthorizedEntitiesCatalog(\n unauthorizedEntitiesCatalog,\n permissionsService,\n permissionsRegistry\n ? createConditionTransformer(\n permissionsRegistry.getPermissionRuleset(\n catalogEntityPermissionResourceRef,\n ),\n )\n : createConditionTransformer(this.permissionRules),\n );\n\n const getResources = async (resourceRefs: string[]) => {\n const { items } = await unauthorizedEntitiesCatalog.entitiesBatch({\n credentials: await auth.getOwnServiceCredentials(),\n entityRefs: resourceRefs,\n });\n\n return entitiesResponseToObjects(items).map(e => e || undefined);\n };\n\n let permissionIntegrationRouter:\n | ReturnType<typeof createPermissionIntegrationRouter>\n | undefined;\n if (permissionsRegistry) {\n permissionsRegistry.addResourceType({\n resourceRef: catalogEntityPermissionResourceRef,\n getResources,\n permissions: this.permissions,\n rules: this.permissionRules,\n });\n } else {\n permissionIntegrationRouter = createPermissionIntegrationRouter({\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n getResources,\n permissions: this.permissions,\n rules: this.permissionRules,\n });\n }\n\n const locationStore = new DefaultLocationStore(dbClient);\n const configLocationProvider = new ConfigLocationEntityProvider(config);\n const entityProviders = lodash.uniqBy(\n [...this.entityProviders, locationStore, configLocationProvider],\n provider => provider.getProviderName(),\n );\n\n const processingEngine = new DefaultCatalogProcessingEngine({\n config,\n scheduler,\n logger,\n knex: dbClient,\n processingDatabase,\n orchestrator,\n stitcher,\n createHash: () => createHash('sha1'),\n pollingIntervalMs: 1000,\n onProcessingError: event => {\n this.onProcessingError?.(event);\n },\n eventBroker: this.eventBroker,\n });\n\n const locationAnalyzer =\n this.locationAnalyzer ??\n new AuthorizedLocationAnalyzer(\n new RepoLocationAnalyzer(logger, integrations, this.locationAnalyzers),\n permissionsService,\n );\n const locationService = new AuthorizedLocationService(\n new DefaultLocationService(locationStore, orchestrator, {\n allowedLocationTypes: this.allowedLocationType,\n }),\n permissionsService,\n );\n const refreshService = new AuthorizedRefreshService(\n new DefaultRefreshService({ database: catalogDatabase }),\n permissionsService,\n );\n\n const router = await createRouter({\n entitiesCatalog,\n locationAnalyzer,\n locationService,\n orchestrator,\n refreshService,\n logger,\n config,\n permissionIntegrationRouter,\n auth,\n httpAuth,\n permissionsService,\n auditor,\n disableRelationsCompatibility,\n });\n\n if (\n config.getOptionalString('catalog.orphanProviderStrategy') === 'delete'\n ) {\n await evictEntitiesFromOrphanedProviders({\n db: providerDatabase,\n providers: entityProviders,\n logger,\n });\n }\n await connectEntityProviders(providerDatabase, entityProviders);\n\n return {\n processingEngine: {\n async start() {\n await processingEngine.start();\n await stitcher.start();\n },\n async stop() {\n await processingEngine.stop();\n await stitcher.stop();\n },\n },\n router,\n };\n }\n\n subscribe(options: {\n onProcessingError: (event: {\n unprocessedEntity: Entity;\n errors: Error[];\n }) => Promise<void> | void;\n }) {\n this.onProcessingError = options.onProcessingError;\n }\n\n private buildEntityPolicy(): EntityPolicy {\n const entityPolicies: EntityPolicy[] = this.entityPoliciesReplace\n ? [new SchemaValidEntityPolicy(), ...this.entityPolicies]\n : [\n new SchemaValidEntityPolicy(),\n new DefaultNamespaceEntityPolicy(),\n new NoForeignRootFieldsEntityPolicy(),\n new FieldFormatEntityPolicy(\n makeValidator(this.fieldFormatValidators),\n ),\n ...this.entityPolicies,\n ];\n\n return EntityPolicies.allOf(entityPolicies);\n }\n\n private buildProcessors(): CatalogProcessor[] {\n const { config, reader } = this.env;\n const integrations = ScmIntegrations.fromConfig(config);\n\n this.checkDeprecatedReaderProcessors();\n\n const placeholderResolvers: Record<string, PlaceholderResolver> = {\n json: jsonPlaceholderResolver,\n yaml: yamlPlaceholderResolver,\n text: textPlaceholderResolver,\n ...this.placeholderResolvers,\n };\n\n // The placeholder is always there no matter what\n const processors: CatalogProcessor[] = [\n new PlaceholderProcessor({\n resolvers: placeholderResolvers,\n reader,\n integrations,\n }),\n ];\n\n const builtinKindsEntityProcessor = new BuiltinKindsEntityProcessor();\n // If the user adds a processor named 'BuiltinKindsEntityProcessor',\n // skip inclusion of the catalog-backend version.\n if (\n !this.processors.some(\n processor =>\n processor.getProcessorName() ===\n builtinKindsEntityProcessor.getProcessorName(),\n )\n ) {\n processors.push(builtinKindsEntityProcessor);\n }\n\n const disableDefaultProcessors = config.getOptionalBoolean(\n 'catalog.disableDefaultProcessors',\n );\n\n // Add default processors if:\n // - processors have NOT been explicitly replaced\n // - and default processors are NOT disabled via config\n if (!this.processorsReplace && !disableDefaultProcessors) {\n processors.push(...this.getDefaultProcessors());\n }\n\n // Add the ones (if any) that the user added\n processors.push(...this.processors);\n\n this.checkMissingExternalProcessors(processors);\n\n return processors;\n }\n\n // TODO(Rugvip): These old processors are removed, for a while we'll be throwing\n // errors here to make sure people know where to move the config\n private checkDeprecatedReaderProcessors() {\n const pc = this.env.config.getOptionalConfig('catalog.processors');\n if (pc?.has('github')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.github, move to using integrations.github instead`,\n );\n }\n if (pc?.has('gitlabApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.gitlabApi, move to using integrations.gitlab instead`,\n );\n }\n if (pc?.has('bitbucketApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.bitbucketApi, move to using integrations.bitbucket instead`,\n );\n }\n if (pc?.has('azureApi')) {\n throw new Error(\n `Using deprecated configuration for catalog.processors.azureApi, move to using integrations.azure instead`,\n );\n }\n }\n\n // TODO(freben): This can be removed no sooner than June 2022, after adopters have had some time to adapt to the new package structure\n private checkMissingExternalProcessors(processors: CatalogProcessor[]) {\n const skipCheckVarName = 'BACKSTAGE_CATALOG_SKIP_MISSING_PROCESSORS_CHECK';\n if (process.env[skipCheckVarName]) {\n return;\n }\n\n const locationTypes = new Set(\n this.env.config\n .getOptionalConfigArray('catalog.locations')\n ?.map(l => l.getString('type')) ?? [],\n );\n const processorNames = new Set(processors.map(p => p.getProcessorName()));\n\n function check(\n locationType: string,\n processorName: string,\n installationUrl: string,\n ) {\n if (\n locationTypes.has(locationType) &&\n !processorNames.has(processorName)\n ) {\n throw new Error(\n [\n `Your config contains a \"catalog.locations\" entry of type ${locationType},`,\n `but does not have the corresponding catalog processor ${processorName} installed.`,\n `This processor used to be built into the catalog itself, but is now moved to an`,\n `external module that has to be installed manually. Please follow the installation`,\n `instructions at ${installationUrl} if you are using this ability, or remove the`,\n `location from your app config if you do not. You can also silence this check entirely`,\n `by setting the environment variable ${skipCheckVarName} to 'true'.`,\n ].join(' '),\n );\n }\n }\n\n check(\n 'aws-cloud-accounts',\n 'AwsOrganizationCloudAccountProcessor',\n 'https://backstage.io/docs/integrations',\n );\n check(\n 's3-discovery',\n 'AwsS3DiscoveryProcessor',\n 'https://backstage.io/docs/integrations/aws-s3/discovery',\n );\n check(\n 'azure-discovery',\n 'AzureDevOpsDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/azure/discovery',\n );\n check(\n 'bitbucket-discovery',\n 'BitbucketDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/bitbucket/discovery',\n );\n check(\n 'github-discovery',\n 'GithubDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/github/discovery',\n );\n check(\n 'github-org',\n 'GithubOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/github/org',\n );\n check(\n 'gitlab-discovery',\n 'GitLabDiscoveryProcessor',\n 'https://backstage.io/docs/integrations/gitlab/discovery',\n );\n check(\n 'ldap-org',\n 'LdapOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/ldap/org',\n );\n check(\n 'microsoft-graph-org',\n 'MicrosoftGraphOrgReaderProcessor',\n 'https://backstage.io/docs/integrations/azure/org',\n );\n }\n\n private static getDefaultProcessingInterval(\n config: Config,\n ): ProcessingIntervalFunction {\n const processingIntervalKey = 'catalog.processingInterval';\n\n if (!config.has(processingIntervalKey)) {\n return createRandomProcessingInterval({\n minSeconds: 100,\n maxSeconds: 150,\n });\n }\n\n if (!Boolean(config.get('catalog.processingInterval'))) {\n return () => {\n throw new Error(\n 'catalog.processingInterval is set to false, processing is disabled.',\n );\n };\n }\n\n const duration = readDurationFromConfig(config, {\n key: processingIntervalKey,\n });\n\n const seconds = Math.max(\n 1,\n Math.round(durationToMilliseconds(duration) / 1000),\n );\n\n return createRandomProcessingInterval({\n minSeconds: seconds,\n maxSeconds: seconds * 1.5,\n });\n }\n}\n"],"names":["catalogPermissions","catalogPermissionRules","createRandomProcessingInterval","lodash","ScmIntegrations","FileReaderProcessor","UrlReaderProcessor","AnnotateLocationEntityProcessor","defaultEntityDataParser","applyDatabaseMigrations","DefaultStitcher","DefaultProcessingDatabase","DefaultProviderDatabase","DefaultCatalogDatabase","DefaultCatalogRulesEnforcer","DefaultEntitiesCatalog","toPermissionEvaluator","DefaultCatalogProcessingOrchestrator","AuthorizedEntitiesCatalog","createConditionTransformer","catalogEntityPermissionResourceRef","entitiesResponseToObjects","createPermissionIntegrationRouter","RESOURCE_TYPE_CATALOG_ENTITY","DefaultLocationStore","ConfigLocationEntityProvider","DefaultCatalogProcessingEngine","createHash","AuthorizedLocationAnalyzer","RepoLocationAnalyzer","AuthorizedLocationService","DefaultLocationService","AuthorizedRefreshService","DefaultRefreshService","createRouter","evictEntitiesFromOrphanedProviders","connectEntityProviders","SchemaValidEntityPolicy","DefaultNamespaceEntityPolicy","NoForeignRootFieldsEntityPolicy","FieldFormatEntityPolicy","makeValidator","EntityPolicies","jsonPlaceholderResolver","yamlPlaceholderResolver","textPlaceholderResolver","PlaceholderProcessor","BuiltinKindsEntityProcessor","config","readDurationFromConfig","durationToMilliseconds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsJO,MAAM,cAAe,CAAA;AAAA,EACT,GAAA;AAAA,EACT,cAAA;AAAA,EACA,qBAAA;AAAA,EACA,oBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,MAAA;AAAA,EACA,iBAAA;AAAA,EAIA,kBAAA;AAAA,EACA,gBAAiD,GAAA,KAAA,CAAA;AAAA,EACxC,WAAA;AAAA,EACA,eAAA;AAAA,EACT,mBAAA;AAAA,EACA,+BAAkC,GAAA,KAAA;AAAA,EAClC,WAAA;AAAA;AAAA;AAAA;AAAA,EAKR,OAAO,OAAO,GAAyC,EAAA;AACrD,IAAO,OAAA,IAAI,eAAe,GAAG,CAAA;AAAA;AAC/B,EAEQ,YAAY,GAAyB,EAAA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AC9C,GAAK,EAAA;AAAA,KACN,CAAA;AAED,IAAA,MAAM,UAAU,IAAK,CAAA,GAAA;AAAA,MACnB,CAAA;AAAA,MACA,IAAK,CAAA,KAAA,CAAME,4BAAuB,CAAA,QAAQ,IAAI,GAAI;AAAA,KACpD;AAEA,IAAA,OAAOhD,sCAA+B,CAAA;AAAA,MACpC,UAAY,EAAA,OAAA;AAAA,MACZ,YAAY,OAAU,GAAA;AAAA,KACvB,CAAA;AAAA;AAEL;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.1",
|
|
4
4
|
"description": "The Backstage backend plugin that provides the Backstage catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
"test": "backstage-cli package test"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@backstage/backend-openapi-utils": "
|
|
77
|
-
"@backstage/backend-plugin-api": "
|
|
78
|
-
"@backstage/catalog-client": "
|
|
79
|
-
"@backstage/catalog-model": "
|
|
80
|
-
"@backstage/config": "
|
|
81
|
-
"@backstage/errors": "
|
|
82
|
-
"@backstage/integration": "
|
|
83
|
-
"@backstage/plugin-catalog-common": "
|
|
84
|
-
"@backstage/plugin-catalog-node": "
|
|
85
|
-
"@backstage/plugin-events-node": "
|
|
86
|
-
"@backstage/plugin-permission-common": "
|
|
87
|
-
"@backstage/plugin-permission-node": "
|
|
88
|
-
"@backstage/types": "
|
|
76
|
+
"@backstage/backend-openapi-utils": "0.5.5-next.0",
|
|
77
|
+
"@backstage/backend-plugin-api": "1.4.1-next.0",
|
|
78
|
+
"@backstage/catalog-client": "1.10.2-next.0",
|
|
79
|
+
"@backstage/catalog-model": "1.7.5-next.0",
|
|
80
|
+
"@backstage/config": "1.3.3-next.0",
|
|
81
|
+
"@backstage/errors": "1.2.7",
|
|
82
|
+
"@backstage/integration": "1.17.1-next.1",
|
|
83
|
+
"@backstage/plugin-catalog-common": "1.1.5-next.0",
|
|
84
|
+
"@backstage/plugin-catalog-node": "1.17.2-next.0",
|
|
85
|
+
"@backstage/plugin-events-node": "0.4.13-next.0",
|
|
86
|
+
"@backstage/plugin-permission-common": "0.9.1-next.0",
|
|
87
|
+
"@backstage/plugin-permission-node": "0.10.2-next.0",
|
|
88
|
+
"@backstage/types": "1.2.1",
|
|
89
89
|
"@opentelemetry/api": "^1.9.0",
|
|
90
90
|
"codeowners-utils": "^1.0.2",
|
|
91
91
|
"core-js": "^3.6.5",
|
|
@@ -106,12 +106,11 @@
|
|
|
106
106
|
"zod": "^3.22.4"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@backstage/backend-defaults": "
|
|
110
|
-
"@backstage/backend-test-utils": "
|
|
111
|
-
"@backstage/cli": "
|
|
112
|
-
"@backstage/plugin-permission-common": "
|
|
113
|
-
"@backstage/repo-tools": "
|
|
114
|
-
"@backstage/test-utils": "^1.7.9",
|
|
109
|
+
"@backstage/backend-defaults": "0.11.1-next.1",
|
|
110
|
+
"@backstage/backend-test-utils": "1.7.0-next.1",
|
|
111
|
+
"@backstage/cli": "0.33.1-next.1",
|
|
112
|
+
"@backstage/plugin-permission-common": "0.9.1-next.0",
|
|
113
|
+
"@backstage/repo-tools": "0.15.0-next.1",
|
|
115
114
|
"@types/core-js": "^2.5.4",
|
|
116
115
|
"@types/express": "^4.17.6",
|
|
117
116
|
"@types/git-url-parse": "^9.0.0",
|