From 2c8e70f25f43b5b0c70cc481c4821f19348f6fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 15 Apr 2021 13:40:34 +0200 Subject: [PATCH] :art: Rename helper function --- packages/cli/src/Server.ts | 6 +++--- packages/cli/src/TagHelpers.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 492c99a080..98bb88711b 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -514,7 +514,7 @@ class App { where: { id: In(tagIds) }, }); - result.tags = TagHelpers.stringifyId(found); + result.tags = TagHelpers.getTagsResponse(found); } // Convert to response format in which the id is a string @@ -566,7 +566,7 @@ class App { const results = await Db.collections.Workflow!.find(findQuery); results.forEach(workflow => { if (workflow.tags) { - workflow.tags = TagHelpers.stringifyId(workflow.tags); + workflow.tags = TagHelpers.getTagsResponse(workflow.tags); } }); @@ -682,7 +682,7 @@ class App { where: { id: In(tagIds) }, }); - responseData.tags = TagHelpers.stringifyId(found); + responseData.tags = TagHelpers.getTagsResponse(found); } // Convert to response format in which the id is a string diff --git a/packages/cli/src/TagHelpers.ts b/packages/cli/src/TagHelpers.ts index 50d1cd4aa4..f4fefb7a2f 100644 --- a/packages/cli/src/TagHelpers.ts +++ b/packages/cli/src/TagHelpers.ts @@ -25,7 +25,7 @@ function isStringArray(tags: unknown[]): tags is string[] { * Stringify the ID in every `ITagDb` in an array. * Side effect: Remove `createdAt` and `updatedAt` for a slimmer response. */ -export function stringifyId(tags: ITagDb[]) { +export function getTagsResponse(tags: ITagDb[]) { return tags.map(({ id, name }) => ({ id: id.toString(), name })); }