Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udpate OneTrustGetUserResponse reference, create OneTrustEnrichedAssessments, and improve OneTrustGetRiskResponse #209

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/privacy-types",
"description": "Core enums and types that can be useful when interacting with Transcend's public APIs.",
"version": "4.105.3",
"version": "4.105.4",
"homepage": "https://github.com/transcend-io/privacy-types",
"repository": {
"type": "git",
Expand Down
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,
]),
Comment on lines +248 to +256
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that source.type (directly above these lines) and sourceType are nearly the same but slightly different? One has t.null in the list

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is intentional but you do give me a good idea to extract these into their own variables!

/** 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
>;
Loading