From a8a4a07110dfbd44df7325c83b9aecfa9ebebcf3 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Tue, 16 Jul 2024 16:43:30 +0100 Subject: [PATCH 1/4] docs(graph): update incorrect references to `ITermInfo` Resolves #3081 --- docs/graph/taxonomy.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/graph/taxonomy.md b/docs/graph/taxonomy.md index 8df23696c..cc91bc11d 100644 --- a/docs/graph/taxonomy.md +++ b/docs/graph/taxonomy.md @@ -203,7 +203,6 @@ This method will get all of a set's child terms in an ordered array. It is a cos ```TypeScript import { graphfi } from "@pnp/graph"; import "@pnp/graph/taxonomy"; -import { ITermInfo } from "@pnp/graph/taxonomy"; import { dateAdd, PnPClientStorage } from "@pnp/core"; const graph = graphfi(...); @@ -276,12 +275,11 @@ Access term set information ```TypeScript import { graphfi } from "@pnp/graph"; import "@pnp/graph/taxonomy"; -import { ITermInfo } from "@pnp/graph/taxonomy"; - +import { TermStore } from '@microsoft/microsoft-graph-types'; const graph = graphfi(...); // list all the terms that are direct children of this set -const infos: ITermInfo[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").children(); +const infos: TermStore.Term[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").children(); ``` ### List (terms) @@ -291,15 +289,15 @@ You can use the terms property to get a flat list of all terms in the set. These ```TypeScript import { graphfi } from "@pnp/graph"; import "@pnp/graph/taxonomy"; -import { ITermInfo } from "@pnp/graph/taxonomy"; +import { TermStore } from '@microsoft/microsoft-graph-types'; const graph = graphfi(...); // list all the terms available in this term set by group id then by term set id -const infos: ITermInfo[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").terms(); +const infos: TermStore.Term[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").terms(); // list all the terms available in this term set by term set id -const infosByTermSetId: ITermInfo[] = await graph.termStore.sets.getById("338666a8-1111-2222-3333-f72471314e72").terms(); +const infosByTermSetId: TermStore.Term[] = await graph.termStore.sets.getById("338666a8-1111-2222-3333-f72471314e72").terms(); ``` ### Get By Id @@ -307,12 +305,12 @@ const infosByTermSetId: ITermInfo[] = await graph.termStore.sets.getById("338666 ```TypeScript import { graphfi } from "@pnp/graph"; import "@pnp/graph/taxonomy"; -import { ITermInfo } from "@pnp/graph/taxonomy"; +import { TermStore } from '@microsoft/microsoft-graph-types'; const graph = graphfi(...); // get term set data -const info: ITermInfo = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").getTermById("338666a8-1111-2222-3333-f72471314e72")(); +const info: TermStore.Term = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").getTermById("338666a8-1111-2222-3333-f72471314e72")(); ``` ### Add @@ -320,7 +318,6 @@ const info: ITermInfo = await graph.termStore.groups.getById("338666a8-1111-2222 ```TypeScript import { graphfi, SPFxToken, SPFx } from "@pnp/graph"; import "@pnp/graph/taxonomy"; -import { ITermInfo } from "@pnp/graph/taxonomy"; const graph = graphfi(...); From 123b6e8162a4b9f0a98db0cac5232301ae4dd6b8 Mon Sep 17 00:00:00 2001 From: Beau Cameron Date: Wed, 7 Aug 2024 17:34:46 -0600 Subject: [PATCH 2/4] Fixes 3091 Fix return type for GetById Updating return from useSharingLink --- docs/graph/shares.md | 2 ++ packages/graph/shares/types.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/graph/shares.md b/docs/graph/shares.md index 30ceafdc2..ce16f59fa 100644 --- a/docs/graph/shares.md +++ b/docs/graph/shares.md @@ -71,7 +71,9 @@ const shareLinkInfo = { encodedSharingUrl: shareLink, redeemSharingLink: false }; +// default shared drive item response (id, name) const sharedDriveItem = await graph.shares.useSharingLink(shareLinkInfo); + ``` ## Create Sharing Link diff --git a/packages/graph/shares/types.ts b/packages/graph/shares/types.ts index a2e2aa590..ce2d3238f 100644 --- a/packages/graph/shares/types.ts +++ b/packages/graph/shares/types.ts @@ -45,7 +45,7 @@ export class _Shares extends _GraphCollection { * @param share: string - Share Id or Encoded Sharing Url * @returns Microsoft Graph - SharingLink */ - public async useSharingLink(shareLink: IShareLinkInfo): Promise { + public async useSharingLink(shareLink: IShareLinkInfo): Promise> { const q = Shares(this, shareLink.shareId || shareLink.encodedSharingUrl); if (shareLink.redeemSharingLink) { q.using(InjectHeaders({ @@ -60,7 +60,7 @@ export class _Shares extends _GraphCollection { return graphPost(q, body(shareLinkAccess)); } } -export interface IShares extends _Shares, IGetById { } +export interface IShares extends _Shares, IGetById { } export const Shares = graphInvokableFactory(_Shares); From 8ec53912e751a568d3f0006c367689a06045dc2e Mon Sep 17 00:00:00 2001 From: Beau Cameron Date: Wed, 7 Aug 2024 20:06:40 -0600 Subject: [PATCH 3/4] Adding Default Selects Making select match v2 and v3 versions of this call. adding retrieveProperties to allow selecting custom properties --- packages/graph/taxonomy/types.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/graph/taxonomy/types.ts b/packages/graph/taxonomy/types.ts index a9f58510b..db0c7fd1c 100644 --- a/packages/graph/taxonomy/types.ts +++ b/packages/graph/taxonomy/types.ts @@ -77,16 +77,14 @@ export class _TermSet extends _GraphInstance { * * @returns Array of children for this item */ - public async getAllChildrenAsTree(): Promise { + public async getAllChildrenAsTree(props?: {retrieveProperties?: boolean}): Promise { - const visitor = async (source: { children(): Promise }, parent: IOrderedTermInfo[]) => { - - const children = await source.children(); + const visitor = async (source: ITerm | ITermSet, parent: IOrderedTermInfo[]) => { + const children = await source.children.select(...selects)(); for (let i = 0; i < children.length; i++) { const child = children[i]; - const orderedTerm: Partial = { children: [], defaultLabel: child.labels.find(l => l.isDefault).name, @@ -99,9 +97,15 @@ export class _TermSet extends _GraphInstance { } }; + let selects = ["*"]; + if(props?.retrieveProperties){ + // graph does not let us wildcard + select properties + selects=["id", "labels", "createdDateTime", "lastModifiedDateTime", "labels", "descriptions", "properties"]; + } + const tree: IOrderedTermInfo[] = []; - await visitor(this, tree); + await visitor(this, tree); return tree; } From 66bd81616531151d2fd5346dc6084996e6781c5e Mon Sep 17 00:00:00 2001 From: Patrick Rodgers Date: Fri, 9 Aug 2024 07:47:50 -0400 Subject: [PATCH 4/4] Update funcs.ts Addressing await within function, possibly related to #3104 --- packages/sp/security/funcs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sp/security/funcs.ts b/packages/sp/security/funcs.ts index 48b6b9cbd..8d5ce4128 100644 --- a/packages/sp/security/funcs.ts +++ b/packages/sp/security/funcs.ts @@ -28,7 +28,7 @@ export async function getCurrentUserEffectivePermissions(this: SecurableQueryabl * @param clearSubscopes Optional. true to make all child securable objects inherit role assignments from the current object */ export async function breakRoleInheritance(this: SecurableQueryable, copyRoleAssignments = false, clearSubscopes = false): Promise { - await spPost(SPQueryable(this, `breakroleinheritance(copyroleassignments=${copyRoleAssignments}, clearsubscopes=${clearSubscopes})`)); + return spPost(SPQueryable(this, `breakroleinheritance(copyroleassignments=${copyRoleAssignments}, clearsubscopes=${clearSubscopes})`)); } /** @@ -36,7 +36,7 @@ export async function breakRoleInheritance(this: SecurableQueryable, copyRoleAss * */ export async function resetRoleInheritance(this: SecurableQueryable): Promise { - await spPost(SPQueryable(this, "resetroleinheritance")); + return spPost(SPQueryable(this, "resetroleinheritance")); } /**