@@ -22,6 +22,8 @@ import Share.Postgres qualified as PG
22
22
import Share.Postgres.Causal.Queries qualified as CausalQ
23
23
import Share.Postgres.Contributions.Queries qualified as ContributionsQ
24
24
import Share.Postgres.IDs (CausalId )
25
+ import Share.Postgres.NameLookups.Types (pathToPathSegments )
26
+ import Share.Postgres.NamesPerspective.Ops qualified as NP
25
27
import Share.Postgres.Queries qualified as Q
26
28
import Share.Postgres.Users.Queries qualified as UserQ
27
29
import Share.Postgres.Users.Queries qualified as UsersQ
@@ -107,6 +109,8 @@ branchCodeBrowsingServer session handle projectSlug branchShortHand =
107
109
:<|> projectBranchDefinitionsByHashEndpoint session handle projectSlug branchShortHand
108
110
:<|> projectBranchTermSummaryEndpoint session handle projectSlug branchShortHand
109
111
:<|> projectBranchTypeSummaryEndpoint session handle projectSlug branchShortHand
112
+ :<|> projectBranchDefinitionDependenciesByNameEndpoint session handle projectSlug branchShortHand
113
+ :<|> projectBranchDefinitionDependenciesByHashEndpoint session handle projectSlug branchShortHand
110
114
:<|> projectBranchFindEndpoint session handle projectSlug branchShortHand
111
115
:<|> projectBranchNamespacesByNameEndpoint session handle projectSlug branchShortHand
112
116
)
@@ -154,7 +158,7 @@ projectBranchDefinitionsByNameEndpoint (AuthN.MaybeAuthedUserID callerUserId) us
154
158
Codebase. cachedCodebaseResponse authZReceipt codebaseLoc " project-branch-definitions-by-name" cacheParams causalId $ do
155
159
PG. runTransactionMode PG. ReadCommitted PG. ReadWrite $ do
156
160
CR. withCodebaseRuntime codebase unisonRuntime \ rt ->
157
- ShareBackend. definitionForHQName codebase (fromMaybe mempty relativeTo) causalId renderWidth (Suffixify False ) rt name
161
+ ShareBackend. displayDefinitionByHQName codebase (fromMaybe mempty relativeTo) causalId renderWidth (Suffixify False ) rt name
158
162
where
159
163
projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
160
164
cacheParams = [IDs. toText projectBranchShortHand, HQ. toTextWith Name. toText name, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
@@ -181,7 +185,7 @@ projectBranchDefinitionsByHashEndpoint (AuthN.MaybeAuthedUserID callerUserId) us
181
185
Codebase. cachedCodebaseResponse authZReceipt codebaseLoc " project-branch-definitions-by-hash" cacheParams causalId $ do
182
186
PG. runTransactionMode PG. ReadCommitted PG. ReadWrite $ do
183
187
CR. withCodebaseRuntime codebase unisonRuntime \ rt ->
184
- ShareBackend. definitionForHQName codebase (fromMaybe mempty relativeTo) causalId renderWidth (Suffixify False ) rt query
188
+ ShareBackend. displayDefinitionByHQName codebase (fromMaybe mempty relativeTo) causalId renderWidth (Suffixify False ) rt query
185
189
where
186
190
projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
187
191
cacheParams = [IDs. toText projectBranchShortHand, toUrlPiece referent, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
@@ -205,7 +209,9 @@ projectBranchTermSummaryEndpoint (AuthN.MaybeAuthedUserID callerUserId) userHand
205
209
causalId <- resolveRootHash codebase branchHead rootHash
206
210
Codebase. cachedCodebaseResponse authZReceipt codebaseLoc " project-branch-term-summary" cacheParams causalId $ do
207
211
PG. runTransactionMode PG. ReadCommitted PG. ReadWrite $ do
208
- serveTermSummary codebase ref mayName causalId relativeTo renderWidth
212
+ rootBHId <- CausalQ. expectNamespaceIdsByCausalIdsOf id causalId
213
+ np <- NP. namesPerspectiveForRootAndPath rootBHId (maybe mempty pathToPathSegments relativeTo)
214
+ serveTermSummary codebase ref mayName np renderWidth
209
215
where
210
216
projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
211
217
cacheParams = [IDs. toText projectBranchShortHand, toUrlPiece ref, maybe " " Name. toText mayName, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
@@ -234,6 +240,62 @@ projectBranchTypeSummaryEndpoint (AuthN.MaybeAuthedUserID callerUserId) userHand
234
240
projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
235
241
cacheParams = [IDs. toText projectBranchShortHand, toUrlPiece ref, maybe " " Name. toText mayName, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
236
242
243
+ projectBranchDefinitionDependenciesByNameEndpoint ::
244
+ Maybe Session ->
245
+ UserHandle ->
246
+ ProjectSlug ->
247
+ BranchShortHand ->
248
+ HQ. HashQualified Name ->
249
+ Maybe Path. Path ->
250
+ Maybe Pretty. Width ->
251
+ Maybe CausalHash ->
252
+ WebApp (Cached JSON DefinitionSearchResults )
253
+ projectBranchDefinitionDependenciesByNameEndpoint (AuthN. MaybeAuthedUserID callerUserId) userHandle projectSlug bsh@ (BranchShortHand {contributorHandle, branchName}) name relativeTo renderWidth rootHash = do
254
+ (Project {ownerUserId = projectOwnerUserId, projectId}, Branch {causal = branchHead, contributorId}) <- getProjectBranch projectBranchShortHand
255
+ authZReceipt <- AuthZ. permissionGuard $ AuthZ. checkProjectBranchRead callerUserId projectId
256
+ let codebaseLoc = Codebase. codebaseLocationForProjectBranchCodebase projectOwnerUserId contributorId
257
+ let codebase = Codebase. codebaseEnv authZReceipt codebaseLoc
258
+ causalId <- resolveRootHash codebase branchHead rootHash
259
+ Codebase. cachedCodebaseResponse authZReceipt codebaseLoc " project-branch-definition-dependencies-by-name" cacheParams causalId $ do
260
+ PG. runTransactionMode PG. ReadCommitted PG. ReadWrite $ do
261
+ rootBranchHashId <- CausalQ. expectNamespaceIdsByCausalIdsOf id causalId
262
+ np <- NP. namesPerspectiveForRootAndPath rootBranchHashId (maybe mempty pathToPathSegments relativeTo)
263
+ DefinitionSearchResults <$> ShareBackend. definitionDependencyResults codebase name projectShorthand branchOrReleaseShortHand np renderWidth
264
+ where
265
+ branchOrReleaseShortHand = IDs. IsBranchShortHand bsh
266
+ projectShorthand = ProjectShortHand {userHandle, projectSlug}
267
+ projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
268
+ cacheParams = [IDs. toText projectBranchShortHand, HQ. toTextWith Name. toText name, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
269
+
270
+ projectBranchDefinitionDependenciesByHashEndpoint ::
271
+ Maybe Session ->
272
+ UserHandle ->
273
+ ProjectSlug ->
274
+ BranchShortHand ->
275
+ Referent ->
276
+ Maybe Path. Path ->
277
+ Maybe Pretty. Width ->
278
+ Maybe CausalHash ->
279
+ WebApp (Cached JSON DefinitionSearchResults )
280
+ projectBranchDefinitionDependenciesByHashEndpoint (AuthN. MaybeAuthedUserID callerUserId) userHandle projectSlug bsh@ (BranchShortHand {contributorHandle, branchName}) referent relativeTo renderWidth rootHash = do
281
+ (Project {ownerUserId = projectOwnerUserId, projectId}, Branch {causal = branchHead, contributorId}) <- getProjectBranch projectBranchShortHand
282
+ authZReceipt <- AuthZ. permissionGuard $ AuthZ. checkProjectBranchRead callerUserId projectId
283
+ let codebaseLoc = Codebase. codebaseLocationForProjectBranchCodebase projectOwnerUserId contributorId
284
+ let codebase = Codebase. codebaseEnv authZReceipt codebaseLoc
285
+ let shortHash = Referent. toShortHash referent
286
+ let query = HQ. HashOnly shortHash
287
+ causalId <- resolveRootHash codebase branchHead rootHash
288
+ Codebase. cachedCodebaseResponse authZReceipt codebaseLoc " project-branch-definition-dependencies-by-hash" (cacheParams query) causalId $ do
289
+ PG. runTransactionMode PG. ReadCommitted PG. ReadWrite $ do
290
+ rootBranchHashId <- CausalQ. expectNamespaceIdsByCausalIdsOf id causalId
291
+ np <- NP. namesPerspectiveForRootAndPath rootBranchHashId (maybe mempty pathToPathSegments relativeTo)
292
+ DefinitionSearchResults <$> ShareBackend. definitionDependencyResults codebase query projectShorthand branchOrReleaseShortHand np renderWidth
293
+ where
294
+ branchOrReleaseShortHand = IDs. IsBranchShortHand bsh
295
+ projectShorthand = ProjectShortHand {userHandle, projectSlug}
296
+ projectBranchShortHand = ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}
297
+ cacheParams query = [IDs. toText projectBranchShortHand, HQ. toTextWith Name. toText query, tShow $ fromMaybe mempty relativeTo, foldMap toUrlPiece renderWidth]
298
+
237
299
projectBranchFindEndpoint ::
238
300
Maybe Session ->
239
301
UserHandle ->
0 commit comments