Skip to content

Commit

Permalink
Merge pull request #70 from pnp/version-4
Browse files Browse the repository at this point in the history
Update 2024-08-12
  • Loading branch information
juliemturner authored Aug 12, 2024
2 parents ef0c494 + ca43648 commit 7597623
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
2 changes: 2 additions & 0 deletions docs/graph/shares.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions docs/graph/taxonomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(...);
Expand Down Expand Up @@ -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)
Expand All @@ -291,36 +289,35 @@ 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

```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

```TypeScript
import { graphfi, SPFxToken, SPFx } from "@pnp/graph";
import "@pnp/graph/taxonomy";
import { ITermInfo } from "@pnp/graph/taxonomy";

const graph = graphfi(...);

Expand Down
4 changes: 2 additions & 2 deletions packages/graph/shares/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class _Shares extends _GraphCollection<IPermissionType[]> {
* @param share: string - Share Id or Encoded Sharing Url
* @returns Microsoft Graph - SharingLink
*/
public async useSharingLink(shareLink: IShareLinkInfo): Promise<ISharedDriveItemType> {
public async useSharingLink(shareLink: IShareLinkInfo): Promise<Pick<ISharedDriveItemType, "id"|"name">> {
const q = Shares(this, shareLink.shareId || shareLink.encodedSharingUrl);
if (shareLink.redeemSharingLink) {
q.using(InjectHeaders({
Expand All @@ -60,7 +60,7 @@ export class _Shares extends _GraphCollection<IPermissionType[]> {
return graphPost(q, body(shareLinkAccess));
}
}
export interface IShares extends _Shares, IGetById<ISharedDriveItemType> { }
export interface IShares extends _Shares, IGetById<IShare> { }
export const Shares = graphInvokableFactory<IShares>(_Shares);


Expand Down
16 changes: 10 additions & 6 deletions packages/graph/taxonomy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ export class _TermSet extends _GraphInstance<ITermStoreType.Set> {
*
* @returns Array of children for this item
*/
public async getAllChildrenAsTree(): Promise<IOrderedTermInfo[]> {
public async getAllChildrenAsTree(props?: {retrieveProperties?: boolean}): Promise<IOrderedTermInfo[]> {

const visitor = async (source: { children(): Promise<ITermStoreType.Term[]> }, 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<IOrderedTermInfo> = {
children: <IOrderedTermInfo[]>[],
defaultLabel: child.labels.find(l => l.isDefault).name,
Expand All @@ -99,9 +97,15 @@ export class _TermSet extends _GraphInstance<ITermStoreType.Set> {
}
};

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(<any>this, tree);

return tree;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sp/security/funcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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<void> {
await spPost(SPQueryable(this, `breakroleinheritance(copyroleassignments=${copyRoleAssignments}, clearsubscopes=${clearSubscopes})`));
return spPost(SPQueryable(this, `breakroleinheritance(copyroleassignments=${copyRoleAssignments}, clearsubscopes=${clearSubscopes})`));
}

/**
* Removes the local role assignments so that it re-inherit role assignments from the parent object.
*
*/
export async function resetRoleInheritance(this: SecurableQueryable): Promise<void> {
await spPost(SPQueryable(this, "resetroleinheritance"));
return spPost(SPQueryable(this, "resetroleinheritance"));
}

/**
Expand Down

0 comments on commit 7597623

Please sign in to comment.