chore(medusa, utils): rename buildLegacyFieldsListFrom to objectToStringPath (#3738)

* chore(medusa): rename buildLegacyFieldsListFrom to objectToStringPath

* chore: address pr comments
This commit is contained in:
Riqwan Thamir
2023-04-07 10:27:13 +02:00
committed by GitHub
parent 08f85fa33b
commit abdb74d997
9 changed files with 26 additions and 18 deletions
+4 -3
View File
@@ -138,7 +138,8 @@ function buildWhere<TWhereKeys extends object, TEntity>(
}
/**
* Revert new object structure of find options to the legacy structure of previous version
* Converts a typeorms structure of find options to an
* array of string paths
* @example
* input: {
* test: {
@@ -153,7 +154,7 @@ function buildWhere<TWhereKeys extends object, TEntity>(
* output: ['test.test1', 'test.test2', 'test.test3.test4', 'test2']
* @param input
*/
export function buildLegacyFieldsListFrom<TEntity>(
export function objectToStringPath<TEntity>(
input:
| FindOptionsWhere<TEntity>
| FindOptionsSelect<TEntity>
@@ -168,7 +169,7 @@ export function buildLegacyFieldsListFrom<TEntity>(
for (const key of Object.keys(input)) {
if (input[key] != undefined && typeof input[key] === "object") {
const deepRes = buildLegacyFieldsListFrom(input[key])
const deepRes = objectToStringPath(input[key])
const items = deepRes.reduce((acc, val) => {
acc.push(`${key}.${val}`)