diff --git a/src/tools/auth0/handlers/flowVaultConnections.ts b/src/tools/auth0/handlers/flowVaultConnections.ts index d0bf8198..6502405c 100644 --- a/src/tools/auth0/handlers/flowVaultConnections.ts +++ b/src/tools/auth0/handlers/flowVaultConnections.ts @@ -47,6 +47,10 @@ export default class FlowVaultHandler extends DefaultHandler { }); } + objString(item): string { + return super.objString({ id: item.id, name: item.name }); + } + async getType(): Promise { if (this.existing) { return this.existing; diff --git a/src/tools/auth0/handlers/flows.ts b/src/tools/auth0/handlers/flows.ts index 26148e52..2ca1609a 100644 --- a/src/tools/auth0/handlers/flows.ts +++ b/src/tools/auth0/handlers/flows.ts @@ -1,7 +1,8 @@ -import _, { isArray } from 'lodash'; +import { isArray, isEmpty } from 'lodash'; import { GetFlows200ResponseOneOfInner, GetFlowsVaultConnections200ResponseOneOfInner, + PostFlows201Response, } from 'auth0'; import dotProp from 'dot-prop'; import DefaultHandler, { order } from './default'; @@ -41,6 +42,25 @@ export default class FlowHandler extends DefaultHandler { }); } + objString(item): string { + return super.objString({ id: item.id, name: item.name }); + } + + async getFlows(flows: Array): Promise { + const allFlows = await this.client.pool + .addEachTask({ + data: flows, + generator: ({ id }) => + this.client.flows.get({ id: id }).then((response) => { + if (isEmpty(response?.data)) return null; + return response.data; + }), + }) + .promise(); + + return allFlows.filter((flow): flow is PostFlows201Response => flow !== null); + } + async getType(): Promise { if (this.existing) { return this.existing; @@ -54,12 +74,8 @@ export default class FlowHandler extends DefaultHandler { this.getAllFlowConnections(), ]); - const allFlows = await Promise.all( - flows.map(async (f) => { - const { data: flow } = await this.client.flows.get({ id: f.id }); - return flow; - }) - ); + // get more details for each flows + const allFlows: Array = await this.getFlows(flows); // create a map for id to name from allFlowConnections const connectionIdMap = {}; diff --git a/src/tools/auth0/handlers/forms.ts b/src/tools/auth0/handlers/forms.ts index d3e760db..5b8425bd 100644 --- a/src/tools/auth0/handlers/forms.ts +++ b/src/tools/auth0/handlers/forms.ts @@ -4,6 +4,7 @@ import { PostForms201Response, } from 'auth0'; import dotProp from 'dot-prop'; +import { isEmpty } from 'lodash'; import DefaultHandler, { order } from './default'; import log from '../../../logger'; import { Asset, Assets, CalculatedChanges } from '../../../types'; @@ -43,6 +44,24 @@ export default class FormsHandler extends DefaultHandler { }); } + objString(item): string { + return super.objString({ id: item.id, name: item.name }); + } + + async getForms(forms: Array): Promise { + const allForms = await this.client.pool + .addEachTask({ + data: forms, + generator: ({ id }) => + this.client.forms.get({ id: id }).then((response) => { + if (isEmpty(response?.data)) return null; + return response.data; + }), + }) + .promise(); + return allForms.filter((form): form is PostForms201Response => form !== null); + } + async getType(): Promise { if (this.existing) { return this.existing; @@ -60,12 +79,7 @@ export default class FormsHandler extends DefaultHandler { ]); // get more details for each form - const allForms = await Promise.all( - forms.map(async (from) => { - const { data: form } = await this.client.forms.get({ id: from.id }); - return form; - }) - ); + const allForms = await this.getForms(forms); // create a map for id to name from allFlows const flowIdMap = {};