diff --git a/src/configuration-manager/client.ts b/src/configuration-manager/client.ts index 8bcad1f..fddb303 100644 --- a/src/configuration-manager/client.ts +++ b/src/configuration-manager/client.ts @@ -9,6 +9,7 @@ import { buildLocalUserList, } from './queries'; import pMap from 'p-map'; +import { IntegrationLogger } from '@jupiterone/integration-sdk-core'; type ResourceIteratee = (each: T) => Promise | void; @@ -96,6 +97,7 @@ class MicrosoftConfigurationManagerClient { async listApplicationDeviceTargets( iteratee: ResourceIteratee, pageSize: number = 600, + logger: IntegrationLogger, ) { let offset = 0; let hasMoreRecords = true; @@ -111,6 +113,9 @@ class MicrosoftConfigurationManagerClient { ); const records = result.recordset; + + logger.info(`Proccesed ${records.length} records from query`); + if (records.length > 0) { await pMap( records, @@ -266,10 +271,12 @@ class MicrosoftConfigurationManagerClient { private async wrapWithRequestFailedHandler( fn: () => Promise, + logger?: IntegrationLogger, ) { try { return await fn(); } catch (err) { + logger?.error(`Received error from SQL query: ${err}`); throw this.onRequestFailed(err); } } diff --git a/src/steps/applications/index.ts b/src/steps/applications/index.ts index c1912d5..0b1b0f4 100644 --- a/src/steps/applications/index.ts +++ b/src/steps/applications/index.ts @@ -94,20 +94,22 @@ export async function buildApplicationRelationships({ logger, ); - await client.listApplicationDeviceTargets(async (application: any) => { - const appID = createApplicationKey(application.CIGUID?.toString()); - const deviceID = createDeviceKey(application.ResourceID?.toString()); - const applicationEntity = await jobState.findEntity(appID); - const deviceEntity = await jobState.findEntity(deviceID); - if (applicationEntity && deviceEntity) { - const deviceApplicationRelationship = createDeviceApplicationRelationship( - deviceEntity, - applicationEntity, - ); + await client.listApplicationDeviceTargets( + async (application: any) => { + const appID = createApplicationKey(application.CIGUID?.toString()); + const deviceID = createDeviceKey(application.ResourceID?.toString()); + const applicationEntity = await jobState.findEntity(appID); + const deviceEntity = await jobState.findEntity(deviceID); + if (applicationEntity && deviceEntity) { + const deviceApplicationRelationship = + createDeviceApplicationRelationship(deviceEntity, applicationEntity); - if (!jobState.hasKey(deviceApplicationRelationship._key)) { - await jobState.addRelationship(deviceApplicationRelationship); + if (!jobState.hasKey(deviceApplicationRelationship._key)) { + await jobState.addRelationship(deviceApplicationRelationship); + } } - } - }); + }, + 600, + logger, + ); }