@backstage/plugin-catalog-backend 1.7.2-next.0 → 1.7.2-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,28 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.7.2-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2380506364: The process of adding or modifying fields in the software-catalog search index has been simplified. For more details, see [how to customize fields in the Software Catalog index](https://backstage.io/docs/features/search/how-to-guides#how-to-customize-fields-in-the-software-catalog-index).
8
+ - 9573651919: The previous migration that adds the `search.original_value` column may leave some of the entities not updated. Add a migration script to trigger a reprocessing of the entities.
9
+ - fc73f6aae5: Switched the order of reprocessing statements retroactively in migrations. This only improves the experience for those who at a later time perform a large upgrade of an old Backstage installation.
10
+ - Updated dependencies
11
+ - @backstage/backend-common@0.18.2-next.1
12
+ - @backstage/backend-plugin-api@0.3.2-next.1
13
+ - @backstage/catalog-client@1.3.1-next.0
14
+ - @backstage/catalog-model@1.1.6-next.0
15
+ - @backstage/config@1.0.6
16
+ - @backstage/errors@1.1.4
17
+ - @backstage/integration@1.4.2
18
+ - @backstage/types@1.0.2
19
+ - @backstage/plugin-catalog-common@1.0.11-next.0
20
+ - @backstage/plugin-catalog-node@1.3.3-next.1
21
+ - @backstage/plugin-permission-common@0.7.3
22
+ - @backstage/plugin-permission-node@0.7.5-next.1
23
+ - @backstage/plugin-scaffolder-common@1.2.5-next.0
24
+ - @backstage/plugin-search-common@1.2.1
25
+
3
26
  ## 1.7.2-next.0
4
27
 
5
28
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.7.2-next.0",
3
+ "version": "1.7.2-next.1",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -338,6 +338,9 @@ export declare class CatalogBuilder {
338
338
  private checkMissingExternalProcessors;
339
339
  }
340
340
 
341
+ /** @public */
342
+ export declare type CatalogCollatorEntityTransformer = (entity: Entity) => Omit<CatalogEntityDocument, 'location' | 'authorization'>;
343
+
341
344
  /**
342
345
  * These conditions are used when creating conditional decisions for catalog
343
346
  * entities that are returned by authorization policies.
@@ -524,20 +527,24 @@ export declare class DefaultCatalogCollator {
524
527
  execute(): Promise<CatalogEntityDocument[]>;
525
528
  }
526
529
 
530
+ /** @public */
531
+ export declare const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer;
532
+
527
533
  /** @public */
528
534
  export declare class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {
529
- readonly type: string;
535
+ readonly type = "software-catalog";
530
536
  readonly visibilityPermission: Permission;
531
537
  private locationTemplate;
532
538
  private filter?;
533
539
  private batchSize;
534
540
  private readonly catalogClient;
535
541
  private tokenManager;
542
+ private entityTransformer;
536
543
  static fromConfig(_config: Config, options: DefaultCatalogCollatorFactoryOptions): DefaultCatalogCollatorFactory;
537
544
  private constructor();
538
545
  getCollator(): Promise<Readable>;
539
- private applyArgsToFormat;
540
546
  private execute;
547
+ private applyArgsToFormat;
541
548
  }
542
549
 
543
550
  /** @public */
@@ -548,6 +555,7 @@ export declare type DefaultCatalogCollatorFactoryOptions = {
548
555
  filter?: GetEntitiesRequest['filter'];
549
556
  batchSize?: number;
550
557
  catalogClient?: CatalogApi;
558
+ entityTransformer?: CatalogCollatorEntityTransformer;
551
559
  };
552
560
 
553
561
  export { DeferredEntity }
@@ -330,6 +330,9 @@ export declare class CatalogBuilder {
330
330
  private checkMissingExternalProcessors;
331
331
  }
332
332
 
333
+ /** @public */
334
+ export declare type CatalogCollatorEntityTransformer = (entity: Entity) => Omit<CatalogEntityDocument, 'location' | 'authorization'>;
335
+
333
336
  /* Excluded from this release type: catalogConditions */
334
337
 
335
338
  /** @public */
@@ -439,20 +442,24 @@ export declare class DefaultCatalogCollator {
439
442
  execute(): Promise<CatalogEntityDocument[]>;
440
443
  }
441
444
 
445
+ /** @public */
446
+ export declare const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer;
447
+
442
448
  /** @public */
443
449
  export declare class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {
444
- readonly type: string;
450
+ readonly type = "software-catalog";
445
451
  readonly visibilityPermission: Permission;
446
452
  private locationTemplate;
447
453
  private filter?;
448
454
  private batchSize;
449
455
  private readonly catalogClient;
450
456
  private tokenManager;
457
+ private entityTransformer;
451
458
  static fromConfig(_config: Config, options: DefaultCatalogCollatorFactoryOptions): DefaultCatalogCollatorFactory;
452
459
  private constructor();
453
460
  getCollator(): Promise<Readable>;
454
- private applyArgsToFormat;
455
461
  private execute;
462
+ private applyArgsToFormat;
456
463
  }
457
464
 
458
465
  /** @public */
@@ -463,6 +470,7 @@ export declare type DefaultCatalogCollatorFactoryOptions = {
463
470
  filter?: GetEntitiesRequest['filter'];
464
471
  batchSize?: number;
465
472
  catalogClient?: CatalogApi;
473
+ entityTransformer?: CatalogCollatorEntityTransformer;
466
474
  };
467
475
 
468
476
  export { DeferredEntity }
package/dist/index.cjs.js CHANGED
@@ -952,7 +952,7 @@ function createRandomProcessingInterval(options) {
952
952
  };
953
953
  }
954
954
 
955
- function getDocumentText(entity) {
955
+ const getDocumentText = (entity) => {
956
956
  var _a, _b;
957
957
  const documentTexts = [];
958
958
  documentTexts.push(entity.metadata.description || "");
@@ -962,7 +962,20 @@ function getDocumentText(entity) {
962
962
  }
963
963
  }
964
964
  return documentTexts.join(" : ");
965
- }
965
+ };
966
+ const defaultCatalogCollatorEntityTransformer = (entity) => {
967
+ var _a, _b, _c, _d, _e, _f, _g;
968
+ return {
969
+ title: (_a = entity.metadata.title) != null ? _a : entity.metadata.name,
970
+ text: getDocumentText(entity),
971
+ componentType: ((_c = (_b = entity.spec) == null ? void 0 : _b.type) == null ? void 0 : _c.toString()) || "other",
972
+ type: ((_e = (_d = entity.spec) == null ? void 0 : _d.type) == null ? void 0 : _e.toString()) || "other",
973
+ namespace: entity.metadata.namespace || "default",
974
+ kind: entity.kind,
975
+ lifecycle: ((_f = entity.spec) == null ? void 0 : _f.lifecycle) || "",
976
+ owner: ((_g = entity.spec) == null ? void 0 : _g.owner) || ""
977
+ };
978
+ };
966
979
 
967
980
  class DefaultCatalogCollatorFactory {
968
981
  constructor(options) {
@@ -974,13 +987,15 @@ class DefaultCatalogCollatorFactory {
974
987
  locationTemplate,
975
988
  filter,
976
989
  catalogClient: catalogClient$1,
977
- tokenManager
990
+ tokenManager,
991
+ entityTransformer
978
992
  } = options;
979
993
  this.locationTemplate = locationTemplate || "/catalog/:namespace/:kind/:name";
980
994
  this.filter = filter;
981
995
  this.batchSize = batchSize || 500;
982
996
  this.catalogClient = catalogClient$1 || new catalogClient.CatalogClient({ discoveryApi: discovery });
983
997
  this.tokenManager = tokenManager;
998
+ this.entityTransformer = entityTransformer != null ? entityTransformer : defaultCatalogCollatorEntityTransformer;
984
999
  }
985
1000
  static fromConfig(_config, options) {
986
1001
  return new DefaultCatalogCollatorFactory(options);
@@ -988,15 +1003,7 @@ class DefaultCatalogCollatorFactory {
988
1003
  async getCollator() {
989
1004
  return stream.Readable.from(this.execute());
990
1005
  }
991
- applyArgsToFormat(format, args) {
992
- let formatted = format;
993
- for (const [key, value] of Object.entries(args)) {
994
- formatted = formatted.replace(`:${key}`, value);
995
- }
996
- return formatted.toLowerCase();
997
- }
998
1006
  async *execute() {
999
- var _a, _b, _c, _d, _e, _f, _g;
1000
1007
  const { token } = await this.tokenManager.getToken();
1001
1008
  let entitiesRetrieved = 0;
1002
1009
  let moreEntitiesToGet = true;
@@ -1013,26 +1020,26 @@ class DefaultCatalogCollatorFactory {
1013
1020
  entitiesRetrieved += entities.length;
1014
1021
  for (const entity of entities) {
1015
1022
  yield {
1016
- title: (_a = entity.metadata.title) != null ? _a : entity.metadata.name,
1023
+ ...this.entityTransformer(entity),
1024
+ authorization: {
1025
+ resourceRef: catalogModel.stringifyEntityRef(entity)
1026
+ },
1017
1027
  location: this.applyArgsToFormat(this.locationTemplate, {
1018
1028
  namespace: entity.metadata.namespace || "default",
1019
1029
  kind: entity.kind,
1020
1030
  name: entity.metadata.name
1021
- }),
1022
- text: getDocumentText(entity),
1023
- componentType: ((_c = (_b = entity.spec) == null ? void 0 : _b.type) == null ? void 0 : _c.toString()) || "other",
1024
- type: ((_e = (_d = entity.spec) == null ? void 0 : _d.type) == null ? void 0 : _e.toString()) || "other",
1025
- namespace: entity.metadata.namespace || "default",
1026
- kind: entity.kind,
1027
- lifecycle: ((_f = entity.spec) == null ? void 0 : _f.lifecycle) || "",
1028
- owner: ((_g = entity.spec) == null ? void 0 : _g.owner) || "",
1029
- authorization: {
1030
- resourceRef: catalogModel.stringifyEntityRef(entity)
1031
- }
1031
+ })
1032
1032
  };
1033
1033
  }
1034
1034
  }
1035
1035
  }
1036
+ applyArgsToFormat(format, args) {
1037
+ let formatted = format;
1038
+ for (const [key, value] of Object.entries(args)) {
1039
+ formatted = formatted.replace(`:${key}`, value);
1040
+ }
1041
+ return formatted.toLowerCase();
1042
+ }
1036
1043
  }
1037
1044
 
1038
1045
  class DefaultCatalogCollator {