Skip to content

Commit

Permalink
udpate OneTrustGetUserResponse reference, create OneTrustEnrichedAsse…
Browse files Browse the repository at this point in the history
…ssments, and improve OneTrustGetRiskResponse (#209)

* udpate OneTrustGetUserResponse reference

* enrich OneTrustEnrichedRisk

* pre-commit fix

* bump package

* fix typo

* fix precommit
  • Loading branch information
abrantesarthur authored Jan 22, 2025
1 parent 79e79b4 commit ec34eb7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
69 changes: 63 additions & 6 deletions src/oneTrust/endpoints/getRisk.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-lines */
import * as t from 'io-ts';

/**
Expand Down Expand Up @@ -61,7 +62,44 @@ export const OneTrustRiskCategories = t.array(
/** Type override */
export type OneTrustRiskCategories = t.TypeOf<typeof OneTrustRiskCategories>;

export const OneTrustRiskReference = t.type({
/** The id of the risk reference */
id: t.string,
/** The type of the risk reference */
type: t.string,
/** The reference type of the risk reference */
referenceType: OneTrustEntityType,
/** The name of the risk reference */
name: t.union([t.string, t.null]),
/** The additional attributes of the risk reference */
additionalAttributes: t.object,
});
/** Type override */
export type OneTrustRiskReference = t.TypeOf<typeof OneTrustRiskReference>;

export const OneTrustRiskReferences = t.array(OneTrustRiskReference);

/** Type override */
export type OneTrustRiskReferences = t.TypeOf<typeof OneTrustRiskReferences>;

export const OneTrustRiskTemplate = t.type({
/** The id of the risk template */
id: t.union([t.string, t.null]),
/** The name of the risk template */
name: t.union([t.string, t.null]),
});
/** Type override */
export type OneTrustRiskTemplate = t.TypeOf<typeof OneTrustRiskTemplate>;

export const OneTrustGetRiskResponse = t.type({
/** The risk references */
references: OneTrustRiskReferences,
/** Whether the risk is closed */
closed: t.boolean,
/** The risk template */
riskTemplate: OneTrustRiskTemplate,
/** The currentStageApproversCount */
currentStageApproversCount: t.number,
/** List of associated inventories to the risk. */
associatedInventories: t.array(
t.type({
Expand Down Expand Up @@ -206,6 +244,16 @@ export const OneTrustGetRiskResponse = t.type({
t.literal('GENERIC'),
]),
}),
/** Risk Source Type. */
sourceType: t.union([
t.literal('PIA'),
t.literal('RA'),
t.literal('GRA'),
t.literal('INVENTORY'),
t.literal('INCIDENT'),
t.literal('GENERIC'),
t.null,
]),
/** The risk stage */
stage: t.intersection([
t.partial({
Expand Down Expand Up @@ -287,13 +335,22 @@ export const OneTrustGetRiskResponse = t.type({
t.null,
]),
/** The risk workflow */
workflow: t.type({
/** ID of an entity. */
id: t.string,
/** Name of an entity. */
name: t.string,
}),
workflow: t.intersection([
t.type({
/** ID of an entity. */
id: t.string,
/** Name of an entity. */
name: t.string,
}),
t.partial({
/** The nameKey */
nameKey: t.array(t.string),
/** The badgeColor */
badgeColor: t.union([t.string, t.null]),
}),
]),
});

/** Type override */
export type OneTrustGetRiskResponse = t.TypeOf<typeof OneTrustGetRiskResponse>;
/* eslint-enable max-lines */
2 changes: 1 addition & 1 deletion src/oneTrust/endpoints/getUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type OneTrustUserEmails = t.TypeOf<typeof OneTrustUserEmails>;

/**
* The response type of the OneTrust GetUser endpoint
* ref: https://developer.onetrust.com/onetrust/reference/getriskusingget
* ref: https://developer.onetrust.com/onetrust/reference/getuserusingget
*/
export const OneTrustGetUserResponse = t.type({
/** ID of the user. */
Expand Down
19 changes: 8 additions & 11 deletions src/oneTrust/enrichedCodecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@ import {
/** The default OneTrust Get Assessment risk response enriched with Get Risk response. */
export const OneTrustEnrichedRisk = t.intersection([
OneTrustAssessmentQuestionRisk,
t.type({
description: OneTrustGetRiskResponse.props.description,
name: OneTrustGetRiskResponse.props.name,
treatment: OneTrustGetRiskResponse.props.treatment,
treatmentStatus: OneTrustGetRiskResponse.props.treatmentStatus,
type: OneTrustGetRiskResponse.props.type,
stage: OneTrustGetRiskResponse.props.stage,
state: OneTrustGetRiskResponse.props.state,
result: OneTrustGetRiskResponse.props.result,
categories: OneTrustGetRiskResponse.props.categories,
}),
OneTrustGetRiskResponse,
]);

/** Type override */
Expand Down Expand Up @@ -127,3 +117,10 @@ export const OneTrustEnrichedAssessment = t.intersection([
export type OneTrustEnrichedAssessment = t.TypeOf<
typeof OneTrustEnrichedAssessment
>;

export const OneTrustEnrichedAssessments = t.array(OneTrustEnrichedAssessment);

/** Type override */
export type OneTrustEnrichedAssessments = t.TypeOf<
typeof OneTrustEnrichedAssessments
>;

0 comments on commit ec34eb7

Please sign in to comment.