@slates-integrations/sharepoint 0.2.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/docs/SPEC.md +98 -0
- package/logo.svg +1 -0
- package/package.json +20 -0
- package/slate.json +19 -0
- package/src/auth.ts +69 -0
- package/src/config.ts +4 -0
- package/src/index.ts +36 -0
- package/src/lib/client.ts +562 -0
- package/src/spec.ts +13 -0
- package/src/tools/errors.ts +16 -0
- package/src/tools/get-content-types.ts +109 -0
- package/src/tools/get-drive.ts +96 -0
- package/src/tools/get-file-versions.ts +53 -0
- package/src/tools/get-site.ts +79 -0
- package/src/tools/index.ts +12 -0
- package/src/tools/list-sites.ts +76 -0
- package/src/tools/manage-columns.ts +159 -0
- package/src/tools/manage-file.ts +262 -0
- package/src/tools/manage-list-items.ts +203 -0
- package/src/tools/manage-list.ts +133 -0
- package/src/tools/manage-permissions.ts +195 -0
- package/src/tools/search-drive.ts +61 -0
- package/src/tools/search.ts +132 -0
- package/src/triggers/drive-item-changes.ts +202 -0
- package/src/triggers/inbound-webhook.ts +67 -0
- package/src/triggers/index.ts +3 -0
- package/src/triggers/list-item-changes.ts +176 -0
- package/tsconfig.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# <img src="https://provider-logos.metorial-cdn.com/sharepoint-icon.svg" height="20"> Sharepoint
|
|
2
|
+
|
|
3
|
+
Manage SharePoint sites, document libraries, lists, and files. Create, read, update, and delete lists and list items with custom columns. Upload, download, move, copy, and version files in document libraries. Search across sites, files, folders, lists, and list items using Microsoft Search. Manage permissions at site, list, and item levels with granular access control. Define and manage content types and site columns. Subscribe to webhooks for list and library change notifications. Retrieve site properties and search for sites across Microsoft 365.
|
|
4
|
+
|
|
5
|
+
## Authentication
|
|
6
|
+
|
|
7
|
+
When registering the OAuth app in Microsoft Entra ID for local CLI auth, use `http://localhost:45873/callback` as the redirect URI.
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
### Get Content Types
|
|
12
|
+
|
|
13
|
+
Retrieve content types and site columns for a SharePoint site. Content types define reusable schemas for lists and libraries. Site columns are reusable field definitions that can be added to content types and lists.
|
|
14
|
+
|
|
15
|
+
### Get Drives
|
|
16
|
+
|
|
17
|
+
Retrieve document libraries (drives) for a SharePoint site. Can get the default drive, a specific drive by ID, or list all drives on a site. Drives are the containers for files in SharePoint.
|
|
18
|
+
|
|
19
|
+
### Get File Versions
|
|
20
|
+
|
|
21
|
+
Retrieve the version history of a file in a SharePoint document library. Returns all versions with their IDs, timestamps, and authors. Useful for auditing changes or rolling back to a previous version.
|
|
22
|
+
|
|
23
|
+
### Get Site
|
|
24
|
+
|
|
25
|
+
Retrieve detailed information about a SharePoint site. Look up a site by its ID, hostname and path, or get the root site. Also supports listing subsites of a given site.
|
|
26
|
+
|
|
27
|
+
### List Sites
|
|
28
|
+
|
|
29
|
+
Search for SharePoint sites by keyword, or list subsites of a given site. Returns a list of matching sites with their IDs and URLs.
|
|
30
|
+
|
|
31
|
+
### Manage Columns
|
|
32
|
+
|
|
33
|
+
List, create, update, or delete columns (fields) on a SharePoint list. Columns define the schema and metadata structure of a list. Supports various column types including text, number, boolean, dateTime, choice, currency, and personOrGroup.
|
|
34
|
+
|
|
35
|
+
### Manage File
|
|
36
|
+
|
|
37
|
+
Upload, download, move, copy, rename, or delete files and folders in a SharePoint document library. Also supports creating folders and listing folder contents. Use this for all file and folder operations within document libraries.
|
|
38
|
+
|
|
39
|
+
### Manage List Items
|
|
40
|
+
|
|
41
|
+
Full CRUD operations on SharePoint list items. Create, read, update, delete, or list items in a SharePoint list. Supports OData filtering and ordering when listing items. Field values match the list's column schema.
|
|
42
|
+
|
|
43
|
+
### Manage List
|
|
44
|
+
|
|
45
|
+
Create, read, update, or delete SharePoint lists within a site. Also supports listing all lists on a site. Lists are the foundation for data storage in SharePoint and can represent custom business data, contact lists, task trackers, and more.
|
|
46
|
+
|
|
47
|
+
### Manage Permissions
|
|
48
|
+
|
|
49
|
+
View, grant, and revoke permissions on SharePoint files and folders. Create sharing links, invite users with specific roles, list current permissions, or remove a permission. Works with drive items in document libraries.
|
|
50
|
+
|
|
51
|
+
### Search Drive
|
|
52
|
+
|
|
53
|
+
Search for files and folders within a specific SharePoint document library (drive). Uses the OneDrive search API scoped to a single drive. Returns matching items with their metadata.
|
|
54
|
+
|
|
55
|
+
### Search
|
|
56
|
+
|
|
57
|
+
Search across SharePoint content using the Microsoft Search API. Search for files, folders, lists, list items, or sites using KQL (Keyword Query Language) queries. Supports filtering by entity type and pagination.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
This integration is licensed under the [FSL-1.1](https://github.com/metorial/metorial-platform/blob/dev/LICENSE).
|
|
62
|
+
|
|
63
|
+
<div align="center">
|
|
64
|
+
<sub>Built with ❤️ by <a href="https://metorial.com">Metorial</a></sub>
|
|
65
|
+
</div>
|
package/docs/SPEC.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Slates Specification for SharePoint
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
SharePoint is Microsoft's cloud-based platform for document management, content collaboration, and intranet sites, available as part of Microsoft 365. It allows teams to create sites, store and organize files, manage lists, and work together from anywhere. SharePoint can be accessed programmatically via two APIs: the legacy SharePoint REST API (for deep SharePoint-specific operations) and the Microsoft Graph API (the recommended, unified approach for accessing SharePoint alongside other Microsoft 365 services).
|
|
6
|
+
|
|
7
|
+
## Authentication
|
|
8
|
+
|
|
9
|
+
SharePoint Online uses **OAuth 2.0** via **Microsoft Entra ID** (formerly Azure AD) for authentication. Both the SharePoint REST API and the Microsoft Graph API use OAuth 2.0 as their standard authentication method.
|
|
10
|
+
|
|
11
|
+
### Setup
|
|
12
|
+
|
|
13
|
+
You need to register an app in your Azure Active Directory, obtain the Client ID and Client Secret values, and then use those to obtain an Access Token. You will need the following credentials:
|
|
14
|
+
|
|
15
|
+
- **Tenant ID**: Identifies the Microsoft Entra ID tenant (directory).
|
|
16
|
+
- **Client ID** (Application ID): Identifies the registered application.
|
|
17
|
+
- **Client Secret** or **Certificate**: Used to authenticate the application.
|
|
18
|
+
- **Redirect URI for local CLI auth**: `http://localhost:45873/callback`
|
|
19
|
+
|
|
20
|
+
### OAuth 2.0 Flows
|
|
21
|
+
|
|
22
|
+
1. **Authorization Code Flow (Delegated)**: For acting on behalf of a signed-in user. The user signs in and grants consent. The authorization and token endpoints are:
|
|
23
|
+
- Authorization: `https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize`
|
|
24
|
+
- Token: `https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token`
|
|
25
|
+
|
|
26
|
+
2. **Client Credentials Flow (Application-only)**: The application can interact with data on its own, without a signed-in user. App-only access is used in scenarios such as automation and backup, and is mostly used by apps that run as background services or daemons. The token request uses:
|
|
27
|
+
- `grant_type=client_credentials`
|
|
28
|
+
- `scope=https://graph.microsoft.com/.default` (for Microsoft Graph) or `scope=https://{tenant}.sharepoint.com/.default` (for the SharePoint REST API directly)
|
|
29
|
+
|
|
30
|
+
### Scopes / Permissions
|
|
31
|
+
|
|
32
|
+
Permissions are configured on the app registration in Microsoft Entra ID. There are two types:
|
|
33
|
+
|
|
34
|
+
- **Delegated permissions** (scopes): Allow the application to act on behalf of the signed-in user.
|
|
35
|
+
- **Application permissions** (app roles): Allow the app to access data on its own, without a signed-in user.
|
|
36
|
+
|
|
37
|
+
Key SharePoint-related scopes for Microsoft Graph include:
|
|
38
|
+
|
|
39
|
+
- `Sites.Read.All`, `Sites.ReadWrite.All`, `Sites.Manage.All`, `Sites.FullControl.All`
|
|
40
|
+
- `Files.Read.All`, `Files.ReadWrite.All`
|
|
41
|
+
- `User.Read`, `offline_access`
|
|
42
|
+
- `Sites.Selected` — restricts an application's access to specific site collections. Now lists, list items, folders, and files are also supported, and all Selected scopes support delegated and application modes.
|
|
43
|
+
|
|
44
|
+
Application permissions typically require admin consent. Access tokens generated for Microsoft Graph resources are not valid for the SharePoint REST API — use the correct audience (`https://graph.microsoft.com` vs. `https://{tenant}.sharepoint.com`) depending on which API you call.
|
|
45
|
+
|
|
46
|
+
### Certificate-Based Authentication
|
|
47
|
+
|
|
48
|
+
For unattended (app-only) access, authentication can also be done using a certificate instead of a client secret. If you want a delegated call on behalf of a user, you don't need certificate authentication.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
### Site Management
|
|
53
|
+
|
|
54
|
+
The SharePoint API in Microsoft Graph supports access to SharePoint sites, lists, and drives (document libraries), with read-only support for site resources (no ability to create new sites) and read-write support for lists, listItems, and driveItems. You can retrieve site properties, search for sites, and access sites associated with Microsoft 365 groups or Teams.
|
|
55
|
+
|
|
56
|
+
### Lists and List Items
|
|
57
|
+
|
|
58
|
+
Lists are the foundation for data storage in SharePoint. You can create lists to store a variety of business data, from a simple customer contact list to a custom business application. When you use columns to define your schema, SharePoint can protect the integrity of your data as well as enable rich indexing, querying, and search capabilities. The API supports full CRUD operations on lists and list items, including defining custom columns.
|
|
59
|
+
|
|
60
|
+
### Document Libraries and Files
|
|
61
|
+
|
|
62
|
+
SharePoint stores files in a special list type called a document library. You can use the OneDrive API to work with a library as a drive, or the SharePoint API to work with it as a list. Just like a regular list, you can extend the schema of a Document Library to support your business needs with custom columns. This includes uploading, downloading, moving, copying, and versioning files.
|
|
63
|
+
|
|
64
|
+
### Search
|
|
65
|
+
|
|
66
|
+
The Microsoft Search API in Microsoft Graph can search content stored in OneDrive or SharePoint: files, folders, lists, list items, or sites. Search supports filtering by entity type and using KQL query templates.
|
|
67
|
+
|
|
68
|
+
### Permissions Management
|
|
69
|
+
|
|
70
|
+
SharePoint supports managing permissions at the site, list, and item level. Through the Graph API and the Selected permissions model, applications can be granted granular access to specific resources. OneDrive for Business and SharePoint support sending notifications of security events on a driveItem. You can subscribe to these events to receive notifications when the permissions on an item change.
|
|
71
|
+
|
|
72
|
+
### Content Types and Columns
|
|
73
|
+
|
|
74
|
+
SharePoint allows defining reusable content types and site columns that govern the schema and metadata of lists and libraries. These can be managed via the API.
|
|
75
|
+
|
|
76
|
+
## Events
|
|
77
|
+
|
|
78
|
+
SharePoint supports webhooks through two mechanisms: native SharePoint webhooks and Microsoft Graph change notifications (subscriptions).
|
|
79
|
+
|
|
80
|
+
### SharePoint Native Webhooks (List/Library Changes)
|
|
81
|
+
|
|
82
|
+
The SharePoint list webhooks cover the events corresponding to list item changes for a given SharePoint list or a document library. SharePoint webhooks only support asynchronous events. This means that webhooks are only fired after a change happened (similar to -ed events), and thus synchronous (-ing events) are not possible.
|
|
83
|
+
|
|
84
|
+
- **Supported resources**: SharePoint lists and document libraries.
|
|
85
|
+
- **Events**: Item added, item updated, item deleted, item moved/renamed, item checked in/out, item attachment changes.
|
|
86
|
+
- The notification doesn't include any information about the changes that triggered it. Your application is expected to use the GetChanges API on the list to query the collection of changes from the change log.
|
|
87
|
+
- **Subscription expiration**: Webhook subscriptions are set to expire after 180 days by default. You need to set an expiration date when creating the subscription, and the expiration date should be less than 180 days.
|
|
88
|
+
- Subscriptions require specifying a notification URL, and SharePoint validates the endpoint upon creation.
|
|
89
|
+
|
|
90
|
+
### Microsoft Graph Change Notifications (SharePoint Resources)
|
|
91
|
+
|
|
92
|
+
Change notifications enable applications to receive alerts when a Microsoft Graph resource they're interested in changes (created, updated, or deleted). Microsoft Graph sends notifications to the specified client endpoint.
|
|
93
|
+
|
|
94
|
+
- **Supported SharePoint resources**: Sites, lists, list items, and drives (document libraries via driveItem hierarchy).
|
|
95
|
+
- **Change types**: `created`, `updated`, `deleted` (specified when creating the subscription).
|
|
96
|
+
- Microsoft Graph supports basic notifications (containing only the resource ID), and rich notifications (including the resource data of the changed object).
|
|
97
|
+
- **Delivery channels**: The Microsoft Graph REST API can deliver change notifications through webhooks, Event Hubs, and Event Grid.
|
|
98
|
+
- Subscriptions must be renewed before expiration. SharePoint currently does not support subscribing to a single folder; you can only subscribe at the list level.
|
package/logo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1333.34 1333.34" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"><defs><style>.fil4{fill:#000;fill-rule:nonzero;fill-opacity:.2}</style></defs><g id="Layer_x0020_1"><g id="_2630364347808"><circle cx="625" cy="395.83" r="395.84" fill="#036c70" fill-rule="nonzero"/><circle cx="994.79" cy="744.79" r="338.54" fill="#1a9ba1" fill-rule="nonzero"/><circle cx="666.67" cy="1062.5" r="270.83" fill="#37c6d0" fill-rule="nonzero"/><path d="M694.46 291.67H243.04a396.731 396.731 0 00-13.87 103.92c0 218.62 177.22 395.99 395.84 396.08 11.54 0 22.96-.54 34.29-1.5l.21 1.58c-146.72 3.87-263.68 123.96-263.68 270.74 0 7.01.26 13.96.8 20.85h297.83c30.63-.09 55.46-24.91 55.54-55.55V347.21c-.09-30.63-24.91-55.46-55.55-55.54z" fill-rule="nonzero" fill-opacity=".102"/><path class="fil4" d="M652.79 333.33H234.04c-3.24 20.57-4.93 41.45-4.93 62.3 0 218.64 177.26 395.99 395.9 396.04 11.54 0 22.96-.54 34.29-1.5l.21 1.58c-146.78 3.97-263.69 124.12-263.69 270.95 0 20.98 2.45 41.89 7.25 62.31h249.72c30.63-.09 55.45-24.91 55.54-55.54V388.89c-.09-30.63-24.91-55.45-55.55-55.54z"/><path class="fil4" d="M652.79 333.33H234.04c-3.24 20.57-4.93 41.45-4.93 62.3 0 218.64 177.26 395.99 395.9 396.04 11.54 0 22.96-.54 34.29-1.5l.21 1.58c-138.68 3.65-252.29 111.6-262.93 249.91l256.22.01c30.63-.09 55.45-24.91 55.54-55.54V388.88c-.09-30.63-24.91-55.45-55.55-55.54z"/><path class="fil4" d="M611.13 333.33H234.04c-3.24 20.57-4.93 41.45-4.93 62.3 0 218.64 177.26 395.99 395.9 396.04 11.54 0 22.96-.54 34.29-1.5l.21 1.58c-138.68 3.65-252.29 111.6-262.93 249.91l214.55.01c30.63-.09 55.45-24.91 55.54-55.54V388.88c-.09-30.63-24.91-55.45-55.54-55.54z"/><path d="M55.54 333.33h555.59c30.67 0 55.54 24.87 55.54 55.54v555.58c0 30.67-24.87 55.54-55.54 55.54H55.54C24.87 999.99 0 975.12 0 944.45V388.87c0-30.67 24.87-55.54 55.54-55.54z" fill="#03787c" fill-rule="nonzero"/><path d="M236.25 659.38A110.186 110.186 0 01202 623.12a98.306 98.306 0 01-11.99-47.06c0-.83.02-1.69.04-2.51-.02-.97-.05-1.98-.05-2.96 0-22.39 7.89-44.09 22.25-61.25 15.76-17.96 36.22-31.3 59.01-38.5 25.12-8.29 51.5-12.52 77.98-12.52h2.65c3.7-.08 7.51-.19 11.25-.19 32.21 0 64.34 5.13 94.95 15.07v75c-14.86-9-31.1-15.65-48.04-19.63a234.22 234.22 0 00-55.7-6.74h-.51a121.89 121.89 0 00-57.76 12.22c-13.84 5.97-22.83 19.61-22.87 34.7v.32c0 9.03 3.48 17.73 9.71 24.26A88.548 88.548 0 00309.04 612c10.95 5.44 27.28 12.67 49 21.67 2.41.76 4.77 1.7 7.04 2.79a404.138 404.138 0 0161.82 30.5 110.62 110.62 0 0136.52 36.78c8.7 15.78 13.28 33.51 13.28 51.53 0 1.31-.04 2.67-.07 3.97a103.37 103.37 0 01-20.79 66.88c-14.48 17.63-33.83 30.63-55.62 37.33a251.94 251.94 0 01-75.49 11.57c-1.23 0-2.56-.03-3.75-.03-.5.01-1.17.01-1.67.01-23.47 0-46.98-1.99-70.09-5.92-20.03-3.15-39.7-8.87-58.34-16.84v-79.25c17.87 12.74 37.86 22.29 59.01 28.12 21 6.57 42.93 10.08 64.92 10.42 2.35.15 4.74.23 7.1.23 18.02 0 35.82-4.38 51.78-12.72a39.498 39.498 0 0019.8-34.22c0-.36 0-.72-.02-1.07v-.31c0-10.01-3.99-19.62-11.08-26.69a112.794 112.794 0 00-30.63-21.34c-13.03-6.56-32.28-15.17-57.75-25.83-20.17-8.07-39.6-18.3-57.76-30.22v.01z" fill="#fff" fill-rule="nonzero"/><path fill="none" fill-rule="nonzero" d="M0 0h1333.34v1333.34H0z"/></g></g></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slates-integrations/sharepoint",
|
|
3
|
+
"main": "src/index.ts",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "bunx @vercel/ncc build src/index.ts -o dist -m -s",
|
|
7
|
+
"typecheck": "tsc --noEmit"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@slates/oauth-microsoft": "1.0.0-rc.2",
|
|
11
|
+
"@lowerdeck/error": "^1.1.0",
|
|
12
|
+
"@types/node": "^20",
|
|
13
|
+
"slates": "1.0.0-rc.9",
|
|
14
|
+
"zod": "^4.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^5"
|
|
18
|
+
},
|
|
19
|
+
"version": "0.2.0-rc.6"
|
|
20
|
+
}
|
package/slate.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/sharepoint",
|
|
3
|
+
"description": "Manage SharePoint sites, document libraries, lists, and files. Create, read, update, and delete lists and list items with custom columns. Upload, download, move, copy, and version files in document libraries. Search across sites, files, folders, lists, and list items using Microsoft Search. Manage permissions at site, list, and item levels with granular access control. Define and manage content types and site columns. Subscribe to webhooks for list and library change notifications. Retrieve site properties and search for sites across Microsoft 365.",
|
|
4
|
+
"categories": ["apis-and-http-requests", "document-processing", "email-and-messaging"],
|
|
5
|
+
"skills": [
|
|
6
|
+
"manage sites and libraries",
|
|
7
|
+
"upload and download files",
|
|
8
|
+
"create and manage lists",
|
|
9
|
+
"CRUD list items",
|
|
10
|
+
"search files and sites",
|
|
11
|
+
"manage permissions",
|
|
12
|
+
"define content types",
|
|
13
|
+
"subscribe to webhooks",
|
|
14
|
+
"version file history",
|
|
15
|
+
"move and copy files"
|
|
16
|
+
],
|
|
17
|
+
"logoUrl": "https://provider-logos.metorial-cdn.com/sharepoint-icon.svg",
|
|
18
|
+
"version": "0.1.11"
|
|
19
|
+
}
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createMicrosoftGraphOauth } from '@slates/oauth-microsoft';
|
|
2
|
+
import { SlateAuth } from 'slates';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
let scopes = [
|
|
6
|
+
{
|
|
7
|
+
title: 'Sites Read',
|
|
8
|
+
description: 'Read items in all site collections',
|
|
9
|
+
scope: 'Sites.Read.All'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
title: 'Sites Read Write',
|
|
13
|
+
description: 'Read and write items in all site collections',
|
|
14
|
+
scope: 'Sites.ReadWrite.All'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'Sites Manage',
|
|
18
|
+
description: 'Create, edit, and delete items and lists in all site collections',
|
|
19
|
+
scope: 'Sites.Manage.All'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Sites Full Control',
|
|
23
|
+
description: 'Full control of all site collections',
|
|
24
|
+
scope: 'Sites.FullControl.All'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: 'Files Read',
|
|
28
|
+
description: 'Read all files that user can access',
|
|
29
|
+
scope: 'Files.Read.All'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Files Read Write',
|
|
33
|
+
description: 'Read and write all files that user can access',
|
|
34
|
+
scope: 'Files.ReadWrite.All'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: 'User Read',
|
|
38
|
+
description: 'Read user profile',
|
|
39
|
+
scope: 'User.Read'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Offline Access',
|
|
43
|
+
description:
|
|
44
|
+
'Maintain access to data you have given it access to (enables refresh tokens)',
|
|
45
|
+
scope: 'offline_access'
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
let createMicrosoftOauth = (name: string, key: string, tenant: string) =>
|
|
50
|
+
createMicrosoftGraphOauth({
|
|
51
|
+
name,
|
|
52
|
+
key,
|
|
53
|
+
tenant,
|
|
54
|
+
scopes,
|
|
55
|
+
normalizeRedirectUri: true,
|
|
56
|
+
missingRefreshTokenMessage:
|
|
57
|
+
'No refresh token available. Ensure "offline_access" scope is included.'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export let auth = SlateAuth.create()
|
|
61
|
+
.output(
|
|
62
|
+
z.object({
|
|
63
|
+
token: z.string(),
|
|
64
|
+
refreshToken: z.string().optional(),
|
|
65
|
+
expiresAt: z.string().optional()
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
.addOauth(createMicrosoftOauth('Work & Personal', 'oauth_common', 'common'))
|
|
69
|
+
.addOauth(createMicrosoftOauth('Work Only', 'oauth_organizations', 'organizations'));
|
package/src/config.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Slate } from 'slates';
|
|
2
|
+
import { spec } from './spec';
|
|
3
|
+
import {
|
|
4
|
+
getSite,
|
|
5
|
+
listSites,
|
|
6
|
+
search,
|
|
7
|
+
searchDrive,
|
|
8
|
+
manageList,
|
|
9
|
+
manageListItems,
|
|
10
|
+
manageFile,
|
|
11
|
+
getDrive,
|
|
12
|
+
getFileVersions,
|
|
13
|
+
managePermissions,
|
|
14
|
+
manageColumns,
|
|
15
|
+
getContentTypes
|
|
16
|
+
} from './tools';
|
|
17
|
+
import { listItemChanges, driveItemChanges, inboundWebhook } from './triggers';
|
|
18
|
+
|
|
19
|
+
export let provider = Slate.create({
|
|
20
|
+
spec,
|
|
21
|
+
tools: [
|
|
22
|
+
getSite,
|
|
23
|
+
listSites,
|
|
24
|
+
search,
|
|
25
|
+
searchDrive,
|
|
26
|
+
manageList,
|
|
27
|
+
manageListItems,
|
|
28
|
+
manageFile,
|
|
29
|
+
getDrive,
|
|
30
|
+
getFileVersions,
|
|
31
|
+
managePermissions,
|
|
32
|
+
manageColumns,
|
|
33
|
+
getContentTypes
|
|
34
|
+
],
|
|
35
|
+
triggers: [inboundWebhook, listItemChanges, driveItemChanges]
|
|
36
|
+
});
|