@backstage/plugin-scaffolder-backend 1.13.2-next.2 → 1.14.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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 67115f532b8: Expose both types of scaffolder permissions and rules through the metadata endpoint.
8
+
9
+ The metadata endpoint now correctly exposes both types of scaffolder permissions and rules (for both the template and action resource types) through the metadata endpoint.
10
+
11
+ - a73b3c0b097: Add ability to use `defaultNamespace` and `defaultKind` for scaffolder action `catalog:fetch`
12
+
13
+ ### Patch Changes
14
+
15
+ - 1a48b84901c: Bump minimum required version of `vm2` to be 3.9.18
16
+ - d20c87966a4: Bump minimum required version of `vm2` to be 3.9.17
17
+ - 6d954de4b06: Update typing for `RouterOptions::actions` and `ScaffolderActionsExtensionPoint::addActions` to allow any kind of action being assigned to it.
18
+ - Updated dependencies
19
+ - @backstage/plugin-catalog-backend@1.9.1
20
+ - @backstage/backend-common@0.18.5
21
+ - @backstage/integration@1.4.5
22
+ - @backstage/plugin-scaffolder-common@1.3.0
23
+ - @backstage/plugin-permission-node@0.7.8
24
+ - @backstage/plugin-scaffolder-node@0.1.3
25
+ - @backstage/backend-tasks@0.5.2
26
+ - @backstage/plugin-auth-node@0.2.14
27
+ - @backstage/plugin-catalog-node@1.3.6
28
+ - @backstage/backend-plugin-api@0.5.2
29
+ - @backstage/catalog-client@1.4.1
30
+ - @backstage/catalog-model@1.3.0
31
+ - @backstage/config@1.0.7
32
+ - @backstage/errors@1.1.5
33
+ - @backstage/types@1.0.2
34
+ - @backstage/plugin-catalog-common@1.0.13
35
+ - @backstage/plugin-permission-common@0.7.5
36
+
3
37
  ## 1.13.2-next.2
4
38
 
5
39
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.13.2-next.2",
3
+ "version": "1.14.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ 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-2f24bb9e.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-021c5dcb.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');
@@ -317,6 +317,7 @@ function createFetchCatalogEntityAction(options) {
317
317
  id: id$2,
318
318
  description: "Returns entity or entities from the catalog by entity reference(s)",
319
319
  examples: examples$2,
320
+ supportsDryRun: true,
320
321
  schema: {
321
322
  input: zod.z.object({
322
323
  entityRef: zod.z.string({
@@ -327,7 +328,9 @@ function createFetchCatalogEntityAction(options) {
327
328
  }).optional(),
328
329
  optional: zod.z.boolean({
329
330
  description: "Allow the entity or entities to optionally exist. Default: false"
330
- }).optional()
331
+ }).optional(),
332
+ defaultKind: zod.z.string({ description: "The default kind" }).optional(),
333
+ defaultNamespace: zod.z.string({ description: "The default namespace" }).optional()
331
334
  }),
332
335
  output: zod.z.object({
333
336
  entity: zod.z.any({
@@ -342,7 +345,7 @@ function createFetchCatalogEntityAction(options) {
342
345
  },
343
346
  async handler(ctx) {
344
347
  var _a, _b;
345
- const { entityRef, entityRefs, optional } = ctx.input;
348
+ const { entityRef, entityRefs, optional, defaultKind, defaultNamespace } = ctx.input;
346
349
  if (!entityRef && !entityRefs) {
347
350
  if (optional) {
348
351
  return;
@@ -350,9 +353,14 @@ function createFetchCatalogEntityAction(options) {
350
353
  throw new Error("Missing entity reference or references");
351
354
  }
352
355
  if (entityRef) {
353
- const entity = await catalogClient.getEntityByRef(entityRef, {
354
- token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
355
- });
356
+ const entity = await catalogClient.getEntityByRef(
357
+ catalogModel.stringifyEntityRef(
358
+ catalogModel.parseEntityRef(entityRef, { defaultKind, defaultNamespace })
359
+ ),
360
+ {
361
+ token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
362
+ }
363
+ );
356
364
  if (!entity && !optional) {
357
365
  throw new Error(`Entity ${entityRef} not found`);
358
366
  }
@@ -360,7 +368,13 @@ function createFetchCatalogEntityAction(options) {
360
368
  }
361
369
  if (entityRefs) {
362
370
  const entities = await catalogClient.getEntitiesByRefs(
363
- { entityRefs },
371
+ {
372
+ entityRefs: entityRefs.map(
373
+ (ref) => catalogModel.stringifyEntityRef(
374
+ catalogModel.parseEntityRef(ref, { defaultKind, defaultNamespace })
375
+ )
376
+ )
377
+ },
364
378
  {
365
379
  token: (_b = ctx.secrets) == null ? void 0 : _b.backstageToken
366
380
  }
@@ -5622,6 +5636,12 @@ async function findTemplate(options) {
5622
5636
  return template;
5623
5637
  }
5624
5638
 
5639
+ function isTemplatePermissionRuleInput(permissionRule) {
5640
+ return permissionRule.resourceType === alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE;
5641
+ }
5642
+ function isActionPermissionRuleInput(permissionRule) {
5643
+ return permissionRule.resourceType === alpha.RESOURCE_TYPE_SCAFFOLDER_ACTION;
5644
+ }
5625
5645
  function isSupportedTemplate(entity) {
5626
5646
  return entity.apiVersion === "scaffolder.backstage.io/v1beta3";
5627
5647
  }
@@ -5753,14 +5773,29 @@ async function createRouter(options) {
5753
5773
  const templateRules = Object.values(
5754
5774
  scaffolderTemplateRules
5755
5775
  );
5776
+ const actionRules = Object.values(
5777
+ scaffolderActionRules
5778
+ );
5756
5779
  if (permissionRules) {
5757
- templateRules.push(...permissionRules);
5780
+ templateRules.push(
5781
+ ...permissionRules.filter(isTemplatePermissionRuleInput)
5782
+ );
5783
+ actionRules.push(...permissionRules.filter(isActionPermissionRuleInput));
5758
5784
  }
5759
5785
  const isAuthorized = pluginPermissionNode.createConditionAuthorizer(Object.values(templateRules));
5760
5786
  const permissionIntegrationRouter = pluginPermissionNode.createPermissionIntegrationRouter({
5761
- resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
5762
- permissions: alpha.scaffolderPermissions,
5763
- rules: templateRules
5787
+ resources: [
5788
+ {
5789
+ resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
5790
+ permissions: alpha.scaffolderTemplatePermissions,
5791
+ rules: templateRules
5792
+ },
5793
+ {
5794
+ resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_ACTION,
5795
+ permissions: alpha.scaffolderActionPermissions,
5796
+ rules: actionRules
5797
+ }
5798
+ ]
5764
5799
  });
5765
5800
  router.use(permissionIntegrationRouter);
5766
5801
  router.get(
@@ -6139,4 +6174,4 @@ exports.executeShellCommand = executeShellCommand;
6139
6174
  exports.fetchContents = fetchContents;
6140
6175
  exports.scaffolderActionRules = scaffolderActionRules;
6141
6176
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6142
- //# sourceMappingURL=ScaffolderEntitiesProcessor-2f24bb9e.cjs.js.map
6177
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-021c5dcb.cjs.js.map