chore(medusa, utils): rename buildLegacyFieldsListFrom to objectToStringPath (#3738)
* chore(medusa): rename buildLegacyFieldsListFrom to objectToStringPath * chore: address pr comments
This commit is contained in:
@@ -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}`)
|
||||
|
||||
Reference in New Issue
Block a user