@backstage/plugin-catalog-node 1.13.1-next.0 → 1.13.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 +15 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +8 -35
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/api/processingResult.cjs.js +65 -0
- package/dist/api/processingResult.cjs.js.map +1 -0
- package/dist/catalogService.cjs.js +20 -0
- package/dist/catalogService.cjs.js.map +1 -0
- package/dist/conversion.cjs.js +63 -0
- package/dist/conversion.cjs.js.map +1 -0
- package/dist/extensions.cjs.js +26 -0
- package/dist/extensions.cjs.js.map +1 -0
- package/dist/index.cjs.js +5 -118
- package/dist/index.cjs.js.map +1 -1
- package/dist/testUtils/catalogServiceMock.cjs.js +56 -0
- package/dist/testUtils/catalogServiceMock.cjs.js.map +1 -0
- package/dist/testUtils.cjs.js +6 -51
- package/dist/testUtils.cjs.js.map +1 -1
- package/package.json +14 -11
- package/testUtils/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-node
|
|
2
2
|
|
|
3
|
+
## 1.13.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0801db6: Documentation for the `testUtils` named export
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/catalog-client@1.7.1-next.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
11
|
+
- @backstage/catalog-model@1.7.0
|
|
12
|
+
- @backstage/errors@1.2.4
|
|
13
|
+
- @backstage/types@1.1.1
|
|
14
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
15
|
+
- @backstage/plugin-permission-common@0.8.1
|
|
16
|
+
- @backstage/plugin-permission-node@0.8.4-next.1
|
|
17
|
+
|
|
3
18
|
## 1.13.1-next.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var catalogService = require('./catalogService.cjs.js');
|
|
4
|
+
var extensions = require('./extensions.cjs.js');
|
|
5
5
|
|
|
6
|
-
const catalogServiceRef = backendPluginApi.createServiceRef({
|
|
7
|
-
id: "catalog-client",
|
|
8
|
-
defaultFactory: async (service) => backendPluginApi.createServiceFactory({
|
|
9
|
-
service,
|
|
10
|
-
deps: {
|
|
11
|
-
discoveryApi: backendPluginApi.coreServices.discovery
|
|
12
|
-
},
|
|
13
|
-
async factory({ discoveryApi }) {
|
|
14
|
-
return new catalogClient.CatalogClient({ discoveryApi });
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
});
|
|
18
6
|
|
|
19
|
-
const catalogLocationsExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
20
|
-
id: "catalog.locations"
|
|
21
|
-
});
|
|
22
|
-
const catalogProcessingExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
23
|
-
id: "catalog.processing"
|
|
24
|
-
});
|
|
25
|
-
const catalogAnalysisExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
26
|
-
id: "catalog.analysis"
|
|
27
|
-
});
|
|
28
|
-
const catalogModelExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
29
|
-
id: "catalog.model"
|
|
30
|
-
});
|
|
31
|
-
const catalogPermissionExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
32
|
-
id: "catalog.permission"
|
|
33
|
-
});
|
|
34
7
|
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.
|
|
8
|
+
exports.catalogServiceRef = catalogService.catalogServiceRef;
|
|
9
|
+
exports.catalogAnalysisExtensionPoint = extensions.catalogAnalysisExtensionPoint;
|
|
10
|
+
exports.catalogLocationsExtensionPoint = extensions.catalogLocationsExtensionPoint;
|
|
11
|
+
exports.catalogModelExtensionPoint = extensions.catalogModelExtensionPoint;
|
|
12
|
+
exports.catalogPermissionExtensionPoint = extensions.catalogPermissionExtensionPoint;
|
|
13
|
+
exports.catalogProcessingExtensionPoint = extensions.catalogProcessingExtensionPoint;
|
|
41
14
|
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@backstage/errors');
|
|
4
|
+
|
|
5
|
+
const processingResult = Object.freeze({
|
|
6
|
+
/**
|
|
7
|
+
* Associates a NotFoundError with the processing state of the current entity.
|
|
8
|
+
*/
|
|
9
|
+
notFoundError(atLocation, message) {
|
|
10
|
+
return {
|
|
11
|
+
type: "error",
|
|
12
|
+
location: atLocation,
|
|
13
|
+
error: new errors.NotFoundError(message)
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Associates an InputError with the processing state of the current entity.
|
|
18
|
+
*/
|
|
19
|
+
inputError(atLocation, message) {
|
|
20
|
+
return {
|
|
21
|
+
type: "error",
|
|
22
|
+
location: atLocation,
|
|
23
|
+
error: new errors.InputError(message)
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Associates a general Error with the processing state of the current entity.
|
|
28
|
+
*/
|
|
29
|
+
generalError(atLocation, message) {
|
|
30
|
+
return { type: "error", location: atLocation, error: new Error(message) };
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Emits a location. In effect, this is analogous to emitting a Location kind
|
|
34
|
+
* child entity. This is commonly used in discovery processors. Do not use
|
|
35
|
+
* this while processing Location entities.
|
|
36
|
+
*/
|
|
37
|
+
location(newLocation) {
|
|
38
|
+
return { type: "location", location: newLocation };
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Emits a child of the current entity, associated with a certain location.
|
|
42
|
+
*/
|
|
43
|
+
entity(atLocation, newEntity) {
|
|
44
|
+
return { type: "entity", location: atLocation, entity: newEntity };
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Emits a relation owned by the current entity. The relation does not have to
|
|
48
|
+
* start or end at the current entity. The relation only lives for as long as
|
|
49
|
+
* the current entity lives.
|
|
50
|
+
*/
|
|
51
|
+
relation(spec) {
|
|
52
|
+
return { type: "relation", relation: spec };
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Associates the given refresh key with the current entity. The effect of
|
|
56
|
+
* this is that the entity will be marked for refresh when such requests are
|
|
57
|
+
* made.
|
|
58
|
+
*/
|
|
59
|
+
refresh(key) {
|
|
60
|
+
return { type: "refresh", key };
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
exports.processingResult = processingResult;
|
|
65
|
+
//# sourceMappingURL=processingResult.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processingResult.cjs.js","sources":["../../src/api/processingResult.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError, NotFoundError } from '@backstage/errors';\nimport { Entity } from '@backstage/catalog-model';\nimport { CatalogProcessorResult } from './processor';\nimport { EntityRelationSpec } from './common';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\n\n/**\n * Factory functions for the standard processing result types.\n *\n * @public\n */\nexport const processingResult = Object.freeze({\n /**\n * Associates a NotFoundError with the processing state of the current entity.\n */\n notFoundError(\n atLocation: LocationSpec,\n message: string,\n ): CatalogProcessorResult {\n return {\n type: 'error',\n location: atLocation,\n error: new NotFoundError(message),\n };\n },\n\n /**\n * Associates an InputError with the processing state of the current entity.\n */\n inputError(\n atLocation: LocationSpec,\n message: string,\n ): CatalogProcessorResult {\n return {\n type: 'error',\n location: atLocation,\n error: new InputError(message),\n };\n },\n\n /**\n * Associates a general Error with the processing state of the current entity.\n */\n generalError(\n atLocation: LocationSpec,\n message: string,\n ): CatalogProcessorResult {\n return { type: 'error', location: atLocation, error: new Error(message) };\n },\n\n /**\n * Emits a location. In effect, this is analogous to emitting a Location kind\n * child entity. This is commonly used in discovery processors. Do not use\n * this while processing Location entities.\n */\n location(newLocation: LocationSpec): CatalogProcessorResult {\n return { type: 'location', location: newLocation };\n },\n\n /**\n * Emits a child of the current entity, associated with a certain location.\n */\n entity(atLocation: LocationSpec, newEntity: Entity): CatalogProcessorResult {\n return { type: 'entity', location: atLocation, entity: newEntity };\n },\n\n /**\n * Emits a relation owned by the current entity. The relation does not have to\n * start or end at the current entity. The relation only lives for as long as\n * the current entity lives.\n */\n relation(spec: EntityRelationSpec): CatalogProcessorResult {\n return { type: 'relation', relation: spec };\n },\n\n /**\n * Associates the given refresh key with the current entity. The effect of\n * this is that the entity will be marked for refresh when such requests are\n * made.\n */\n refresh(key: string): CatalogProcessorResult {\n return { type: 'refresh', key };\n },\n} as const);\n"],"names":["NotFoundError","InputError"],"mappings":";;;;AA2Ba,MAAA,gBAAA,GAAmB,OAAO,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,EAI5C,aAAA,CACE,YACA,OACwB,EAAA;AACxB,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,QAAU,EAAA,UAAA;AAAA,MACV,KAAA,EAAO,IAAIA,oBAAA,CAAc,OAAO,CAAA;AAAA,KAClC,CAAA;AAAA,GACF;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,CACE,YACA,OACwB,EAAA;AACxB,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,QAAU,EAAA,UAAA;AAAA,MACV,KAAA,EAAO,IAAIC,iBAAA,CAAW,OAAO,CAAA;AAAA,KAC/B,CAAA;AAAA,GACF;AAAA;AAAA;AAAA;AAAA,EAKA,YAAA,CACE,YACA,OACwB,EAAA;AACxB,IAAO,OAAA,EAAE,MAAM,OAAS,EAAA,QAAA,EAAU,YAAY,KAAO,EAAA,IAAI,KAAM,CAAA,OAAO,CAAE,EAAA,CAAA;AAAA,GAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,WAAmD,EAAA;AAC1D,IAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,QAAA,EAAU,WAAY,EAAA,CAAA;AAAA,GACnD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA,CAAO,YAA0B,SAA2C,EAAA;AAC1E,IAAA,OAAO,EAAE,IAAM,EAAA,QAAA,EAAU,QAAU,EAAA,UAAA,EAAY,QAAQ,SAAU,EAAA,CAAA;AAAA,GACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,IAAkD,EAAA;AACzD,IAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,QAAA,EAAU,IAAK,EAAA,CAAA;AAAA,GAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAQ,GAAqC,EAAA;AAC3C,IAAO,OAAA,EAAE,IAAM,EAAA,SAAA,EAAW,GAAI,EAAA,CAAA;AAAA,GAChC;AACF,CAAU;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var catalogClient = require('@backstage/catalog-client');
|
|
5
|
+
|
|
6
|
+
const catalogServiceRef = backendPluginApi.createServiceRef({
|
|
7
|
+
id: "catalog-client",
|
|
8
|
+
defaultFactory: async (service) => backendPluginApi.createServiceFactory({
|
|
9
|
+
service,
|
|
10
|
+
deps: {
|
|
11
|
+
discoveryApi: backendPluginApi.coreServices.discovery
|
|
12
|
+
},
|
|
13
|
+
async factory({ discoveryApi }) {
|
|
14
|
+
return new catalogClient.CatalogClient({ discoveryApi });
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
exports.catalogServiceRef = catalogServiceRef;
|
|
20
|
+
//# sourceMappingURL=catalogService.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogService.cjs.js","sources":["../src/catalogService.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createServiceFactory,\n createServiceRef,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\n\n/**\n * The catalogService provides the catalog API.\n * @alpha\n */\nexport const catalogServiceRef = createServiceRef<CatalogApi>({\n id: 'catalog-client',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n discoveryApi: coreServices.discovery,\n },\n async factory({ discoveryApi }) {\n return new CatalogClient({ discoveryApi });\n },\n }),\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","CatalogClient"],"mappings":";;;;;AA2BO,MAAM,oBAAoBA,iCAA6B,CAAA;AAAA,EAC5D,EAAI,EAAA,gBAAA;AAAA,EACJ,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAqB,CAAA;AAAA,IACnB,OAAA;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,cAAcC,6BAAa,CAAA,SAAA;AAAA,KAC7B;AAAA,IACA,MAAM,OAAA,CAAQ,EAAE,YAAA,EAAgB,EAAA;AAC9B,MAAA,OAAO,IAAIC,2BAAA,CAAc,EAAE,YAAA,EAAc,CAAA,CAAA;AAAA,KAC3C;AAAA,GACD,CAAA;AACL,CAAC;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
4
|
+
var crypto = require('crypto');
|
|
5
|
+
|
|
6
|
+
function locationSpecToMetadataName(location) {
|
|
7
|
+
const hash = crypto.createHash("sha1").update(`${location.type}:${location.target}`).digest("hex");
|
|
8
|
+
return `generated-${hash}`;
|
|
9
|
+
}
|
|
10
|
+
function locationSpecToLocationEntity(opts) {
|
|
11
|
+
const location = opts.location;
|
|
12
|
+
const parentEntity = opts.parentEntity;
|
|
13
|
+
let ownLocation;
|
|
14
|
+
let originLocation;
|
|
15
|
+
if (parentEntity) {
|
|
16
|
+
const maybeOwnLocation = parentEntity.metadata.annotations?.[catalogModel.ANNOTATION_LOCATION];
|
|
17
|
+
if (!maybeOwnLocation) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`Parent entity '${catalogModel.stringifyEntityRef(
|
|
20
|
+
parentEntity
|
|
21
|
+
)}' of location '${catalogModel.stringifyLocationRef(
|
|
22
|
+
location
|
|
23
|
+
)}' does not have a location annotation`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
ownLocation = maybeOwnLocation;
|
|
27
|
+
const maybeOriginLocation = parentEntity.metadata.annotations?.[catalogModel.ANNOTATION_ORIGIN_LOCATION];
|
|
28
|
+
if (!maybeOriginLocation) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Parent entity '${catalogModel.stringifyEntityRef(
|
|
31
|
+
parentEntity
|
|
32
|
+
)}' of location '${catalogModel.stringifyLocationRef(
|
|
33
|
+
location
|
|
34
|
+
)}' does not have an origin location annotation`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
originLocation = maybeOriginLocation;
|
|
38
|
+
} else {
|
|
39
|
+
ownLocation = catalogModel.stringifyLocationRef(location);
|
|
40
|
+
originLocation = ownLocation;
|
|
41
|
+
}
|
|
42
|
+
const result = {
|
|
43
|
+
apiVersion: "backstage.io/v1alpha1",
|
|
44
|
+
kind: "Location",
|
|
45
|
+
metadata: {
|
|
46
|
+
name: locationSpecToMetadataName(location),
|
|
47
|
+
annotations: {
|
|
48
|
+
[catalogModel.ANNOTATION_LOCATION]: ownLocation,
|
|
49
|
+
[catalogModel.ANNOTATION_ORIGIN_LOCATION]: originLocation
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
spec: {
|
|
53
|
+
type: location.type,
|
|
54
|
+
target: location.target,
|
|
55
|
+
presence: location.presence
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.locationSpecToLocationEntity = locationSpecToLocationEntity;
|
|
62
|
+
exports.locationSpecToMetadataName = locationSpecToMetadataName;
|
|
63
|
+
//# sourceMappingURL=conversion.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion.cjs.js","sources":["../src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n LocationEntityV1alpha1,\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n stringifyEntityRef,\n stringifyLocationRef,\n} from '@backstage/catalog-model';\nimport { createHash } from 'crypto';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\n\n/**\n * A standard way of producing a machine generated name for a location.\n *\n * @public\n */\nexport function locationSpecToMetadataName(location: LocationSpec) {\n const hash = createHash('sha1')\n .update(`${location.type}:${location.target}`)\n .digest('hex');\n return `generated-${hash}`;\n}\n\n/**\n * A standard way of producing a machine generated Location kind entity for a\n * location.\n *\n * @public\n */\nexport function locationSpecToLocationEntity(opts: {\n location: LocationSpec;\n parentEntity?: Entity;\n}): LocationEntityV1alpha1 {\n const location = opts.location;\n const parentEntity = opts.parentEntity;\n\n let ownLocation: string;\n let originLocation: string;\n if (parentEntity) {\n const maybeOwnLocation =\n parentEntity.metadata.annotations?.[ANNOTATION_LOCATION];\n if (!maybeOwnLocation) {\n throw new Error(\n `Parent entity '${stringifyEntityRef(\n parentEntity,\n )}' of location '${stringifyLocationRef(\n location,\n )}' does not have a location annotation`,\n );\n }\n ownLocation = maybeOwnLocation;\n const maybeOriginLocation =\n parentEntity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];\n if (!maybeOriginLocation) {\n throw new Error(\n `Parent entity '${stringifyEntityRef(\n parentEntity,\n )}' of location '${stringifyLocationRef(\n location,\n )}' does not have an origin location annotation`,\n );\n }\n originLocation = maybeOriginLocation;\n } else {\n ownLocation = stringifyLocationRef(location);\n originLocation = ownLocation;\n }\n\n const result: LocationEntityV1alpha1 = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Location',\n metadata: {\n name: locationSpecToMetadataName(location),\n annotations: {\n [ANNOTATION_LOCATION]: ownLocation,\n [ANNOTATION_ORIGIN_LOCATION]: originLocation,\n },\n },\n spec: {\n type: location.type,\n target: location.target,\n presence: location.presence,\n },\n };\n\n return result;\n}\n"],"names":["createHash","ANNOTATION_LOCATION","stringifyEntityRef","stringifyLocationRef","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;AAgCO,SAAS,2BAA2B,QAAwB,EAAA;AACjE,EAAA,MAAM,IAAO,GAAAA,iBAAA,CAAW,MAAM,CAAA,CAC3B,OAAO,CAAG,EAAA,QAAA,CAAS,IAAI,CAAA,CAAA,EAAI,QAAS,CAAA,MAAM,CAAE,CAAA,CAAA,CAC5C,OAAO,KAAK,CAAA,CAAA;AACf,EAAA,OAAO,aAAa,IAAI,CAAA,CAAA,CAAA;AAC1B,CAAA;AAQO,SAAS,6BAA6B,IAGlB,EAAA;AACzB,EAAA,MAAM,WAAW,IAAK,CAAA,QAAA,CAAA;AACtB,EAAA,MAAM,eAAe,IAAK,CAAA,YAAA,CAAA;AAE1B,EAAI,IAAA,WAAA,CAAA;AACJ,EAAI,IAAA,cAAA,CAAA;AACJ,EAAA,IAAI,YAAc,EAAA;AAChB,IAAA,MAAM,gBACJ,GAAA,YAAA,CAAa,QAAS,CAAA,WAAA,GAAcC,gCAAmB,CAAA,CAAA;AACzD,IAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAkB,eAAA,EAAAC,+BAAA;AAAA,UAChB,YAAA;AAAA,SACD,CAAkB,eAAA,EAAAC,iCAAA;AAAA,UACjB,QAAA;AAAA,SACD,CAAA,qCAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AACA,IAAc,WAAA,GAAA,gBAAA,CAAA;AACd,IAAA,MAAM,mBACJ,GAAA,YAAA,CAAa,QAAS,CAAA,WAAA,GAAcC,uCAA0B,CAAA,CAAA;AAChE,IAAA,IAAI,CAAC,mBAAqB,EAAA;AACxB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAkB,eAAA,EAAAF,+BAAA;AAAA,UAChB,YAAA;AAAA,SACD,CAAkB,eAAA,EAAAC,iCAAA;AAAA,UACjB,QAAA;AAAA,SACD,CAAA,6CAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AACA,IAAiB,cAAA,GAAA,mBAAA,CAAA;AAAA,GACZ,MAAA;AACL,IAAA,WAAA,GAAcA,kCAAqB,QAAQ,CAAA,CAAA;AAC3C,IAAiB,cAAA,GAAA,WAAA,CAAA;AAAA,GACnB;AAEA,EAAA,MAAM,MAAiC,GAAA;AAAA,IACrC,UAAY,EAAA,uBAAA;AAAA,IACZ,IAAM,EAAA,UAAA;AAAA,IACN,QAAU,EAAA;AAAA,MACR,IAAA,EAAM,2BAA2B,QAAQ,CAAA;AAAA,MACzC,WAAa,EAAA;AAAA,QACX,CAACF,gCAAmB,GAAG,WAAA;AAAA,QACvB,CAACG,uCAA0B,GAAG,cAAA;AAAA,OAChC;AAAA,KACF;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,MAAM,QAAS,CAAA,IAAA;AAAA,MACf,QAAQ,QAAS,CAAA,MAAA;AAAA,MACjB,UAAU,QAAS,CAAA,QAAA;AAAA,KACrB;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
|
|
5
|
+
const catalogLocationsExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
6
|
+
id: "catalog.locations"
|
|
7
|
+
});
|
|
8
|
+
const catalogProcessingExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
9
|
+
id: "catalog.processing"
|
|
10
|
+
});
|
|
11
|
+
const catalogAnalysisExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
12
|
+
id: "catalog.analysis"
|
|
13
|
+
});
|
|
14
|
+
const catalogModelExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
15
|
+
id: "catalog.model"
|
|
16
|
+
});
|
|
17
|
+
const catalogPermissionExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
18
|
+
id: "catalog.permission"
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
exports.catalogAnalysisExtensionPoint = catalogAnalysisExtensionPoint;
|
|
22
|
+
exports.catalogLocationsExtensionPoint = catalogLocationsExtensionPoint;
|
|
23
|
+
exports.catalogModelExtensionPoint = catalogModelExtensionPoint;
|
|
24
|
+
exports.catalogPermissionExtensionPoint = catalogPermissionExtensionPoint;
|
|
25
|
+
exports.catalogProcessingExtensionPoint = catalogProcessingExtensionPoint;
|
|
26
|
+
//# sourceMappingURL=extensions.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { Entity, Validators } from '@backstage/catalog-model';\nimport {\n CatalogProcessor,\n CatalogProcessorParser,\n EntitiesSearchFilter,\n EntityProvider,\n PlaceholderResolver,\n LocationAnalyzer,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport {\n Permission,\n PermissionRuleParams,\n} from '@backstage/plugin-permission-common';\nimport { PermissionRule } from '@backstage/plugin-permission-node';\n\n/**\n * @alpha\n */\nexport interface CatalogLocationsExtensionPoint {\n /**\n * Allows setting custom location types, such as showcased in: https://backstage.io/docs/features/software-catalog/external-integrations/#creating-a-catalog-data-reader-processor\n * @param locationTypes - List of location types to allow, default is \"url\" and \"file\"\n */\n setAllowedLocationTypes(locationTypes: Array<string>): void;\n}\n\n/**\n * @alpha\n */\nexport const catalogLocationsExtensionPoint =\n createExtensionPoint<CatalogLocationsExtensionPoint>({\n id: 'catalog.locations',\n });\n\n/**\n * @alpha\n */\nexport interface CatalogProcessingExtensionPoint {\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void;\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void;\n addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void;\n setOnProcessingErrorHandler(\n handler: (event: {\n unprocessedEntity: Entity;\n errors: Error[];\n }) => Promise<void> | void,\n ): void;\n}\n\n/** @alpha */\nexport interface CatalogModelExtensionPoint {\n /**\n * Sets the validator function to use for one or more special fields of an\n * entity. This is useful if the default rules for formatting of fields are\n * not sufficient.\n *\n * @param validators - The (subset of) validators to set\n */\n setFieldValidators(validators: Partial<Validators>): void;\n\n /**\n * Sets the entity data parser which is used to read raw data from locations\n * @param parser - Parser which will used to extract entities from raw data\n */\n setEntityDataParser(parser: CatalogProcessorParser): void;\n}\n\n/**\n * @alpha\n */\nexport const catalogProcessingExtensionPoint =\n createExtensionPoint<CatalogProcessingExtensionPoint>({\n id: 'catalog.processing',\n });\n\n/**\n * @alpha\n */\nexport interface CatalogAnalysisExtensionPoint {\n /**\n * Replaces the entire location analyzer with a new one.\n *\n * @remarks\n *\n * By providing a factory function you can access all the SCM analyzers that\n * have been added through `addScmLocationAnalyzer`. If you provide a\n * `LocationAnalyzer` directly, the SCM analyzers will be ignored.\n */\n setLocationAnalyzer(\n analyzerOrFactory:\n | LocationAnalyzer\n | ((options: {\n scmLocationAnalyzers: ScmLocationAnalyzer[];\n }) => Promise<{ locationAnalyzer: LocationAnalyzer }>),\n ): void;\n\n /**\n * Adds an analyzer for a specific SCM type to the default location analyzer.\n */\n addScmLocationAnalyzer(analyzer: ScmLocationAnalyzer): void;\n}\n\n/**\n * @alpha\n */\nexport const catalogAnalysisExtensionPoint =\n createExtensionPoint<CatalogAnalysisExtensionPoint>({\n id: 'catalog.analysis',\n });\n\n/** @alpha */\nexport const catalogModelExtensionPoint =\n createExtensionPoint<CatalogModelExtensionPoint>({\n id: 'catalog.model',\n });\n\n/**\n * @alpha\n */\nexport type CatalogPermissionRuleInput<\n TParams extends PermissionRuleParams = PermissionRuleParams,\n> = PermissionRule<Entity, EntitiesSearchFilter, 'catalog-entity', TParams>;\n\n/**\n * @alpha\n */\nexport interface CatalogPermissionExtensionPoint {\n addPermissions(...permissions: Array<Permission | Array<Permission>>): void;\n addPermissionRules(\n ...rules: Array<\n CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>\n >\n ): void;\n}\n\n/**\n * @alpha\n */\nexport const catalogPermissionExtensionPoint =\n createExtensionPoint<CatalogPermissionExtensionPoint>({\n id: 'catalog.permission',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;AA+CO,MAAM,iCACXA,qCAAqD,CAAA;AAAA,EACnD,EAAI,EAAA,mBAAA;AACN,CAAC,EAAA;AA0CI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC,EAAA;AAgCI,MAAM,gCACXA,qCAAoD,CAAA;AAAA,EAClD,EAAI,EAAA,kBAAA;AACN,CAAC,EAAA;AAGI,MAAM,6BACXA,qCAAiD,CAAA;AAAA,EAC/C,EAAI,EAAA,eAAA;AACN,CAAC,EAAA;AAwBI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC;;;;;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,124 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var crypto = require('crypto');
|
|
3
|
+
var processingResult = require('./api/processingResult.cjs.js');
|
|
4
|
+
var conversion = require('./conversion.cjs.js');
|
|
6
5
|
|
|
7
|
-
const processingResult = Object.freeze({
|
|
8
|
-
/**
|
|
9
|
-
* Associates a NotFoundError with the processing state of the current entity.
|
|
10
|
-
*/
|
|
11
|
-
notFoundError(atLocation, message) {
|
|
12
|
-
return {
|
|
13
|
-
type: "error",
|
|
14
|
-
location: atLocation,
|
|
15
|
-
error: new errors.NotFoundError(message)
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* Associates an InputError with the processing state of the current entity.
|
|
20
|
-
*/
|
|
21
|
-
inputError(atLocation, message) {
|
|
22
|
-
return {
|
|
23
|
-
type: "error",
|
|
24
|
-
location: atLocation,
|
|
25
|
-
error: new errors.InputError(message)
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Associates a general Error with the processing state of the current entity.
|
|
30
|
-
*/
|
|
31
|
-
generalError(atLocation, message) {
|
|
32
|
-
return { type: "error", location: atLocation, error: new Error(message) };
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Emits a location. In effect, this is analogous to emitting a Location kind
|
|
36
|
-
* child entity. This is commonly used in discovery processors. Do not use
|
|
37
|
-
* this while processing Location entities.
|
|
38
|
-
*/
|
|
39
|
-
location(newLocation) {
|
|
40
|
-
return { type: "location", location: newLocation };
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Emits a child of the current entity, associated with a certain location.
|
|
44
|
-
*/
|
|
45
|
-
entity(atLocation, newEntity) {
|
|
46
|
-
return { type: "entity", location: atLocation, entity: newEntity };
|
|
47
|
-
},
|
|
48
|
-
/**
|
|
49
|
-
* Emits a relation owned by the current entity. The relation does not have to
|
|
50
|
-
* start or end at the current entity. The relation only lives for as long as
|
|
51
|
-
* the current entity lives.
|
|
52
|
-
*/
|
|
53
|
-
relation(spec) {
|
|
54
|
-
return { type: "relation", relation: spec };
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* Associates the given refresh key with the current entity. The effect of
|
|
58
|
-
* this is that the entity will be marked for refresh when such requests are
|
|
59
|
-
* made.
|
|
60
|
-
*/
|
|
61
|
-
refresh(key) {
|
|
62
|
-
return { type: "refresh", key };
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
6
|
|
|
66
|
-
function locationSpecToMetadataName(location) {
|
|
67
|
-
const hash = crypto.createHash("sha1").update(`${location.type}:${location.target}`).digest("hex");
|
|
68
|
-
return `generated-${hash}`;
|
|
69
|
-
}
|
|
70
|
-
function locationSpecToLocationEntity(opts) {
|
|
71
|
-
const location = opts.location;
|
|
72
|
-
const parentEntity = opts.parentEntity;
|
|
73
|
-
let ownLocation;
|
|
74
|
-
let originLocation;
|
|
75
|
-
if (parentEntity) {
|
|
76
|
-
const maybeOwnLocation = parentEntity.metadata.annotations?.[catalogModel.ANNOTATION_LOCATION];
|
|
77
|
-
if (!maybeOwnLocation) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
`Parent entity '${catalogModel.stringifyEntityRef(
|
|
80
|
-
parentEntity
|
|
81
|
-
)}' of location '${catalogModel.stringifyLocationRef(
|
|
82
|
-
location
|
|
83
|
-
)}' does not have a location annotation`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
ownLocation = maybeOwnLocation;
|
|
87
|
-
const maybeOriginLocation = parentEntity.metadata.annotations?.[catalogModel.ANNOTATION_ORIGIN_LOCATION];
|
|
88
|
-
if (!maybeOriginLocation) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`Parent entity '${catalogModel.stringifyEntityRef(
|
|
91
|
-
parentEntity
|
|
92
|
-
)}' of location '${catalogModel.stringifyLocationRef(
|
|
93
|
-
location
|
|
94
|
-
)}' does not have an origin location annotation`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
originLocation = maybeOriginLocation;
|
|
98
|
-
} else {
|
|
99
|
-
ownLocation = catalogModel.stringifyLocationRef(location);
|
|
100
|
-
originLocation = ownLocation;
|
|
101
|
-
}
|
|
102
|
-
const result = {
|
|
103
|
-
apiVersion: "backstage.io/v1alpha1",
|
|
104
|
-
kind: "Location",
|
|
105
|
-
metadata: {
|
|
106
|
-
name: locationSpecToMetadataName(location),
|
|
107
|
-
annotations: {
|
|
108
|
-
[catalogModel.ANNOTATION_LOCATION]: ownLocation,
|
|
109
|
-
[catalogModel.ANNOTATION_ORIGIN_LOCATION]: originLocation
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
spec: {
|
|
113
|
-
type: location.type,
|
|
114
|
-
target: location.target,
|
|
115
|
-
presence: location.presence
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
7
|
|
|
121
|
-
exports.
|
|
122
|
-
exports.
|
|
123
|
-
exports.
|
|
8
|
+
exports.processingResult = processingResult.processingResult;
|
|
9
|
+
exports.locationSpecToLocationEntity = conversion.locationSpecToLocationEntity;
|
|
10
|
+
exports.locationSpecToMetadataName = conversion.locationSpecToMetadataName;
|
|
124
11
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var testUtils = require('@backstage/catalog-client/testUtils');
|
|
5
|
+
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
6
|
+
|
|
7
|
+
function simpleMock(ref, mockFactory) {
|
|
8
|
+
return (partialImpl) => {
|
|
9
|
+
const mock = mockFactory();
|
|
10
|
+
if (partialImpl) {
|
|
11
|
+
for (const [key, impl] of Object.entries(partialImpl)) {
|
|
12
|
+
if (typeof impl === "function") {
|
|
13
|
+
mock[key].mockImplementation(impl);
|
|
14
|
+
} else {
|
|
15
|
+
mock[key] = impl;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return Object.assign(mock, {
|
|
20
|
+
factory: backendPluginApi.createServiceFactory({
|
|
21
|
+
service: ref,
|
|
22
|
+
deps: {},
|
|
23
|
+
factory: () => mock
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function catalogServiceMock(options) {
|
|
29
|
+
return new testUtils.InMemoryCatalogClient(options);
|
|
30
|
+
}
|
|
31
|
+
((catalogServiceMock2) => {
|
|
32
|
+
catalogServiceMock2.factory = (options) => backendPluginApi.createServiceFactory({
|
|
33
|
+
service: alpha.catalogServiceRef,
|
|
34
|
+
deps: {},
|
|
35
|
+
factory: () => new testUtils.InMemoryCatalogClient(options)
|
|
36
|
+
});
|
|
37
|
+
catalogServiceMock2.mock = simpleMock(alpha.catalogServiceRef, () => ({
|
|
38
|
+
getEntities: jest.fn(),
|
|
39
|
+
getEntitiesByRefs: jest.fn(),
|
|
40
|
+
queryEntities: jest.fn(),
|
|
41
|
+
getEntityAncestors: jest.fn(),
|
|
42
|
+
getEntityByRef: jest.fn(),
|
|
43
|
+
removeEntityByUid: jest.fn(),
|
|
44
|
+
refreshEntity: jest.fn(),
|
|
45
|
+
getEntityFacets: jest.fn(),
|
|
46
|
+
getLocationById: jest.fn(),
|
|
47
|
+
getLocationByRef: jest.fn(),
|
|
48
|
+
addLocation: jest.fn(),
|
|
49
|
+
removeLocationById: jest.fn(),
|
|
50
|
+
getLocationByEntity: jest.fn(),
|
|
51
|
+
validateEntity: jest.fn()
|
|
52
|
+
}));
|
|
53
|
+
})(catalogServiceMock || (catalogServiceMock = {}));
|
|
54
|
+
|
|
55
|
+
exports.catalogServiceMock = catalogServiceMock;
|
|
56
|
+
//# sourceMappingURL=catalogServiceMock.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogServiceMock.cjs.js","sources":["../../src/testUtils/catalogServiceMock.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ServiceRef,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { ServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogApi } from '@backstage/catalog-client';\n\n/** @internal */\nfunction simpleMock<TService>(\n ref: ServiceRef<TService, any>,\n mockFactory: () => jest.Mocked<TService>,\n): (partialImpl?: Partial<TService>) => ServiceMock<TService> {\n return partialImpl => {\n const mock = mockFactory();\n if (partialImpl) {\n for (const [key, impl] of Object.entries(partialImpl)) {\n if (typeof impl === 'function') {\n (mock as any)[key].mockImplementation(impl);\n } else {\n (mock as any)[key] = impl;\n }\n }\n }\n return Object.assign(mock, {\n factory: createServiceFactory({\n service: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ServiceMock<TService>;\n };\n}\n\n/**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n *\n * @public\n */\nexport function catalogServiceMock(options?: {\n entities?: Entity[];\n}): CatalogApi {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogServiceMock {\n /**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n */\n export const factory = (options?: { entities?: Entity[] }) =>\n createServiceFactory({\n service: catalogServiceRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n });\n /**\n * Creates a catalog client whose methods are mock functions, possibly with\n * some of them overloaded by the caller.\n */\n export const mock = simpleMock(catalogServiceRef, () => ({\n getEntities: jest.fn(),\n getEntitiesByRefs: jest.fn(),\n queryEntities: jest.fn(),\n getEntityAncestors: jest.fn(),\n getEntityByRef: jest.fn(),\n removeEntityByUid: jest.fn(),\n refreshEntity: jest.fn(),\n getEntityFacets: jest.fn(),\n getLocationById: jest.fn(),\n getLocationByRef: jest.fn(),\n addLocation: jest.fn(),\n removeLocationById: jest.fn(),\n getLocationByEntity: jest.fn(),\n validateEntity: jest.fn(),\n }));\n}\n"],"names":["createServiceFactory","InMemoryCatalogClient","catalogServiceMock","catalogServiceRef"],"mappings":";;;;;;AA4BA,SAAS,UAAA,CACP,KACA,WAC4D,EAAA;AAC5D,EAAA,OAAO,CAAe,WAAA,KAAA;AACpB,IAAA,MAAM,OAAO,WAAY,EAAA,CAAA;AACzB,IAAA,IAAI,WAAa,EAAA;AACf,MAAA,KAAA,MAAW,CAAC,GAAK,EAAA,IAAI,KAAK,MAAO,CAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AACrD,QAAI,IAAA,OAAO,SAAS,UAAY,EAAA;AAC9B,UAAC,IAAa,CAAA,GAAG,CAAE,CAAA,kBAAA,CAAmB,IAAI,CAAA,CAAA;AAAA,SACrC,MAAA;AACL,UAAC,IAAA,CAAa,GAAG,CAAI,GAAA,IAAA,CAAA;AAAA,SACvB;AAAA,OACF;AAAA,KACF;AACA,IAAO,OAAA,MAAA,CAAO,OAAO,IAAM,EAAA;AAAA,MACzB,SAASA,qCAAqB,CAAA;AAAA,QAC5B,OAAS,EAAA,GAAA;AAAA,QACT,MAAM,EAAC;AAAA,QACP,SAAS,MAAM,IAAA;AAAA,OAChB,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GACH,CAAA;AACF,CAAA;AASO,SAAS,mBAAmB,OAEpB,EAAA;AACb,EAAO,OAAA,IAAIC,gCAAsB,OAAO,CAAA,CAAA;AAC1C,CAAA;AAAA,CAOO,CAAUC,mBAAV,KAAA;AAME,EAAMA,mBAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KACtBF,qCAAqB,CAAA;AAAA,IACnB,OAAS,EAAAG,uBAAA;AAAA,IACT,MAAM,EAAC;AAAA,IACP,OAAS,EAAA,MAAM,IAAIF,+BAAA,CAAsB,OAAO,CAAA;AAAA,GACjD,CAAA,CAAA;AAKI,EAAMC,mBAAA,CAAA,IAAA,GAAO,UAAW,CAAAC,uBAAA,EAAmB,OAAO;AAAA,IACvD,WAAA,EAAa,KAAK,EAAG,EAAA;AAAA,IACrB,iBAAA,EAAmB,KAAK,EAAG,EAAA;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAG,EAAA;AAAA,IACvB,kBAAA,EAAoB,KAAK,EAAG,EAAA;AAAA,IAC5B,cAAA,EAAgB,KAAK,EAAG,EAAA;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAG,EAAA;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAG,EAAA;AAAA,IACvB,eAAA,EAAiB,KAAK,EAAG,EAAA;AAAA,IACzB,eAAA,EAAiB,KAAK,EAAG,EAAA;AAAA,IACzB,gBAAA,EAAkB,KAAK,EAAG,EAAA;AAAA,IAC1B,WAAA,EAAa,KAAK,EAAG,EAAA;AAAA,IACrB,kBAAA,EAAoB,KAAK,EAAG,EAAA;AAAA,IAC5B,mBAAA,EAAqB,KAAK,EAAG,EAAA;AAAA,IAC7B,cAAA,EAAgB,KAAK,EAAG,EAAA;AAAA,GACxB,CAAA,CAAA,CAAA;AAAA,CA/Ba,EAAA,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/testUtils.cjs.js
CHANGED
|
@@ -1,56 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var testUtils = require('@backstage/catalog-client/testUtils');
|
|
5
|
-
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
3
|
+
var catalogServiceMock = require('./testUtils/catalogServiceMock.cjs.js');
|
|
6
4
|
|
|
7
|
-
function simpleMock(ref, mockFactory) {
|
|
8
|
-
return (partialImpl) => {
|
|
9
|
-
const mock = mockFactory();
|
|
10
|
-
if (partialImpl) {
|
|
11
|
-
for (const [key, impl] of Object.entries(partialImpl)) {
|
|
12
|
-
if (typeof impl === "function") {
|
|
13
|
-
mock[key].mockImplementation(impl);
|
|
14
|
-
} else {
|
|
15
|
-
mock[key] = impl;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return Object.assign(mock, {
|
|
20
|
-
factory: backendPluginApi.createServiceFactory({
|
|
21
|
-
service: ref,
|
|
22
|
-
deps: {},
|
|
23
|
-
factory: () => mock
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function catalogServiceMock(options) {
|
|
29
|
-
return new testUtils.InMemoryCatalogClient(options);
|
|
30
|
-
}
|
|
31
|
-
((catalogServiceMock2) => {
|
|
32
|
-
catalogServiceMock2.factory = (options) => backendPluginApi.createServiceFactory({
|
|
33
|
-
service: alpha.catalogServiceRef,
|
|
34
|
-
deps: {},
|
|
35
|
-
factory: () => new testUtils.InMemoryCatalogClient(options)
|
|
36
|
-
});
|
|
37
|
-
catalogServiceMock2.mock = simpleMock(alpha.catalogServiceRef, () => ({
|
|
38
|
-
getEntities: jest.fn(),
|
|
39
|
-
getEntitiesByRefs: jest.fn(),
|
|
40
|
-
queryEntities: jest.fn(),
|
|
41
|
-
getEntityAncestors: jest.fn(),
|
|
42
|
-
getEntityByRef: jest.fn(),
|
|
43
|
-
removeEntityByUid: jest.fn(),
|
|
44
|
-
refreshEntity: jest.fn(),
|
|
45
|
-
getEntityFacets: jest.fn(),
|
|
46
|
-
getLocationById: jest.fn(),
|
|
47
|
-
getLocationByRef: jest.fn(),
|
|
48
|
-
addLocation: jest.fn(),
|
|
49
|
-
removeLocationById: jest.fn(),
|
|
50
|
-
getLocationByEntity: jest.fn(),
|
|
51
|
-
validateEntity: jest.fn()
|
|
52
|
-
}));
|
|
53
|
-
})(catalogServiceMock || (catalogServiceMock = {}));
|
|
54
5
|
|
|
55
|
-
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "catalogServiceMock", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return catalogServiceMock.catalogServiceMock; }
|
|
10
|
+
});
|
|
56
11
|
//# sourceMappingURL=testUtils.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"testUtils.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-node",
|
|
3
|
-
"version": "1.13.1-next.
|
|
3
|
+
"version": "1.13.1-next.1",
|
|
4
4
|
"description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"backstage"
|
|
21
|
+
],
|
|
19
22
|
"homepage": "https://backstage.io",
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
|
@@ -58,17 +61,17 @@
|
|
|
58
61
|
"test": "backstage-cli package test"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"@backstage/backend-plugin-api": "
|
|
62
|
-
"@backstage/catalog-client": "
|
|
63
|
-
"@backstage/catalog-model": "
|
|
64
|
-
"@backstage/errors": "
|
|
65
|
-
"@backstage/plugin-catalog-common": "
|
|
66
|
-
"@backstage/plugin-permission-common": "
|
|
67
|
-
"@backstage/plugin-permission-node": "
|
|
68
|
-
"@backstage/types": "
|
|
64
|
+
"@backstage/backend-plugin-api": "1.0.1-next.1",
|
|
65
|
+
"@backstage/catalog-client": "1.7.1-next.0",
|
|
66
|
+
"@backstage/catalog-model": "1.7.0",
|
|
67
|
+
"@backstage/errors": "1.2.4",
|
|
68
|
+
"@backstage/plugin-catalog-common": "1.1.0",
|
|
69
|
+
"@backstage/plugin-permission-common": "0.8.1",
|
|
70
|
+
"@backstage/plugin-permission-node": "0.8.4-next.1",
|
|
71
|
+
"@backstage/types": "1.1.1"
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"@backstage/backend-test-utils": "
|
|
72
|
-
"@backstage/cli": "
|
|
74
|
+
"@backstage/backend-test-utils": "1.0.1-next.2",
|
|
75
|
+
"@backstage/cli": "0.28.0-next.2"
|
|
73
76
|
}
|
|
74
77
|
}
|