Skip to content

Commit

Permalink
Merge pull request #2993 from juliemturner/version-4
Browse files Browse the repository at this point in the history
V4 release updates
  • Loading branch information
juliemturner authored Apr 14, 2024
2 parents 2dbefa2 + e25944b commit e7876c5
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 17 deletions.
17 changes: 3 additions & 14 deletions docs/graph/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ const endDate = new Date("2020-03-01");
const events = graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").getCalendarView(startDate, endDate);
```

## Group Membership

Get the members and/or owners of a group.

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/members";

const graph = graphfi(...);
const members = await graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").members();
const owners = await graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").owners();
```

## Get the Team Site for a Group

```TypeScript
Expand All @@ -158,6 +144,9 @@ const graph = graphfi(...);
const teamSite = await graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").sites.root();
const url = teamSite.webUrl
```
## Group Membership (Members and Owners)

See [Members](./members.md)

## Group Photo Operations

Expand Down
50 changes: 50 additions & 0 deletions docs/graph/members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# @pnp/graph/members

Members are collections of users and other principals. Other API objects have membership so all membership functionality is encapsulated in one import.

## IMember, IMembers

[![Invokable Banner](https://img.shields.io/badge/Invokable-informational.svg)](../concepts/invokable.md) [![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md)

## List Group Members/Owners

Get the members and/or owners of a group.

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/members";

const graph = graphfi(...);
const members = await graph.groups.getById({groupId}).members();
const owners = await graph.groups.getById({groupId}).owners();
```

## Add Member/Owner

Add a member/owner to an group

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/members";

const graph = graphfi(...);
const members = await graph.groups.getById({groupId}).members.add({directoryObjectId}).
const owners = await graph.groups.getById({groupId}).owners.add({directoryObjectId});
```

## Remove Member/Owner

Remove a member/owner to an group

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/members";

const graph = graphfi(...);
const members = await graph.groups.getById({groupId}).members.getById({directoryObjectId}).remove().
const owners = await graph.groups.getById({groupId}).owners.getById({directoryObjectId}).remove();
```

46 changes: 46 additions & 0 deletions docs/sp/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,56 @@ Gets information about an item, including details about the parent list, parent
```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const sp = spfi(...);

const item: any = await sp.web.lists.getByTitle("My List").items.getById(1)();
await item.getParentInfos();
```

### Get Version History

Get's the version history information for a list item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const sp = spfi(...);

const itemVersions: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions();
```

### Get Version History Item by Id

Get's the specific version information for a list item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const sp = spfi(...);

const itemVersion: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions.getById({version id})();
```

### Delete Version History Item by Id

Get's the specific version information for a list item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const sp = spfi(...);

await sp.web.lists.getByTitle("My List").items.getById({item id}).versions.getById({version id}).delete({eTag});
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nav:
- 'mailbox': 'graph/mail-mailbox.md'
- 'messages': 'graph/mail-messages.md'
- 'rules': 'graph/mail-rules.md'
- members: 'graph/members.md'
- outlook: 'graph/outlook.md'
- operations: 'graph/operations.md'
- permissions: 'graph/permissions.md'
Expand Down
5 changes: 3 additions & 2 deletions packages/graph/mail/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IOutlook, Outlook } from "./categories.js";
import { FocusedInboxOverrides, IFocusedInboxOverrides, IMailboxSettings, MailboxSettings } from "./mailbox.js";
import { addProp, body } from "@pnp/queryable";
import { graphPost } from "../graphqueryable.js";
import { Message as IMessageType } from "@microsoft/microsoft-graph-types";

declare module "../users/types" {
interface _User {
Expand All @@ -13,7 +14,7 @@ declare module "../users/types" {
readonly mailFolders: IMailFolders;
readonly outlook: IOutlook;
readonly focusedInboxOverrides: IFocusedInboxOverrides;
sendMail(message: IMessage): Promise<void>;
sendMail(message: IMessageType): Promise<void>;
translateExchangeIds(translateExchangeIds: ITranslateExchangeIds): Promise<ITranslateExchangeIdsResponse[]>;
}
interface IUser {
Expand All @@ -33,7 +34,7 @@ addProp(_User, "mailFolders", MailFolders);
addProp(_User, "outlook", Outlook);
addProp(_User, "focusedInboxOverrides", FocusedInboxOverrides, "inferenceClassification/overrides");

_User.prototype.sendMail = function (this: _User, message: IMessage): Promise<void> {
_User.prototype.sendMail = function (this: _User, message: IMessageType): Promise<void> {
return graphPost(User(this, "sendMail"), body(message));
};

Expand Down
2 changes: 1 addition & 1 deletion packages/graph/members/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ declare module "../groups/types" {
}
}

addProp(_Group, "owners", Members);
addProp(_Group, "owners", Members, "owners");
addProp(_Group, "members", Members);

0 comments on commit e7876c5

Please sign in to comment.