@backstage/plugin-catalog-backend-module-scaffolder-entity-model 0.0.0-nightly-20230913021415
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 +33 -0
- package/README.md +3 -0
- package/dist/index.cjs.js +88 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/package.json +46 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @backstage/plugin-catalog-backend-module-scaffolder-entity-model
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20230913021415
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d5313ede3529: Added a dedicated module to collect the `ScaffolderEntitiesProcessor` and `catalogModuleTemplateKind`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/catalog-model@0.0.0-nightly-20230913021415
|
|
13
|
+
- @backstage/plugin-catalog-common@0.0.0-nightly-20230913021415
|
|
14
|
+
- @backstage/plugin-scaffolder-common@0.0.0-nightly-20230913021415
|
|
15
|
+
- @backstage/backend-common@0.0.0-nightly-20230913021415
|
|
16
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20230913021415
|
|
17
|
+
- @backstage/plugin-catalog-node@0.0.0-nightly-20230913021415
|
|
18
|
+
|
|
19
|
+
## 0.1.0-next.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- d5313ede3529: Added a dedicated module to collect the `ScaffolderEntitiesProcessor` and `catalogModuleTemplateKind`.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- @backstage/catalog-model@1.4.2-next.2
|
|
29
|
+
- @backstage/plugin-catalog-common@1.0.16-next.2
|
|
30
|
+
- @backstage/plugin-scaffolder-common@1.4.1-next.2
|
|
31
|
+
- @backstage/backend-plugin-api@0.6.3-next.3
|
|
32
|
+
- @backstage/backend-common@0.19.5-next.3
|
|
33
|
+
- @backstage/plugin-catalog-node@1.4.4-next.3
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
6
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
7
|
+
var pluginScaffolderCommon = require('@backstage/plugin-scaffolder-common');
|
|
8
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
|
+
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
10
|
+
var pluginCatalogBackendModuleScaffolderEntityModel = require('@backstage/plugin-catalog-backend-module-scaffolder-entity-model');
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __publicField = (obj, key, value) => {
|
|
15
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
18
|
+
class ScaffolderEntitiesProcessor {
|
|
19
|
+
constructor() {
|
|
20
|
+
__publicField(this, "validators", [pluginScaffolderCommon.templateEntityV1beta3Validator]);
|
|
21
|
+
}
|
|
22
|
+
getProcessorName() {
|
|
23
|
+
return "ScaffolderEntitiesProcessor";
|
|
24
|
+
}
|
|
25
|
+
async validateEntityKind(entity) {
|
|
26
|
+
for (const validator of this.validators) {
|
|
27
|
+
if (await validator.check(entity)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
async postProcessEntity(entity, _location, emit) {
|
|
34
|
+
const selfRef = catalogModel.getCompoundEntityRef(entity);
|
|
35
|
+
if (entity.apiVersion === "scaffolder.backstage.io/v1beta3" && entity.kind === "Template") {
|
|
36
|
+
const template = entity;
|
|
37
|
+
const target = template.spec.owner;
|
|
38
|
+
if (target) {
|
|
39
|
+
const targetRef = catalogModel.parseEntityRef(target, {
|
|
40
|
+
defaultKind: "Group",
|
|
41
|
+
defaultNamespace: selfRef.namespace
|
|
42
|
+
});
|
|
43
|
+
emit(
|
|
44
|
+
pluginCatalogNode.processingResult.relation({
|
|
45
|
+
source: selfRef,
|
|
46
|
+
type: catalogModel.RELATION_OWNED_BY,
|
|
47
|
+
target: {
|
|
48
|
+
kind: targetRef.kind,
|
|
49
|
+
namespace: targetRef.namespace,
|
|
50
|
+
name: targetRef.name
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
emit(
|
|
55
|
+
pluginCatalogNode.processingResult.relation({
|
|
56
|
+
source: {
|
|
57
|
+
kind: targetRef.kind,
|
|
58
|
+
namespace: targetRef.namespace,
|
|
59
|
+
name: targetRef.name
|
|
60
|
+
},
|
|
61
|
+
type: catalogModel.RELATION_OWNER_OF,
|
|
62
|
+
target: selfRef
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return entity;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const catalogModuleScaffolderEntityModel = backendPluginApi.createBackendModule({
|
|
72
|
+
pluginId: "catalog",
|
|
73
|
+
moduleId: "scaffolderEntityModel",
|
|
74
|
+
register(env) {
|
|
75
|
+
env.registerInit({
|
|
76
|
+
deps: {
|
|
77
|
+
catalog: alpha.catalogProcessingExtensionPoint
|
|
78
|
+
},
|
|
79
|
+
async init({ catalog }) {
|
|
80
|
+
catalog.addProcessor(new pluginCatalogBackendModuleScaffolderEntityModel.ScaffolderEntitiesProcessor());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
exports.ScaffolderEntitiesProcessor = ScaffolderEntitiesProcessor;
|
|
87
|
+
exports["default"] = catalogModuleScaffolderEntityModel;
|
|
88
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/processor/ScaffolderEntitiesProcessor.ts","../src/module.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 {\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n RELATION_OWNED_BY,\n RELATION_OWNER_OF,\n} from '@backstage/catalog-model';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n TemplateEntityV1beta3,\n templateEntityV1beta3Validator,\n} from '@backstage/plugin-scaffolder-common';\n\n/**\n * Adds support for scaffolder specific entity kinds to the catalog.\n *\n * @public\n */\nexport class ScaffolderEntitiesProcessor implements CatalogProcessor {\n getProcessorName(): string {\n return 'ScaffolderEntitiesProcessor';\n }\n\n private readonly validators = [templateEntityV1beta3Validator];\n\n async validateEntityKind(entity: Entity): Promise<boolean> {\n for (const validator of this.validators) {\n if (await validator.check(entity)) {\n return true;\n }\n }\n\n return false;\n }\n\n async postProcessEntity(\n entity: Entity,\n _location: LocationSpec,\n emit: CatalogProcessorEmit,\n ): Promise<Entity> {\n const selfRef = getCompoundEntityRef(entity);\n\n if (\n entity.apiVersion === 'scaffolder.backstage.io/v1beta3' &&\n entity.kind === 'Template'\n ) {\n const template = entity as TemplateEntityV1beta3;\n\n const target = template.spec.owner;\n if (target) {\n const targetRef = parseEntityRef(target, {\n defaultKind: 'Group',\n defaultNamespace: selfRef.namespace,\n });\n emit(\n processingResult.relation({\n source: selfRef,\n type: RELATION_OWNED_BY,\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: RELATION_OWNER_OF,\n target: selfRef,\n }),\n );\n }\n }\n\n return entity;\n }\n}\n","/*\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';\n\n/**\n * Registers support for the scaffolder specific entity model (e.g. the Template\n * kind) to the catalog backend plugin.\n *\n * @public\n */\nexport const catalogModuleScaffolderEntityModel = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'scaffolderEntityModel',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addProcessor(new ScaffolderEntitiesProcessor());\n },\n });\n },\n});\n"],"names":["templateEntityV1beta3Validator","getCompoundEntityRef","parseEntityRef","processingResult","RELATION_OWNED_BY","RELATION_OWNER_OF","createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor"],"mappings":";;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AAA,WACD,CAAA;AAAA,SACH,CAAA;AACA,QAAA,IAAA;AAAA,UACED,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,EAAAE,8BAAA;AAAA,YACN,MAAQ,EAAA,OAAA;AAAA,WACT,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAEA,IAAO,OAAA,MAAA,CAAA;AAAA,GACT;AACF;;AC5EO,MAAM,qCAAqCC,oCAAoB,CAAA;AAAA,EACpE,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,uBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAW,EAAA;AACtB,QAAQ,OAAA,CAAA,YAAA,CAAa,IAAIC,2EAAA,EAA6B,CAAA,CAAA;AAAA,OACxD;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Entity } from '@backstage/catalog-model';
|
|
2
|
+
import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-node';
|
|
3
|
+
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
|
4
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Adds support for scaffolder specific entity kinds to the catalog.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
|
12
|
+
getProcessorName(): string;
|
|
13
|
+
private readonly validators;
|
|
14
|
+
validateEntityKind(entity: Entity): Promise<boolean>;
|
|
15
|
+
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Registers support for the scaffolder specific entity model (e.g. the Template
|
|
20
|
+
* kind) to the catalog backend plugin.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare const catalogModuleScaffolderEntityModel: () => _backstage_backend_plugin_api.BackendFeature;
|
|
25
|
+
|
|
26
|
+
export { ScaffolderEntitiesProcessor, catalogModuleScaffolderEntityModel as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-catalog-backend-module-scaffolder-entity-model",
|
|
3
|
+
"description": "Adds support for the scaffolder specific entity model (e.g. the Template kind) to the catalog backend plugin.",
|
|
4
|
+
"version": "0.0.0-nightly-20230913021415",
|
|
5
|
+
"main": "./dist/index.cjs.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./dist/index.cjs.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.cjs.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"backstage": {
|
|
20
|
+
"role": "backend-plugin-module"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"start": "backstage-cli package start",
|
|
24
|
+
"build": "backstage-cli package build",
|
|
25
|
+
"lint": "backstage-cli package lint",
|
|
26
|
+
"test": "backstage-cli package test",
|
|
27
|
+
"clean": "backstage-cli package clean",
|
|
28
|
+
"prepack": "backstage-cli package prepack",
|
|
29
|
+
"postpack": "backstage-cli package postpack"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@backstage/backend-common": "^0.0.0-nightly-20230913021415",
|
|
33
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20230913021415",
|
|
34
|
+
"@backstage/catalog-model": "^0.0.0-nightly-20230913021415",
|
|
35
|
+
"@backstage/plugin-catalog-common": "^0.0.0-nightly-20230913021415",
|
|
36
|
+
"@backstage/plugin-catalog-node": "^0.0.0-nightly-20230913021415",
|
|
37
|
+
"@backstage/plugin-scaffolder-common": "^0.0.0-nightly-20230913021415"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20230913021415",
|
|
41
|
+
"@backstage/cli": "^0.0.0-nightly-20230913021415"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|