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

addEntity should return the type of the added entity #497

Open
aiwilliams opened this issue Jun 30, 2021 · 0 comments
Open

addEntity should return the type of the added entity #497

aiwilliams opened this issue Jun 30, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@aiwilliams
Copy link
Contributor

In some integrations there is a type representing the entities created by the integration. Consider the following code:

function createGroupEntity(group: BitbucketGroup): BitbucketGroupEntity {
  return createIntegrationEntity({
    entityData: {
      source: group,
      assign: {
        displayName: group.name,
      },
    },
  }) as BitbucketGroupEntity;
}

export function createWorkspaceHasGroupRelationship(
  workspace: BitbucketWorkspaceEntity,
  group: BitbucketGroupEntity,
): BitbucketWorkspaceGroupRelationship {
  return {
    _key: `${workspace._key}|has|${group._key}`,
    _class: 'HAS',
    _type: BITBUCKET_WORKSPACE_GROUP_RELATIONSHIP_TYPE,
    _fromEntityKey: workspace._key,
    _toEntityKey: group._key,
    displayName: 'HAS',
  };
}

const workspaceEntity = ....;
const groupEntity = await jobState.addEntity(createGroupEntity(group)); // groupEntity is type Entity
createWorkspaceHasGroupRelationship(workspaceEntity, groupEntity); // < -- compilation problem

addEntity should return the type of the argument so that groupEntity: BitbucketGroupEntity.

Related to #270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant