-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated node typings to 18
- Loading branch information
Julie Turner
committed
Mar 20, 2024
1 parent
6996a3b
commit 5c89971
Showing
24 changed files
with
911 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
"args": [ | ||
"--verbose", | ||
"--logging", | ||
"Error", | ||
"verbose", | ||
"--record", | ||
"write" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ const shared = await graph.me.drives.getById({drive id}).sharedWithMe(options); | |
|
||
``` | ||
|
||
## Get the following drive item | ||
## Get the drive item being followed | ||
|
||
List the items that have been followed by the signed in user. | ||
|
||
|
@@ -208,9 +208,9 @@ const rootChildren = await graph.users.getById({user id}).drives.getById({drive | |
|
||
const rootChildren = await graph.me.drives.getById({drive id}).root.children(); | ||
|
||
const itemChildren = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").children(); | ||
const itemChildren = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").children(); | ||
|
||
const itemChildren = await graph.me.drives.getById({drive id}).root.items.getById("{item id}").children(); | ||
const itemChildren = await graph.me.drives.getById({drive id}).root.getItemById("{item id}").children(); | ||
|
||
``` | ||
|
||
|
@@ -368,9 +368,9 @@ import "@pnp/graph/files"; | |
|
||
const graph = graphfi(...); | ||
|
||
const item = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}")(); | ||
const item = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}")(); | ||
|
||
const item = await graph.me.drives.getById({drive id}).items.getById("{item id}")(); | ||
const item = await graph.me.drives.getById({drive id}).getItemById("{item id}")(); | ||
|
||
``` | ||
|
||
|
@@ -462,9 +462,9 @@ import "@pnp/graph/files"; | |
|
||
const graph = graphfi(...); | ||
|
||
const thumbs = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").thumbnails(); | ||
const thumbs = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").thumbnails(); | ||
|
||
const thumbs = await graph.me.drives.getById({drive id}).items.getById("{item id}").thumbnails(); | ||
const thumbs = await graph.me.drives.getById({drive id}).getItemById("{item id}").thumbnails(); | ||
|
||
``` | ||
|
||
|
@@ -479,10 +479,10 @@ import "@pnp/graph/files"; | |
|
||
const graph = graphfi(...); | ||
|
||
await graph.me.drives.getById({drive id}).items.getById({item id}).delete(); | ||
await graph.me.drives.getById({drive id}).items.getById({item id}).permanentDelete(); | ||
await graph.users.getById({user id}).drives.getById({drive id}).items.getById({item id}).delete(); | ||
await graph.users.getById({user id}).drives.getById({drive id}).items.getById({item id}).permanentDelete(); | ||
await graph.me.drives.getById({drive id}).getItemById({item id}).delete(); | ||
await graph.me.drives.getById({drive id}).getItemById({item id}).permanentDelete(); | ||
await graph.users.getById({user id}).drives.getById({drive id}).getItemById({item id}).delete(); | ||
await graph.users.getById({user id}).drives.getById({drive id}).getItemById({item id}).permanentDelete(); | ||
``` | ||
|
||
## Update drive item metadata | ||
|
@@ -496,9 +496,9 @@ import "@pnp/graph/files"; | |
|
||
const graph = graphfi(...); | ||
|
||
const update = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").update({name: "New Name"}); | ||
const update = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").update({name: "New Name"}); | ||
|
||
const update = await graph.me.drives.getById({drive id}).items.getById("{item id}").update({name: "New Name"}); | ||
const update = await graph.me.drives.getById({drive id}).getItemById("{item id}").update({name: "New Name"}); | ||
|
||
``` | ||
|
||
|
@@ -522,9 +522,9 @@ const moveOptions: IItemOptions = { | |
name?: {newName}; | ||
}; | ||
|
||
const move = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").move(moveOptions); | ||
const move = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").move(moveOptions); | ||
|
||
const move = await graph.me.drives.getById({drive id}).items.getById("{item id}").move(moveOptions); | ||
const move = await graph.me.drives.getById({drive id}).getItemById("{item id}").move(moveOptions); | ||
|
||
``` | ||
|
||
|
@@ -548,9 +548,9 @@ const copyOptions: IItemOptions = { | |
name?: {newName}; | ||
}; | ||
|
||
const copy = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").copy(copyOptions); | ||
const copy = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").copy(copyOptions); | ||
|
||
const copy = await graph.me.drives.getById({drive id}).items.getById("{item id}").copy(copyOptions); | ||
const copy = await graph.me.drives.getById({drive id}).getItemById("{item id}").copy(copyOptions); | ||
|
||
``` | ||
|
||
|
@@ -590,16 +590,16 @@ import { ItemPreviewInfo } from "@microsoft/microsoft-graph-types" | |
|
||
const graph = graphfi(...); | ||
|
||
const preview: ItemPreviewInfo = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").preview(); | ||
const preview: ItemPreviewInfo = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").preview(); | ||
|
||
const preview: ItemPreviewInfo = await graph.me.drives.getById({drive id}).items.getById("{item id}").preview(); | ||
const preview: ItemPreviewInfo = await graph.me.drives.getById({drive id}).getItemById("{item id}").preview(); | ||
|
||
const previewOptions: IPreviewOptions = { | ||
page: 1, | ||
zoom: 90 | ||
} | ||
|
||
const preview2: ItemPreviewInfo = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").preview(previewOptions); | ||
const preview2: ItemPreviewInfo = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").preview(previewOptions); | ||
|
||
``` | ||
|
||
|
@@ -640,16 +640,57 @@ import { IAnalyticsOptions } from "@pnp/graph/files"; | |
const graph = graphfi(...); | ||
|
||
// Defaults to lastSevenDays | ||
const analytics = await graph.users.getById({user id}).drives.getById({drive id}).items.getById("{item id}").analytics()(); | ||
const analytics = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").analytics()(); | ||
|
||
const analytics = await graph.me.drives.getById({drive id}).items.getById("{item id}").analytics()(); | ||
const analytics = await graph.me.drives.getById({drive id}).getItemById("{item id}").analytics()(); | ||
|
||
const analyticOptions: IAnalyticsOptions = { | ||
timeRange: "allTime" | ||
}; | ||
|
||
const analyticsAllTime = await graph.me.drives.getById({drive id}).items.getById("{item id}").analytics(analyticOptions)(); | ||
const analyticsAllTime = await graph.me.drives.getById({drive id}).getItemById("{item id}").analytics(analyticOptions)(); | ||
``` | ||
|
||
For more information on: | ||
[Sensitivity and Retention Labels (Premium Endpoint)](./files-labels.md) | ||
|
||
## Permissions | ||
|
||
### List/Get/Add/Update/Delete Drive Item Permissions | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/users"; | ||
import "@pnp/graph/files"; | ||
import "@pnp/graph/permissions/drive-item"; | ||
import {IPermissionsInviteInfo} from "@pnp/graph/permissions/drive-item"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const newPermissions: IPermissionsInviteInfo = { | ||
recipients: [{email: "[email protected]"}], | ||
requireSignIn: true, | ||
sendInvitation: true, | ||
roles: ["read"] | ||
}; | ||
|
||
// List permissions | ||
const permissions = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").permissions(); | ||
|
||
// Add permissions | ||
const permissions = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").addPermissions(newPermissions); | ||
|
||
// Get permissions | ||
const itemPermissions = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").permissions.getById(permissions.id)(); | ||
|
||
// Update permissions | ||
const updatedPermissions = await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").permissions.getById(permissions.id).update({roles: ["write"]}); | ||
|
||
// Delete permissions | ||
await graph.users.getById({user id}).drives.getById({drive id}).getItemById("{item id}").permissions.getById(permissions.id).delete(); | ||
|
||
``` | ||
|
||
## Sharing | ||
|
||
[Shares](./shares.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,74 @@ const graph = graphfi(...); | |
|
||
const driveItemInfo = await graph.shares.getById("{shareId}").driveItem(); | ||
``` | ||
|
||
## Convert sharing URL to a sharing token | ||
|
||
To use a sharing URL with this API, your app needs to transform the URL into a sharing token. | ||
|
||
```TS | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/shares"; | ||
import {IShareLinkInfo} from "@pnp/graph/shares"; | ||
|
||
const graph = graphfi(...); | ||
|
||
// Use ShareId | ||
const shareLinkInfo: IShareLinkInfo = { | ||
shareId: shareId, | ||
redeemSharingLink: false, | ||
}; | ||
const sharedDriveItem = await graph.shares.useSharingLink(shareLinkInfo); | ||
|
||
// Use Encoded Sharing Link | ||
const shareLink: string = graph.shares.encodeSharingLink("https://{tenant}.sharepoint.com/sites/dev/Shared%20Documents/new.pptx"); | ||
const shareLinkInfo = { | ||
encodedSharingUrl: shareLink, | ||
redeemSharingLink: false | ||
}; | ||
const sharedDriveItem = await graph.shares.useSharingLink(shareLinkInfo); | ||
``` | ||
|
||
## Create Sharing Link | ||
|
||
You can use createLink action to share a DriveItem via a sharing link. | ||
|
||
The createLink action will create a new sharing link if the specified link type doesn't already exist for the calling application. If a sharing link of the specified type already exists for the app, the existing sharing link will be returned. | ||
|
||
```TS | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/shares"; | ||
import "@pnp/graph/users"; | ||
import "@pnp/graph/files"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const sharingLinkInfo: ICreateShareLinkInfo = { | ||
type: "view", | ||
scope: "anonymous", | ||
}; | ||
const sharingLink = await graph.users.getById({userId}).drives.getById({driveId}).getItemById({itemId}).createSharingLink(sharingLinkInfo); | ||
|
||
``` | ||
|
||
## Grant Sharing Link Access | ||
|
||
Grant users access to a link represented by a permission. | ||
|
||
```TS | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/shares"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const shareLink: string = graph.shares.encodeSharingLink("https://{tenant}.sharepoint.com/sites/dev/Shared%20Documents/new.pptx"); | ||
const sharingLinkAccess = { | ||
encodedSharingUrl: shareLink, | ||
recipients: [{email: "[email protected]"}], | ||
roles: ["read"] | ||
}; | ||
|
||
// | ||
const permissions = await graph.shares.grantSharingLinkAccess(sharingLinkAccess); | ||
|
||
``` |
Oops, something went wrong.