Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
change userId to be string. remove broken mrr.
Browse files Browse the repository at this point in the history
  • Loading branch information
zemberdotnet committed Jul 3, 2024
1 parent d102213 commit 23fad3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
31 changes: 2 additions & 29 deletions src/steps/fetch-users/converter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import {
createIntegrationEntity,
parseTimePropertyValue,
RelationshipDirection,
createMappedRelationship,
MappedRelationship,
Entity,
} from '@jupiterone/integration-sdk-core';
import { SnipeItUser } from '../../collector';
import { Entities, MappedRelationships } from '../constants';
import { Entities } from '../constants';

export function getUserKey(id: string): string {
return `snipeit_user:${id}`;
Expand All @@ -28,7 +24,7 @@ export function convertUser(
_type: Entities.USER._type,
_class: Entities.USER._class,
id: getUserKey(String(data.id)),
userId: data.id,
userId: String(data.id),
displayName: data.name,
avatar: data.avatar,
firstName: data.first_name,
Expand Down Expand Up @@ -200,26 +196,3 @@ export function convertUser(
},
});
}

export function createUserPersonMappedRelationship(
user: Entity,
): MappedRelationship {
return createMappedRelationship({
_key: `${user._key}|is|${user.username}`,
_class: MappedRelationships.USER_IS_PERSON._class,
_type: MappedRelationships.USER_IS_PERSON._type,
_mapping: {
relationshipDirection: RelationshipDirection.FORWARD,
sourceEntityKey: user._key,
targetFilterKeys: [['_class', 'username', 'email']],
targetEntity: {
_class: Entities.PERSON._class,
id: user.id,
userId: user.userId as number,
username: user.username as number,
email: user.userId as number,
},
skipTargetCreation: true,
},
});
}
7 changes: 3 additions & 4 deletions src/steps/fetch-users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@jupiterone/integration-sdk-core';

import { createServicesClient } from '../../collector';
import { convertUser, createUserPersonMappedRelationship } from './converter';
import { convertUser } from './converter';
import { ACCOUNT_ENTITY_KEY } from '../fetch-account';
import {
Entities,
Expand All @@ -30,14 +30,13 @@ export async function fetchUsers({
await jobState.addEntities(userEntities);

userEntities.map(async (userEntity) => {
await jobState.addRelationships([
await jobState.addRelationship(
createDirectRelationship({
from: accountEntity,
to: userEntity,
_class: RelationshipClass.HAS,
}),
createUserPersonMappedRelationship(userEntity),
]);
);
});
}

Expand Down

0 comments on commit 23fad3b

Please sign in to comment.