@backstage/plugin-catalog-backend 1.24.1-next.3 → 1.25.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,45 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.25.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2fb4670: Fixed an issue with the by-query call, where ordering by a field that does not exist on all entities led to not all results being returned
8
+
9
+ ## 1.25.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 163ba08: Deprecated `RouterOptions`, `CatalogBuilder`, and `CatalogEnvironment`. Please make sure to upgrade to the new backend system.
14
+ - fc24d9e: Stop using `@backstage/backend-tasks` as it will be deleted in near future.
15
+
16
+ ### Patch Changes
17
+
18
+ - 776eb56: `ProcessorOutputCollector` returns an error when receiving deferred entities that have an invalid `metadata.annotations` format.
19
+
20
+ This allows to return an error on an actual validation issue instead of reporting that the location annotations are missing afterwards, which is misleading for the users.
21
+
22
+ - 389f5a4: Update deprecated url-reader-related imports.
23
+ - 93095ee: Make sure node-fetch is version 2.7.0 or greater
24
+ - a629fb2: Added setAllowedLocationTypes while introducing a new extension point called CatalogLocationsExtensionPoint
25
+ - 51240ee: Preserve default `allowedLocationTypes` when `setAllowedLocationTypes()` of `CatalogLocationsExtensionPoint` is not called.
26
+ - Updated dependencies
27
+ - @backstage/backend-plugin-api@0.8.0
28
+ - @backstage/backend-common@0.24.0
29
+ - @backstage/plugin-permission-common@0.8.1
30
+ - @backstage/plugin-permission-node@0.8.1
31
+ - @backstage/plugin-search-backend-module-catalog@0.2.0
32
+ - @backstage/plugin-catalog-node@1.12.5
33
+ - @backstage/integration@1.14.0
34
+ - @backstage/catalog-model@1.6.0
35
+ - @backstage/backend-openapi-utils@0.1.16
36
+ - @backstage/catalog-client@1.6.6
37
+ - @backstage/config@1.2.0
38
+ - @backstage/errors@1.2.4
39
+ - @backstage/types@1.1.1
40
+ - @backstage/plugin-catalog-common@1.0.26
41
+ - @backstage/plugin-events-node@0.3.9
42
+
3
43
  ## 1.24.1-next.3
4
44
 
5
45
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend__alpha",
3
- "version": "1.24.1-next.3",
3
+ "version": "1.25.1",
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-D0vAEZa8.cjs.js');
7
+ var CatalogBuilder = require('./cjs/CatalogBuilder-C7ANIkk3.cjs.js');
8
8
  var backendPluginApi = require('@backstage/backend-plugin-api');
9
9
  var pluginEventsNode = require('@backstage/plugin-events-node');
10
10
  var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
@@ -2496,9 +2496,18 @@ class DefaultEntitiesCatalog {
2496
2496
  ...cursor.orderFields[0]
2497
2497
  };
2498
2498
  const [prevItemOrderFieldValue, prevItemUid] = cursor.orderFieldValues || [];
2499
- const dbQuery = db("search").join("final_entities", "search.entity_id", "final_entities.entity_id").where("search.key", sortField.field);
2499
+ const dbQuery = db("final_entities").leftOuterJoin(
2500
+ "search",
2501
+ (qb) => qb.on("search.entity_id", "final_entities.entity_id").andOnVal("search.key", sortField.field)
2502
+ );
2500
2503
  if (cursor.filter) {
2501
- parseFilter(cursor.filter, dbQuery, db, false, "search.entity_id");
2504
+ parseFilter(
2505
+ cursor.filter,
2506
+ dbQuery,
2507
+ db,
2508
+ false,
2509
+ "final_entities.entity_id"
2510
+ );
2502
2511
  }
2503
2512
  const normalizedFullTextFilterTerm = cursor.fullTextFilter?.term?.trim();
2504
2513
  const textFilterFields = cursor.fullTextFilter?.fields ?? [sortField.field];
@@ -2515,7 +2524,7 @@ class DefaultEntitiesCatalog {
2515
2524
  `%${normalizedFullTextFilterTerm.toLocaleLowerCase("en-US")}%`
2516
2525
  );
2517
2526
  });
2518
- dbQuery.andWhere("search.entity_id", "in", matchQuery);
2527
+ dbQuery.andWhere("final_entities.entity_id", "in", matchQuery);
2519
2528
  }
2520
2529
  }
2521
2530
  const countQuery = dbQuery.clone();
@@ -2527,23 +2536,43 @@ class DefaultEntitiesCatalog {
2527
2536
  isFetchingBackwards !== isOrderingDescending ? "<" : ">",
2528
2537
  prevItemOrderFieldValue
2529
2538
  ).orWhere("value", "=", prevItemOrderFieldValue).andWhere(
2530
- "search.entity_id",
2539
+ "final_entities.entity_id",
2531
2540
  isFetchingBackwards !== isOrderingDescending ? "<" : ">",
2532
2541
  prevItemUid
2533
2542
  );
2534
2543
  });
2535
2544
  }
2536
- dbQuery.orderBy([
2537
- {
2538
- column: "value",
2539
- order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order
2540
- },
2541
- {
2542
- column: "search.entity_id",
2543
- order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order
2544
- }
2545
- ]).limit(isFetchingBackwards ? limit : limit + 1);
2546
- countQuery.count("search.entity_id", { as: "count" });
2545
+ if (db.client.config.client === "pg") {
2546
+ dbQuery.orderBy([
2547
+ {
2548
+ column: "search.value",
2549
+ order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order,
2550
+ nulls: "last"
2551
+ },
2552
+ {
2553
+ column: "final_entities.entity_id",
2554
+ order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order
2555
+ }
2556
+ ]);
2557
+ } else {
2558
+ dbQuery.orderBy([
2559
+ {
2560
+ column: "search.value",
2561
+ order: void 0,
2562
+ nulls: "last"
2563
+ },
2564
+ {
2565
+ column: "search.value",
2566
+ order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order
2567
+ },
2568
+ {
2569
+ column: "final_entities.entity_id",
2570
+ order: isFetchingBackwards ? invertOrder(sortField.order) : sortField.order
2571
+ }
2572
+ ]);
2573
+ }
2574
+ dbQuery.limit(isFetchingBackwards ? limit : limit + 1);
2575
+ countQuery.count("final_entities.entity_id", { as: "count" });
2547
2576
  const [rows, [{ count }]] = await Promise.all([
2548
2577
  limit > 0 ? dbQuery : [],
2549
2578
  // for performance reasons we invoke the countQuery
@@ -2787,20 +2816,24 @@ class ProcessorOutputCollector {
2787
2816
  return;
2788
2817
  }
2789
2818
  const annotations = entity.metadata.annotations || {};
2790
- if (typeof annotations === "object" && !Array.isArray(annotations)) {
2791
- const originLocation = getEntityOriginLocationRef(this.parentEntity);
2792
- entity = {
2793
- ...entity,
2794
- metadata: {
2795
- ...entity.metadata,
2796
- annotations: {
2797
- ...annotations,
2798
- [catalogModel.ANNOTATION_ORIGIN_LOCATION]: originLocation,
2799
- [catalogModel.ANNOTATION_LOCATION]: location
2800
- }
2801
- }
2802
- };
2819
+ if (typeof annotations !== "object" || Array.isArray(annotations)) {
2820
+ this.errors.push(
2821
+ new Error("metadata.annotations must be a valid object")
2822
+ );
2823
+ return;
2803
2824
  }
2825
+ const originLocation = getEntityOriginLocationRef(this.parentEntity);
2826
+ entity = {
2827
+ ...entity,
2828
+ metadata: {
2829
+ ...entity.metadata,
2830
+ annotations: {
2831
+ ...annotations,
2832
+ [catalogModel.ANNOTATION_ORIGIN_LOCATION]: originLocation,
2833
+ [catalogModel.ANNOTATION_LOCATION]: location
2834
+ }
2835
+ }
2836
+ };
2804
2837
  this.deferredEntities.push({ entity, locationKey: location });
2805
2838
  } else if (i.type === "location") {
2806
2839
  const entity = locationSpecToLocationEntity({
@@ -7255,4 +7288,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
7255
7288
  exports.createRandomProcessingInterval = createRandomProcessingInterval;
7256
7289
  exports.parseEntityYaml = parseEntityYaml;
7257
7290
  exports.permissionRules = permissionRules;
7258
- //# sourceMappingURL=CatalogBuilder-D0vAEZa8.cjs.js.map
7291
+ //# sourceMappingURL=CatalogBuilder-C7ANIkk3.cjs.js.map