@backstage/plugin-catalog-backend 0.21.0-next.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,99 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9f2a8dc423: **BREAKING**: Removed all remnants of the old catalog engine implementation.
8
+
9
+ The old implementation has been deprecated for over half a year. To ensure that
10
+ you are not using the old implementation, check that your
11
+ `packages/backend/src/plugins/catalog.ts` creates the catalog builder using
12
+ `CatalogBuilder.create`. If you instead call `new CatalogBuilder`, you are on
13
+ the old implementation and will experience breakage if you upgrade to this
14
+ version. If you are still on the old version, see [the relevant change log
15
+ entry](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend/CHANGELOG.md#patch-changes-27)
16
+ for migration instructions.
17
+
18
+ The minimal `packages/backend/src/plugins/catalog.ts` file is now:
19
+
20
+ ```ts
21
+ export default async function createPlugin(
22
+ env: PluginEnvironment,
23
+ ): Promise<Router> {
24
+ const builder = await CatalogBuilder.create(env);
25
+ builder.addProcessor(new ScaffolderEntitiesProcessor());
26
+ const { processingEngine, router } = await builder.build();
27
+ await processingEngine.start();
28
+ return router;
29
+ }
30
+ ```
31
+
32
+ The following classes and interfaces have been removed:
33
+
34
+ - The `CatalogBuilder` constructor (see above; use `CatalogBuilder.create`
35
+ instead)
36
+ - `AddLocationResult`
37
+ - `CommonDatabase`
38
+ - `CreateDatabaseOptions`
39
+ - `createNextRouter` (use `createRouter` instead - or preferably, use the
40
+ `router` field returned for you by `catalogBuilder.build()`)
41
+ - `Database`
42
+ - `DatabaseEntitiesCatalog` (use `EntitiesCatalog` instead)
43
+ - `DatabaseLocationsCatalog` (use `LocationService` instead)
44
+ - `DatabaseLocationUpdateLogEvent`
45
+ - `DatabaseLocationUpdateLogStatus`
46
+ - `DatabaseManager`
47
+ - `DbEntitiesRequest`
48
+ - `DbEntitiesResponse`
49
+ - `DbEntityRequest`
50
+ - `DbEntityResponse`
51
+ - `DbLocationsRow`
52
+ - `DbLocationsRowWithStatus`
53
+ - `DbPageInfo`
54
+ - `EntitiesCatalog.batchAddOrUpdateEntities` (was only used by the legacy
55
+ engine)
56
+ - `EntityUpsertRequest`
57
+ - `EntityUpsertResponse`
58
+ - `HigherOrderOperation`
59
+ - `HigherOrderOperations`
60
+ - `LocationReader`
61
+ - `LocationReaders`
62
+ - `LocationResponse`
63
+ - `LocationsCatalog`
64
+ - `LocationUpdateLogEvent`
65
+ - `LocationUpdateStatus`
66
+ - `NextCatalogBuilder` (use `CatalogBuilder.create` instead)
67
+ - `NextRouterOptions` (use `RouterOptions` instead)
68
+ - `ReadLocationEntity`
69
+ - `ReadLocationError`
70
+ - `ReadLocationResult`
71
+ - `Transaction`
72
+
73
+ The `RouterOptions` interface has been un-deprecated, and has instead found use
74
+ for passing into `createRouter`. Its shape has been significantly changed to
75
+ accommodate the new router.
76
+
77
+ ### Patch Changes
78
+
79
+ - e15ce5c16e: Integrate authorization into the delete entities endpoint
80
+ - dce98a92f7: Now when entities are deleted, the parent entity state is updated such that it will "heal" accidental deletes on the next refresh round.
81
+ - 02687954ca: Fixed a typo and made a little clarification to a warning message
82
+ - 48248e2db5: Integrate permissions into entity ancestry endpoint in catalog-backend
83
+ - 68edbbeafd: Fix bug with resource loading in permission integration
84
+ - 7e38acaa9e: Integrate permissions into catalog-backend location endpoints
85
+ - 6680853e0c: Export conditional permission policy helpers from catalog-backend
86
+ - 2b27e49eb1: Internal update to match status field changes in `@backstage/catalog-model`.
87
+ - Updated dependencies
88
+ - @backstage/integration@0.7.2
89
+ - @backstage/plugin-permission-common@0.4.0
90
+ - @backstage/backend-common@0.10.4
91
+ - @backstage/config@0.1.13
92
+ - @backstage/plugin-permission-node@0.4.0
93
+ - @backstage/plugin-catalog-common@0.1.1
94
+ - @backstage/catalog-model@0.9.10
95
+ - @backstage/catalog-client@0.5.5
96
+
3
97
  ## 0.21.0-next.0
4
98
 
5
99
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -4235,6 +4235,41 @@ class AuthorizedEntitiesCatalog {
4235
4235
  }
4236
4236
  }
4237
4237
 
4238
+ class AuthorizedLocationService {
4239
+ constructor(locationService, permissionApi) {
4240
+ this.locationService = locationService;
4241
+ this.permissionApi = permissionApi;
4242
+ }
4243
+ async createLocation(spec, dryRun, options) {
4244
+ const authorizationResponse = (await this.permissionApi.authorize([{ permission: pluginCatalogCommon.catalogLocationCreatePermission }], { token: options == null ? void 0 : options.authorizationToken }))[0];
4245
+ if (authorizationResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
4246
+ throw new errors.NotAllowedError();
4247
+ }
4248
+ return this.locationService.createLocation(spec, dryRun);
4249
+ }
4250
+ async listLocations(options) {
4251
+ const authorizationResponse = (await this.permissionApi.authorize([{ permission: pluginCatalogCommon.catalogLocationReadPermission }], { token: options == null ? void 0 : options.authorizationToken }))[0];
4252
+ if (authorizationResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
4253
+ return [];
4254
+ }
4255
+ return this.locationService.listLocations();
4256
+ }
4257
+ async getLocation(id, options) {
4258
+ const authorizationResponse = (await this.permissionApi.authorize([{ permission: pluginCatalogCommon.catalogLocationReadPermission }], { token: options == null ? void 0 : options.authorizationToken }))[0];
4259
+ if (authorizationResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
4260
+ throw new errors.NotFoundError(`Found no location with ID ${id}`);
4261
+ }
4262
+ return this.locationService.getLocation(id);
4263
+ }
4264
+ async deleteLocation(id, options) {
4265
+ const authorizationResponse = (await this.permissionApi.authorize([{ permission: pluginCatalogCommon.catalogLocationDeletePermission }], { token: options == null ? void 0 : options.authorizationToken }))[0];
4266
+ if (authorizationResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
4267
+ throw new errors.NotAllowedError();
4268
+ }
4269
+ return this.locationService.deleteLocation(id);
4270
+ }
4271
+ }
4272
+
4238
4273
  class CatalogBuilder {
4239
4274
  constructor(env) {
4240
4275
  this.refreshInterval = createRandomRefreshInterval({
@@ -4384,7 +4419,7 @@ class CatalogBuilder {
4384
4419
  const entityProviders = lodash__default["default"].uniqBy([...this.entityProviders, locationStore, configLocationProvider], (provider) => provider.getProviderName());
4385
4420
  const processingEngine = new DefaultCatalogProcessingEngine(logger, processingDatabase, orchestrator, stitcher, () => crypto.createHash("sha1"));
4386
4421
  const locationAnalyzer = (_b = this.locationAnalyzer) != null ? _b : new RepoLocationAnalyzer(logger, integrations);
4387
- const locationService = new DefaultLocationService(locationStore, orchestrator);
4422
+ const locationService = new AuthorizedLocationService(new DefaultLocationService(locationStore, orchestrator), permissions);
4388
4423
  const refreshService = new AuthorizedRefreshService(new DefaultRefreshService({ database: processingDatabase }), permissions);
4389
4424
  const router = await createRouter({
4390
4425
  entitiesCatalog,
@@ -4455,6 +4490,14 @@ class CatalogBuilder {
4455
4490
  }
4456
4491
  }
4457
4492
 
4493
+ const conditionExports = pluginPermissionNode.createConditionExports({
4494
+ pluginId: "catalog",
4495
+ resourceType: pluginCatalogCommon.RESOURCE_TYPE_CATALOG_ENTITY,
4496
+ rules: permissionRules
4497
+ });
4498
+ const catalogConditions = conditionExports.conditions;
4499
+ const createCatalogPolicyDecision = conditionExports.createPolicyDecision;
4500
+
4458
4501
  exports.AnnotateLocationEntityProcessor = AnnotateLocationEntityProcessor;
4459
4502
  exports.AnnotateScmSlugEntityProcessor = AnnotateScmSlugEntityProcessor;
4460
4503
  exports.AwsOrganizationCloudAccountProcessor = AwsOrganizationCloudAccountProcessor;
@@ -4477,7 +4520,9 @@ exports.LocationEntityProcessor = LocationEntityProcessor;
4477
4520
  exports.PlaceholderProcessor = PlaceholderProcessor;
4478
4521
  exports.StaticLocationProcessor = StaticLocationProcessor;
4479
4522
  exports.UrlReaderProcessor = UrlReaderProcessor;
4523
+ exports.catalogConditions = catalogConditions;
4480
4524
  exports.createCatalogPermissionRule = createCatalogPermissionRule;
4525
+ exports.createCatalogPolicyDecision = createCatalogPolicyDecision;
4481
4526
  exports.createRandomRefreshInterval = createRandomRefreshInterval;
4482
4527
  exports.createRouter = createRouter;
4483
4528
  exports.durationText = durationText;