@backstage/plugin-catalog-backend 1.15.1-next.1 → 1.16.0-next.3

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,57 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.16.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-common@0.20.0-next.3
9
+ - @backstage/backend-openapi-utils@0.1.1-next.3
10
+ - @backstage/backend-plugin-api@0.6.8-next.3
11
+ - @backstage/backend-tasks@0.5.13-next.3
12
+ - @backstage/catalog-client@1.5.0-next.1
13
+ - @backstage/catalog-model@1.4.3
14
+ - @backstage/config@1.1.1
15
+ - @backstage/errors@1.2.3
16
+ - @backstage/integration@1.8.0-next.1
17
+ - @backstage/types@1.1.1
18
+ - @backstage/plugin-auth-node@0.4.2-next.3
19
+ - @backstage/plugin-catalog-common@1.0.18
20
+ - @backstage/plugin-catalog-node@1.6.0-next.3
21
+ - @backstage/plugin-events-node@0.2.17-next.3
22
+ - @backstage/plugin-permission-common@0.7.10
23
+ - @backstage/plugin-permission-node@0.7.19-next.3
24
+ - @backstage/plugin-search-backend-module-catalog@0.1.12-next.3
25
+
26
+ ## 1.16.0-next.2
27
+
28
+ ### Minor Changes
29
+
30
+ - 7804597: Permission rules can now be added for the Catalog plugin through the `CatalogPermissionExtensionPoint` interface.
31
+
32
+ ### Patch Changes
33
+
34
+ - 50ee804: Wrap single `pipelineLoop` of TaskPipeline in a span for better traces
35
+ - a168507: Deprecated `EntitiesSearchFilter` and `EntityFilter`, which can now be imported from `@backstage/plugin-catalog-node` instead
36
+ - Updated dependencies
37
+ - @backstage/plugin-catalog-node@1.6.0-next.2
38
+ - @backstage/backend-common@0.20.0-next.2
39
+ - @backstage/plugin-auth-node@0.4.2-next.2
40
+ - @backstage/catalog-client@1.5.0-next.1
41
+ - @backstage/plugin-search-backend-module-catalog@0.1.12-next.2
42
+ - @backstage/backend-openapi-utils@0.1.1-next.2
43
+ - @backstage/backend-plugin-api@0.6.8-next.2
44
+ - @backstage/backend-tasks@0.5.13-next.2
45
+ - @backstage/catalog-model@1.4.3
46
+ - @backstage/config@1.1.1
47
+ - @backstage/errors@1.2.3
48
+ - @backstage/integration@1.8.0-next.1
49
+ - @backstage/types@1.1.1
50
+ - @backstage/plugin-catalog-common@1.0.18
51
+ - @backstage/plugin-events-node@0.2.17-next.2
52
+ - @backstage/plugin-permission-common@0.7.10
53
+ - @backstage/plugin-permission-node@0.7.19-next.2
54
+
3
55
  ## 1.15.1-next.1
4
56
 
5
57
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.15.1-next.1",
3
+ "version": "1.16.0-next.3",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
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-948d91db.cjs.js');
7
+ var CatalogBuilder = require('./cjs/CatalogBuilder-59dba5ef.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');
@@ -61,7 +61,7 @@ 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, _locationAnalyzers;
64
+ var _processors, _entityProviders, _placeholderResolvers, _locationAnalyzers, _permissionRules;
65
65
  class CatalogProcessingExtensionPointImpl {
66
66
  constructor() {
67
67
  __privateAdd(this, _processors, new Array());
@@ -106,6 +106,18 @@ class CatalogAnalysisExtensionPointImpl {
106
106
  }
107
107
  }
108
108
  _locationAnalyzers = new WeakMap();
109
+ class CatalogPermissionExtensionPointImpl {
110
+ constructor() {
111
+ __privateAdd(this, _permissionRules, new Array());
112
+ }
113
+ addPermissionRules(...rules) {
114
+ __privateGet(this, _permissionRules).push(...rules.flat());
115
+ }
116
+ get permissionRules() {
117
+ return __privateGet(this, _permissionRules);
118
+ }
119
+ }
120
+ _permissionRules = new WeakMap();
109
121
  const catalogPlugin = backendPluginApi.createBackendPlugin({
110
122
  pluginId: "catalog",
111
123
  register(env) {
@@ -119,6 +131,11 @@ const catalogPlugin = backendPluginApi.createBackendPlugin({
119
131
  alpha$1.catalogAnalysisExtensionPoint,
120
132
  analysisExtensions
121
133
  );
134
+ const permissionExtensions = new CatalogPermissionExtensionPointImpl();
135
+ env.registerExtensionPoint(
136
+ alpha$1.catalogPermissionExtensionPoint,
137
+ permissionExtensions
138
+ );
122
139
  env.registerInit({
123
140
  deps: {
124
141
  logger: backendPluginApi.coreServices.logger,
@@ -155,6 +172,7 @@ const catalogPlugin = backendPluginApi.createBackendPlugin({
155
172
  ([key, resolver]) => builder.setPlaceholderResolver(key, resolver)
156
173
  );
157
174
  builder.addLocationAnalyzers(...analysisExtensions.locationAnalyzers);
175
+ builder.addPermissionRules(...permissionExtensions.permissionRules);
158
176
  const { processingEngine, router } = await builder.build();
159
177
  await processingEngine.start();
160
178
  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 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;;;;;;;;;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,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, CatalogPermissionRuleInput } from './CatalogBuilder';\nimport {\n CatalogAnalysisExtensionPoint,\n catalogAnalysisExtensionPoint,\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n CatalogPermissionExtensionPoint,\n catalogPermissionExtensionPoint,\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\nclass CatalogPermissionExtensionPointImpl\n implements CatalogPermissionExtensionPoint\n{\n #permissionRules = new Array<CatalogPermissionRuleInput>();\n\n addPermissionRules(\n ...rules: Array<\n CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>\n >\n ): void {\n this.#permissionRules.push(...rules.flat());\n }\n\n get permissionRules() {\n return this.#permissionRules;\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 const permissionExtensions = new CatalogPermissionExtensionPointImpl();\n env.registerExtensionPoint(\n catalogPermissionExtensionPoint,\n permissionExtensions,\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 builder.addPermissionRules(...permissionExtensions.permissionRules);\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","catalogPermissionExtensionPoint","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,EAAA,gBAAA,CAAA;AAoCA,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,YAA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CAAqB,eAAe,CAAA,CAAA;AAElE,QAAA,MAAM,EAAE,gBAAkB,EAAA,MAAA,EAAW,GAAA,MAAM,QAAQ,KAAM,EAAA,CAAA;AAEzD,QAAA,MAAM,iBAAiB,KAAM,EAAA,CAAA;AAC7B,QAAA,SAAA,CAAU,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;;;;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { E as EntitiesSearchFilter } from './types/types.d-c2093007.js';
2
- export { E as EntitiesSearchFilter } from './types/types.d-c2093007.js';
3
1
  import * as _backstage_plugin_permission_common from '@backstage/plugin-permission-common';
4
2
  import { PermissionRuleParams } from '@backstage/plugin-permission-common';
5
3
  import * as _backstage_plugin_permission_node from '@backstage/plugin-permission-node';
6
4
  import { PermissionRule } from '@backstage/plugin-permission-node';
5
+ import * as _backstage_plugin_catalog_node from '@backstage/plugin-catalog-node';
6
+ import { EntitiesSearchFilter } from '@backstage/plugin-catalog-node';
7
7
  import * as _backstage_catalog_model from '@backstage/catalog-model';
8
8
  import { Entity } from '@backstage/catalog-model';
9
9
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
@@ -15,25 +15,25 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
15
15
  * @alpha
16
16
  */
17
17
  declare const catalogConditions: _backstage_plugin_permission_node.Conditions<{
18
- hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
18
+ hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
19
19
  annotation: string;
20
20
  value?: string | undefined;
21
21
  }>;
22
- hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
22
+ hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
23
23
  label: string;
24
24
  }>;
25
- hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
25
+ hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
26
26
  key: string;
27
27
  value?: string | undefined;
28
28
  }>;
29
- hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
29
+ hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
30
30
  key: string;
31
31
  value?: string | undefined;
32
32
  }>;
33
- isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
33
+ isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
34
34
  kinds: string[];
35
35
  }>;
36
- isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
36
+ isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
37
37
  claims: string[];
38
38
  }>;
39
39
  }>;
@@ -94,25 +94,25 @@ declare const createCatalogPermissionRule: <TParams extends PermissionRuleParams
94
94
  * @alpha
95
95
  */
96
96
  declare const permissionRules: {
97
- hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
97
+ hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
98
98
  annotation: string;
99
99
  value?: string | undefined;
100
100
  }>;
101
- hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
101
+ hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
102
102
  label: string;
103
103
  }>;
104
- hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
104
+ hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
105
105
  key: string;
106
106
  value?: string | undefined;
107
107
  }>;
108
- hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
108
+ hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
109
109
  key: string;
110
110
  value?: string | undefined;
111
111
  }>;
112
- isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
112
+ isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
113
113
  kinds: string[];
114
114
  }>;
115
- isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, "catalog-entity", {
115
+ isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, _backstage_plugin_catalog_node.EntitiesSearchFilter, "catalog-entity", {
116
116
  claims: string[];
117
117
  }>;
118
118
  };
@@ -1504,7 +1504,67 @@ function stitchingStrategyFromConfig(config) {
1504
1504
  );
1505
1505
  }
1506
1506
 
1507
+ const TRACER_ID = "backstage-plugin-catalog-backend";
1508
+ function setAttributeIfDefined(span, attribute, value) {
1509
+ if (value !== null && value !== void 0) {
1510
+ span.setAttribute(attribute, value);
1511
+ }
1512
+ }
1513
+ function addEntityAttributes(span, entity) {
1514
+ var _a, _b;
1515
+ setAttributeIfDefined(span, "backstage.entity.apiVersion", entity.apiVersion);
1516
+ setAttributeIfDefined(span, "backstage.entity.kind", entity.kind);
1517
+ setAttributeIfDefined(
1518
+ span,
1519
+ "backstage.entity.metadata.namespace",
1520
+ (_a = entity.metadata) == null ? void 0 : _a.namespace
1521
+ );
1522
+ setAttributeIfDefined(
1523
+ span,
1524
+ "backstage.entity.metadata.name",
1525
+ (_b = entity.metadata) == null ? void 0 : _b.name
1526
+ );
1527
+ }
1528
+ const onException = (e, span) => {
1529
+ span.recordException(e);
1530
+ span.setStatus({
1531
+ code: api.SpanStatusCode.ERROR
1532
+ });
1533
+ };
1534
+ function isPromiseLike(obj) {
1535
+ return !!obj && (typeof obj === "object" || typeof obj === "function") && "then" in obj && typeof obj.then === "function";
1536
+ }
1537
+ function handleFn(span, fn) {
1538
+ try {
1539
+ const ret = fn(span);
1540
+ if (isPromiseLike(ret)) {
1541
+ ret.then(
1542
+ () => {
1543
+ span.end();
1544
+ },
1545
+ (e) => {
1546
+ onException(e, span);
1547
+ span.end();
1548
+ }
1549
+ );
1550
+ } else {
1551
+ span.end();
1552
+ }
1553
+ return ret;
1554
+ } catch (e) {
1555
+ onException(e, span);
1556
+ span.end();
1557
+ throw e;
1558
+ }
1559
+ }
1560
+ function withActiveSpan(tracer, name, fn, spanOptions = {}) {
1561
+ return tracer.startActiveSpan(name, spanOptions, (span) => {
1562
+ return handleFn(span, fn);
1563
+ });
1564
+ }
1565
+
1507
1566
  const DEFAULT_POLLING_INTERVAL_MS = 1e3;
1567
+ const tracer$2 = api.trace.getTracer(TRACER_ID);
1508
1568
  function startTaskPipeline(options) {
1509
1569
  const {
1510
1570
  loadTasks,
@@ -1526,20 +1586,23 @@ function startTaskPipeline(options) {
1526
1586
  async function pipelineLoop() {
1527
1587
  while (!abortSignal.aborted) {
1528
1588
  if (state.inFlightCount <= lowWatermark) {
1529
- const loadCount = highWatermark - state.inFlightCount;
1530
- const loadedItems = await Promise.resolve().then(() => loadTasks(loadCount)).catch(() => {
1531
- return [];
1532
- });
1533
- if (loadedItems.length && !abortSignal.aborted) {
1534
- state.inFlightCount += loadedItems.length;
1535
- for (const item of loadedItems) {
1536
- Promise.resolve().then(() => processTask(item)).catch(() => {
1537
- }).finally(() => {
1538
- state.inFlightCount -= 1;
1539
- barrier.release();
1540
- });
1589
+ await withActiveSpan(tracer$2, "TaskPipelineLoop", async (span) => {
1590
+ const loadCount = highWatermark - state.inFlightCount;
1591
+ const loadedItems = await Promise.resolve().then(() => loadTasks(loadCount)).catch(() => {
1592
+ return [];
1593
+ });
1594
+ span.setAttribute("itemCount", loadedItems.length);
1595
+ if (loadedItems.length && !abortSignal.aborted) {
1596
+ state.inFlightCount += loadedItems.length;
1597
+ for (const item of loadedItems) {
1598
+ Promise.resolve().then(() => processTask(item)).catch(() => {
1599
+ }).finally(() => {
1600
+ state.inFlightCount -= 1;
1601
+ barrier.release();
1602
+ });
1603
+ }
1541
1604
  }
1542
- }
1605
+ });
1543
1606
  }
1544
1607
  await barrier.wait();
1545
1608
  }
@@ -1584,65 +1647,6 @@ function createBarrier(options) {
1584
1647
  };
1585
1648
  }
1586
1649
 
1587
- const TRACER_ID = "backstage-plugin-catalog-backend";
1588
- function setAttributeIfDefined(span, attribute, value) {
1589
- if (value !== null && value !== void 0) {
1590
- span.setAttribute(attribute, value);
1591
- }
1592
- }
1593
- function addEntityAttributes(span, entity) {
1594
- var _a, _b;
1595
- setAttributeIfDefined(span, "backstage.entity.apiVersion", entity.apiVersion);
1596
- setAttributeIfDefined(span, "backstage.entity.kind", entity.kind);
1597
- setAttributeIfDefined(
1598
- span,
1599
- "backstage.entity.metadata.namespace",
1600
- (_a = entity.metadata) == null ? void 0 : _a.namespace
1601
- );
1602
- setAttributeIfDefined(
1603
- span,
1604
- "backstage.entity.metadata.name",
1605
- (_b = entity.metadata) == null ? void 0 : _b.name
1606
- );
1607
- }
1608
- const onException = (e, span) => {
1609
- span.recordException(e);
1610
- span.setStatus({
1611
- code: api.SpanStatusCode.ERROR
1612
- });
1613
- };
1614
- function isPromiseLike(obj) {
1615
- return !!obj && (typeof obj === "object" || typeof obj === "function") && "then" in obj && typeof obj.then === "function";
1616
- }
1617
- function handleFn(span, fn) {
1618
- try {
1619
- const ret = fn(span);
1620
- if (isPromiseLike(ret)) {
1621
- ret.then(
1622
- () => {
1623
- span.end();
1624
- },
1625
- (e) => {
1626
- onException(e, span);
1627
- span.end();
1628
- }
1629
- );
1630
- } else {
1631
- span.end();
1632
- }
1633
- return ret;
1634
- } catch (e) {
1635
- onException(e, span);
1636
- span.end();
1637
- throw e;
1638
- }
1639
- }
1640
- function withActiveSpan(tracer, name, fn, spanOptions = {}) {
1641
- return tracer.startActiveSpan(name, spanOptions, (span) => {
1642
- return handleFn(span, fn);
1643
- });
1644
- }
1645
-
1646
1650
  async function markForStitching(options) {
1647
1651
  const entityRefs = split(options.entityRefs);
1648
1652
  const entityIds = split(options.entityIds);
@@ -7252,4 +7256,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
7252
7256
  exports.createRandomProcessingInterval = createRandomProcessingInterval;
7253
7257
  exports.parseEntityYaml = parseEntityYaml;
7254
7258
  exports.permissionRules = permissionRules;
7255
- //# sourceMappingURL=CatalogBuilder-948d91db.cjs.js.map
7259
+ //# sourceMappingURL=CatalogBuilder-59dba5ef.cjs.js.map