@backstage/plugin-scaffolder-backend 1.11.1-next.0 → 1.12.0-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/dist/index.cjs.js CHANGED
@@ -8,6 +8,7 @@ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
8
8
  var yaml = require('yaml');
9
9
  var fs = require('fs-extra');
10
10
  var backendCommon = require('@backstage/backend-common');
11
+ var zod = require('zod');
11
12
  var integration = require('@backstage/integration');
12
13
  var path = require('path');
13
14
  var globby = require('globby');
@@ -36,7 +37,6 @@ var promClient = require('prom-client');
36
37
  var pluginScaffolderCommon = require('@backstage/plugin-scaffolder-common');
37
38
  var express = require('express');
38
39
  var Router = require('express-promise-router');
39
- var zod = require('zod');
40
40
  var url = require('url');
41
41
  var os = require('os');
42
42
  var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
@@ -252,24 +252,16 @@ function createCatalogWriteAction() {
252
252
  return pluginScaffolderNode.createTemplateAction({
253
253
  id: id$2,
254
254
  description: "Writes the catalog-info.yaml for your template",
255
- examples: examples$2,
256
255
  schema: {
257
- input: {
258
- type: "object",
259
- properties: {
260
- filePath: {
261
- title: "Catalog file path",
262
- description: "Defaults to catalog-info.yaml",
263
- type: "string"
264
- },
265
- entity: {
266
- title: "Entity info to write catalog-info.yaml",
267
- description: "You can provide the same values used in the Entity schema.",
268
- type: "object"
269
- }
270
- }
271
- }
256
+ input: zod.z.object({
257
+ filePath: zod.z.string().optional().describe("Defaults to catalog-info.yaml"),
258
+ // TODO: this should reference an zod entity validator if it existed.
259
+ entity: zod.z.object({}).passthrough().describe(
260
+ "You can provide the same values used in the Entity schema."
261
+ )
262
+ })
272
263
  },
264
+ examples: examples$2,
273
265
  supportsDryRun: true,
274
266
  async handler(ctx) {
275
267
  ctx.logStream.write(`Writing catalog-info.yaml`);
@@ -3494,11 +3486,12 @@ const defaultClientFactory = async ({
3494
3486
  ...{ throttle: { enabled: false } }
3495
3487
  });
3496
3488
  };
3497
- const createPublishGithubPullRequestAction = ({
3498
- integrations,
3499
- githubCredentialsProvider,
3500
- clientFactory = defaultClientFactory
3501
- }) => {
3489
+ const createPublishGithubPullRequestAction = (options) => {
3490
+ const {
3491
+ integrations,
3492
+ githubCredentialsProvider,
3493
+ clientFactory = defaultClientFactory
3494
+ } = options;
3502
3495
  return pluginScaffolderNode.createTemplateAction({
3503
3496
  id: "publish:github:pull-request",
3504
3497
  schema: {
@@ -4394,7 +4387,8 @@ class DatabaseTaskStore {
4394
4387
  });
4395
4388
  return { events };
4396
4389
  }
4397
- async shutdownTask({ taskId }) {
4390
+ async shutdownTask(options) {
4391
+ const { taskId } = options;
4398
4392
  const message = `This task was marked as stale as it exceeded its timeout`;
4399
4393
  const statusStepEvents = (await this.listEvents({ taskId })).events.filter(
4400
4394
  ({ body }) => body == null ? void 0 : body.stepId
@@ -5199,13 +5193,12 @@ async function findTemplate(options) {
5199
5193
  function isSupportedTemplate(entity) {
5200
5194
  return entity.apiVersion === "scaffolder.backstage.io/v1beta3";
5201
5195
  }
5202
- function buildDefaultIdentityClient({
5203
- logger
5204
- }) {
5196
+ function buildDefaultIdentityClient(options) {
5205
5197
  return {
5206
5198
  getIdentity: async ({ request }) => {
5207
5199
  var _a;
5208
5200
  const header = request.headers.authorization;
5201
+ const { logger } = options;
5209
5202
  if (!header) {
5210
5203
  return void 0;
5211
5204
  }
@@ -5225,6 +5218,9 @@ function buildDefaultIdentityClient({
5225
5218
  if (typeof sub !== "string") {
5226
5219
  throw new TypeError("Expected string sub claim");
5227
5220
  }
5221
+ if (sub === "backstage-server") {
5222
+ return void 0;
5223
+ }
5228
5224
  catalogModel.parseEntityRef(sub);
5229
5225
  return {
5230
5226
  identity: {
@@ -5258,7 +5254,7 @@ async function createRouter(options) {
5258
5254
  additionalTemplateGlobals
5259
5255
  } = options;
5260
5256
  const logger = parentLogger.child({ plugin: "scaffolder" });
5261
- const identity = options.identity || buildDefaultIdentityClient({ logger });
5257
+ const identity = options.identity || buildDefaultIdentityClient(options);
5262
5258
  const workingDirectory = await getWorkingDirectory(config, logger);
5263
5259
  const integrations = integration.ScmIntegrations.fromConfig(config);
5264
5260
  let taskBroker;