Skip to content

Conversation

ChrisPenner
Copy link
Member

@ChrisPenner ChrisPenner commented Sep 15, 2025

Overview

Adds /api/projects/<project>/branches/<branch>/getDefinitionDependen(ts|cies)?name=<fqn> which lists the dependents/dependencies of a term in the same format as Share (includes the type signature, name, hash, kind, and tag).

Implementation notes

  • Splits up the current dependents and dependencies implementations into core logic, which I moved into the Codebase module, and the CLI stuff which stayed behind so I can use bits of it outside of the Cli monad (we should probably depend less on Cli or split it up for commands going forwards, since more commands will be converted to APIs.
  • Changes dependents and dependencies queries to avoid self-references in results.

See transcript for api format.

Note: @hojberg this doesn't support the relativeTo query param at the moment, the name must be the fqn and it returns all dependents within the scope of the project. Let me know if that needs to change.

Test coverage

See transcripts

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually just moved this over from GetDefinitions.hs and generalized it to hold more than one endpoint, I'm surprised Git isn't smart enough to pick up on that :'(


-- | Servant utility for a query param that's required, providing a useful error message if it's missing.
type RequiredQueryParam = Servant.QueryParam' '[Servant.Required, Servant.Strict]

Copy link
Member Author

Choose a reason for hiding this comment

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

These types were all added so the output format can match what's on Share :)

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH I don't really know what this file is... is it a debugfile thing (What's that?) or is it the dependents-dependencies transcript?

@ChrisPenner ChrisPenner requested a review from hojberg September 15, 2025 21:59
@ChrisPenner ChrisPenner self-assigned this Sep 15, 2025
@ChrisPenner ChrisPenner marked this pull request as draft September 15, 2025 22:00
@hojberg
Copy link
Member

hojberg commented Sep 16, 2025

Hmmm we might need to support a by-hash as well (those come into place when clicking on a link in some source and then clicking dependents on that newly opened definition).

I feel like I've seen the by-hash and by-name conventions we have in Share in the Codebase server APIs as well (though I'm not sure I even use them). That might be a convention to more towards (at some point ofc).

@ChrisPenner
Copy link
Member Author

@hojberg

Hmmm we might need to support a by-hash as well (those come into place when clicking on a link in some source and then clicking dependents on that newly opened definition).

I feel like I've seen the by-hash and by-name conventions we have in Share in the Codebase server APIs as well (though I'm not sure I even use them). That might be a convention to more towards (at some point ofc).

Yeah, actually the name query param supports hash-only "names", e.g. name=@abcdefg, which is in line with how the current getDefinition endpoint works; I can change them both, but that'll break things, or just add the new endpoint using the by-name/by-hash convention we use on share if we want, though I think the implementation is going to probably be exactly the same haha, it's not specialized to a different implementation in UCM like it is on Share (yet)

I'm happy to do either, I just copied existing (questionable) conventions for this one

I went ahead and added a transcript for the by-hash case.

@ChrisPenner ChrisPenner changed the title Add Dependents API for UCM Desktop Add Dependents/Dependencies API for UCM Desktop Sep 16, 2025
@ChrisPenner
Copy link
Member Author

Also added the getDependencies API.

@ChrisPenner ChrisPenner marked this pull request as ready for review September 18, 2025 21:02
@aryairani aryairani merged commit a330f60 into trunk Sep 22, 2025
46 checks passed
@aryairani aryairani deleted the cp/ucm-dependents-api branch September 22, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants