From 8eeda82511286b58775d9a05a85228766dc3b4db Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 4 Feb 2021 17:17:05 +0000 Subject: [PATCH] Updating so that strings get coerced into arrays for relationships. --- packages/server/src/utilities/index.js | 16 +++++++++++----- packages/standard-components/yarn.lock | 5 ----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index 31cc74b5e6..cba2e81094 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -16,6 +16,12 @@ const TYPE_TRANSFORM_MAP = { "": [], [null]: [], [undefined]: undefined, + parse: link => { + if (typeof link === "string") { + return [link] + } + return link + }, }, options: { "": "", @@ -165,15 +171,15 @@ exports.walkDir = (dirPath, callback) => { * @param {object} type The type fo coerce to * @returns {object} The coerced value */ -exports.coerceValue = (value, type) => { +exports.coerceValue = (row, type) => { // eslint-disable-next-line no-prototype-builtins - if (TYPE_TRANSFORM_MAP[type].hasOwnProperty(value)) { - return TYPE_TRANSFORM_MAP[type][value] + if (TYPE_TRANSFORM_MAP[type].hasOwnProperty(row)) { + return TYPE_TRANSFORM_MAP[type][row] } else if (TYPE_TRANSFORM_MAP[type].parse) { - return TYPE_TRANSFORM_MAP[type].parse(value) + return TYPE_TRANSFORM_MAP[type].parse(row) } - return value + return row } /** diff --git a/packages/standard-components/yarn.lock b/packages/standard-components/yarn.lock index dfd6154fb7..f0864bff24 100644 --- a/packages/standard-components/yarn.lock +++ b/packages/standard-components/yarn.lock @@ -1773,11 +1773,6 @@ mri@^1.1.0: resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.6.tgz#49952e1044db21dbf90f6cd92bc9c9a777d415a6" integrity sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ== -nanoid@^3.1.20: - version "3.1.20" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788" - integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw== - node-releases@^1.1.60: version "1.1.60" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.60.tgz#6948bdfce8286f0b5d0e5a88e8384e954dfe7084"