diff --git a/src/app/app-client.ts b/src/app/app-client.ts index ba5b6fd4d..3aebdee1a 100644 --- a/src/app/app-client.ts +++ b/src/app/app-client.ts @@ -9,6 +9,7 @@ import { PackageType, type PackageTypeMap, } from '../gen/app/packages/v1/packages_pb'; +import type { FragmentVisibilityMap } from '../gen/app/v1/app_pb'; /** * Creates an Authorization object from auth details. @@ -1019,15 +1020,26 @@ export class AppClient { * Lists all fragments within an organization. * * @param orgId The ID of the organization to list fragments for - * @param publicOnly Optional boolean, if true then only public fragments will - * be listed. Defaults to true. + * @param publicOnly Optional, deprecated boolean. Use fragmentVisibilities + * instead. If true then only public fragments will be listed. Defaults to + * true + * @param fragmentVisibilities Optional list of fragment visibilities to + * include in returned list. An empty fragmentVisibilities list defaults to + * normal publicOnly behavior (discludes unlisted public fragments) + * Otherwise, fragment visibilities should contain one of the three + * visibilities and takes precendence over the publicOnly field * @returns The list of fragment objects */ - async listFragments(orgId: string, publicOnly = true) { + async listFragments( + orgId: string, + publicOnly = true, + fragmentVisibilities: FragmentVisibilityMap[keyof FragmentVisibilityMap][] = [] + ) { const { service } = this; const req = new pb.ListFragmentsRequest(); req.setOrganizationId(orgId); req.setShowPublic(publicOnly); + req.setFragmentVisibilityList(fragmentVisibilities); const response = await promisify< pb.ListFragmentsRequest, @@ -1082,16 +1094,22 @@ export class AppClient { * @param id The ID of the fragment to update * @param name The name to update the fragment to * @param config The config to update the fragment to - * @param makePublic Optional boolean specifying whether the fragment should - * be public or not. If not passed the visibility will be unchanged. - * Fragments are private by default when created + * @param makePublic Optional, deprecated boolean specifying whether the + * fragment should be public or not. If not passed, the visibility will be + * unchanged. Fragments are private by default when created + * @param visibility Optional FragmentVisibility specifying the updated + * fragment visibility. If not passed, the visibility will be unchanged. If + * visibility is not set and makePublic is set, makePublic takes effect. If + * makePublic and visibility are set, they must not be conflicting. If + * neither is set, the fragment visibility will remain unchanged. * @returns The updated fragment */ async updateFragment( id: string, name: string, config: StructType, - makePublic?: boolean + makePublic?: boolean, + visibility?: keyof pb.FragmentVisibilityMap ) { const { service } = this; const req = new pb.UpdateFragmentRequest(); @@ -1101,6 +1119,9 @@ export class AppClient { if (makePublic !== undefined) { req.setPublic(makePublic); } + if (visibility !== undefined) { + req.setVisibility(pb.FragmentVisibility[visibility]); + } const response = await promisify< pb.UpdateFragmentRequest,