feat(scenarios): export used snippets with a scenario
- list the snippets a scenario uses in the export dialog, checked by default, with the versions the scenario uses - export each selected snippet once per used version (latest and pinned) via the new snippetIds query parameter - resolve used snippets from the exported version's steps - show the scenario version in the export dialog - document the export query parameters - bump version to 1.22.0
This commit is contained in:
1 parent
f43d902297
commit
23fa302b25
13 files changed
+163
-18
No files matched your search
@@ -135,18 +135,17 @@ export class ScenarioController {
|
||||
@Param("id", ParseUUIDPipe) id: string,
|
||||
@Query("includeEnvironment") includeEnvironment: string,
|
||||
@Query("credentialIds") credentialIds: string | string[] | undefined,
|
||||
@Query("snippetIds") snippetIds: string | string[] | undefined,
|
||||
@Query("version", new ParseIntPipe({ optional: true }))
|
||||
version: number | undefined,
|
||||
@Res({ passthrough: true }) res: Response,
|
||||
) {
|
||||
const credIds: string[] = credentialIds
|
||||
? Array.isArray(credentialIds)
|
||||
? credentialIds
|
||||
: credentialIds.split(",").filter(Boolean)
|
||||
: [];
|
||||
const toIds = (ids: string | string[] | undefined): string[] =>
|
||||
ids ? (Array.isArray(ids) ? ids : ids.split(",").filter(Boolean)) : [];
|
||||
const entities = await this.scenarioService.exportScenario(id, {
|
||||
includeEnvironment: includeEnvironment === "true",
|
||||
credentialIds: credIds,
|
||||
credentialIds: toIds(credentialIds),
|
||||
snippetIds: toIds(snippetIds),
|
||||
version,
|
||||
});
|
||||
res.setHeader("Content-Type", "application/yaml; charset=utf-8");
|
||||
@@ -155,12 +154,17 @@ export class ScenarioController {
|
||||
const kindLabels: Record<string, string> = {
|
||||
environment: "Environment",
|
||||
credential: "Credential",
|
||||
snippet: "Snippet",
|
||||
scenario: "Scenario",
|
||||
};
|
||||
return (entities as ExportEntity[])
|
||||
.map((entity) => {
|
||||
const label = kindLabels[entity.kind ?? ""] ?? entity.kind ?? "Entity";
|
||||
const comment = `# ${label}: ${entity.name ?? entity.id ?? ""}`;
|
||||
const title =
|
||||
entity.kind === "snippet"
|
||||
? `${entity.alias ?? entity.name} v${entity.version}`
|
||||
: entity.name;
|
||||
const comment = `# ${label}: ${title ?? entity.id ?? ""}`;
|
||||
return `---\n${comment}\n${yamlStringify(entity)}`;
|
||||
})
|
||||
.join("");
|
||||
|
||||
Reference in new issue
Block a user