@backstage/plugin-scaffolder-backend 1.16.6-next.1 → 1.17.0-next.3
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 +73 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +13 -30
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/alpha.d.ts +2 -9
- package/dist/cjs/{ScaffolderEntitiesProcessor-96675669.cjs.js → router-129b368d.cjs.js} +233 -118
- package/dist/cjs/router-129b368d.cjs.js.map +1 -0
- package/dist/index.cjs.js +38 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +8 -11
- package/package.json +21 -20
- package/dist/cjs/ScaffolderEntitiesProcessor-96675669.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.17.0-next.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b5f239b50bcf: Improved the `parseEntityRef` Scaffolder filter by introducing the ability for users to provide default kind and/or namespace values. The filter now takes
|
|
8
|
+
2 arguments, similarly to the original [parseEntityRef](https://github.com/backstage/backstage/blob/v1.17.2/packages/catalog-model/src/entity/ref.ts#L77).
|
|
9
|
+
- d5313ede3529: **DEPRECATION**: Deprecated `ScaffolderEntitiesProcessor`, which should now instead be imported from `@backstage/plugin-catalog-backend-module-scaffolder-entity-model`.
|
|
10
|
+
|
|
11
|
+
`catalogModuleTemplateKind` was also moved to that package and renamed to `catalogModuleScaffolderEntityModel`, without any deprecation since it was an alpha export.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 71114ac50e02: The export for the new backend system has been moved to be the `default` export.
|
|
16
|
+
|
|
17
|
+
For example, if you are currently importing the plugin using the following pattern:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { examplePlugin } from '@backstage/plugin-example-backend';
|
|
21
|
+
|
|
22
|
+
backend.add(examplePlugin);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
It should be migrated to this:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
backend.add(import('@backstage/plugin-example-backend'));
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- @backstage/plugin-catalog-backend@1.13.0-next.3
|
|
33
|
+
- @backstage/catalog-client@1.4.4-next.2
|
|
34
|
+
- @backstage/catalog-model@1.4.2-next.2
|
|
35
|
+
- @backstage/config@1.1.0-next.2
|
|
36
|
+
- @backstage/errors@1.2.2-next.0
|
|
37
|
+
- @backstage/integration@1.7.0-next.3
|
|
38
|
+
- @backstage/plugin-catalog-common@1.0.16-next.2
|
|
39
|
+
- @backstage/plugin-permission-common@0.7.8-next.2
|
|
40
|
+
- @backstage/plugin-scaffolder-common@1.4.1-next.2
|
|
41
|
+
- @backstage/types@1.1.1-next.0
|
|
42
|
+
- @backstage/plugin-permission-node@0.7.14-next.3
|
|
43
|
+
- @backstage/backend-plugin-api@0.6.3-next.3
|
|
44
|
+
- @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.0-next.0
|
|
45
|
+
- @backstage/backend-common@0.19.5-next.3
|
|
46
|
+
- @backstage/backend-tasks@0.5.8-next.3
|
|
47
|
+
- @backstage/plugin-auth-node@0.3.0-next.3
|
|
48
|
+
- @backstage/plugin-catalog-node@1.4.4-next.3
|
|
49
|
+
- @backstage/plugin-scaffolder-node@0.2.3-next.3
|
|
50
|
+
|
|
51
|
+
## 1.16.6-next.2
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- ded27b83ead2: Add examples for `publish:bitbucket` scaffolder actions.
|
|
56
|
+
- 814feeed7343: Update to handle invalid luxon values
|
|
57
|
+
- Updated dependencies
|
|
58
|
+
- @backstage/plugin-catalog-backend@1.13.0-next.2
|
|
59
|
+
- @backstage/config@1.1.0-next.1
|
|
60
|
+
- @backstage/backend-tasks@0.5.8-next.2
|
|
61
|
+
- @backstage/backend-common@0.19.5-next.2
|
|
62
|
+
- @backstage/plugin-auth-node@0.3.0-next.2
|
|
63
|
+
- @backstage/plugin-catalog-node@1.4.4-next.2
|
|
64
|
+
- @backstage/plugin-permission-node@0.7.14-next.2
|
|
65
|
+
- @backstage/integration@1.7.0-next.2
|
|
66
|
+
- @backstage/backend-plugin-api@0.6.3-next.2
|
|
67
|
+
- @backstage/catalog-model@1.4.2-next.1
|
|
68
|
+
- @backstage/plugin-permission-common@0.7.8-next.1
|
|
69
|
+
- @backstage/plugin-scaffolder-node@0.2.3-next.2
|
|
70
|
+
- @backstage/catalog-client@1.4.4-next.1
|
|
71
|
+
- @backstage/errors@1.2.1
|
|
72
|
+
- @backstage/types@1.1.0
|
|
73
|
+
- @backstage/plugin-catalog-common@1.0.16-next.1
|
|
74
|
+
- @backstage/plugin-scaffolder-common@1.4.1-next.1
|
|
75
|
+
|
|
3
76
|
## 1.16.6-next.1
|
|
4
77
|
|
|
5
78
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
7
|
-
var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-96675669.cjs.js');
|
|
8
|
-
var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
|
|
5
|
+
var alpha = require('@backstage/plugin-scaffolder-common/alpha');
|
|
9
6
|
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
|
+
var router = require('./cjs/router-129b368d.cjs.js');
|
|
8
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
10
9
|
var backendCommon = require('@backstage/backend-common');
|
|
11
10
|
var integration = require('@backstage/integration');
|
|
11
|
+
var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
|
|
12
12
|
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
13
13
|
require('@backstage/errors');
|
|
14
14
|
require('@backstage/catalog-model');
|
|
@@ -46,32 +46,16 @@ require('prom-client');
|
|
|
46
46
|
require('@backstage/plugin-permission-common');
|
|
47
47
|
require('url');
|
|
48
48
|
require('os');
|
|
49
|
-
require('@backstage/plugin-catalog-node');
|
|
50
|
-
|
|
51
|
-
const catalogModuleTemplateKind = backendPluginApi.createBackendModule({
|
|
52
|
-
moduleId: "templateKind",
|
|
53
|
-
pluginId: "catalog",
|
|
54
|
-
register(env) {
|
|
55
|
-
env.registerInit({
|
|
56
|
-
deps: {
|
|
57
|
-
catalog: alpha.catalogProcessingExtensionPoint
|
|
58
|
-
},
|
|
59
|
-
async init({ catalog }) {
|
|
60
|
-
catalog.addProcessor(new ScaffolderEntitiesProcessor.ScaffolderEntitiesProcessor());
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
49
|
|
|
66
50
|
const templateConditionExports = pluginPermissionNode.createConditionExports({
|
|
67
51
|
pluginId: "scaffolder",
|
|
68
|
-
resourceType: alpha
|
|
69
|
-
rules:
|
|
52
|
+
resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
|
|
53
|
+
rules: router.scaffolderTemplateRules
|
|
70
54
|
});
|
|
71
55
|
const actionsConditionExports = pluginPermissionNode.createConditionExports({
|
|
72
56
|
pluginId: "scaffolder",
|
|
73
|
-
resourceType: alpha
|
|
74
|
-
rules:
|
|
57
|
+
resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_ACTION,
|
|
58
|
+
rules: router.scaffolderActionRules
|
|
75
59
|
});
|
|
76
60
|
const createScaffolderTemplateConditionalDecision = templateConditionExports.createConditionalDecision;
|
|
77
61
|
const scaffolderTemplateConditions = templateConditionExports.conditions;
|
|
@@ -114,7 +98,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
|
|
|
114
98
|
permissions: backendPluginApi.coreServices.permissions,
|
|
115
99
|
database: backendPluginApi.coreServices.database,
|
|
116
100
|
httpRouter: backendPluginApi.coreServices.httpRouter,
|
|
117
|
-
catalogClient: alpha.catalogServiceRef
|
|
101
|
+
catalogClient: alpha$1.catalogServiceRef
|
|
118
102
|
},
|
|
119
103
|
async init({
|
|
120
104
|
logger,
|
|
@@ -128,7 +112,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
|
|
|
128
112
|
const log = backendCommon.loggerToWinstonLogger(logger);
|
|
129
113
|
const actions = [
|
|
130
114
|
...addedActions,
|
|
131
|
-
...
|
|
115
|
+
...router.createBuiltinActions({
|
|
132
116
|
integrations: integration.ScmIntegrations.fromConfig(config),
|
|
133
117
|
catalogClient,
|
|
134
118
|
reader,
|
|
@@ -141,7 +125,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
|
|
|
141
125
|
log.info(
|
|
142
126
|
`Starting scaffolder with the following actions enabled ${actionIds}`
|
|
143
127
|
);
|
|
144
|
-
const router = await
|
|
128
|
+
const router$1 = await router.createRouter({
|
|
145
129
|
logger: log,
|
|
146
130
|
config,
|
|
147
131
|
database,
|
|
@@ -153,16 +137,15 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
|
|
|
153
137
|
additionalTemplateGlobals,
|
|
154
138
|
permissions
|
|
155
139
|
});
|
|
156
|
-
httpRouter.use(router);
|
|
140
|
+
httpRouter.use(router$1);
|
|
157
141
|
}
|
|
158
142
|
});
|
|
159
143
|
}
|
|
160
144
|
});
|
|
161
145
|
|
|
162
|
-
exports.catalogModuleTemplateKind = catalogModuleTemplateKind;
|
|
163
146
|
exports.createScaffolderActionConditionalDecision = createScaffolderActionConditionalDecision;
|
|
164
147
|
exports.createScaffolderTemplateConditionalDecision = createScaffolderTemplateConditionalDecision;
|
|
148
|
+
exports["default"] = scaffolderPlugin;
|
|
165
149
|
exports.scaffolderActionConditions = scaffolderActionConditions;
|
|
166
|
-
exports.scaffolderPlugin = scaffolderPlugin;
|
|
167
150
|
exports.scaffolderTemplateConditions = scaffolderTemplateConditions;
|
|
168
151
|
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/modules/catalogModuleTemplateKind.ts","../src/service/conditionExports.ts","../src/ScaffolderPlugin.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '../processor';\n\n/**\n * Registers support for the Template kind to the catalog backend plugin.\n *\n * @alpha\n */\nexport const catalogModuleTemplateKind = createBackendModule({\n moduleId: 'templateKind',\n pluginId: 'catalog',\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","/*\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 RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\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 {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Scaffolder plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: Record<string, TemplateFilter> = {};\n const additionalTemplateGlobals: Record<string, TemplateGlobal> = {};\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n Object.assign(additionalTemplateFilters, newFilters);\n },\n addTemplateGlobals(newGlobals) {\n Object.assign(additionalTemplateGlobals, newGlobals);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const log = loggerToWinstonLogger(logger);\n\n const actions = [\n ...addedActions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,cAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EA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AAA,SACH,CAAA;AAEA,QAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAC5D,QAAI,GAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,SACrE,CAAA;AAEA,QAAM,MAAA,MAAA,GAAS,MAAMC,wCAAa,CAAA;AAAA,UAChC,MAAQ,EAAA,GAAA;AAAA,UACR,MAAA;AAAA,UACA,QAAA;AAAA,UACA,aAAA;AAAA,UACA,MAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,WAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/service/conditionExports.ts","../src/ScaffolderPlugin.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 RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\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 {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Scaffolder plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: Record<string, TemplateFilter> = {};\n const additionalTemplateGlobals: Record<string, TemplateGlobal> = {};\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n Object.assign(additionalTemplateFilters, newFilters);\n },\n addTemplateGlobals(newGlobals) {\n Object.assign(additionalTemplateGlobals, newGlobals);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const log = loggerToWinstonLogger(logger);\n\n const actions = [\n ...addedActions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","router","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,2BAA2BA,2CAAuB,CAAA;AAAA,EACtD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAC,uCAAA;AAAA,EACd,KAAO,EAAAC,8BAAA;AACT,CAAC,CAAA,CAAA;AAED,MAAM,0BAA0BF,2CAAuB,CAAA;AAAA,EACrD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAG,qCAAA;AAAA,EACd,KAAO,EAAAC,4BAAA;AACT,CAAC,CAAA,CAAA;AAkCM,MAAM,8CACX,wBAAyB,CAAA,0BAAA;AAQpB,MAAM,+BAA+B,wBAAyB,CAAA,WAAA;AAK9D,MAAM,4CACX,uBAAwB,CAAA,0BAAA;AASnB,MAAM,6BAA6B,uBAAwB,CAAA;;ACnD3D,MAAM,mBAAmBC,oCAAoB,CAAA;AAAA,EAClD,QAAU,EAAA,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B;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,MAAA;AAAA,QACA,MAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,QACA,aAAA;AAAA,QACA,WAAA;AAAA,OACC,EAAA;AACD,QAAM,MAAA,GAAA,GAAMC,oCAAsB,MAAM,CAAA,CAAA;AAExC,QAAA,MAAM,OAAU,GAAA;AAAA,UACd,GAAG,YAAA;AAAA,UACH,GAAGC,2BAAqB,CAAA;AAAA,YACtB,YAAA,EAAcC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAAA,YAC/C,aAAA;AAAA,YACA,MAAA;AAAA,YACA,MAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAEA,QAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAC5D,QAAI,GAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,SACrE,CAAA;AAEA,QAAM,MAAAC,QAAA,GAAS,MAAMC,mBAAa,CAAA;AAAA,UAChC,MAAQ,EAAA,GAAA;AAAA,UACR,MAAA;AAAA,UACA,QAAA;AAAA,UACA,aAAA;AAAA,UACA,MAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,WAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
1
|
import * as _backstage_types from '@backstage/types';
|
|
3
2
|
import * as _backstage_plugin_permission_node from '@backstage/plugin-permission-node';
|
|
4
3
|
import * as _backstage_plugin_scaffolder_common from '@backstage/plugin-scaffolder-common';
|
|
5
4
|
import * as _backstage_plugin_permission_common from '@backstage/plugin-permission-common';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Registers support for the Template kind to the catalog backend plugin.
|
|
9
|
-
*
|
|
10
|
-
* @alpha
|
|
11
|
-
*/
|
|
12
|
-
declare const catalogModuleTemplateKind: () => _backstage_backend_plugin_api.BackendFeature;
|
|
5
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* `createScaffolderTemplateConditionalDecision` can be used when authoring policies to
|
|
@@ -103,4 +96,4 @@ declare const scaffolderActionConditions: _backstage_plugin_permission_node.Cond
|
|
|
103
96
|
*/
|
|
104
97
|
declare const scaffolderPlugin: () => _backstage_backend_plugin_api.BackendFeature;
|
|
105
98
|
|
|
106
|
-
export {
|
|
99
|
+
export { createScaffolderActionConditionalDecision, createScaffolderTemplateConditionalDecision, scaffolderPlugin as default, scaffolderActionConditions, scaffolderTemplateConditions };
|