SharePoint sites: the tenant root site, a site by URL or by hostname + server-relative path, search, subsites, every site (app-only), and a site's document libraries (drives).

Permissions. Sites.Read.All (delegated or application), or Sites.Selected with a grant on the site (app-only reads of a granted site by id work; search and get-all-sites do not see sites the app has no grant on).

Functions

collect

fn (path: Str, opts: Map, limit: Int?): Vec

drive-opts

fn (drive: Any): Map
fn (drive: Any, opts: Map): Map

Opts that point microsoft-onedrive at a library: {drive: id} from a drive Map or id, merged into opts (pure).

```hot
lib ::microsoft::sharepoint::sites/find-drive(site-id, "Contracts")
::microsoft::onedrive::items/list-all-children("root", ::microsoft::sharepoint::sites/drive-opts(lib))
```

find-drive

fn (site-id: Str, name: Str): Map
fn (site-id: Str, name: Str, opts: Map): Map

The site library whose name matches (case-insensitive), or an Err listing the names there are. Library names are display names, e.g. "Documents", "Contracts".

get-all-sites

fn (): Vec
fn (opts: Map): Vec
fn (opts: Map, limit: Int?): Vec

GET /sites/getAllSites - every site in the tenant (app-only with Sites.Read.All), all pages or at most limit. Includes OneDrive personal sites unless filtered.

get-default-drive

fn (site-id: Str): Map
fn (site-id: Str, opts: Map): Map

GET /sites/{site-id}/drive - the site's default document library ("Documents" / "Shared Documents").

get-json

fn (path: Str, opts: Map): Any

get-root-site

fn (): Map
fn (opts: Map): Map

GET /sites/root - the tenant's root site (https://{tenant}.sharepoint.com).

get-site

fn (site-id: Str): Map
fn (site-id: Str, opts: Map): Map

GET /sites/{site-id}. opts takes select, expand (e.g. "drive", "lists").

get-site-by-path

fn (hostname: Str, path: Str): Map
fn (hostname: Str, path: Str, opts: Map): Map

GET /sites/{hostname}:/{server-relative-path} - a site by host and path.

site ::microsoft::sharepoint::sites/get-site-by-path("contoso.sharepoint.com", "/sites/engineering")
site.id   // "contoso.sharepoint.com,2C712604-...,2D2244C3-..."

get-site-by-url

fn (url: Str): Map
fn (url: Str, opts: Map): Map

GET a site from its browser URL (https://contoso.sharepoint.com/sites/eng, or a library or page URL inside it). See parse-site-url.

site ::microsoft::sharepoint::sites/get-site-by-url("https://contoso.sharepoint.com/sites/engineering")

list-drives

fn (site-id: Str): Vec
fn (site-id: Str, opts: Map): Vec

GET /sites/{site-id}/drives - the site's document libraries, each a drive (id, name, webUrl, driveType: "documentLibrary"). Pass a library's id as opts.drive to microsoft-onedrive.

list-subsites

fn (site-id: Str): Vec
fn (site-id: Str, opts: Map): Vec

GET /sites/{site-id}/sites - a site's direct subsites, all pages.

opts-query

fn (opts: Map): Map

parse-site-url

fn (url: Str): Map

Split a site URL into {hostname, path} (pure), dropping any query or fragment, and a library/page suffix after the site (/Shared Documents/..., /Lists/..., /SitePages/..., /_layouts/...). Returns an Err for a non-https URL.

::microsoft::sharepoint::sites/parse-site-url("https://contoso.sharepoint.com/sites/eng/Shared%20Documents/Forms/AllItems.aspx")
// {hostname: "contoso.sharepoint.com", path: "/sites/eng"}

search-path

fn (query: Str): Str

The site search path (pure): /sites?search={encoded query} (Graph's search parameter, not OData $search).

search-sites

fn (query: Str): Vec
fn (query: Str, opts: Map): Vec
fn (query: Str, opts: Map, limit: Int?): Vec

GET /sites?search={query} - sites whose name or description matches, all pages or at most limit. "*" lists every site the caller can see.

hits ::microsoft::sharepoint::sites/search-sites("engineering", {}, 20)
map(hits, (s) { s.webUrl })

site-by-path-path

fn (hostname: Str, path: Str?): Str

The Graph path for a site by host and server-relative path (pure): /sites/{hostname}:/{path} (each segment encoded), or /sites/{hostname} for the host's root site.