@backstage/plugin-catalog-backend 1.3.1-next.1 → 1.3.2-next.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,48 @@
1
1
  # @backstage/plugin-catalog-backend
2
2
 
3
+ ## 1.3.2-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 243533ecdc: Added support to mysql on some raw queries
8
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
9
+ - 62788b2ee8: The experimental `CatalogProcessingExtensionPoint` now accepts multiple providers and processors at once.
10
+ - Updated dependencies
11
+ - @backstage/backend-common@0.15.1-next.0
12
+ - @backstage/backend-plugin-api@0.1.2-next.0
13
+ - @backstage/catalog-client@1.0.5-next.0
14
+ - @backstage/integration@1.3.1-next.0
15
+ - @backstage/plugin-permission-common@0.6.4-next.0
16
+ - @backstage/plugin-permission-node@0.6.5-next.0
17
+ - @backstage/plugin-scaffolder-common@1.2.0-next.0
18
+ - @backstage/plugin-catalog-node@1.0.2-next.0
19
+ - @backstage/plugin-catalog-common@1.0.6-next.0
20
+ - @backstage/plugin-search-common@1.0.1-next.0
21
+
22
+ ## 1.3.1
23
+
24
+ ### Patch Changes
25
+
26
+ - 56e1b4b89c: Fixed typos in alpha types.
27
+ - e3d3018531: Fix issue for conditional decisions based on properties stored as arrays, like tags.
28
+
29
+ Before this change, having a permission policy returning conditional decisions based on metadata like tags, such like `createCatalogConditionalDecision(permission, catalogConditions.hasMetadata('tags', 'java'),)`, was producing wrong results. The issue occurred when authorizing entities already loaded from the database, for example when authorizing `catalogEntityDeletePermission`.
30
+
31
+ - 059ae348b4: Use the non-deprecated form of table.unique in knex
32
+ - Updated dependencies
33
+ - @backstage/backend-common@0.15.0
34
+ - @backstage/backend-plugin-api@0.1.1
35
+ - @backstage/plugin-catalog-node@1.0.1
36
+ - @backstage/integration@1.3.0
37
+ - @backstage/plugin-catalog-common@1.0.5
38
+ - @backstage/plugin-permission-node@0.6.4
39
+
40
+ ## 1.3.1-next.2
41
+
42
+ ### Patch Changes
43
+
44
+ - 059ae348b4: Use the non-deprecated form of table.unique in knex
45
+
3
46
  ## 1.3.1-next.1
4
47
 
5
48
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend",
3
- "version": "1.3.1-next.1",
3
+ "version": "1.3.2-next.0",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  /// <reference types="node" />
8
8
 
9
- import { BackendRegistrable } from '@backstage/backend-plugin-api';
9
+ import { BackendFeature } from '@backstage/backend-plugin-api';
10
10
  import { CatalogApi } from '@backstage/catalog-client';
11
11
  import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
12
12
  import { CatalogProcessor } from '@backstage/plugin-catalog-node';
@@ -349,7 +349,7 @@ export declare type CatalogPermissionRule<TParams extends unknown[] = unknown[]>
349
349
  * Catalog plugin
350
350
  * @alpha
351
351
  */
352
- export declare const catalogPlugin: (option: unknown) => BackendRegistrable;
352
+ export declare const catalogPlugin: (options?: unknown) => BackendFeature;
353
353
 
354
354
  /** @public */
355
355
  export declare interface CatalogProcessingEngine {
@@ -6,7 +6,7 @@
6
6
 
7
7
  /// <reference types="node" />
8
8
 
9
- import { BackendRegistrable } from '@backstage/backend-plugin-api';
9
+ import { BackendFeature } from '@backstage/backend-plugin-api';
10
10
  import { CatalogApi } from '@backstage/catalog-client';
11
11
  import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
12
12
  import { CatalogProcessor } from '@backstage/plugin-catalog-node';
package/dist/index.cjs.js CHANGED
@@ -1506,7 +1506,7 @@ class DefaultProcessingDatabase {
1506
1506
  sourceEntityRef
1507
1507
  });
1508
1508
  let previousRelationRows;
1509
- if (tx.client.config.client.includes("sqlite3")) {
1509
+ if (tx.client.config.client.includes("sqlite3") || tx.client.config.client.includes("mysql")) {
1510
1510
  previousRelationRows = await tx("relations").select("*").where({ originating_entity_id: id });
1511
1511
  await tx("relations").where({ originating_entity_id: id }).delete();
1512
1512
  } else {
@@ -1558,6 +1558,12 @@ class DefaultProcessingDatabase {
1558
1558
  const { toAdd, toUpsert, toRemove } = await this.createDelta(tx, options);
1559
1559
  if (toRemove.length) {
1560
1560
  let removedCount = 0;
1561
+ const rootId = () => {
1562
+ if (tx.client.config.client.includes("mysql")) {
1563
+ return tx.raw("CAST(NULL as UNSIGNED INT)", []);
1564
+ }
1565
+ return tx.raw("CAST(NULL as INT)", []);
1566
+ };
1561
1567
  for (const refs of lodash__default["default"].chunk(toRemove, 1e3)) {
1562
1568
  removedCount += await tx("refresh_state").whereIn("entity_ref", function orphanedEntityRefs(orphans) {
1563
1569
  return orphans.withRecursive("descendants", function descendants(outer) {
@@ -1571,7 +1577,7 @@ class DefaultProcessingDatabase {
1571
1577
  });
1572
1578
  }).withRecursive("ancestors", function ancestors(outer) {
1573
1579
  return outer.select({
1574
- root_id: tx.raw("CAST(NULL as INT)", []),
1580
+ root_id: rootId(),
1575
1581
  via_entity_ref: "entity_ref",
1576
1582
  to_entity_ref: "entity_ref"
1577
1583
  }).from("descendants").union(function recursive(inner) {
@@ -1695,11 +1701,20 @@ class DefaultProcessingDatabase {
1695
1701
  }
1696
1702
  const items = await itemsQuery.where("next_update_at", "<=", tx.fn.now()).limit(request.processBatchSize).orderBy("next_update_at", "asc");
1697
1703
  const interval = this.options.refreshInterval();
1704
+ const nextUpdateAt = (refreshInterval) => {
1705
+ if (tx.client.config.client.includes("sqlite3")) {
1706
+ return tx.raw(`datetime('now', ?)`, [`${refreshInterval} seconds`]);
1707
+ }
1708
+ if (tx.client.config.client.includes("mysql")) {
1709
+ return tx.raw(`now() + interval ${refreshInterval} second`);
1710
+ }
1711
+ return tx.raw(`now() + interval '${refreshInterval} seconds'`);
1712
+ };
1698
1713
  await tx("refresh_state").whereIn(
1699
1714
  "entity_ref",
1700
1715
  items.map((i) => i.entity_ref)
1701
1716
  ).update({
1702
- next_update_at: tx.client.config.client.includes("sqlite3") ? tx.raw(`datetime('now', ?)`, [`${interval} seconds`]) : tx.raw(`now() + interval '${interval} seconds'`)
1717
+ next_update_at: nextUpdateAt(interval)
1703
1718
  });
1704
1719
  return {
1705
1720
  items: items.map(
@@ -4234,11 +4249,11 @@ class CatalogExtensionPointImpl {
4234
4249
  __privateAdd(this, _processors, new Array());
4235
4250
  __privateAdd(this, _entityProviders, new Array());
4236
4251
  }
4237
- addProcessor(processor) {
4238
- __privateGet(this, _processors).push(processor);
4252
+ addProcessor(...processors) {
4253
+ __privateGet(this, _processors).push(...processors.flat());
4239
4254
  }
4240
- addEntityProvider(provider) {
4241
- __privateGet(this, _entityProviders).push(provider);
4255
+ addEntityProvider(...providers) {
4256
+ __privateGet(this, _entityProviders).push(...providers.flat());
4242
4257
  }
4243
4258
  get processors() {
4244
4259
  return __privateGet(this, _processors);
@@ -4254,7 +4269,7 @@ const catalogPlugin = backendPluginApi.createBackendPlugin({
4254
4269
  register(env) {
4255
4270
  const processingExtensions = new CatalogExtensionPointImpl();
4256
4271
  env.registerExtensionPoint(
4257
- pluginCatalogNode.catalogProcessingExtentionPoint,
4272
+ pluginCatalogNode.catalogProcessingExtensionPoint,
4258
4273
  processingExtensions
4259
4274
  );
4260
4275
  env.registerInit({