diff --git a/src/context/yaml/handlers/clientGrants.ts b/src/context/yaml/handlers/clientGrants.ts index d864f66ad..d9962ba5b 100644 --- a/src/context/yaml/handlers/clientGrants.ts +++ b/src/context/yaml/handlers/clientGrants.ts @@ -3,6 +3,7 @@ import { YAMLHandler } from '.'; import YAMLContext from '..'; import { ParsedAsset } from '../../../types'; import { ClientGrant } from '../../../tools/auth0/handlers/clientGrants'; +import { convertClientNameToId } from '../../../tools/utils'; type ParsedClientGrants = ParsedAsset<'clientGrants', ClientGrant[]>; @@ -11,13 +12,24 @@ async function parse(context: YAMLContext): Promise { if (!clientGrants) return { clientGrants: null }; + // can not use client from context.assets because it does not have the client_id + const clients = await context.mgmtClient.clients.getAll({ + paginate: true, + include_totals: true, + }); + return { - clientGrants, + clientGrants: clientGrants.map((grant) => { + const dumpGrant = { ...grant }; + dumpGrant.client_id = convertClientNameToId(dumpGrant.client_id, clients || []); + return dumpGrant; + }), }; } async function dump(context: YAMLContext): Promise { - let { clientGrants, clients } = context.assets; + const { clientGrants } = context.assets; + let { clients } = context.assets; if (!clientGrants) return { clientGrants: null }; diff --git a/src/keywordPreservation.ts b/src/keywordPreservation.ts index 51e31c1c2..0cf738da1 100644 --- a/src/keywordPreservation.ts +++ b/src/keywordPreservation.ts @@ -1,8 +1,8 @@ import { get as getByDotNotation, set as setByDotNotation } from 'dot-prop'; +import { cloneDeep, isArray } from 'lodash'; import { keywordReplace } from './tools/utils'; import { AssetTypes, KeywordMappings } from './types'; import { keywordReplaceArrayRegExp, keywordReplaceStringRegExp } from './tools/utils'; -import { cloneDeep, forEach, isArray } from 'lodash'; import APIHandler from './tools/auth0/handlers/default'; /*