Skip to content

Commit

Permalink
Adds mapping from resource type to field in inventory (#353)
Browse files Browse the repository at this point in the history
* Fixes action item scope

* Updates

* Updates
  • Loading branch information
michaelfarrell76 authored Sep 14, 2024
1 parent 96feda5 commit 2da9c63
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 24 deletions.
10 changes: 5 additions & 5 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/cli",
"description": "Small package containing useful typescript utilities.",
"version": "6.2.1",
"version": "6.2.3",
"homepage": "https://github.com/transcend-io/cli",
"repository": {
"type": "git",
Expand Down Expand Up @@ -64,7 +64,7 @@
"@transcend-io/handlebars-utils": "^1.1.0",
"@transcend-io/internationalization": "^1.6.0",
"@transcend-io/persisted-state": "^1.0.4",
"@transcend-io/privacy-types": "^4.83.0",
"@transcend-io/privacy-types": "^4.84.0",
"@transcend-io/secret-value": "^1.2.0",
"@transcend-io/type-utils": "^1.4.2",
"bluebird": "^3.7.2",
Expand Down
42 changes: 41 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ScopeName } from '@transcend-io/privacy-types';
import { TranscendPullResource } from './enums';
import { TranscendInput } from './codecs';

export const ADMIN_DASH = 'https://app.transcend.io';

Expand Down Expand Up @@ -58,7 +59,10 @@ export const TR_PUSH_RESOURCE_SCOPE_MAP: {
[TranscendPullResource.Vendors]: [ScopeName.ManageDataInventory],
[TranscendPullResource.DataCategories]: [ScopeName.ManageDataInventory],
[TranscendPullResource.ProcessingPurposes]: [ScopeName.ManageDataInventory],
[TranscendPullResource.ActionItems]: [ScopeName.ManageAllActionItems],
[TranscendPullResource.ActionItems]: [
ScopeName.ManageAllActionItems,
ScopeName.ViewGlobalAttributes,
],
[TranscendPullResource.ActionItemCollections]: [
ScopeName.ManageActionItemCollections,
],
Expand Down Expand Up @@ -110,3 +114,39 @@ export const TR_PULL_RESOURCE_SCOPE_MAP: {
[TranscendPullResource.PrivacyCenters]: [ScopeName.ViewPrivacyCenter],
[TranscendPullResource.Policies]: [ScopeName.ViewPolicies],
};

export const TR_YML_RESOURCE_TO_FIELD_NAME: Record<
TranscendPullResource,
keyof TranscendInput
> = {
[TranscendPullResource.ApiKeys]: 'api-keys',
[TranscendPullResource.Attributes]: 'attributes',
[TranscendPullResource.DataFlows]: 'data-flows',
[TranscendPullResource.Cookies]: 'cookies',
[TranscendPullResource.ConsentManager]: 'consent-manager',
[TranscendPullResource.Partitions]: 'partitions',
[TranscendPullResource.Actions]: 'actions',
[TranscendPullResource.DataSubjects]: 'data-subjects',
[TranscendPullResource.BusinessEntities]: 'business-entities',
[TranscendPullResource.Identifiers]: 'identifiers',
[TranscendPullResource.Enrichers]: 'enrichers',
[TranscendPullResource.DataSilos]: 'data-silos',
[TranscendPullResource.Templates]: 'templates',
[TranscendPullResource.Assessment]: 'assessments',
[TranscendPullResource.AssessmentTemplate]: 'assessment-templates',
[TranscendPullResource.Prompts]: 'prompts',
[TranscendPullResource.PromptPartials]: 'prompt-partials',
[TranscendPullResource.PromptGroups]: 'prompt-groups',
[TranscendPullResource.Agents]: 'agents',
[TranscendPullResource.AgentFunctions]: 'agent-functions',
[TranscendPullResource.AgentFiles]: 'agent-files',
[TranscendPullResource.Vendors]: 'vendors',
[TranscendPullResource.DataCategories]: 'data-categories',
[TranscendPullResource.ProcessingPurposes]: 'processing-purposes',
[TranscendPullResource.ActionItems]: 'action-items',
[TranscendPullResource.ActionItemCollections]: 'action-item-collections',
[TranscendPullResource.Teams]: 'teams',
[TranscendPullResource.Messages]: 'messages',
[TranscendPullResource.PrivacyCenters]: 'privacy-center',
[TranscendPullResource.Policies]: 'policies',
};
26 changes: 15 additions & 11 deletions src/graphql/syncActionItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ export async function createActionItems(
client: GraphQLClient,
actionItems: ActionItemInput[],
actionItemCollectionByTitle: { [k in string]: ActionItemCollection },
// TODO: https://transcend.height.app/T-38961 - insert attributes
// eslint-disable-next-line @typescript-eslint/no-unused-vars
attributeKeysByName: { [k in string]: Attribute } = {},
): Promise<void> {
const getAttribute = (key: string): string => {
const existing = attributeKeysByName[key];
if (!existing) {
throw new Error(`Attribute key "${key}" does not exist!`);
}
return existing.id;
};
// TODO: https://transcend.height.app/T-38961 - insert attributes
// const getAttribute = (key: string): string => {
// const existing = attributeKeysByName[key];
// if (!existing) {
// throw new Error(`Attribute key "${key}" does not exist!`);
// }
// return existing.id;
// };
const chunked = chunk(actionItems, 100);
await mapSeries(chunked, async (chunkToUpload) => {
await makeGraphQLRequest(client, CREATE_ACTION_ITEMS, {
Expand All @@ -53,10 +56,11 @@ export async function createActionItems(
assigneesTeamNames: actionItem.teams,
...(actionItem.attributes
? {
attributes: actionItem.attributes.map(({ key, values }) => ({
attributeKeyId: getAttribute(key),
attributeValueNames: values,
})),
// TODO: https://transcend.height.app/T-38961 - insert attributes
// attributes: actionItem.attributes.map(({ key, values }) => ({
// attributeKeyId: getAttribute(key),
// attributeValueNames: values,
// })),
}
: {}),
collectionIds: actionItem.collections.map(
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ __metadata:
"@transcend-io/handlebars-utils": ^1.1.0
"@transcend-io/internationalization": ^1.6.0
"@transcend-io/persisted-state": ^1.0.4
"@transcend-io/privacy-types": ^4.83.0
"@transcend-io/privacy-types": ^4.84.0
"@transcend-io/secret-value": ^1.2.0
"@transcend-io/type-utils": ^1.4.2
"@types/bluebird": ^3.5.38
Expand Down Expand Up @@ -641,14 +641,14 @@ __metadata:
languageName: node
linkType: hard

"@transcend-io/privacy-types@npm:^4.83.0":
version: 4.83.0
resolution: "@transcend-io/privacy-types@npm:4.83.0"
"@transcend-io/privacy-types@npm:^4.84.0":
version: 4.84.0
resolution: "@transcend-io/privacy-types@npm:4.84.0"
dependencies:
"@transcend-io/type-utils": ^1.0.5
fp-ts: ^2.16.1
io-ts: ^2.2.21
checksum: 77495e316f2f56d9c820eb01b18aa1d2bb90ca1af35b5abf7efc4472f10e9631ad515a114fea4dd4ffcb5e41c1c34798e9c5e6523adcad9791ea654459cea621
checksum: 3f34afac26b253f4ddbed4be488d200373c8df6b4f29858758c462bf3613dded420971b1e1b994a826fcc2f37371b5cb678d5c2b84d3960da25c99eaca76b4f1
languageName: node
linkType: hard

Expand Down

0 comments on commit 2da9c63

Please sign in to comment.