@backstage/plugin-catalog-backend 1.16.2 → 1.17.0-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 +53 -2
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +1 -1
- package/dist/cjs/{CatalogBuilder-59dba5ef.cjs.js → CatalogBuilder-2dd9e66c.cjs.js} +107 -6
- package/dist/cjs/CatalogBuilder-2dd9e66c.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/package.json +16 -16
- package/dist/cjs/CatalogBuilder-59dba5ef.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,61 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.17.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 43dad25: Add API to get location by entity
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
-
|
|
11
|
+
- 89b674c: Minor performance improvement for `queryEntities` when the limit is 0.
|
|
12
|
+
- efa8160: Rollback the change for wildcard discovery, this fixes a bug with the `AzureUrlReader` not working with wildcard paths
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/catalog-model@1.4.4-next.0
|
|
15
|
+
- @backstage/catalog-client@1.6.0-next.1
|
|
16
|
+
- @backstage/backend-plugin-api@0.6.10-next.1
|
|
17
|
+
- @backstage/backend-common@0.21.0-next.1
|
|
18
|
+
- @backstage/integration@1.9.0-next.0
|
|
19
|
+
- @backstage/backend-openapi-utils@0.1.3-next.1
|
|
20
|
+
- @backstage/backend-tasks@0.5.15-next.1
|
|
21
|
+
- @backstage/config@1.1.1
|
|
22
|
+
- @backstage/errors@1.2.3
|
|
23
|
+
- @backstage/types@1.1.1
|
|
24
|
+
- @backstage/plugin-auth-node@0.4.4-next.1
|
|
25
|
+
- @backstage/plugin-catalog-common@1.0.21-next.0
|
|
26
|
+
- @backstage/plugin-catalog-node@1.6.2-next.1
|
|
27
|
+
- @backstage/plugin-events-node@0.2.19-next.1
|
|
28
|
+
- @backstage/plugin-permission-common@0.7.12
|
|
29
|
+
- @backstage/plugin-permission-node@0.7.21-next.1
|
|
30
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.14-next.1
|
|
31
|
+
|
|
32
|
+
## 1.17.0-next.0
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- 126c2f9: Updates the OpenAPI spec to use plugin as `info.title` instead of package name.
|
|
37
|
+
- 04907c3: Updates the OpenAPI specification title to plugin ID instead of package name.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies
|
|
42
|
+
- @backstage/backend-common@0.21.0-next.0
|
|
43
|
+
- @backstage/backend-openapi-utils@0.1.3-next.0
|
|
44
|
+
- @backstage/catalog-client@1.6.0-next.0
|
|
45
|
+
- @backstage/backend-tasks@0.5.15-next.0
|
|
46
|
+
- @backstage/plugin-auth-node@0.4.4-next.0
|
|
47
|
+
- @backstage/plugin-catalog-node@1.6.2-next.0
|
|
48
|
+
- @backstage/plugin-permission-node@0.7.21-next.0
|
|
49
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.14-next.0
|
|
50
|
+
- @backstage/backend-plugin-api@0.6.10-next.0
|
|
51
|
+
- @backstage/catalog-model@1.4.3
|
|
52
|
+
- @backstage/config@1.1.1
|
|
53
|
+
- @backstage/errors@1.2.3
|
|
54
|
+
- @backstage/integration@1.8.0
|
|
55
|
+
- @backstage/types@1.1.1
|
|
56
|
+
- @backstage/plugin-catalog-common@1.0.20
|
|
57
|
+
- @backstage/plugin-events-node@0.2.19-next.0
|
|
58
|
+
- @backstage/plugin-permission-common@0.7.12
|
|
8
59
|
|
|
9
60
|
## 1.16.1
|
|
10
61
|
|
package/alpha/package.json
CHANGED
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-
|
|
7
|
+
var CatalogBuilder = require('./cjs/CatalogBuilder-2dd9e66c.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');
|
|
@@ -947,6 +947,30 @@ class DefaultLocationStore {
|
|
|
947
947
|
removed: [{ entity, locationKey: getEntityLocationRef(entity) }]
|
|
948
948
|
});
|
|
949
949
|
}
|
|
950
|
+
async getLocationByEntity(entityRef) {
|
|
951
|
+
const entityRefString = catalogModel.stringifyEntityRef(entityRef);
|
|
952
|
+
const [entity] = await this.db("refresh_state").where({ entity_ref: entityRefString }).select("entity_id").limit(1);
|
|
953
|
+
if (!entity) {
|
|
954
|
+
throw new errors.NotFoundError(`found no entity for ref ${entityRefString}`);
|
|
955
|
+
}
|
|
956
|
+
const [locationKeyValue] = await this.db("search").where({
|
|
957
|
+
entity_id: entity.entity_id,
|
|
958
|
+
key: `metadata.annotations.${catalogModel.ANNOTATION_ORIGIN_LOCATION}`
|
|
959
|
+
}).select("value").limit(1);
|
|
960
|
+
if (!locationKeyValue) {
|
|
961
|
+
throw new errors.NotFoundError(
|
|
962
|
+
`found no origin annotation for ref ${entityRefString}`
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
const { type, target } = catalogModel.parseLocationRef(entityRefString);
|
|
966
|
+
const [location] = await this.db("locations").where({ type, target }).select().limit(1);
|
|
967
|
+
if (!location) {
|
|
968
|
+
throw new errors.NotFoundError(
|
|
969
|
+
`Found no location with type ${type} and target ${target}`
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
return location;
|
|
973
|
+
}
|
|
950
974
|
get connection() {
|
|
951
975
|
if (!this._connection) {
|
|
952
976
|
throw new Error("location store is not initialized");
|
|
@@ -2133,6 +2157,9 @@ class DefaultLocationService {
|
|
|
2133
2157
|
deleteLocation(id) {
|
|
2134
2158
|
return this.store.deleteLocation(id);
|
|
2135
2159
|
}
|
|
2160
|
+
getLocationByEntity(entityRef) {
|
|
2161
|
+
return this.store.getLocationByEntity(catalogModel.parseEntityRef(entityRef));
|
|
2162
|
+
}
|
|
2136
2163
|
async processEntities(unprocessedEntities) {
|
|
2137
2164
|
const entities = [];
|
|
2138
2165
|
while (unprocessedEntities.length) {
|
|
@@ -2559,7 +2586,7 @@ class DefaultEntitiesCatalog {
|
|
|
2559
2586
|
]).limit(isFetchingBackwards ? limit : limit + 1);
|
|
2560
2587
|
countQuery.count("search.entity_id", { as: "count" });
|
|
2561
2588
|
const [rows, [{ count }]] = await Promise.all([
|
|
2562
|
-
dbQuery,
|
|
2589
|
+
limit > 0 ? dbQuery : [],
|
|
2563
2590
|
// for performance reasons we invoke the countQuery
|
|
2564
2591
|
// only on the first request.
|
|
2565
2592
|
// The result is then embedded into the cursor
|
|
@@ -3914,7 +3941,7 @@ function parseEntityOrderParams(params) {
|
|
|
3914
3941
|
const spec = {
|
|
3915
3942
|
openapi: "3.0.3",
|
|
3916
3943
|
info: {
|
|
3917
|
-
title: "
|
|
3944
|
+
title: "catalog",
|
|
3918
3945
|
version: "1",
|
|
3919
3946
|
description: "The Backstage backend plugin that provides the Backstage catalog",
|
|
3920
3947
|
license: {
|
|
@@ -3926,9 +3953,6 @@ const spec = {
|
|
|
3926
3953
|
servers: [
|
|
3927
3954
|
{
|
|
3928
3955
|
url: "/"
|
|
3929
|
-
},
|
|
3930
|
-
{
|
|
3931
|
-
url: "catalog"
|
|
3932
3956
|
}
|
|
3933
3957
|
],
|
|
3934
3958
|
components: {
|
|
@@ -5274,6 +5298,62 @@ const spec = {
|
|
|
5274
5298
|
]
|
|
5275
5299
|
}
|
|
5276
5300
|
},
|
|
5301
|
+
"/locations/by-entity/{kind}/{namespace}/{name}": {
|
|
5302
|
+
get: {
|
|
5303
|
+
operationId: "getLocationByEntity",
|
|
5304
|
+
description: "Get a location for entity.",
|
|
5305
|
+
responses: {
|
|
5306
|
+
"200": {
|
|
5307
|
+
description: "Ok",
|
|
5308
|
+
content: {
|
|
5309
|
+
"application/json": {
|
|
5310
|
+
schema: {
|
|
5311
|
+
$ref: "#/components/schemas/Location"
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
},
|
|
5316
|
+
default: {
|
|
5317
|
+
$ref: "#/components/responses/ErrorResponse"
|
|
5318
|
+
}
|
|
5319
|
+
},
|
|
5320
|
+
security: [
|
|
5321
|
+
{},
|
|
5322
|
+
{
|
|
5323
|
+
JWT: []
|
|
5324
|
+
}
|
|
5325
|
+
],
|
|
5326
|
+
parameters: [
|
|
5327
|
+
{
|
|
5328
|
+
in: "path",
|
|
5329
|
+
name: "kind",
|
|
5330
|
+
required: true,
|
|
5331
|
+
allowReserved: true,
|
|
5332
|
+
schema: {
|
|
5333
|
+
type: "string"
|
|
5334
|
+
}
|
|
5335
|
+
},
|
|
5336
|
+
{
|
|
5337
|
+
in: "path",
|
|
5338
|
+
name: "namespace",
|
|
5339
|
+
required: true,
|
|
5340
|
+
allowReserved: true,
|
|
5341
|
+
schema: {
|
|
5342
|
+
type: "string"
|
|
5343
|
+
}
|
|
5344
|
+
},
|
|
5345
|
+
{
|
|
5346
|
+
in: "path",
|
|
5347
|
+
name: "name",
|
|
5348
|
+
required: true,
|
|
5349
|
+
allowReserved: true,
|
|
5350
|
+
schema: {
|
|
5351
|
+
type: "string"
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
]
|
|
5355
|
+
}
|
|
5356
|
+
},
|
|
5277
5357
|
"/analyze-location": {
|
|
5278
5358
|
post: {
|
|
5279
5359
|
operationId: "AnalyzeLocation",
|
|
@@ -5601,6 +5681,17 @@ async function createRouter(options) {
|
|
|
5601
5681
|
)
|
|
5602
5682
|
});
|
|
5603
5683
|
res.status(204).end();
|
|
5684
|
+
}).get("/locations/by-entity/:kind/:namespace/:name", async (req, res) => {
|
|
5685
|
+
const { kind, namespace, name } = req.params;
|
|
5686
|
+
const output = await locationService.getLocationByEntity(
|
|
5687
|
+
{ kind, namespace, name },
|
|
5688
|
+
{
|
|
5689
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
5690
|
+
req.header("authorization")
|
|
5691
|
+
)
|
|
5692
|
+
}
|
|
5693
|
+
);
|
|
5694
|
+
res.status(200).json(output);
|
|
5604
5695
|
});
|
|
5605
5696
|
}
|
|
5606
5697
|
if (locationAnalyzer) {
|
|
@@ -6322,6 +6413,16 @@ class AuthorizedLocationService {
|
|
|
6322
6413
|
}
|
|
6323
6414
|
return this.locationService.deleteLocation(id);
|
|
6324
6415
|
}
|
|
6416
|
+
async getLocationByEntity(entityRef, options) {
|
|
6417
|
+
const authorizationResponse = (await this.permissionApi.authorize(
|
|
6418
|
+
[{ permission: alpha.catalogLocationReadPermission }],
|
|
6419
|
+
{ token: options == null ? void 0 : options.authorizationToken }
|
|
6420
|
+
))[0];
|
|
6421
|
+
if (authorizationResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
|
|
6422
|
+
throw new errors.NotFoundError();
|
|
6423
|
+
}
|
|
6424
|
+
return this.locationService.getLocationByEntity(entityRef);
|
|
6425
|
+
}
|
|
6325
6426
|
}
|
|
6326
6427
|
|
|
6327
6428
|
async function deleteWithEagerPruningOfChildren(options) {
|
|
@@ -7256,4 +7357,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
|
|
|
7256
7357
|
exports.createRandomProcessingInterval = createRandomProcessingInterval;
|
|
7257
7358
|
exports.parseEntityYaml = parseEntityYaml;
|
|
7258
7359
|
exports.permissionRules = permissionRules;
|
|
7259
|
-
//# sourceMappingURL=CatalogBuilder-
|
|
7360
|
+
//# sourceMappingURL=CatalogBuilder-2dd9e66c.cjs.js.map
|