-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df76064
commit b424c03
Showing
8 changed files
with
174 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './flattenOneTrustAssessment'; | ||
export * from './parseCliSyncOtArguments'; | ||
export * from './writeOneTrustAssessment'; | ||
export * from './syncOneTrustAssessmentToDisk'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { logger } from '../../logger'; | ||
import { oneTrustAssessmentToCsvRecord } from './oneTrustAssessmentToCsvRecord'; | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { | ||
IMPORT_ONE_TRUST_ASSESSMENT_FORMS, | ||
makeGraphQLRequest, | ||
} from '../../graphql'; | ||
import { ImportOnetrustAssessmentsInput } from '../../codecs'; | ||
import { OneTrustEnrichedAssessment } from '../codecs'; | ||
|
||
export interface AssessmentForm { | ||
/** ID of Assessment Form */ | ||
id: string; | ||
/** Title of Assessment Form */ | ||
name: string; | ||
} | ||
|
||
/** | ||
* Write the assessment to a Transcend instance. | ||
* | ||
* | ||
* @param param - information about the assessment and Transcend instance to write to | ||
*/ | ||
export const syncOneTrustAssessmentToTranscend = async ({ | ||
transcend, | ||
assessment, | ||
}: { | ||
/** the Transcend client instance */ | ||
transcend: GraphQLClient; | ||
/** the assessment to sync to Transcend */ | ||
assessment: OneTrustEnrichedAssessment; | ||
}): Promise<AssessmentForm | undefined> => { | ||
logger.info(); | ||
|
||
// convert the OneTrust assessment object into a CSV Record (a map from the csv header to values) | ||
const csvRecord = oneTrustAssessmentToCsvRecord(assessment); | ||
|
||
// transform the csv record into a valid input to the mutation | ||
const input: ImportOnetrustAssessmentsInput = { | ||
rows: [ | ||
{ | ||
columns: Object.entries(csvRecord).map(([key, value]) => ({ | ||
title: key, | ||
value: value.toString(), | ||
})), | ||
}, | ||
], | ||
}; | ||
|
||
const { | ||
importOneTrustAssessmentForms: { assessmentForms }, | ||
} = await makeGraphQLRequest<{ | ||
/** the importOneTrustAssessmentForms mutation */ | ||
importOneTrustAssessmentForms: { | ||
/** Created Assessment Forms */ | ||
assessmentForms: AssessmentForm[]; | ||
}; | ||
}>(transcend, IMPORT_ONE_TRUST_ASSESSMENT_FORMS, { | ||
input, | ||
}); | ||
|
||
return assessmentForms[0]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters