@backstage/plugin-catalog-backend 1.9.2-next.1 → 1.10.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,64 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 44c7ad6b8e11: Adds an optional `EventBroker` that is used for sending an event when there are conflicts, with details of the conflict so that it can be handled elsewhere.
8
+
9
+ ### Patch Changes
10
+
11
+ - 77e04a2d55be: Replace getBearerToken with library function of same
12
+ - ee411e7c2623: Update OpenAPI specs to be in line with linting standards.
13
+ - b8374d5d93b6: Add a base plate for performance testing of the catalog
14
+ - Updated dependencies
15
+ - @backstage/backend-common@0.19.0
16
+ - @backstage/catalog-client@1.4.2
17
+ - @backstage/types@1.1.0
18
+ - @backstage/integration@1.5.0
19
+ - @backstage/catalog-model@1.4.0
20
+ - @backstage/errors@1.2.0
21
+ - @backstage/backend-plugin-api@0.5.3
22
+ - @backstage/backend-tasks@0.5.3
23
+ - @backstage/plugin-auth-node@0.2.15
24
+ - @backstage/plugin-catalog-node@1.3.7
25
+ - @backstage/plugin-permission-node@0.7.9
26
+ - @backstage/plugin-search-backend-module-catalog@0.1.2
27
+ - @backstage/config@1.0.8
28
+ - @backstage/plugin-catalog-common@1.0.14
29
+ - @backstage/plugin-events-node@0.2.7
30
+ - @backstage/plugin-permission-common@0.7.6
31
+ - @backstage/plugin-scaffolder-common@1.3.1
32
+ - @backstage/plugin-search-common@1.2.4
33
+
34
+ ## 1.10.0-next.2
35
+
36
+ ### Minor Changes
37
+
38
+ - 44c7ad6b8e11: Adds an optional `EventBroker` that is used for sending an event when there are conflicts, with details of the conflict so that it can be handled elsewhere.
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies
43
+ - @backstage/backend-common@0.19.0-next.2
44
+ - @backstage/catalog-model@1.4.0-next.1
45
+ - @backstage/backend-plugin-api@0.5.3-next.2
46
+ - @backstage/backend-tasks@0.5.3-next.2
47
+ - @backstage/catalog-client@1.4.2-next.2
48
+ - @backstage/config@1.0.7
49
+ - @backstage/errors@1.2.0-next.0
50
+ - @backstage/integration@1.5.0-next.0
51
+ - @backstage/types@1.0.2
52
+ - @backstage/plugin-auth-node@0.2.15-next.2
53
+ - @backstage/plugin-catalog-common@1.0.14-next.1
54
+ - @backstage/plugin-catalog-node@1.3.7-next.2
55
+ - @backstage/plugin-events-node@0.2.7-next.2
56
+ - @backstage/plugin-permission-common@0.7.6-next.0
57
+ - @backstage/plugin-permission-node@0.7.9-next.2
58
+ - @backstage/plugin-scaffolder-common@1.3.1-next.1
59
+ - @backstage/plugin-search-backend-module-catalog@0.1.2-next.2
60
+ - @backstage/plugin-search-common@1.2.4-next.0
61
+
3
62
  ## 1.9.2-next.1
4
63
 
5
64
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.9.2-next.1",
3
+ "version": "1.10.0",
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-99a535c6.cjs.js');
7
+ var CatalogBuilder = require('./cjs/CatalogBuilder-26406e82.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');
@@ -1220,6 +1220,8 @@ function generateStableHash$1(entity) {
1220
1220
  return crypto.createHash("sha1").update(stableStringify__default["default"]({ ...entity })).digest("hex");
1221
1221
  }
1222
1222
 
1223
+ const CATALOG_CONFLICTS_TOPIC = "experimental.catalog.conflict";
1224
+
1223
1225
  const BATCH_SIZE$2 = 50;
1224
1226
  class DefaultProcessingDatabase {
1225
1227
  constructor(options) {
@@ -1389,6 +1391,7 @@ class DefaultProcessingDatabase {
1389
1391
  * The entities will be added at the front of the processing queue.
1390
1392
  */
1391
1393
  async addUnprocessedEntities(txOpaque, options) {
1394
+ var _a;
1392
1395
  const tx = txOpaque;
1393
1396
  const stateReferences = new Array();
1394
1397
  for (const { entity, locationKey } of options.entities) {
@@ -1424,6 +1427,19 @@ class DefaultProcessingDatabase {
1424
1427
  this.options.logger.warn(
1425
1428
  `Detected conflicting entityRef ${entityRef} already referenced by ${conflictingKey} and now also ${locationKey}`
1426
1429
  );
1430
+ if (this.options.eventBroker && locationKey) {
1431
+ const eventParams = {
1432
+ topic: CATALOG_CONFLICTS_TOPIC,
1433
+ eventPayload: {
1434
+ unprocessedEntity: entity,
1435
+ entityRef,
1436
+ newLocationKey: locationKey,
1437
+ existingLocationKey: conflictingKey,
1438
+ lastConflictAt: luxon.DateTime.now().toISO()
1439
+ }
1440
+ };
1441
+ await ((_a = this.options.eventBroker) == null ? void 0 : _a.publish(eventParams));
1442
+ }
1427
1443
  }
1428
1444
  }
1429
1445
  await tx("refresh_state_references").andWhere({ source_entity_ref: options.sourceEntityRef }).delete();
@@ -4794,6 +4810,13 @@ class CatalogBuilder {
4794
4810
  this.legacySingleProcessorValidation = true;
4795
4811
  return this;
4796
4812
  }
4813
+ /**
4814
+ * Enables the publishing of events for cloflicts in the DefaultProcessingDatabase
4815
+ */
4816
+ setEventBroker(broker) {
4817
+ this.eventBroker = broker;
4818
+ return this;
4819
+ }
4797
4820
  /**
4798
4821
  * Wires up and returns all of the component parts of the catalog
4799
4822
  */
@@ -4811,7 +4834,8 @@ class CatalogBuilder {
4811
4834
  const processingDatabase = new DefaultProcessingDatabase({
4812
4835
  database: dbClient,
4813
4836
  logger,
4814
- refreshInterval: this.processingInterval
4837
+ refreshInterval: this.processingInterval,
4838
+ eventBroker: this.eventBroker
4815
4839
  });
4816
4840
  const providerDatabase = new DefaultProviderDatabase({
4817
4841
  database: dbClient,
@@ -5068,6 +5092,7 @@ class CatalogBuilder {
5068
5092
 
5069
5093
  exports.AnnotateLocationEntityProcessor = AnnotateLocationEntityProcessor;
5070
5094
  exports.BuiltinKindsEntityProcessor = BuiltinKindsEntityProcessor;
5095
+ exports.CATALOG_CONFLICTS_TOPIC = CATALOG_CONFLICTS_TOPIC;
5071
5096
  exports.CatalogBuilder = CatalogBuilder;
5072
5097
  exports.CodeOwnersProcessor = CodeOwnersProcessor;
5073
5098
  exports.FileReaderProcessor = FileReaderProcessor;
@@ -5077,4 +5102,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
5077
5102
  exports.createRandomProcessingInterval = createRandomProcessingInterval;
5078
5103
  exports.parseEntityYaml = parseEntityYaml;
5079
5104
  exports.permissionRules = permissionRules;
5080
- //# sourceMappingURL=CatalogBuilder-99a535c6.cjs.js.map
5105
+ //# sourceMappingURL=CatalogBuilder-26406e82.cjs.js.map