@backstage/plugin-scaffolder-backend 1.15.2-next.1 → 1.16.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.
@@ -81,14 +81,13 @@ var winston__namespace = /*#__PURE__*/_interopNamespace(winston);
81
81
  var nunjucks__default = /*#__PURE__*/_interopDefaultLegacy(nunjucks);
82
82
  var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
83
83
 
84
- const id$4 = "catalog:register";
85
- const examples$4 = [
84
+ const examples$b = [
86
85
  {
87
86
  description: "Register with the catalog",
88
87
  example: yaml__default["default"].stringify({
89
88
  steps: [
90
89
  {
91
- action: id$4,
90
+ action: "catalog:register",
92
91
  id: "register-with-catalog",
93
92
  name: "Register with the catalog",
94
93
  input: {
@@ -99,12 +98,14 @@ const examples$4 = [
99
98
  })
100
99
  }
101
100
  ];
101
+
102
+ const id$4 = "catalog:register";
102
103
  function createCatalogRegisterAction(options) {
103
104
  const { catalogClient, integrations } = options;
104
105
  return pluginScaffolderNode.createTemplateAction({
105
106
  id: id$4,
106
107
  description: "Registers entities from a catalog descriptor file in the workspace into the software catalog.",
107
- examples: examples$4,
108
+ examples: examples$b,
108
109
  schema: {
109
110
  input: {
110
111
  oneOf: [
@@ -228,14 +229,13 @@ function createCatalogRegisterAction(options) {
228
229
  });
229
230
  }
230
231
 
231
- const id$3 = "catalog:write";
232
- const examples$3 = [
232
+ const examples$a = [
233
233
  {
234
234
  description: "Write a catalog yaml file",
235
235
  example: yaml__namespace.stringify({
236
236
  steps: [
237
237
  {
238
- action: id$3,
238
+ action: "catalog:write",
239
239
  id: "create-catalog-info-file",
240
240
  name: "Create catalog file",
241
241
  input: {
@@ -258,6 +258,8 @@ const examples$3 = [
258
258
  })
259
259
  }
260
260
  ];
261
+
262
+ const id$3 = "catalog:write";
261
263
  function createCatalogWriteAction() {
262
264
  return pluginScaffolderNode.createTemplateAction({
263
265
  id: id$3,
@@ -271,7 +273,7 @@ function createCatalogWriteAction() {
271
273
  )
272
274
  })
273
275
  },
274
- examples: examples$3,
276
+ examples: examples$a,
275
277
  supportsDryRun: true,
276
278
  async handler(ctx) {
277
279
  ctx.logStream.write(`Writing catalog-info.yaml`);
@@ -285,14 +287,13 @@ function createCatalogWriteAction() {
285
287
  });
286
288
  }
287
289
 
288
- const id$2 = "catalog:fetch";
289
- const examples$2 = [
290
+ const examples$9 = [
290
291
  {
291
292
  description: "Fetch entity by reference",
292
293
  example: yaml__default["default"].stringify({
293
294
  steps: [
294
295
  {
295
- action: id$2,
296
+ action: "catalog:fetch",
296
297
  id: "fetch",
297
298
  name: "Fetch catalog entity",
298
299
  input: {
@@ -303,11 +304,11 @@ const examples$2 = [
303
304
  })
304
305
  },
305
306
  {
306
- description: "Fetch multiple entities by referencse",
307
+ description: "Fetch multiple entities by reference",
307
308
  example: yaml__default["default"].stringify({
308
309
  steps: [
309
310
  {
310
- action: id$2,
311
+ action: "catalog:fetch",
311
312
  id: "fetchMultiple",
312
313
  name: "Fetch catalog entities",
313
314
  input: {
@@ -318,12 +319,14 @@ const examples$2 = [
318
319
  })
319
320
  }
320
321
  ];
322
+
323
+ const id$2 = "catalog:fetch";
321
324
  function createFetchCatalogEntityAction(options) {
322
325
  const { catalogClient } = options;
323
326
  return pluginScaffolderNode.createTemplateAction({
324
327
  id: id$2,
325
328
  description: "Returns entity or entities from the catalog by entity reference(s)",
326
- examples: examples$2,
329
+ examples: examples$9,
327
330
  supportsDryRun: true,
328
331
  schema: {
329
332
  input: zod.z.object({
@@ -398,14 +401,13 @@ function createFetchCatalogEntityAction(options) {
398
401
  });
399
402
  }
400
403
 
401
- const id$1 = "debug:log";
402
- const examples$1 = [
404
+ const examples$8 = [
403
405
  {
404
406
  description: "Write a debug message",
405
407
  example: yaml__default["default"].stringify({
406
408
  steps: [
407
409
  {
408
- action: id$1,
410
+ action: "debug:log",
409
411
  id: "write-debug-line",
410
412
  name: 'Write "Hello Backstage!" log line',
411
413
  input: {
@@ -420,7 +422,7 @@ const examples$1 = [
420
422
  example: yaml__default["default"].stringify({
421
423
  steps: [
422
424
  {
423
- action: id$1,
425
+ action: "debug:log",
424
426
  id: "write-workspace-directory",
425
427
  name: "List the workspace directory",
426
428
  input: {
@@ -431,11 +433,13 @@ const examples$1 = [
431
433
  })
432
434
  }
433
435
  ];
436
+
437
+ const id$1 = "debug:log";
434
438
  function createDebugLogAction() {
435
439
  return pluginScaffolderNode.createTemplateAction({
436
440
  id: id$1,
437
441
  description: "Writes a message into the log or lists all files in the workspace.",
438
- examples: examples$1,
442
+ examples: examples$8,
439
443
  schema: {
440
444
  input: {
441
445
  type: "object",
@@ -482,15 +486,28 @@ async function recursiveReadDir(dir) {
482
486
  return files.reduce((a, f) => a.concat(f), []);
483
487
  }
484
488
 
485
- const id = "debug:wait";
486
- const MAX_WAIT_TIME_IN_ISO = "T00:00:30";
487
- const examples = [
489
+ const examples$7 = [
490
+ {
491
+ description: "Waiting for 50 milliseconds",
492
+ example: yaml__default["default"].stringify({
493
+ steps: [
494
+ {
495
+ action: "debug:wait",
496
+ id: "wait-milliseconds",
497
+ name: "Waiting for 50 milliseconds",
498
+ input: {
499
+ milliseconds: 50
500
+ }
501
+ }
502
+ ]
503
+ })
504
+ },
488
505
  {
489
506
  description: "Waiting for 5 seconds",
490
507
  example: yaml__default["default"].stringify({
491
508
  steps: [
492
509
  {
493
- action: id,
510
+ action: "debug:wait",
494
511
  id: "wait-5sec",
495
512
  name: "Waiting for 5 seconds",
496
513
  input: {
@@ -501,21 +518,24 @@ const examples = [
501
518
  })
502
519
  },
503
520
  {
504
- description: "Waiting for 5 minutes",
521
+ description: "Waiting for 1 minutes",
505
522
  example: yaml__default["default"].stringify({
506
523
  steps: [
507
524
  {
508
- action: id,
509
- id: "wait-5min",
510
- name: "Waiting for 5 minutes",
525
+ action: "debug:wait",
526
+ id: "wait-1min",
527
+ name: "Waiting for 1 minutes",
511
528
  input: {
512
- minutes: 5
529
+ minutes: 1
513
530
  }
514
531
  }
515
532
  ]
516
533
  })
517
534
  }
518
535
  ];
536
+
537
+ const id = "debug:wait";
538
+ const MAX_WAIT_TIME_IN_ISO = "T00:00:30";
519
539
  function createWaitAction(options) {
520
540
  const toDuration = (maxWaitTime) => {
521
541
  if (maxWaitTime) {
@@ -529,7 +549,7 @@ function createWaitAction(options) {
529
549
  return pluginScaffolderNode.createTemplateAction({
530
550
  id,
531
551
  description: "Waits for a certain period of time.",
532
- examples,
552
+ examples: examples$7,
533
553
  schema: {
534
554
  input: {
535
555
  type: "object",
@@ -574,10 +594,46 @@ function createWaitAction(options) {
574
594
  });
575
595
  }
576
596
 
597
+ const examples$6 = [
598
+ {
599
+ description: "Downloads content and places it in the workspace.",
600
+ example: yaml__default["default"].stringify({
601
+ steps: [
602
+ {
603
+ action: "fetch:plain",
604
+ id: "fetch-plain",
605
+ name: "Fetch plain",
606
+ input: {
607
+ url: "https://github.com/backstage/community/tree/main/backstage-community-sessions/assets"
608
+ }
609
+ }
610
+ ]
611
+ })
612
+ },
613
+ {
614
+ description: "Optionally, if you would prefer the data to be downloaded to a subdirectory in the workspace you may specify the \u2018targetPath\u2019 input option.",
615
+ example: yaml__default["default"].stringify({
616
+ steps: [
617
+ {
618
+ action: "fetch:plain",
619
+ id: "fetch-plain",
620
+ name: "Fetch plain",
621
+ input: {
622
+ url: "https://github.com/backstage/community/tree/main/backstage-community-sessions/assets",
623
+ targetPath: "fetched-data"
624
+ }
625
+ }
626
+ ]
627
+ })
628
+ }
629
+ ];
630
+
631
+ const ACTION_ID = "fetch:plain";
577
632
  function createFetchPlainAction(options) {
578
633
  const { reader, integrations } = options;
579
634
  return pluginScaffolderNode.createTemplateAction({
580
- id: "fetch:plain",
635
+ id: ACTION_ID,
636
+ examples: examples$6,
581
637
  description: "Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
582
638
  schema: {
583
639
  input: {
@@ -614,11 +670,31 @@ function createFetchPlainAction(options) {
614
670
  });
615
671
  }
616
672
 
673
+ const examples$5 = [
674
+ {
675
+ description: "Downloads a file and places it in the workspace.",
676
+ example: yaml__default["default"].stringify({
677
+ steps: [
678
+ {
679
+ action: "fetch:plain:file",
680
+ id: "fetch-plain-file",
681
+ name: "Fetch plain file",
682
+ input: {
683
+ url: "https://github.com/backstage/community/tree/main/backstage-community-sessions/assets/Backstage%20Community%20Sessions.png",
684
+ targetPath: "target-path"
685
+ }
686
+ }
687
+ ]
688
+ })
689
+ }
690
+ ];
691
+
617
692
  function createFetchPlainFileAction(options) {
618
693
  const { reader, integrations } = options;
619
694
  return pluginScaffolderNode.createTemplateAction({
620
695
  id: "fetch:plain:file",
621
696
  description: "Downloads single file and places it in the workspace.",
697
+ examples: examples$5,
622
698
  schema: {
623
699
  input: {
624
700
  type: "object",
@@ -886,6 +962,31 @@ const createDefaultFilters = ({
886
962
  };
887
963
  };
888
964
 
965
+ const examples$4 = [
966
+ {
967
+ description: "Downloads a skelaton directory that lives alongside the template file and fill it out with values.",
968
+ example: yaml__default["default"].stringify({
969
+ steps: [
970
+ {
971
+ action: "fetch:template",
972
+ id: "fetch-template",
973
+ name: "Fetch template",
974
+ input: {
975
+ url: "./skeleton",
976
+ targetPath: "./target",
977
+ values: {
978
+ name: "test-project",
979
+ count: 1234,
980
+ itemList: ["first", "second", "third"],
981
+ showDummyFile: false
982
+ }
983
+ }
984
+ }
985
+ ]
986
+ })
987
+ }
988
+ ];
989
+
889
990
  function createFetchTemplateAction(options) {
890
991
  const {
891
992
  reader,
@@ -897,6 +998,7 @@ function createFetchTemplateAction(options) {
897
998
  return pluginScaffolderNode.createTemplateAction({
898
999
  id: "fetch:template",
899
1000
  description: "Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
1001
+ examples: examples$4,
900
1002
  schema: {
901
1003
  input: {
902
1004
  type: "object",
@@ -1101,10 +1203,29 @@ function containsSkippedContent(localOutputPath) {
1101
1203
  return localOutputPath === "" || localOutputPath.startsWith("/") || localOutputPath.includes("//");
1102
1204
  }
1103
1205
 
1206
+ const examples$3 = [
1207
+ {
1208
+ description: "Delete specified files",
1209
+ example: yaml__namespace.stringify({
1210
+ steps: [
1211
+ {
1212
+ action: "fs:delete",
1213
+ id: "deleteFiles",
1214
+ name: "Delete files",
1215
+ input: {
1216
+ files: ["file1.txt", "file2.txt"]
1217
+ }
1218
+ }
1219
+ ]
1220
+ })
1221
+ }
1222
+ ];
1223
+
1104
1224
  const createFilesystemDeleteAction = () => {
1105
1225
  return pluginScaffolderNode.createTemplateAction({
1106
1226
  id: "fs:delete",
1107
1227
  description: "Deletes files and directories from the workspace",
1228
+ examples: examples$3,
1108
1229
  schema: {
1109
1230
  input: {
1110
1231
  required: ["files"],
@@ -1141,10 +1262,33 @@ const createFilesystemDeleteAction = () => {
1141
1262
  });
1142
1263
  };
1143
1264
 
1265
+ const examples$2 = [
1266
+ {
1267
+ description: "Rename specified files ",
1268
+ example: yaml__namespace.stringify({
1269
+ steps: [
1270
+ {
1271
+ action: "fs:rename",
1272
+ id: "renameFiles",
1273
+ name: "Rename files",
1274
+ input: {
1275
+ files: [
1276
+ { from: "file1.txt", to: "file1Renamed.txt" },
1277
+ { from: "file2.txt", to: "file2Renamed.txt" },
1278
+ { from: "file3.txt", to: "file3Renamed.txt", overwrite: true }
1279
+ ]
1280
+ }
1281
+ }
1282
+ ]
1283
+ })
1284
+ }
1285
+ ];
1286
+
1144
1287
  const createFilesystemRenameAction = () => {
1145
1288
  return pluginScaffolderNode.createTemplateAction({
1146
1289
  id: "fs:rename",
1147
1290
  description: "Renames files and directories within the workspace",
1291
+ examples: examples$2,
1148
1292
  schema: {
1149
1293
  input: {
1150
1294
  required: ["files"],
@@ -2026,11 +2170,60 @@ const commitHash = {
2026
2170
  type: "string"
2027
2171
  };
2028
2172
 
2173
+ const examples$1 = [
2174
+ {
2175
+ description: "Creates a GitHub repository with default configuration.",
2176
+ example: yaml__default["default"].stringify({
2177
+ steps: [
2178
+ {
2179
+ action: "github:repo:create",
2180
+ name: "Create a new GitHub repository",
2181
+ input: {
2182
+ repoUrl: "github.com?repo=repo&owner=owner"
2183
+ }
2184
+ }
2185
+ ]
2186
+ })
2187
+ },
2188
+ {
2189
+ description: "Add a description.",
2190
+ example: yaml__default["default"].stringify({
2191
+ steps: [
2192
+ {
2193
+ action: "github:repo:create",
2194
+ name: "Create a new GitHub repository with a description",
2195
+ input: {
2196
+ repoUrl: "github.com?repo=repo&owner=owner",
2197
+ description: "My new repository"
2198
+ }
2199
+ }
2200
+ ]
2201
+ })
2202
+ },
2203
+ {
2204
+ description: "Disable wiki and issues.",
2205
+ example: yaml__default["default"].stringify({
2206
+ steps: [
2207
+ {
2208
+ action: "github:repo:create",
2209
+ name: "Create a new GitHub repository without wiki and issues",
2210
+ input: {
2211
+ repoUrl: "github.com?repo=repo&owner=owner",
2212
+ hasIssues: false,
2213
+ hasWiki: false
2214
+ }
2215
+ }
2216
+ ]
2217
+ })
2218
+ }
2219
+ ];
2220
+
2029
2221
  function createGithubRepoCreateAction(options) {
2030
2222
  const { integrations, githubCredentialsProvider } = options;
2031
2223
  return pluginScaffolderNode.createTemplateAction({
2032
2224
  id: "github:repo:create",
2033
2225
  description: "Creates a GitHub repository.",
2226
+ examples: examples$1,
2034
2227
  schema: {
2035
2228
  input: {
2036
2229
  type: "object",
@@ -2137,11 +2330,59 @@ function createGithubRepoCreateAction(options) {
2137
2330
  });
2138
2331
  }
2139
2332
 
2333
+ const examples = [
2334
+ {
2335
+ description: "Setup repo with no modifications to branch protection rules",
2336
+ example: yaml__default["default"].stringify({
2337
+ steps: [
2338
+ {
2339
+ action: "github:repo:push",
2340
+ name: "Create test repo with testuser as owner.",
2341
+ input: {
2342
+ repoUrl: "github.com?repo=test&owner=testuser"
2343
+ }
2344
+ }
2345
+ ]
2346
+ })
2347
+ },
2348
+ {
2349
+ description: "Setup repo with required codeowners check",
2350
+ example: yaml__default["default"].stringify({
2351
+ steps: [
2352
+ {
2353
+ action: "github:repo:push",
2354
+ name: "Require codeowner branch protection rule",
2355
+ input: {
2356
+ repoUrl: "github.com?repo=reponame&owner=owner",
2357
+ requireCodeOwnerReviews: true
2358
+ }
2359
+ }
2360
+ ]
2361
+ })
2362
+ },
2363
+ {
2364
+ description: "Change the default required number of approvals",
2365
+ example: yaml__default["default"].stringify({
2366
+ steps: [
2367
+ {
2368
+ action: "github:repo:push",
2369
+ name: "Require two approvals before merging",
2370
+ input: {
2371
+ repoUrl: "github.com?repo=reponame&owner=owner",
2372
+ requiredApprovingReviewCount: 2
2373
+ }
2374
+ }
2375
+ ]
2376
+ })
2377
+ }
2378
+ ];
2379
+
2140
2380
  function createGithubRepoPushAction(options) {
2141
2381
  const { integrations, config, githubCredentialsProvider } = options;
2142
2382
  return pluginScaffolderNode.createTemplateAction({
2143
2383
  id: "github:repo:push",
2144
2384
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
2385
+ examples,
2145
2386
  schema: {
2146
2387
  input: {
2147
2388
  type: "object",
@@ -5653,7 +5894,7 @@ class NunjucksWorkflowRunner {
5653
5894
  });
5654
5895
  }
5655
5896
  async executeStep(task, step, context, renderTemplate, taskTrack, workspacePath, decision) {
5656
- var _a, _b, _c, _d, _e, _f, _g;
5897
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
5657
5898
  const stepTrack = await this.tracker.stepStart(task, step);
5658
5899
  if (task.cancelSignal.aborted) {
5659
5900
  throw new Error(`Step ${step.name} has been cancelled.`);
@@ -5728,25 +5969,58 @@ class NunjucksWorkflowRunner {
5728
5969
  }
5729
5970
  const tmpDirs = new Array();
5730
5971
  const stepOutput = {};
5731
- await action.handler({
5732
- input,
5733
- secrets: (_g = task.secrets) != null ? _g : {},
5734
- logger: taskLogger,
5735
- logStream: streamLogger,
5736
- workspacePath,
5737
- createTemporaryDirectory: async () => {
5738
- const tmpDir = await fs__default["default"].mkdtemp(`${workspacePath}_step-${step.id}-`);
5739
- tmpDirs.push(tmpDir);
5740
- return tmpDir;
5741
- },
5742
- output(name, value) {
5743
- stepOutput[name] = value;
5744
- },
5745
- templateInfo: task.spec.templateInfo,
5746
- user: task.spec.user,
5747
- isDryRun: task.isDryRun,
5748
- signal: task.cancelSignal
5749
- });
5972
+ const iterations = new Array();
5973
+ if (step.each) {
5974
+ const each = await this.render(step.each, context, renderTemplate);
5975
+ iterations.push(
5976
+ ...Object.keys(each).map((key) => {
5977
+ return { key, value: each[key] };
5978
+ })
5979
+ );
5980
+ } else {
5981
+ iterations.push({});
5982
+ }
5983
+ let actionInput = input;
5984
+ for (const iteration of iterations) {
5985
+ if (step.each) {
5986
+ taskLogger.info(`Running step each: ${iteration}`);
5987
+ const iterationContext = {
5988
+ ...context,
5989
+ each: iteration
5990
+ };
5991
+ actionInput = (_h = step.input && this.render(
5992
+ step.input,
5993
+ { ...iterationContext, secrets: (_g = task.secrets) != null ? _g : {} },
5994
+ renderTemplate
5995
+ )) != null ? _h : {};
5996
+ }
5997
+ await action.handler({
5998
+ input: actionInput,
5999
+ secrets: (_i = task.secrets) != null ? _i : {},
6000
+ logger: taskLogger,
6001
+ logStream: streamLogger,
6002
+ workspacePath,
6003
+ createTemporaryDirectory: async () => {
6004
+ const tmpDir = await fs__default["default"].mkdtemp(
6005
+ `${workspacePath}_step-${step.id}-`
6006
+ );
6007
+ tmpDirs.push(tmpDir);
6008
+ return tmpDir;
6009
+ },
6010
+ output(name, value) {
6011
+ if (step.each) {
6012
+ stepOutput[name] = stepOutput[name] || [];
6013
+ stepOutput[name].push(value);
6014
+ } else {
6015
+ stepOutput[name] = value;
6016
+ }
6017
+ },
6018
+ templateInfo: task.spec.templateInfo,
6019
+ user: task.spec.user,
6020
+ isDryRun: task.isDryRun,
6021
+ signal: task.cancelSignal
6022
+ });
6023
+ }
5750
6024
  for (const tmpDir of tmpDirs) {
5751
6025
  await fs__default["default"].remove(tmpDir);
5752
6026
  }
@@ -6227,6 +6501,7 @@ function buildDefaultIdentityClient(options) {
6227
6501
  };
6228
6502
  }
6229
6503
  async function createRouter(options) {
6504
+ var _a;
6230
6505
  const router = Router__default["default"]();
6231
6506
  router.use(express__default["default"].json({ limit: "10MB" }));
6232
6507
  const {
@@ -6237,13 +6512,13 @@ async function createRouter(options) {
6237
6512
  catalogClient,
6238
6513
  actions,
6239
6514
  taskWorkers,
6240
- concurrentTasksLimit,
6241
6515
  scheduler,
6242
6516
  additionalTemplateFilters,
6243
6517
  additionalTemplateGlobals,
6244
6518
  permissions,
6245
6519
  permissionRules
6246
6520
  } = options;
6521
+ const concurrentTasksLimit = (_a = options.concurrentTasksLimit) != null ? _a : options.config.getOptionalNumber("scaffolder.concurrentTasksLimit");
6247
6522
  const logger = parentLogger.child({ plugin: "scaffolder" });
6248
6523
  const identity = options.identity || buildDefaultIdentityClient(options);
6249
6524
  const workingDirectory = await getWorkingDirectory(config, logger);
@@ -6274,19 +6549,21 @@ async function createRouter(options) {
6274
6549
  }
6275
6550
  const actionRegistry = new TemplateActionRegistry();
6276
6551
  const workers = [];
6277
- for (let i = 0; i < (taskWorkers || 1); i++) {
6278
- const worker = await TaskWorker.create({
6279
- taskBroker,
6280
- actionRegistry,
6281
- integrations,
6282
- logger,
6283
- workingDirectory,
6284
- additionalTemplateFilters,
6285
- additionalTemplateGlobals,
6286
- concurrentTasksLimit,
6287
- permissions
6288
- });
6289
- workers.push(worker);
6552
+ if (concurrentTasksLimit !== 0) {
6553
+ for (let i = 0; i < (taskWorkers || 1); i++) {
6554
+ const worker = await TaskWorker.create({
6555
+ taskBroker,
6556
+ actionRegistry,
6557
+ integrations,
6558
+ logger,
6559
+ workingDirectory,
6560
+ additionalTemplateFilters,
6561
+ additionalTemplateGlobals,
6562
+ concurrentTasksLimit,
6563
+ permissions
6564
+ });
6565
+ workers.push(worker);
6566
+ }
6290
6567
  }
6291
6568
  const actionsToRegister = Array.isArray(actions) ? actions : createBuiltinActions({
6292
6569
  integrations,
@@ -6338,21 +6615,21 @@ async function createRouter(options) {
6338
6615
  router.get(
6339
6616
  "/v2/templates/:namespace/:kind/:name/parameter-schema",
6340
6617
  async (req, res) => {
6341
- var _a, _b;
6618
+ var _a2, _b;
6342
6619
  const userIdentity = await identity.getIdentity({
6343
6620
  request: req
6344
6621
  });
6345
6622
  const token = userIdentity == null ? void 0 : userIdentity.token;
6346
6623
  const template = await authorizeTemplate(req.params, token);
6347
- const parameters = [(_a = template.spec.parameters) != null ? _a : []].flat();
6624
+ const parameters = [(_a2 = template.spec.parameters) != null ? _a2 : []].flat();
6348
6625
  res.json({
6349
6626
  title: (_b = template.metadata.title) != null ? _b : template.metadata.name,
6350
6627
  description: template.metadata.description,
6351
6628
  "ui:options": template.metadata["ui:options"],
6352
6629
  steps: parameters.map((schema) => {
6353
- var _a2;
6630
+ var _a3;
6354
6631
  return {
6355
- title: (_a2 = schema.title) != null ? _a2 : "Please enter the following information",
6632
+ title: (_a3 = schema.title) != null ? _a3 : "Please enter the following information",
6356
6633
  description: schema.description,
6357
6634
  schema
6358
6635
  };
@@ -6370,7 +6647,7 @@ async function createRouter(options) {
6370
6647
  });
6371
6648
  res.json(actionsList);
6372
6649
  }).post("/v2/tasks", async (req, res) => {
6373
- var _a, _b;
6650
+ var _a2, _b;
6374
6651
  const templateRef = req.body.templateRef;
6375
6652
  const { kind, namespace, name } = catalogModel.parseEntityRef(templateRef, {
6376
6653
  defaultKind: "template"
@@ -6391,7 +6668,7 @@ async function createRouter(options) {
6391
6668
  { kind, namespace, name },
6392
6669
  token
6393
6670
  );
6394
- for (const parameters of [(_a = template.spec.parameters) != null ? _a : []].flat()) {
6671
+ for (const parameters of [(_a2 = template.spec.parameters) != null ? _a2 : []].flat()) {
6395
6672
  const result2 = jsonschema.validate(values, parameters);
6396
6673
  if (!result2.valid) {
6397
6674
  res.status(400).json({ errors: result2.errors });
@@ -6402,10 +6679,10 @@ async function createRouter(options) {
6402
6679
  const taskSpec = {
6403
6680
  apiVersion: template.apiVersion,
6404
6681
  steps: template.spec.steps.map((step, index) => {
6405
- var _a2, _b2;
6682
+ var _a3, _b2;
6406
6683
  return {
6407
6684
  ...step,
6408
- id: (_a2 = step.id) != null ? _a2 : `step-${index + 1}`,
6685
+ id: (_a3 = step.id) != null ? _a3 : `step-${index + 1}`,
6409
6686
  name: (_b2 = step.name) != null ? _b2 : step.action
6410
6687
  };
6411
6688
  }),
@@ -6455,9 +6732,9 @@ async function createRouter(options) {
6455
6732
  delete task.secrets;
6456
6733
  res.status(200).json(task);
6457
6734
  }).post("/v2/tasks/:taskId/cancel", async (req, res) => {
6458
- var _a;
6735
+ var _a2;
6459
6736
  const { taskId } = req.params;
6460
- await ((_a = taskBroker.cancel) == null ? void 0 : _a.call(taskBroker, taskId));
6737
+ await ((_a2 = taskBroker.cancel) == null ? void 0 : _a2.call(taskBroker, taskId));
6461
6738
  res.status(200).json({ status: "cancelled" });
6462
6739
  }).get("/v2/tasks/:taskId/eventstream", async (req, res) => {
6463
6740
  const { taskId } = req.params;
@@ -6476,7 +6753,7 @@ async function createRouter(options) {
6476
6753
  res.end();
6477
6754
  },
6478
6755
  next: ({ events }) => {
6479
- var _a;
6756
+ var _a2;
6480
6757
  let shouldUnsubscribe = false;
6481
6758
  for (const event of events) {
6482
6759
  res.write(
@@ -6489,7 +6766,7 @@ data: ${JSON.stringify(event)}
6489
6766
  shouldUnsubscribe = true;
6490
6767
  }
6491
6768
  }
6492
- (_a = res.flush) == null ? void 0 : _a.call(res);
6769
+ (_a2 = res.flush) == null ? void 0 : _a2.call(res);
6493
6770
  if (shouldUnsubscribe) {
6494
6771
  subscription.unsubscribe();
6495
6772
  res.end();
@@ -6523,7 +6800,7 @@ data: ${JSON.stringify(event)}
6523
6800
  clearTimeout(timeout);
6524
6801
  });
6525
6802
  }).post("/v2/dry-run", async (req, res) => {
6526
- var _a, _b, _c, _d;
6803
+ var _a2, _b, _c, _d;
6527
6804
  const bodySchema = zod.z.object({
6528
6805
  template: zod.z.unknown(),
6529
6806
  values: zod.z.record(zod.z.unknown()),
@@ -6539,9 +6816,9 @@ data: ${JSON.stringify(event)}
6539
6816
  if (!await pluginScaffolderCommon.templateEntityV1beta3Validator.check(template)) {
6540
6817
  throw new errors.InputError("Input template is not a template");
6541
6818
  }
6542
- const token = (_a = await identity.getIdentity({
6819
+ const token = (_a2 = await identity.getIdentity({
6543
6820
  request: req
6544
- })) == null ? void 0 : _a.token;
6821
+ })) == null ? void 0 : _a2.token;
6545
6822
  for (const parameters of [(_b = template.spec.parameters) != null ? _b : []].flat()) {
6546
6823
  const result2 = jsonschema.validate(body.values, parameters);
6547
6824
  if (!result2.valid) {
@@ -6550,10 +6827,10 @@ data: ${JSON.stringify(event)}
6550
6827
  }
6551
6828
  }
6552
6829
  const steps = template.spec.steps.map((step, index) => {
6553
- var _a2, _b2;
6830
+ var _a3, _b2;
6554
6831
  return {
6555
6832
  ...step,
6556
- id: (_a2 = step.id) != null ? _a2 : `step-${index + 1}`,
6833
+ id: (_a3 = step.id) != null ? _a3 : `step-${index + 1}`,
6557
6834
  name: (_b2 = step.name) != null ? _b2 : step.action
6558
6835
  };
6559
6836
  });
@@ -6718,4 +6995,4 @@ exports.createRouter = createRouter;
6718
6995
  exports.createWaitAction = createWaitAction;
6719
6996
  exports.scaffolderActionRules = scaffolderActionRules;
6720
6997
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6721
- //# sourceMappingURL=ScaffolderEntitiesProcessor-1d387347.cjs.js.map
6998
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-4b7489dd.cjs.js.map