@backstage/plugin-scaffolder-backend 1.15.2-next.0 → 1.15.2-next.2

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 CHANGED
@@ -1,5 +1,46 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.15.2-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 33c76caef72a: Added examples for the fs:delete and fs:rename actions
8
+ - 0b1d775be05b: Adds examples to a few scaffolder actions.
9
+ - Updated dependencies
10
+ - @backstage/plugin-catalog-backend@1.12.0-next.2
11
+ - @backstage/backend-plugin-api@0.6.0-next.2
12
+ - @backstage/backend-tasks@0.5.5-next.2
13
+ - @backstage/plugin-scaffolder-node@0.1.6-next.2
14
+ - @backstage/backend-common@0.19.2-next.2
15
+ - @backstage/plugin-catalog-node@1.4.1-next.2
16
+ - @backstage/plugin-permission-node@0.7.11-next.2
17
+ - @backstage/plugin-auth-node@0.2.17-next.2
18
+
19
+ ## 1.15.2-next.1
20
+
21
+ ### Patch Changes
22
+
23
+ - 629cbd194a87: Use `coreServices.rootConfig` instead of `coreService.config`
24
+ - d3b31a791eb1: Deprecated `executeShellCommand`, `RunCommandOptions`, and `fetchContents` from `@backstage/plugin-scaffolder-backend`, since they are useful for Scaffolder modules (who should not be importing from the plugin package itself). You should now import these from `@backstage/plugin-scaffolder-backend-node` instead. `RunCommandOptions` was renamed in the Node package as `ExecuteShellCommandOptions`, for consistency.
25
+ - Updated dependencies
26
+ - @backstage/backend-common@0.19.2-next.1
27
+ - @backstage/plugin-catalog-backend@1.12.0-next.1
28
+ - @backstage/plugin-scaffolder-node@0.1.6-next.1
29
+ - @backstage/plugin-catalog-node@1.4.1-next.1
30
+ - @backstage/plugin-auth-node@0.2.17-next.1
31
+ - @backstage/backend-plugin-api@0.6.0-next.1
32
+ - @backstage/backend-tasks@0.5.5-next.1
33
+ - @backstage/plugin-permission-node@0.7.11-next.1
34
+ - @backstage/integration@1.5.1
35
+ - @backstage/catalog-client@1.4.3
36
+ - @backstage/catalog-model@1.4.1
37
+ - @backstage/config@1.0.8
38
+ - @backstage/errors@1.2.1
39
+ - @backstage/types@1.1.0
40
+ - @backstage/plugin-catalog-common@1.0.15
41
+ - @backstage/plugin-permission-common@0.7.7
42
+ - @backstage/plugin-scaffolder-common@1.3.2
43
+
3
44
  ## 1.15.2-next.0
4
45
 
5
46
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.15.2-next.0",
3
+ "version": "1.15.2-next.2",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,22 +4,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-b514f9e5.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-82f18a18.cjs.js');
8
8
  var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
9
9
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
10
10
  var backendCommon = require('@backstage/backend-common');
11
11
  var integration = require('@backstage/integration');
12
12
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
13
13
  require('@backstage/errors');
14
+ require('@backstage/catalog-model');
14
15
  require('fs-extra');
16
+ require('yaml');
17
+ require('zod');
15
18
  require('path');
19
+ require('luxon');
16
20
  require('globby');
17
21
  require('isbinaryfile');
18
22
  require('isolated-vm');
19
- require('@backstage/catalog-model');
20
23
  require('lodash/get');
21
- require('child_process');
22
- require('stream');
23
24
  require('azure-devops-node-api');
24
25
  require('node-fetch');
25
26
  require('crypto');
@@ -36,12 +37,10 @@ require('@backstage/plugin-scaffolder-common');
36
37
  require('express');
37
38
  require('express-promise-router');
38
39
  require('jsonschema');
39
- require('zod');
40
- require('yaml');
41
- require('luxon');
42
40
  require('uuid');
43
41
  require('winston');
44
42
  require('nunjucks');
43
+ require('stream');
45
44
  require('lodash');
46
45
  require('prom-client');
47
46
  require('@backstage/plugin-permission-common');
@@ -117,7 +116,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin(
117
116
  env.registerInit({
118
117
  deps: {
119
118
  logger: backendPluginApi.coreServices.logger,
120
- config: backendPluginApi.coreServices.config,
119
+ config: backendPluginApi.coreServices.rootConfig,
121
120
  reader: backendPluginApi.coreServices.urlReader,
122
121
  permissions: backendPluginApi.coreServices.permissions,
123
122
  database: backendPluginApi.coreServices.database,
@@ -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: 'scaffolder',\n pluginId: 'templateKind',\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 ScaffolderActionsExtensionPoint,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n TemplateFilter,\n TemplateGlobal,\n TaskBroker,\n} from '@backstage/plugin-scaffolder-backend';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Catalog plugin options\n *\n * @alpha\n */\nexport type ScaffolderPluginOptions = {\n actions?: TemplateAction<any, any>[];\n taskWorkers?: number;\n taskBroker?: TaskBroker;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n};\n\nclass ScaffolderActionsExtensionPointImpl\n implements ScaffolderActionsExtensionPoint\n{\n #actions = new Array<TemplateAction<any, any>>();\n\n addActions(...actions: TemplateAction<any>[]): void {\n this.#actions.push(...actions);\n }\n\n get actions() {\n return this.#actions;\n }\n}\n\n/**\n * Catalog plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin(\n (options?: ScaffolderPluginOptions) => ({\n pluginId: 'scaffolder',\n register(env) {\n const actionsExtensions = new ScaffolderActionsExtensionPointImpl();\n\n env.registerExtensionPoint(\n scaffolderActionsExtensionPoint,\n actionsExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\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 {\n additionalTemplateFilters,\n taskBroker,\n taskWorkers,\n additionalTemplateGlobals,\n } = options ?? {};\n const log = loggerToWinstonLogger(logger);\n\n const actions = options?.actions || [\n ...actionsExtensions.actions,\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 taskWorkers,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions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B,CAAA,OAAA;AAAA,YACrB,GAAGC,gDAAqB,CAAA;AAAA,cACtB,YAAA,EAAcC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAAA,cAC/C,aAAA;AAAA,cACA,MAAA;AAAA,cACA,MAAA;AAAA,cACA,yBAAA;AAAA,cACA,yBAAA;AAAA,aACD,CAAA;AAAA,WACH,CAAA;AAEA,UAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAC5D,UAAI,GAAA,CAAA,IAAA;AAAA,YACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,WACrE,CAAA;AAEA,UAAM,MAAA,MAAA,GAAS,MAAMC,wCAAa,CAAA;AAAA,YAChC,MAAQ,EAAA,GAAA;AAAA,YACR,MAAA;AAAA,YACA,QAAA;AAAA,YACA,aAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAA;AAAA,YACA,UAAA;AAAA,YACA,WAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,YACA,WAAA;AAAA,WACD,CAAA,CAAA;AACD,UAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,SACvB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;;;;;;"}
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: 'scaffolder',\n pluginId: 'templateKind',\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 ScaffolderActionsExtensionPoint,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n TemplateFilter,\n TemplateGlobal,\n TaskBroker,\n} from '@backstage/plugin-scaffolder-backend';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Catalog plugin options\n *\n * @alpha\n */\nexport type ScaffolderPluginOptions = {\n actions?: TemplateAction<any, any>[];\n taskWorkers?: number;\n taskBroker?: TaskBroker;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n};\n\nclass ScaffolderActionsExtensionPointImpl\n implements ScaffolderActionsExtensionPoint\n{\n #actions = new Array<TemplateAction<any, any>>();\n\n addActions(...actions: TemplateAction<any>[]): void {\n this.#actions.push(...actions);\n }\n\n get actions() {\n return this.#actions;\n }\n}\n\n/**\n * Catalog plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin(\n (options?: ScaffolderPluginOptions) => ({\n pluginId: 'scaffolder',\n register(env) {\n const actionsExtensions = new ScaffolderActionsExtensionPointImpl();\n\n env.registerExtensionPoint(\n scaffolderActionsExtensionPoint,\n actionsExtensions,\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 {\n additionalTemplateFilters,\n taskBroker,\n taskWorkers,\n additionalTemplateGlobals,\n } = options ?? {};\n const log = loggerToWinstonLogger(logger);\n\n const actions = options?.actions || [\n ...actionsExtensions.actions,\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 taskWorkers,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,cAAA;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,uDAAA,EAA6B,CAAA,CAAA;AAAA,OACxD;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACfD,MAAM,2BAA2BC,2CAAuB,CAAA;AAAA,EACtD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAC,yCAAA;AAAA,EACd,KAAO,EAAAC,mDAAA;AACT,CAAC,CAAA,CAAA;AAED,MAAM,0BAA0BF,2CAAuB,CAAA;AAAA,EACrD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAG,uCAAA;AAAA,EACd,KAAO,EAAAC,iDAAA;AACT,CAAC,CAAA,CAAA;AAkCM,MAAM,8CACX,wBAAyB,CAAA,0BAAA;AAQpB,MAAM,+BAA+B,wBAAyB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