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

feat: Add includeMetadata optional parameter to getPlugin and getPlugins functions #341

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ TEMPLATE:

## [UPCOMING]

## [1.26.0]

### Changed
- Add `includeMetadata` optional parameter to `getPlugin` and `getPlugins` functions which defaults to `true`.

## [1.25.1]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion modules/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aragon/sdk-client",
"author": "Aragon Association",
"version": "1.25.1",
"version": "1.26.0",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/sdk-client.esm.js",
Expand Down
21 changes: 18 additions & 3 deletions modules/client/src/internal/client/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,16 @@ export class ClientMethods extends ClientCore implements IClientMethods {

private async getPluginRepo(
pluginRepo: SubgraphPluginRepo,
inlcudeMetadata?: boolean,
): Promise<PluginRepo> {
if (!inlcudeMetadata) {
return toPluginRepo(
pluginRepo,
EMPTY_RELEASE_METADATA_LINK,
EMPTY_BUILD_METADATA_LINK
);
}

let releaseMetadata: PluginRepoReleaseMetadata;
// releases are ordered son the index 0 will be the latest
const releaseIpfsUri = pluginRepo?.releases[0]?.metadata;
Expand Down Expand Up @@ -1006,6 +1015,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
* - direction = SortDirection.ASC
* - sortBy = PluginSortBy.SUBDOMAIN
* - subdomain
* @param {boolean} [includeMetadata=true]
* @return {(Promise<PluginRepo[] | null>)}
* @memberof ClientMethods
*/
Expand All @@ -1015,6 +1025,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
direction = SortDirection.ASC,
sortBy = PluginSortBy.SUBDOMAIN,
subdomain,
includeMetadata = true,
}: PluginQueryParams = {}): Promise<PluginRepoListItem[]> {
await PluginQuerySchema.strict().validate({
limit,
Expand Down Expand Up @@ -1046,7 +1057,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
return Promise.all(
pluginRepos.map(
(pluginRepo: SubgraphPluginRepoListItem) => {
return this.getPluginRepo(pluginRepo);
return this.getPluginRepo(pluginRepo, includeMetadata);
},
),
);
Expand All @@ -1055,10 +1066,14 @@ export class ClientMethods extends ClientCore implements IClientMethods {
* Get plugin details given an address, release and build
*
* @param {string} pluginAddress
* @param {boolean} [includeMetadata=true]
* @return {Promise<PluginRepo>}
* @memberof ClientMethods
*/
public async getPlugin(pluginAddress: string): Promise<PluginRepo> {
public async getPlugin(
pluginAddress: string,
includeMetadata: boolean = true
): Promise<PluginRepo> {
await AddressOrEnsSchema.strict().validate(pluginAddress);
const name = "plugin version";
const query = QueryPlugin;
Expand All @@ -1069,7 +1084,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
name,
});
// get release metadata
return this.getPluginRepo(pluginRepo);
return this.getPluginRepo(pluginRepo, includeMetadata);
}
/**
* Returns the protocol version of a contract
Expand Down
4 changes: 2 additions & 2 deletions modules/client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export interface IClientMethods {
/** Retrieves metadata for many daos */
getDaos: (params: DaoQueryParams) => Promise<DaoListItem[]>;
/** retrieves the plugin details given an address, release and build */
getPlugin: (pluginAddress: string) => Promise<PluginRepo>;
getPlugin: (pluginAddress: string, includeMetadata?: boolean) => Promise<PluginRepo>;
/** Retrieves the list of plugins available on the PluginRegistry */
getPlugins: (params?: PluginQueryParams) => Promise<PluginRepoListItem[]>;
getPlugins: (params?: PluginQueryParams, includeMetadata?: boolean) => Promise<PluginRepoListItem[]>;
/** Prepare uninstallation of a plugin */
prepareUninstallation: (
params: PrepareUninstallationParams,
Expand Down
1 change: 1 addition & 0 deletions modules/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum PluginSortBy {
export type PluginQueryParams = Pagination & {
sortBy?: PluginSortBy;
subdomain?: string;
includeMetadata?: boolean;
};

/* Plugin repos */
Expand Down
Loading