@backstage/plugin-catalog-backend 1.4.0 → 1.4.1-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,48 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.4.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/catalog-client@1.1.1-next.1
9
+ - @backstage/backend-common@0.15.2-next.1
10
+ - @backstage/backend-plugin-api@0.1.3-next.1
11
+ - @backstage/plugin-search-common@1.1.0-next.1
12
+ - @backstage/catalog-model@1.1.2-next.1
13
+ - @backstage/config@1.0.3-next.1
14
+ - @backstage/errors@1.1.2-next.1
15
+ - @backstage/integration@1.3.2-next.1
16
+ - @backstage/types@1.0.0
17
+ - @backstage/plugin-catalog-common@1.0.7-next.1
18
+ - @backstage/plugin-catalog-node@1.1.1-next.1
19
+ - @backstage/plugin-permission-common@0.6.5-next.1
20
+ - @backstage/plugin-permission-node@0.6.6-next.1
21
+ - @backstage/plugin-scaffolder-common@1.2.1-next.1
22
+
23
+ ## 1.4.1-next.0
24
+
25
+ ### Patch Changes
26
+
27
+ - 8cb6e10105: Fixed a bug where entities provided without a location key would always replace existing entities, rather than updating them.
28
+ - 63296ebcd4: Allow Placeholder value to be any value, not only string.
29
+ - 74022e0163: Make sure to stitch entities correctly after deletion, to ensure that their relations are updated.
30
+ - Updated dependencies
31
+ - @backstage/catalog-model@1.1.2-next.0
32
+ - @backstage/backend-plugin-api@0.1.3-next.0
33
+ - @backstage/catalog-client@1.1.1-next.0
34
+ - @backstage/plugin-catalog-node@1.1.1-next.0
35
+ - @backstage/plugin-scaffolder-common@1.2.1-next.0
36
+ - @backstage/backend-common@0.15.2-next.0
37
+ - @backstage/plugin-permission-node@0.6.6-next.0
38
+ - @backstage/config@1.0.3-next.0
39
+ - @backstage/errors@1.1.2-next.0
40
+ - @backstage/integration@1.3.2-next.0
41
+ - @backstage/types@1.0.0
42
+ - @backstage/plugin-catalog-common@1.0.7-next.0
43
+ - @backstage/plugin-permission-common@0.6.5-next.0
44
+ - @backstage/plugin-search-common@1.0.2-next.0
45
+
3
46
  ## 1.4.0
4
47
 
5
48
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.4.0",
3
+ "version": "1.4.1-next.1",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
package/dist/index.cjs.js CHANGED
@@ -608,7 +608,7 @@ class PlaceholderProcessor {
608
608
  const resolverKey = keys[0].substr(1);
609
609
  const resolverValue = data[keys[0]];
610
610
  const resolver = this.options.resolvers[resolverKey];
611
- if (!resolver || typeof resolverValue !== "string") {
611
+ if (!resolver) {
612
612
  return [data, false];
613
613
  }
614
614
  const read = async (url) => {
@@ -1872,6 +1872,7 @@ class DefaultProcessingDatabase {
1872
1872
  );
1873
1873
  }
1874
1874
  async createDelta(tx, options) {
1875
+ var _a, _b;
1875
1876
  if (options.type === "delta") {
1876
1877
  return {
1877
1878
  toAdd: [],
@@ -1914,7 +1915,7 @@ class DefaultProcessingDatabase {
1914
1915
  const upsertItem = { deferred: item.deferred, hash: item.hash };
1915
1916
  if (!oldRef) {
1916
1917
  toAdd.push(upsertItem);
1917
- } else if (oldRef.locationKey !== item.deferred.locationKey) {
1918
+ } else if (((_a = oldRef == null ? void 0 : oldRef.locationKey) != null ? _a : void 0) !== ((_b = item.deferred.locationKey) != null ? _b : void 0)) {
1918
1919
  toRemove.push(item.ref);
1919
1920
  toAdd.push(upsertItem);
1920
1921
  } else if (oldRef.oldEntityHash !== item.hash) {
@@ -2032,7 +2033,7 @@ function startTaskPipeline(options) {
2032
2033
 
2033
2034
  const CACHE_TTL = 5;
2034
2035
  class DefaultCatalogProcessingEngine {
2035
- constructor(logger, processingDatabase, orchestrator, stitcher, createHash, pollingIntervalMs = 1e3, onProcessingError) {
2036
+ constructor(logger, processingDatabase, orchestrator, stitcher, createHash, pollingIntervalMs = 1e3, onProcessingError, tracker = progressTracker()) {
2036
2037
  this.logger = logger;
2037
2038
  this.processingDatabase = processingDatabase;
2038
2039
  this.orchestrator = orchestrator;
@@ -2040,7 +2041,7 @@ class DefaultCatalogProcessingEngine {
2040
2041
  this.createHash = createHash;
2041
2042
  this.pollingIntervalMs = pollingIntervalMs;
2042
2043
  this.onProcessingError = onProcessingError;
2043
- this.tracker = progressTracker();
2044
+ this.tracker = tracker;
2044
2045
  }
2045
2046
  async start() {
2046
2047
  if (this.stopFunc) {
@@ -2443,8 +2444,9 @@ function parseFilter(filter, query, db, negate = false) {
2443
2444
  });
2444
2445
  }
2445
2446
  class DefaultEntitiesCatalog {
2446
- constructor(database) {
2447
+ constructor(database, stitcher) {
2447
2448
  this.database = database;
2449
+ this.stitcher = stitcher;
2448
2450
  }
2449
2451
  async entities(request) {
2450
2452
  const db = this.database;
@@ -2496,13 +2498,22 @@ class DefaultEntitiesCatalog {
2496
2498
  }
2497
2499
  async removeEntityByUid(uid) {
2498
2500
  await this.database("refresh_state").update({
2499
- result_hash: "child-was-deleted"
2501
+ result_hash: "child-was-deleted",
2502
+ next_update_at: this.database.fn.now()
2500
2503
  }).whereIn("entity_ref", function parents(builder) {
2501
2504
  return builder.from("refresh_state").innerJoin("refresh_state_references", {
2502
2505
  "refresh_state_references.target_entity_ref": "refresh_state.entity_ref"
2503
2506
  }).where("refresh_state.entity_id", "=", uid).select("refresh_state_references.source_entity_ref");
2504
2507
  });
2508
+ const relationPeers = await this.database.from("relations").innerJoin("refresh_state", {
2509
+ "refresh_state.entity_ref": "relations.target_entity_ref"
2510
+ }).where("relations.originating_entity_id", "=", uid).andWhere("refresh_state.entity_id", "!=", uid).select({ ref: "relations.target_entity_ref" }).union(
2511
+ (other) => other.from("relations").innerJoin("refresh_state", {
2512
+ "refresh_state.entity_ref": "relations.source_entity_ref"
2513
+ }).where("relations.originating_entity_id", "=", uid).andWhere("refresh_state.entity_id", "!=", uid).select({ ref: "relations.source_entity_ref" })
2514
+ );
2505
2515
  await this.database("refresh_state").where("entity_id", uid).delete();
2516
+ await this.stitcher.stitch(new Set(relationPeers.map((p) => p.ref)));
2506
2517
  }
2507
2518
  async entityAncestry(rootRef) {
2508
2519
  const [rootRow] = await this.database("refresh_state").leftJoin("final_entities", {
@@ -4050,7 +4061,11 @@ class CatalogBuilder {
4050
4061
  parser,
4051
4062
  policy
4052
4063
  });
4053
- const unauthorizedEntitiesCatalog = new DefaultEntitiesCatalog(dbClient);
4064
+ const stitcher = new Stitcher(dbClient, logger);
4065
+ const unauthorizedEntitiesCatalog = new DefaultEntitiesCatalog(
4066
+ dbClient,
4067
+ stitcher
4068
+ );
4054
4069
  let permissionEvaluator;
4055
4070
  if ("authorizeConditional" in permissions) {
4056
4071
  permissionEvaluator = permissions;
@@ -4088,7 +4103,6 @@ class CatalogBuilder {
4088
4103
  permissions: pluginCatalogCommon.catalogPermissions,
4089
4104
  rules: this.permissionRules
4090
4105
  });
4091
- const stitcher = new Stitcher(dbClient, logger);
4092
4106
  const locationStore = new DefaultLocationStore(dbClient);
4093
4107
  const configLocationProvider = new ConfigLocationEntityProvider(config);
4094
4108
  const entityProviders = lodash__default["default"].uniqBy(