@backstage/plugin-scaffolder-backend 1.12.0-next.2 → 1.12.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 +31 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +56 -15
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/index.cjs.js +56 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7d724d8ef56: Added the ability to be able to define an actions `input` and `output` schema using `zod` instead of hand writing types and `jsonschema`
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 860de10fa67: Make identity valid if subject of token is a backstage server-2-server auth token
|
|
12
|
+
- 65454876fb2: Minor API report tweaks
|
|
13
|
+
- c6c78b4acbe: throw error from catalog:fetch scaffolder action when entity is null and optional is false
|
|
14
|
+
- 9968f455921: catalog write action should allow any shape of object
|
|
15
|
+
- 928a12a9b3e: Internal refactor of `/alpha` exports.
|
|
16
|
+
- 52b0022dab7: Updated dependency `msw` to `^1.0.0`.
|
|
17
|
+
- 7af12854970: Extended scaffolder action `catalog:fetch` to fetch multiple catalog entities by entity references.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/plugin-catalog-backend@1.8.0
|
|
20
|
+
- @backstage/catalog-client@1.4.0
|
|
21
|
+
- @backstage/plugin-auth-node@0.2.12
|
|
22
|
+
- @backstage/backend-tasks@0.5.0
|
|
23
|
+
- @backstage/backend-common@0.18.3
|
|
24
|
+
- @backstage/errors@1.1.5
|
|
25
|
+
- @backstage/plugin-catalog-node@1.3.4
|
|
26
|
+
- @backstage/backend-plugin-api@0.5.0
|
|
27
|
+
- @backstage/catalog-model@1.2.1
|
|
28
|
+
- @backstage/integration@1.4.3
|
|
29
|
+
- @backstage/config@1.0.7
|
|
30
|
+
- @backstage/types@1.0.2
|
|
31
|
+
- @backstage/plugin-scaffolder-common@1.2.6
|
|
32
|
+
- @backstage/plugin-scaffolder-node@0.1.1
|
|
33
|
+
|
|
3
34
|
## 1.12.0-next.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -361,17 +361,31 @@ const examples$1 = [
|
|
|
361
361
|
}
|
|
362
362
|
]
|
|
363
363
|
})
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
description: "Fetch multiple entities by referencse",
|
|
367
|
+
example: yaml__default["default"].stringify({
|
|
368
|
+
steps: [
|
|
369
|
+
{
|
|
370
|
+
action: id$1,
|
|
371
|
+
id: "fetchMultiple",
|
|
372
|
+
name: "Fetch catalog entities",
|
|
373
|
+
input: {
|
|
374
|
+
entityRefs: ["component:default/name"]
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
})
|
|
364
379
|
}
|
|
365
380
|
];
|
|
366
381
|
function createFetchCatalogEntityAction(options) {
|
|
367
382
|
const { catalogClient } = options;
|
|
368
383
|
return pluginScaffolderNode.createTemplateAction({
|
|
369
384
|
id: id$1,
|
|
370
|
-
description: "Returns entity from the catalog by entity reference",
|
|
385
|
+
description: "Returns entity or entities from the catalog by entity reference(s)",
|
|
371
386
|
examples: examples$1,
|
|
372
387
|
schema: {
|
|
373
388
|
input: {
|
|
374
|
-
required: ["entityRef"],
|
|
375
389
|
type: "object",
|
|
376
390
|
properties: {
|
|
377
391
|
entityRef: {
|
|
@@ -379,9 +393,14 @@ function createFetchCatalogEntityAction(options) {
|
|
|
379
393
|
title: "Entity reference",
|
|
380
394
|
description: "Entity reference of the entity to get"
|
|
381
395
|
},
|
|
396
|
+
entityRefs: {
|
|
397
|
+
type: "array",
|
|
398
|
+
title: "Entity references",
|
|
399
|
+
description: "Entity references of the entities to get"
|
|
400
|
+
},
|
|
382
401
|
optional: {
|
|
383
402
|
title: "Optional",
|
|
384
|
-
description: "
|
|
403
|
+
description: "Allow the entity or entities to optionally exist. Default: false",
|
|
385
404
|
type: "boolean"
|
|
386
405
|
}
|
|
387
406
|
}
|
|
@@ -392,28 +411,50 @@ function createFetchCatalogEntityAction(options) {
|
|
|
392
411
|
entity: {
|
|
393
412
|
title: "Entity found by the entity reference",
|
|
394
413
|
type: "object",
|
|
395
|
-
description: "Object containing same values used in the Entity schema."
|
|
414
|
+
description: "Object containing same values used in the Entity schema. Only when used with `entityRef` parameter."
|
|
415
|
+
},
|
|
416
|
+
entities: {
|
|
417
|
+
title: "Entities found by the entity references",
|
|
418
|
+
type: "array",
|
|
419
|
+
items: { type: "object" },
|
|
420
|
+
description: "Array containing objects with same values used in the Entity schema. Only when used with `entityRefs` parameter."
|
|
396
421
|
}
|
|
397
422
|
}
|
|
398
423
|
}
|
|
399
424
|
},
|
|
400
425
|
async handler(ctx) {
|
|
401
|
-
var _a;
|
|
402
|
-
const { entityRef, optional } = ctx.input;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
426
|
+
var _a, _b;
|
|
427
|
+
const { entityRef, entityRefs, optional } = ctx.input;
|
|
428
|
+
if (!entityRef && !entityRefs) {
|
|
429
|
+
if (optional) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
throw new Error("Missing entity reference or references");
|
|
433
|
+
}
|
|
434
|
+
if (entityRef) {
|
|
435
|
+
const entity = await catalogClient.getEntityByRef(entityRef, {
|
|
406
436
|
token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
|
|
407
437
|
});
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
throw e;
|
|
438
|
+
if (!entity && !optional) {
|
|
439
|
+
throw new Error(`Entity ${entityRef} not found`);
|
|
411
440
|
}
|
|
441
|
+
ctx.output("entity", entity != null ? entity : null);
|
|
412
442
|
}
|
|
413
|
-
if (
|
|
414
|
-
|
|
443
|
+
if (entityRefs) {
|
|
444
|
+
const entities = await catalogClient.getEntitiesByRefs(
|
|
445
|
+
{ entityRefs },
|
|
446
|
+
{
|
|
447
|
+
token: (_b = ctx.secrets) == null ? void 0 : _b.backstageToken
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
const finalEntities = entities.items.map((e, i) => {
|
|
451
|
+
if (!e && !optional) {
|
|
452
|
+
throw new Error(`Entity ${entityRefs[i]} not found`);
|
|
453
|
+
}
|
|
454
|
+
return e != null ? e : null;
|
|
455
|
+
});
|
|
456
|
+
ctx.output("entities", finalEntities);
|
|
415
457
|
}
|
|
416
|
-
ctx.output("entity", entity != null ? entity : null);
|
|
417
458
|
}
|
|
418
459
|
});
|
|
419
460
|
}
|