@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor 1.2.8 → 2.0.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 +12 -0
- package/README.md +1 -28
- package/dist/index.cjs.js +77 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist-dynamic/package.json +16 -19
- package/dist-dynamic/yarn.lock +3 -6
- package/package.json +8 -16
- package/alpha/package.json +0 -6
- package/dist/alpha.cjs.js +0 -31
- package/dist/alpha.cjs.js.map +0 -1
- package/dist/alpha.d.ts +0 -10
- package/dist/cjs/ScaffolderRelationEntityProcessor-CDT-3f59.cjs.js +0 -59
- package/dist/cjs/ScaffolderRelationEntityProcessor-CDT-3f59.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 94fb1a0: **Breaking** migrate to the new backend system and remove deprecations
|
|
8
|
+
|
|
9
|
+
## 1.2.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- cd31d0e: Backstage version bump to v1.31.2
|
|
14
|
+
|
|
3
15
|
## 1.2.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ const backend = createBackend();
|
|
|
20
20
|
// highlight-add-start
|
|
21
21
|
backend.add(
|
|
22
22
|
import(
|
|
23
|
-
'@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor
|
|
23
|
+
'@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor'
|
|
24
24
|
),
|
|
25
25
|
);
|
|
26
26
|
// highlight-add-end
|
|
@@ -28,33 +28,6 @@ backend.add(
|
|
|
28
28
|
backend.start();
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
### Installing on the legacy backend system
|
|
32
|
-
|
|
33
|
-
To install this module into the legacy backend system, add the following to the `packages/backend/src/plugins/catalog.ts` file:
|
|
34
|
-
|
|
35
|
-
```ts title=packages/backend/src/plugins/catalog.ts
|
|
36
|
-
// highlight-add-start
|
|
37
|
-
import { ScaffolderRelationEntityProcessor } from '@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor';
|
|
38
|
-
|
|
39
|
-
// highlight-add-end
|
|
40
|
-
|
|
41
|
-
export default async function createPlugin(
|
|
42
|
-
env: PluginEnvironment,
|
|
43
|
-
): Promise<Router> {
|
|
44
|
-
const builder = await CatalogBuilder.create(env);
|
|
45
|
-
|
|
46
|
-
/* ... other processors and/or providers ... */
|
|
47
|
-
// highlight-add-start
|
|
48
|
-
builder.addProcessor(new ScaffolderRelationEntityProcessor());
|
|
49
|
-
// highlight-add-end
|
|
50
|
-
|
|
51
|
-
const { processingEngine, router } = await builder.build();
|
|
52
|
-
await processingEngine.start();
|
|
53
|
-
|
|
54
|
-
return router;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
31
|
### Usage
|
|
59
32
|
|
|
60
33
|
Catalog entities containing the `spec.scaffoldedFrom` field will have a relation link be formed between it and the `template` corresponding to the entity ref in the `spec.scaffoldedFrom` field.
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,18 +1,83 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require('@backstage/catalog-model');
|
|
5
|
-
require('@backstage/plugin-catalog-node');
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
|
+
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
7
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
8
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
9
|
+
|
|
10
|
+
const RELATION_SCAFFOLDER_OF = "scaffolderOf";
|
|
11
|
+
const RELATION_SCAFFOLDED_FROM = "scaffoldedFrom";
|
|
12
|
+
|
|
13
|
+
class ScaffolderRelationEntityProcessor {
|
|
14
|
+
getProcessorName() {
|
|
15
|
+
return "ScaffolderRelationEntityProcessor";
|
|
16
|
+
}
|
|
17
|
+
async postProcessEntity(entity, _location, emit) {
|
|
18
|
+
const selfRef = catalogModel.getCompoundEntityRef(entity);
|
|
19
|
+
function doEmit(targets, context, outgoingRelation, incomingRelation) {
|
|
20
|
+
if (!targets) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const target of [targets].flat()) {
|
|
24
|
+
const targetRef = catalogModel.parseEntityRef(target, context);
|
|
25
|
+
emit(
|
|
26
|
+
pluginCatalogNode.processingResult.relation({
|
|
27
|
+
source: selfRef,
|
|
28
|
+
type: outgoingRelation,
|
|
29
|
+
target: {
|
|
30
|
+
kind: targetRef.kind,
|
|
31
|
+
namespace: targetRef.namespace,
|
|
32
|
+
name: targetRef.name
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
emit(
|
|
37
|
+
pluginCatalogNode.processingResult.relation({
|
|
38
|
+
source: {
|
|
39
|
+
kind: targetRef.kind,
|
|
40
|
+
namespace: targetRef.namespace,
|
|
41
|
+
name: targetRef.name
|
|
42
|
+
},
|
|
43
|
+
type: incomingRelation,
|
|
44
|
+
target: selfRef
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const arbitraryEntity = entity;
|
|
50
|
+
doEmit(
|
|
51
|
+
arbitraryEntity.spec?.scaffoldedFrom,
|
|
52
|
+
{ defaultKind: "Template", defaultNamespace: selfRef.namespace },
|
|
53
|
+
RELATION_SCAFFOLDED_FROM,
|
|
54
|
+
RELATION_SCAFFOLDER_OF
|
|
55
|
+
);
|
|
56
|
+
return entity;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const catalogModuleScaffolderRelationProcessor = backendPluginApi.createBackendModule({
|
|
61
|
+
pluginId: "catalog",
|
|
62
|
+
moduleId: "scaffolder-relation-processor",
|
|
63
|
+
register(env) {
|
|
64
|
+
env.registerInit({
|
|
65
|
+
deps: {
|
|
66
|
+
catalog: alpha.catalogProcessingExtensionPoint,
|
|
67
|
+
logger: backendPluginApi.coreServices.logger
|
|
68
|
+
},
|
|
69
|
+
async init({ catalog, logger }) {
|
|
70
|
+
logger.debug(
|
|
71
|
+
"Registering the scaffolder-relation-processor catalog module"
|
|
72
|
+
);
|
|
73
|
+
catalog.addProcessor(new ScaffolderRelationEntityProcessor());
|
|
74
|
+
}
|
|
75
|
+
});
|
|
11
76
|
}
|
|
12
|
-
};
|
|
77
|
+
});
|
|
13
78
|
|
|
14
|
-
exports.RELATION_SCAFFOLDED_FROM =
|
|
15
|
-
exports.RELATION_SCAFFOLDER_OF =
|
|
16
|
-
exports.ScaffolderRelationEntityProcessor = ScaffolderRelationEntityProcessor
|
|
17
|
-
exports.
|
|
79
|
+
exports.RELATION_SCAFFOLDED_FROM = RELATION_SCAFFOLDED_FROM;
|
|
80
|
+
exports.RELATION_SCAFFOLDER_OF = RELATION_SCAFFOLDER_OF;
|
|
81
|
+
exports.ScaffolderRelationEntityProcessor = ScaffolderRelationEntityProcessor;
|
|
82
|
+
exports.default = catalogModuleScaffolderRelationProcessor;
|
|
18
83
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/relations.ts","../src/ScaffolderRelationEntityProcessor.ts","../src/module.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\n/**\n * A relation from a scaffolder template entity to the entity it generated.\n * Reverse direction of {@link RELATION_SCAFFOLDED_FROM}\n *\n * @public\n */\nexport const RELATION_SCAFFOLDER_OF = 'scaffolderOf';\n\n/**\n * A relation of an entity generated from a scaffolder template entity\n * Reverse direction of {@link RELATION_SCAFFOLDER_OF}\n *\n * @public\n */\nexport const RELATION_SCAFFOLDED_FROM = 'scaffoldedFrom';\n","/*\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 */\nimport {\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport type { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n processingResult,\n} from '@backstage/plugin-catalog-node';\n\nimport { RELATION_SCAFFOLDED_FROM, RELATION_SCAFFOLDER_OF } from './relations';\nimport type { ScaffoldedFromSpec } from './types';\n\n/** @public */\nexport class ScaffolderRelationEntityProcessor implements CatalogProcessor {\n getProcessorName(): string {\n return 'ScaffolderRelationEntityProcessor';\n }\n\n async postProcessEntity(\n entity: Entity,\n _location: LocationSpec,\n emit: CatalogProcessorEmit,\n ): Promise<Entity> {\n const selfRef = getCompoundEntityRef(entity);\n\n /**\n * Utilities\n */\n function doEmit(\n targets: string | string[] | undefined,\n context: { defaultKind?: string; defaultNamespace: string },\n outgoingRelation: string,\n incomingRelation: string,\n ): void {\n if (!targets) {\n return;\n }\n for (const target of [targets].flat()) {\n const targetRef = parseEntityRef(target, context);\n emit(\n processingResult.relation({\n source: selfRef,\n type: outgoingRelation,\n target: {\n kind: targetRef.kind,\n namespace: targetRef.namespace,\n name: targetRef.name,\n },\n }),\n );\n emit(\n processingResult.relation({\n source: {\n kind: targetRef.kind,\n namespace: targetRef.namespace,\n name: targetRef.name,\n },\n type: incomingRelation,\n target: selfRef,\n }),\n );\n }\n }\n\n /**\n * Emit relations for entities generated by templates (can be any entity type)\n */\n const arbitraryEntity = entity as Entity & Partial<ScaffoldedFromSpec>;\n doEmit(\n arbitraryEntity.spec?.scaffoldedFrom,\n { defaultKind: 'Template', defaultNamespace: selfRef.namespace },\n RELATION_SCAFFOLDED_FROM,\n RELATION_SCAFFOLDER_OF,\n );\n return entity;\n }\n}\n","/*\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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\n\nimport { ScaffolderRelationEntityProcessor } from './ScaffolderRelationEntityProcessor';\n\n/**\n * Catalog processor that adds link relation between scaffolder templates and their generated entities\n *\n * @public\n */\nexport const catalogModuleScaffolderRelationProcessor = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'scaffolder-relation-processor',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n logger: coreServices.logger,\n },\n async init({ catalog, logger }) {\n logger.debug(\n 'Registering the scaffolder-relation-processor catalog module',\n );\n catalog.addProcessor(new ScaffolderRelationEntityProcessor());\n },\n });\n },\n});\n"],"names":["getCompoundEntityRef","parseEntityRef","processingResult","createBackendModule","catalogProcessingExtensionPoint","coreServices"],"mappings":";;;;;;;;;AAsBO,MAAM,sBAAyB,GAAA,eAAA;AAQ/B,MAAM,wBAA2B,GAAA;;ACCjC,MAAM,iCAA8D,CAAA;AAAA,EACzE,gBAA2B,GAAA;AACzB,IAAO,OAAA,mCAAA,CAAA;AAAA,GACT;AAAA,EAEA,MAAM,iBAAA,CACJ,MACA,EAAA,SAAA,EACA,IACiB,EAAA;AACjB,IAAM,MAAA,OAAA,GAAUA,kCAAqB,MAAM,CAAA,CAAA;AAK3C,IAAA,SAAS,MACP,CAAA,OAAA,EACA,OACA,EAAA,gBAAA,EACA,gBACM,EAAA;AACN,MAAA,IAAI,CAAC,OAAS,EAAA;AACZ,QAAA,OAAA;AAAA,OACF;AACA,MAAA,KAAA,MAAW,MAAU,IAAA,CAAC,OAAO,CAAA,CAAE,MAAQ,EAAA;AACrC,QAAM,MAAA,SAAA,GAAYC,2BAAe,CAAA,MAAA,EAAQ,OAAO,CAAA,CAAA;AAChD,QAAA,IAAA;AAAA,UACEC,mCAAiB,QAAS,CAAA;AAAA,YACxB,MAAQ,EAAA,OAAA;AAAA,YACR,IAAM,EAAA,gBAAA;AAAA,YACN,MAAQ,EAAA;AAAA,cACN,MAAM,SAAU,CAAA,IAAA;AAAA,cAChB,WAAW,SAAU,CAAA,SAAA;AAAA,cACrB,MAAM,SAAU,CAAA,IAAA;AAAA,aAClB;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AACA,QAAA,IAAA;AAAA,UACEA,mCAAiB,QAAS,CAAA;AAAA,YACxB,MAAQ,EAAA;AAAA,cACN,MAAM,SAAU,CAAA,IAAA;AAAA,cAChB,WAAW,SAAU,CAAA,SAAA;AAAA,cACrB,MAAM,SAAU,CAAA,IAAA;AAAA,aAClB;AAAA,YACA,IAAM,EAAA,gBAAA;AAAA,YACN,MAAQ,EAAA,OAAA;AAAA,WACT,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAKA,IAAA,MAAM,eAAkB,GAAA,MAAA,CAAA;AACxB,IAAA,MAAA;AAAA,MACE,gBAAgB,IAAM,EAAA,cAAA;AAAA,MACtB,EAAE,WAAA,EAAa,UAAY,EAAA,gBAAA,EAAkB,QAAQ,SAAU,EAAA;AAAA,MAC/D,wBAAA;AAAA,MACA,sBAAA;AAAA,KACF,CAAA;AACA,IAAO,OAAA,MAAA,CAAA;AAAA,GACT;AACF;;AClEO,MAAM,2CAA2CC,oCAAoB,CAAA;AAAA,EAC1E,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,+BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,QACT,QAAQC,6BAAa,CAAA,MAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAS,QAAU,EAAA;AAC9B,QAAO,MAAA,CAAA,KAAA;AAAA,UACL,8DAAA;AAAA,SACF,CAAA;AACA,QAAQ,OAAA,CAAA,YAAA,CAAa,IAAI,iCAAA,EAAmC,CAAA,CAAA;AAAA,OAC9D;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
2
|
import { Entity } from '@backstage/catalog-model';
|
|
3
3
|
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
|
4
4
|
import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-node';
|
|
@@ -31,10 +31,11 @@ type ScaffoldedFromSpec = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
+
* Catalog processor that adds link relation between scaffolder templates and their generated entities
|
|
34
35
|
*
|
|
35
36
|
* @public
|
|
36
37
|
*/
|
|
37
|
-
declare const
|
|
38
|
+
declare const catalogModuleScaffolderRelationProcessor: _backstage_backend_plugin_api.BackendFeature;
|
|
38
39
|
|
|
39
40
|
/** @public */
|
|
40
41
|
declare class ScaffolderRelationEntityProcessor implements CatalogProcessor {
|
|
@@ -42,4 +43,4 @@ declare class ScaffolderRelationEntityProcessor implements CatalogProcessor {
|
|
|
42
43
|
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export { RELATION_SCAFFOLDED_FROM, RELATION_SCAFFOLDER_OF, type ScaffoldedFromSpec, ScaffolderRelationEntityProcessor,
|
|
46
|
+
export { RELATION_SCAFFOLDED_FROM, RELATION_SCAFFOLDER_OF, type ScaffoldedFromSpec, ScaffolderRelationEntityProcessor, catalogModuleScaffolderRelationProcessor as default };
|
|
@@ -1,42 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor-dynamic",
|
|
3
3
|
"description": "The scaffolder-relation-processor backend module for the catalog plugin.",
|
|
4
|
-
"version": "
|
|
5
|
-
"main": "dist/index.cjs.js",
|
|
6
|
-
"types": "
|
|
4
|
+
"version": "1.2.9",
|
|
5
|
+
"main": "./dist/index.cjs.js",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"publishConfig": {
|
|
9
|
-
"access": "public"
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/backstage/community-plugins",
|
|
14
|
+
"directory": "workspaces/scaffolder-relation-processor/plugins/catalog-backend-module-scaffolder-relation-processor"
|
|
12
15
|
},
|
|
13
16
|
"backstage": {
|
|
14
|
-
"role": "backend-plugin-module"
|
|
17
|
+
"role": "backend-plugin-module",
|
|
18
|
+
"pluginId": "scaffolder-relation-processor",
|
|
19
|
+
"pluginPackage": "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor"
|
|
15
20
|
},
|
|
16
21
|
"exports": {
|
|
17
22
|
".": {
|
|
18
23
|
"require": "./dist/index.cjs.js",
|
|
19
24
|
"default": "./dist/index.cjs.js"
|
|
20
25
|
},
|
|
21
|
-
"./alpha": {
|
|
22
|
-
"require": "./dist/alpha.cjs.js",
|
|
23
|
-
"default": "./dist/alpha.cjs.js"
|
|
24
|
-
},
|
|
25
26
|
"./package.json": "./package.json"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"dist",
|
|
29
|
-
"config.d.ts"
|
|
30
|
-
"alpha"
|
|
30
|
+
"config.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"bundleDependencies": true,
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@backstage/backend-
|
|
35
|
-
"@backstage/
|
|
36
|
-
"@backstage/
|
|
37
|
-
"@backstage/catalog-model": "^1.4.5",
|
|
38
|
-
"@backstage/plugin-catalog-common": "^1.0.22",
|
|
39
|
-
"@backstage/plugin-catalog-node": "^1.11.1"
|
|
34
|
+
"@backstage/backend-plugin-api": "^1.0.0",
|
|
35
|
+
"@backstage/catalog-model": "^1.7.0",
|
|
36
|
+
"@backstage/plugin-catalog-node": "^1.13.0"
|
|
40
37
|
},
|
|
41
38
|
"overrides": {
|
|
42
39
|
"@aws-sdk/util-utf8-browser": {
|
package/dist-dynamic/yarn.lock
CHANGED
|
@@ -8,11 +8,8 @@ __metadata:
|
|
|
8
8
|
version: 0.0.0-use.local
|
|
9
9
|
resolution: "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor-dynamic@workspace:."
|
|
10
10
|
peerDependencies:
|
|
11
|
-
"@backstage/backend-
|
|
12
|
-
"@backstage/
|
|
13
|
-
"@backstage/
|
|
14
|
-
"@backstage/catalog-model": ^1.4.5
|
|
15
|
-
"@backstage/plugin-catalog-common": ^1.0.22
|
|
16
|
-
"@backstage/plugin-catalog-node": ^1.11.1
|
|
11
|
+
"@backstage/backend-plugin-api": ^1.0.0
|
|
12
|
+
"@backstage/catalog-model": ^1.7.0
|
|
13
|
+
"@backstage/plugin-catalog-node": ^1.13.0
|
|
17
14
|
languageName: unknown
|
|
18
15
|
linkType: soft
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor",
|
|
3
3
|
"description": "The scaffolder-relation-processor backend module for the catalog plugin.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -24,11 +24,6 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"default": "./dist/index.cjs.js"
|
|
26
26
|
},
|
|
27
|
-
"./alpha": {
|
|
28
|
-
"require": "./dist/alpha.cjs.js",
|
|
29
|
-
"types": "./dist/alpha.d.ts",
|
|
30
|
-
"default": "./dist/alpha.cjs.js"
|
|
31
|
-
},
|
|
32
27
|
"./package.json": "./package.json"
|
|
33
28
|
},
|
|
34
29
|
"scripts": {
|
|
@@ -44,16 +39,14 @@
|
|
|
44
39
|
"tsc": "tsc"
|
|
45
40
|
},
|
|
46
41
|
"dependencies": {
|
|
47
|
-
"@backstage/backend-
|
|
48
|
-
"@backstage/
|
|
49
|
-
"@backstage/
|
|
50
|
-
"@backstage/catalog-model": "^1.6.0",
|
|
51
|
-
"@backstage/plugin-catalog-common": "^1.0.26",
|
|
52
|
-
"@backstage/plugin-catalog-node": "^1.12.5"
|
|
42
|
+
"@backstage/backend-plugin-api": "^1.0.0",
|
|
43
|
+
"@backstage/catalog-model": "^1.7.0",
|
|
44
|
+
"@backstage/plugin-catalog-node": "^1.13.0"
|
|
53
45
|
},
|
|
54
46
|
"devDependencies": {
|
|
55
|
-
"@backstage/backend-test-utils": "^0.
|
|
56
|
-
"@backstage/cli": "^0.27.
|
|
47
|
+
"@backstage/backend-test-utils": "^1.0.0",
|
|
48
|
+
"@backstage/cli": "^0.27.1",
|
|
49
|
+
"@backstage/plugin-catalog-common": "^1.1.0",
|
|
57
50
|
"@janus-idp/cli": "1.13.1"
|
|
58
51
|
},
|
|
59
52
|
"files": [
|
|
@@ -61,7 +54,6 @@
|
|
|
61
54
|
"config.d.ts",
|
|
62
55
|
"dist-dynamic/*.*",
|
|
63
56
|
"dist-dynamic/dist/**",
|
|
64
|
-
"dist-dynamic/alpha/*"
|
|
65
|
-
"alpha"
|
|
57
|
+
"dist-dynamic/alpha/*"
|
|
66
58
|
]
|
|
67
59
|
}
|
package/alpha/package.json
DELETED
package/dist/alpha.cjs.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
|
-
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
7
|
-
var ScaffolderRelationEntityProcessor = require('./cjs/ScaffolderRelationEntityProcessor-CDT-3f59.cjs.js');
|
|
8
|
-
require('@backstage/catalog-model');
|
|
9
|
-
require('@backstage/plugin-catalog-node');
|
|
10
|
-
|
|
11
|
-
const catalogModuleScaffolderRelationProcessor = backendPluginApi.createBackendModule({
|
|
12
|
-
pluginId: "catalog",
|
|
13
|
-
moduleId: "scaffolder-relation-processor",
|
|
14
|
-
register(env) {
|
|
15
|
-
env.registerInit({
|
|
16
|
-
deps: {
|
|
17
|
-
catalog: alpha.catalogProcessingExtensionPoint,
|
|
18
|
-
logger: backendPluginApi.coreServices.logger
|
|
19
|
-
},
|
|
20
|
-
async init({ catalog, logger }) {
|
|
21
|
-
logger.debug(
|
|
22
|
-
"Registering the scaffolder-relation-processor catalog module"
|
|
23
|
-
);
|
|
24
|
-
catalog.addProcessor(new ScaffolderRelationEntityProcessor.ScaffolderRelationEntityProcessor());
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
exports.default = catalogModuleScaffolderRelationProcessor;
|
|
31
|
-
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/module.ts"],"sourcesContent":["import {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\n\nimport { ScaffolderRelationEntityProcessor } from './ScaffolderRelationEntityProcessor';\n\n/**\n * Catalog processor that adds link relation between scaffolder templates and their generated entities\n *\n * @public\n */\nexport const catalogModuleScaffolderRelationProcessor = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'scaffolder-relation-processor',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n logger: coreServices.logger,\n },\n async init({ catalog, logger }) {\n logger.debug(\n 'Registering the scaffolder-relation-processor catalog module',\n );\n catalog.addProcessor(new ScaffolderRelationEntityProcessor());\n },\n });\n },\n});\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","coreServices","ScaffolderRelationEntityProcessor"],"mappings":";;;;;;;;;;AAaO,MAAM,2CAA2CA,oCAAoB,CAAA;AAAA,EAC1E,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,+BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,QACT,QAAQC,6BAAa,CAAA,MAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAS,QAAU,EAAA;AAC9B,QAAO,MAAA,CAAA,KAAA;AAAA,UACL,8DAAA;AAAA,SACF,CAAA;AACA,QAAQ,OAAA,CAAA,YAAA,CAAa,IAAIC,mEAAA,EAAmC,CAAA,CAAA;AAAA,OAC9D;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
package/dist/alpha.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Catalog processor that adds link relation between scaffolder templates and their generated entities
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
declare const catalogModuleScaffolderRelationProcessor: _backstage_backend_plugin_api.BackendFeatureCompat;
|
|
9
|
-
|
|
10
|
-
export { catalogModuleScaffolderRelationProcessor as default };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var catalogModel = require('@backstage/catalog-model');
|
|
4
|
-
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
5
|
-
|
|
6
|
-
const RELATION_SCAFFOLDER_OF = "scaffolderOf";
|
|
7
|
-
const RELATION_SCAFFOLDED_FROM = "scaffoldedFrom";
|
|
8
|
-
|
|
9
|
-
class ScaffolderRelationEntityProcessor {
|
|
10
|
-
getProcessorName() {
|
|
11
|
-
return "ScaffolderRelationEntityProcessor";
|
|
12
|
-
}
|
|
13
|
-
async postProcessEntity(entity, _location, emit) {
|
|
14
|
-
const selfRef = catalogModel.getCompoundEntityRef(entity);
|
|
15
|
-
function doEmit(targets, context, outgoingRelation, incomingRelation) {
|
|
16
|
-
if (!targets) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
for (const target of [targets].flat()) {
|
|
20
|
-
const targetRef = catalogModel.parseEntityRef(target, context);
|
|
21
|
-
emit(
|
|
22
|
-
pluginCatalogNode.processingResult.relation({
|
|
23
|
-
source: selfRef,
|
|
24
|
-
type: outgoingRelation,
|
|
25
|
-
target: {
|
|
26
|
-
kind: targetRef.kind,
|
|
27
|
-
namespace: targetRef.namespace,
|
|
28
|
-
name: targetRef.name
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
emit(
|
|
33
|
-
pluginCatalogNode.processingResult.relation({
|
|
34
|
-
source: {
|
|
35
|
-
kind: targetRef.kind,
|
|
36
|
-
namespace: targetRef.namespace,
|
|
37
|
-
name: targetRef.name
|
|
38
|
-
},
|
|
39
|
-
type: incomingRelation,
|
|
40
|
-
target: selfRef
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const arbitraryEntity = entity;
|
|
46
|
-
doEmit(
|
|
47
|
-
arbitraryEntity.spec?.scaffoldedFrom,
|
|
48
|
-
{ defaultKind: "Template", defaultNamespace: selfRef.namespace },
|
|
49
|
-
RELATION_SCAFFOLDED_FROM,
|
|
50
|
-
RELATION_SCAFFOLDER_OF
|
|
51
|
-
);
|
|
52
|
-
return entity;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
exports.RELATION_SCAFFOLDED_FROM = RELATION_SCAFFOLDED_FROM;
|
|
57
|
-
exports.RELATION_SCAFFOLDER_OF = RELATION_SCAFFOLDER_OF;
|
|
58
|
-
exports.ScaffolderRelationEntityProcessor = ScaffolderRelationEntityProcessor;
|
|
59
|
-
//# sourceMappingURL=ScaffolderRelationEntityProcessor-CDT-3f59.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScaffolderRelationEntityProcessor-CDT-3f59.cjs.js","sources":["../../src/relations.ts","../../src/ScaffolderRelationEntityProcessor.ts"],"sourcesContent":["/**\n * A relation from a scaffolder template entity to the entity it generated.\n * Reverse direction of {@link RELATION_SCAFFOLDED_FROM}\n *\n * @public\n */\nexport const RELATION_SCAFFOLDER_OF = 'scaffolderOf';\n\n/**\n * A relation of an entity generated from a scaffolder template entity\n * Reverse direction of {@link RELATION_SCAFFOLDER_OF}\n *\n * @public\n */\nexport const RELATION_SCAFFOLDED_FROM = 'scaffoldedFrom';\n","import {\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n processingResult,\n} from '@backstage/plugin-catalog-node';\n\nimport { RELATION_SCAFFOLDED_FROM, RELATION_SCAFFOLDER_OF } from './relations';\nimport { ScaffoldedFromSpec } from './types';\n\n/** @public */\nexport class ScaffolderRelationEntityProcessor implements CatalogProcessor {\n getProcessorName(): string {\n return 'ScaffolderRelationEntityProcessor';\n }\n\n async postProcessEntity(\n entity: Entity,\n _location: LocationSpec,\n emit: CatalogProcessorEmit,\n ): Promise<Entity> {\n const selfRef = getCompoundEntityRef(entity);\n\n /**\n * Utilities\n */\n function doEmit(\n targets: string | string[] | undefined,\n context: { defaultKind?: string; defaultNamespace: string },\n outgoingRelation: string,\n incomingRelation: string,\n ): void {\n if (!targets) {\n return;\n }\n for (const target of [targets].flat()) {\n const targetRef = parseEntityRef(target, context);\n emit(\n processingResult.relation({\n source: selfRef,\n type: outgoingRelation,\n target: {\n kind: targetRef.kind,\n namespace: targetRef.namespace,\n name: targetRef.name,\n },\n }),\n );\n emit(\n processingResult.relation({\n source: {\n kind: targetRef.kind,\n namespace: targetRef.namespace,\n name: targetRef.name,\n },\n type: incomingRelation,\n target: selfRef,\n }),\n );\n }\n }\n\n /**\n * Emit relations for entities generated by templates (can be any entity type)\n */\n const arbitraryEntity = entity as Entity & Partial<ScaffoldedFromSpec>;\n doEmit(\n arbitraryEntity.spec?.scaffoldedFrom,\n { defaultKind: 'Template', defaultNamespace: selfRef.namespace },\n RELATION_SCAFFOLDED_FROM,\n RELATION_SCAFFOLDER_OF,\n );\n return entity;\n }\n}\n"],"names":["getCompoundEntityRef","parseEntityRef","processingResult"],"mappings":";;;;;AAMO,MAAM,sBAAyB,GAAA,eAAA;AAQ/B,MAAM,wBAA2B,GAAA;;ACEjC,MAAM,iCAA8D,CAAA;AAAA,EACzE,gBAA2B,GAAA;AACzB,IAAO,OAAA,mCAAA,CAAA;AAAA,GACT;AAAA,EAEA,MAAM,iBAAA,CACJ,MACA,EAAA,SAAA,EACA,IACiB,EAAA;AACjB,IAAM,MAAA,OAAA,GAAUA,kCAAqB,MAAM,CAAA,CAAA;AAK3C,IAAA,SAAS,MACP,CAAA,OAAA,EACA,OACA,EAAA,gBAAA,EACA,gBACM,EAAA;AACN,MAAA,IAAI,CAAC,OAAS,EAAA;AACZ,QAAA,OAAA;AAAA,OACF;AACA,MAAA,KAAA,MAAW,MAAU,IAAA,CAAC,OAAO,CAAA,CAAE,MAAQ,EAAA;AACrC,QAAM,MAAA,SAAA,GAAYC,2BAAe,CAAA,MAAA,EAAQ,OAAO,CAAA,CAAA;AAChD,QAAA,IAAA;AAAA,UACEC,mCAAiB,QAAS,CAAA;AAAA,YACxB,MAAQ,EAAA,OAAA;AAAA,YACR,IAAM,EAAA,gBAAA;AAAA,YACN,MAAQ,EAAA;AAAA,cACN,MAAM,SAAU,CAAA,IAAA;AAAA,cAChB,WAAW,SAAU,CAAA,SAAA;AAAA,cACrB,MAAM,SAAU,CAAA,IAAA;AAAA,aAClB;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AACA,QAAA,IAAA;AAAA,UACEA,mCAAiB,QAAS,CAAA;AAAA,YACxB,MAAQ,EAAA;AAAA,cACN,MAAM,SAAU,CAAA,IAAA;AAAA,cAChB,WAAW,SAAU,CAAA,SAAA;AAAA,cACrB,MAAM,SAAU,CAAA,IAAA;AAAA,aAClB;AAAA,YACA,IAAM,EAAA,gBAAA;AAAA,YACN,MAAQ,EAAA,OAAA;AAAA,WACT,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAKA,IAAA,MAAM,eAAkB,GAAA,MAAA,CAAA;AACxB,IAAA,MAAA;AAAA,MACE,gBAAgB,IAAM,EAAA,cAAA;AAAA,MACtB,EAAE,WAAA,EAAa,UAAY,EAAA,gBAAA,EAAkB,QAAQ,SAAU,EAAA;AAAA,MAC/D,wBAAA;AAAA,MACA,sBAAA;AAAA,KACF,CAAA;AACA,IAAO,OAAA,MAAA,CAAA;AAAA,GACT;AACF;;;;;;"}
|