@backstage/plugin-catalog-backend 1.14.0 → 1.15.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 CHANGED
@@ -1,5 +1,71 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.15.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - e5bf3749ad: Support adding location analyzers in new catalog analysis extension point and move `AnalyzeOptions` and `ScmLocationAnalyzer` types to `@backstage/plugin-catalog-node`
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/plugin-catalog-node@1.5.0-next.1
13
+ - @backstage/integration@1.7.2-next.0
14
+ - @backstage/plugin-search-backend-module-catalog@0.1.11-next.1
15
+ - @backstage/backend-common@0.19.9-next.1
16
+ - @backstage/backend-tasks@0.5.12-next.1
17
+ - @backstage/plugin-auth-node@0.4.1-next.1
18
+ - @backstage/plugin-permission-node@0.7.18-next.1
19
+ - @backstage/backend-openapi-utils@0.1.0-next.1
20
+ - @backstage/backend-plugin-api@0.6.7-next.1
21
+ - @backstage/catalog-client@1.4.5
22
+ - @backstage/catalog-model@1.4.3
23
+ - @backstage/config@1.1.1
24
+ - @backstage/errors@1.2.3
25
+ - @backstage/types@1.1.1
26
+ - @backstage/plugin-catalog-common@1.0.17
27
+ - @backstage/plugin-events-node@0.2.16-next.1
28
+ - @backstage/plugin-permission-common@0.7.9
29
+
30
+ ## 1.15.0-next.0
31
+
32
+ ### Minor Changes
33
+
34
+ - 8d756968f9: Introduce a new optional config parameter `catalog.stitchingStrategy.mode`,
35
+ which can have the values `'immediate'` (default) and `'deferred'`. The default
36
+ is for stitching to work as it did before this change, which means that it
37
+ happens "in-band" (blocking) immediately when each processing task finishes.
38
+ When set to `'deferred'`, stitching is instead deferred to happen on a separate
39
+ asynchronous worker queue just like processing.
40
+
41
+ Deferred stitching should make performance smoother when ingesting large amounts
42
+ of entities, and reduce p99 processing times and repeated over-stitching of
43
+ hot spot entities when fan-out/fan-in in terms of relations is very large. It
44
+ does however also come with some performance cost due to the queuing with how
45
+ much wall-clock time some types of task take.
46
+
47
+ ### Patch Changes
48
+
49
+ - 6694b369a3: Update the OpenAPI spec with more complete error responses and request bodies using Optic. Also, updates the test cases to use the new `supertest` pass through from `@backstage/backend-openapi-utils`.
50
+ - Updated dependencies
51
+ - @backstage/backend-openapi-utils@0.1.0-next.0
52
+ - @backstage/backend-common@0.19.9-next.0
53
+ - @backstage/integration@1.7.1
54
+ - @backstage/backend-plugin-api@0.6.7-next.0
55
+ - @backstage/backend-tasks@0.5.12-next.0
56
+ - @backstage/catalog-client@1.4.5
57
+ - @backstage/catalog-model@1.4.3
58
+ - @backstage/config@1.1.1
59
+ - @backstage/errors@1.2.3
60
+ - @backstage/types@1.1.1
61
+ - @backstage/plugin-auth-node@0.4.1-next.0
62
+ - @backstage/plugin-catalog-common@1.0.17
63
+ - @backstage/plugin-catalog-node@1.4.8-next.0
64
+ - @backstage/plugin-events-node@0.2.16-next.0
65
+ - @backstage/plugin-permission-common@0.7.9
66
+ - @backstage/plugin-permission-node@0.7.18-next.0
67
+ - @backstage/plugin-search-backend-module-catalog@0.1.11-next.0
68
+
3
69
  ## 1.14.0
4
70
 
5
71
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.14.0",
3
+ "version": "1.15.0-next.1",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/config.d.ts CHANGED
@@ -145,6 +145,19 @@ export interface Config {
145
145
  */
146
146
  orphanStrategy?: 'keep' | 'delete';
147
147
 
148
+ /**
149
+ * The strategy to use when stitching together the final entities.
150
+ */
151
+ stitchingStrategy?:
152
+ | {
153
+ /** Perform stitching in-band immediately when needed */
154
+ mode: 'immediate';
155
+ }
156
+ | {
157
+ /** Defer stitching to be performed asynchronously */
158
+ mode: 'deferred';
159
+ };
160
+
148
161
  /**
149
162
  * The interval at which the catalog should process its entities.
150
163
  *
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var alpha = require('@backstage/plugin-catalog-common/alpha');
6
6
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
7
- var CatalogBuilder = require('./cjs/CatalogBuilder-9cfeea71.cjs.js');
7
+ var CatalogBuilder = require('./cjs/CatalogBuilder-2ff47757.cjs.js');
8
8
  var backendPluginApi = require('@backstage/backend-plugin-api');
9
9
  var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
10
10
  var backendCommon = require('@backstage/backend-common');
@@ -31,6 +31,7 @@ require('fast-json-stable-stringify');
31
31
  require('lodash/uniq');
32
32
  require('lodash/chunk');
33
33
  require('zod');
34
+ require('@backstage/types');
34
35
  require('@backstage/catalog-client');
35
36
  require('yn');
36
37
  require('@backstage/backend-openapi-utils');
@@ -38,7 +39,6 @@ require('@backstage/plugin-auth-node');
38
39
  require('@backstage/plugin-permission-common');
39
40
  require('minimatch');
40
41
  require('@backstage/config');
41
- require('@backstage/types');
42
42
 
43
43
  const { conditions, createConditionalDecision } = pluginPermissionNode.createConditionExports({
44
44
  pluginId: "catalog",
@@ -61,8 +61,8 @@ var __privateAdd = (obj, member, value) => {
61
61
  throw TypeError("Cannot add the same private member more than once");
62
62
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
63
63
  };
64
- var _processors, _entityProviders, _placeholderResolvers;
65
- class CatalogExtensionPointImpl {
64
+ var _processors, _entityProviders, _placeholderResolvers, _locationAnalyzers;
65
+ class CatalogProcessingExtensionPointImpl {
66
66
  constructor() {
67
67
  __privateAdd(this, _processors, new Array());
68
68
  __privateAdd(this, _entityProviders, new Array());
@@ -94,14 +94,31 @@ class CatalogExtensionPointImpl {
94
94
  _processors = new WeakMap();
95
95
  _entityProviders = new WeakMap();
96
96
  _placeholderResolvers = new WeakMap();
97
+ class CatalogAnalysisExtensionPointImpl {
98
+ constructor() {
99
+ __privateAdd(this, _locationAnalyzers, new Array());
100
+ }
101
+ addLocationAnalyzer(analyzer) {
102
+ __privateGet(this, _locationAnalyzers).push(analyzer);
103
+ }
104
+ get locationAnalyzers() {
105
+ return __privateGet(this, _locationAnalyzers);
106
+ }
107
+ }
108
+ _locationAnalyzers = new WeakMap();
97
109
  const catalogPlugin = backendPluginApi.createBackendPlugin({
98
110
  pluginId: "catalog",
99
111
  register(env) {
100
- const processingExtensions = new CatalogExtensionPointImpl();
112
+ const processingExtensions = new CatalogProcessingExtensionPointImpl();
101
113
  env.registerExtensionPoint(
102
114
  alpha$1.catalogProcessingExtensionPoint,
103
115
  processingExtensions
104
116
  );
117
+ const analysisExtensions = new CatalogAnalysisExtensionPointImpl();
118
+ env.registerExtensionPoint(
119
+ alpha$1.catalogAnalysisExtensionPoint,
120
+ analysisExtensions
121
+ );
105
122
  env.registerInit({
106
123
  deps: {
107
124
  logger: backendPluginApi.coreServices.logger,
@@ -137,6 +154,7 @@ const catalogPlugin = backendPluginApi.createBackendPlugin({
137
154
  Object.entries(processingExtensions.placeholderResolvers).forEach(
138
155
  ([key, resolver]) => builder.setPlaceholderResolver(key, resolver)
139
156
  );
157
+ builder.addLocationAnalyzers(...analysisExtensions.locationAnalyzers);
140
158
  const { processingEngine, router } = await builder.build();
141
159
  await processingEngine.start();
142
160
  lifecycle.addShutdownHook(() => processingEngine.stop());
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { PlaceholderResolver } from '../modules';\n\nclass CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint {\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n #placeholderResolvers: Record<string, PlaceholderResolver> = {};\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n addPlaceholderResolver(key: string, resolver: PlaceholderResolver) {\n if (key in this.#placeholderResolvers)\n throw new Error(\n `A placeholder resolver for '${key}' has already been set up, please check your config.`,\n );\n this.#placeholderResolvers[key] = resolver;\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n\n get placeholderResolvers() {\n return this.#placeholderResolvers;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n Object.entries(processingExtensions.placeholderResolvers).forEach(\n ([key, resolver]) => builder.setPlaceholderResolver(key, resolver),\n );\n\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAE,UAAA,EAAY,yBAA0B,EAAA,GAAIA,2CAAuB,CAAA;AAAA,EACvE,QAAU,EAAA,SAAA;AAAA,EACV,YAAc,EAAAC,kCAAA;AAAA,EACd,KAAO,EAAAC,8BAAA;AACT,CAAC,CAAA,CAAA;AAQM,MAAM,iBAAoB,GAAA,WAAA;AAiC1B,MAAM,gCAAmC,GAAA;;;;;;;;;;;;;;;ACjEhD,IAAA,WAAA,EAAA,gBAAA,EAAA,qBAAA,CAAA;AA+BA,MAAM,yBAAqE,CAAA;AAAA,EAA3E,WAAA,GAAA;AACE,IAAA,YAAA,CAAA,IAAA,EAAA,WAAA,EAAc,IAAI,KAAwB,EAAA,CAAA,CAAA;AAC1C,IAAA,YAAA,CAAA,IAAA,EAAA,gBAAA,EAAmB,IAAI,KAAsB,EAAA,CAAA,CAAA;AAC7C,IAAA,YAAA,CAAA,IAAA,EAAA,qBAAA,EAA6D,EAAC,CAAA,CAAA;AAAA,GAAA;AAAA,EAE9D,gBACK,UACG,EAAA;AACN,IAAA,YAAA,CAAA,IAAA,EAAK,WAAY,CAAA,CAAA,IAAA,CAAK,GAAG,UAAA,CAAW,MAAM,CAAA,CAAA;AAAA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eAAgB,CAAA,MAAM,gBAAiB,CAAA,IAAA,EAAM,CAAA,CAAA;AACvD,QAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogAnalysisExtensionPoint,\n catalogAnalysisExtensionPoint,\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { PlaceholderResolver } from '../modules';\n\nclass CatalogProcessingExtensionPointImpl\n implements CatalogProcessingExtensionPoint\n{\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n #placeholderResolvers: Record<string, PlaceholderResolver> = {};\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n addPlaceholderResolver(key: string, resolver: PlaceholderResolver) {\n if (key in this.#placeholderResolvers)\n throw new Error(\n `A placeholder resolver for '${key}' has already been set up, please check your config.`,\n );\n this.#placeholderResolvers[key] = resolver;\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n\n get placeholderResolvers() {\n return this.#placeholderResolvers;\n }\n}\n\nclass CatalogAnalysisExtensionPointImpl\n implements CatalogAnalysisExtensionPoint\n{\n #locationAnalyzers = new Array<ScmLocationAnalyzer>();\n\n addLocationAnalyzer(analyzer: ScmLocationAnalyzer): void {\n this.#locationAnalyzers.push(analyzer);\n }\n\n get locationAnalyzers() {\n return this.#locationAnalyzers;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogProcessingExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n const analysisExtensions = new CatalogAnalysisExtensionPointImpl();\n env.registerExtensionPoint(\n catalogAnalysisExtensionPoint,\n analysisExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n Object.entries(processingExtensions.placeholderResolvers).forEach(\n ([key, resolver]) => builder.setPlaceholderResolver(key, resolver),\n );\n builder.addLocationAnalyzers(...analysisExtensions.locationAnalyzers);\n\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","catalogAnalysisExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAE,UAAA,EAAY,yBAA0B,EAAA,GAAIA,2CAAuB,CAAA;AAAA,EACvE,QAAU,EAAA,SAAA;AAAA,EACV,YAAc,EAAAC,kCAAA;AAAA,EACd,KAAO,EAAAC,8BAAA;AACT,CAAC,CAAA,CAAA;AAQM,MAAM,iBAAoB,GAAA,WAAA;AAiC1B,MAAM,gCAAmC,GAAA;;;;;;;;;;;;;;;ACjEhD,IAAA,WAAA,EAAA,gBAAA,EAAA,qBAAA,EAAA,kBAAA,CAAA;AAkCA,MAAM,mCAEN,CAAA;AAAA,EAFA,WAAA,GAAA;AAGE,IAAA,YAAA,CAAA,IAAA,EAAA,WAAA,EAAc,IAAI,KAAwB,EAAA,CAAA,CAAA;AAC1C,IAAA,YAAA,CAAA,IAAA,EAAA,gBAAA,EAAmB,IAAI,KAAsB,EAAA,CAAA,CAAA;AAC7C,IAAA,YAAA,CAAA,IAAA,EAAA,qBAAA,EAA6D,EAAC,CAAA,CAAA;AAAA,GAAA;AAAA,EAE9D,gBACK,UACG,EAAA;AACN,IAAA,YAAA,CAAA,IAAA,EAAK,WAAY,CAAA,CAAA,IAAA,CAAK,GAAG,UAAA,CAAW,MAAM,CAAA,CAAA;AAAA,GAC5C;AAAA,EAEA,qBACK,SACG,EAAA;AACN,IAAA,YAAA,CAAA,IAAA,EAAK,gBAAiB,CAAA,CAAA,IAAA,CAAK,GAAG,SAAA,CAAU,MAAM,CAAA,CAAA;AAAA,GAChD;AAAA,EAEA,sBAAA,CAAuB,KAAa,QAA+B,EAAA;AACjE,IAAA,IAAI,OAAO,YAAK,CAAA,IAAA,EAAA,qBAAA,CAAA;AACd,MAAA,MAAM,I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