Skip to content

Commit

Permalink
Add get project entities by classifier APIs in depot server client (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
YannanGao-gs authored Sep 23, 2024
1 parent ca407e7 commit 0a8601e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-lemons-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-server-depot': patch
---

Add get project entities by classifier APIs in depot server client
13 changes: 10 additions & 3 deletions packages/legend-server-depot/src/DepotServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export class DepotServerClient extends AbstractServerClient {
groupId: string,
artifactId: string,
version: string,
classifier?: string,
): string =>
`${this._versions(groupId, artifactId)}/${encodeURIComponent(version)}`;
`${this._versions(groupId, artifactId)}/${encodeURIComponent(version)}${classifier ? `/classifiers/${classifier}` : ``}`;

getAllVersions = (groupId: string, artifactId: string): Promise<string[]> =>
this.get(this._versions(groupId, artifactId));
Expand All @@ -85,17 +86,20 @@ export class DepotServerClient extends AbstractServerClient {
groupId: string,
artifactId: string,
version: string,
classifier?: string,
): Promise<PlainObject<Entity>[]> =>
this.get(this._version(groupId, artifactId, version));
this.get(this._version(groupId, artifactId, version, classifier));

getEntities(
project: StoreProjectData,
versionId: string,
classifier?: string,
): Promise<PlainObject<Entity>[]> {
return this.getVersionEntities(
project.groupId,
project.artifactId,
resolveVersion(versionId),
classifier,
);
}

Expand Down Expand Up @@ -213,9 +217,10 @@ export class DepotServerClient extends AbstractServerClient {
* Flag indicating whether to return the root of the dependency tree.
*/
includeOrigin: boolean,
classifier?: string,
): Promise<PlainObject<ProjectVersionEntities>[]> =>
this.get(
`${this._version(groupId, artifactId, version)}/dependencies`,
`${this._version(groupId, artifactId, version)}${classifier ? `/classifiers/${classifier}` : ''}/dependencies`,
undefined,
undefined,
{
Expand All @@ -228,6 +233,7 @@ export class DepotServerClient extends AbstractServerClient {
async getIndexedDependencyEntities(
project: StoreProjectData,
versionId: string,
classifier?: string,
): Promise<Map<string, EntitiesWithOrigin>> {
const dependencyEntitiesIndex = new Map<string, EntitiesWithOrigin>();
const dependencies = await this.getDependencyEntities(
Expand All @@ -236,6 +242,7 @@ export class DepotServerClient extends AbstractServerClient {
resolveVersion(versionId),
true,
false,
classifier,
);
dependencies
.map((v) => ProjectVersionEntities.serialization.fromJson(v))
Expand Down

0 comments on commit 0a8601e

Please sign in to comment.