Add page-level permissions and guests
Pages can now be shared with people and groups beyond their space, and restricted so that only those grants count. A grant covers the page and everything under it. Space admins always keep access, and an editor who restricts a page keeps editor through a grant of their own. Sharing a page with someone from the organization who is outside the workspace adds them as a guest. Anyone else gets a guest invite that carries the page grant, which is made when they accept. Guests see a "limited" space holding only the pages shared with them. The page tree, breadcrumbs, search, favorites, recents, trash and import all follow the page role. Public links skip restricted subtrees. Grants are cleaned up when a member leaves or a group is deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8aeebbff12
commit
7968e82cc2
29 files changed
+2277
-119
No files matched your search
@@ -44,6 +44,11 @@ export type AdminHealth = Schemas["AdminHealth"];
|
||||
export type Job = Schemas["Job"];
|
||||
export type Backup = Schemas["Backup"];
|
||||
export type SharedPage = Schemas["SharedPage"];
|
||||
export type PageGrantRole = Schemas["PageGrantRole"];
|
||||
export type PageGrant = Schemas["PageGrant"];
|
||||
export type PageInvite = Schemas["PageInvite"];
|
||||
export type PageAccess = Schemas["PageAccess"];
|
||||
export type SharePageResult = Schemas["SharePageResult"];
|
||||
export type SearchResult = Schemas["SearchResult"];
|
||||
export type GroupRequest = Schemas["GroupRequest"];
|
||||
export type SpaceGroup = Schemas["SpaceGroup"];
|
||||
@@ -339,6 +344,29 @@ export function createClient(opts: ClientOptions) {
|
||||
setShareLink: (id: string, includeSubpages: boolean) =>
|
||||
request<ShareLink>("PUT", `/api/v1/pages/${encodeURIComponent(id)}/share`, { includeSubpages }),
|
||||
deleteShareLink: (id: string) => request<void>("DELETE", `/api/v1/pages/${encodeURIComponent(id)}/share`),
|
||||
/** Who has access beyond the space's members: grants and the restricted switch. */
|
||||
access: (id: string) => request<PageAccess>("GET", `/api/v1/pages/${encodeURIComponent(id)}/access`),
|
||||
setRestricted: (id: string, restricted: boolean) =>
|
||||
request<PageAccess>("PATCH", `/api/v1/pages/${encodeURIComponent(id)}/access`, { restricted }),
|
||||
/** Shares with someone by email; people outside the workspace are invited as guests. */
|
||||
shareWithUser: (id: string, email: string, role: PageGrantRole) =>
|
||||
request<SharePageResult>("PUT", `/api/v1/pages/${encodeURIComponent(id)}/access/users`, { email, role }),
|
||||
unshareUser: (id: string, userId: string) =>
|
||||
request<PageAccess>(
|
||||
"DELETE",
|
||||
`/api/v1/pages/${encodeURIComponent(id)}/access/users/${encodeURIComponent(userId)}`,
|
||||
),
|
||||
shareWithGroup: (id: string, groupId: string, role: PageGrantRole) =>
|
||||
request<PageAccess>(
|
||||
"PUT",
|
||||
`/api/v1/pages/${encodeURIComponent(id)}/access/groups/${encodeURIComponent(groupId)}`,
|
||||
{ role },
|
||||
),
|
||||
unshareGroup: (id: string, groupId: string) =>
|
||||
request<PageAccess>(
|
||||
"DELETE",
|
||||
`/api/v1/pages/${encodeURIComponent(id)}/access/groups/${encodeURIComponent(groupId)}`,
|
||||
),
|
||||
export: (id: string, format: "markdown" | "html") =>
|
||||
download(`/api/v1/pages/${encodeURIComponent(id)}/export${query({ format })}`),
|
||||
/** Records that the user opened the page, for their recent list. */
|
||||
|
||||
Vendored
+311
-3
@@ -1190,6 +1190,92 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/pages/{id}/access": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
/** Who has access to the page beyond the space's members (viewer) */
|
||||
get: operations["getPageAccess"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
/**
|
||||
* Restrict the page and its subpages to the people it is shared with, or lift that (editor)
|
||||
* @description Space admins always keep access. An editor who restricts a page keeps editor on it through a grant.
|
||||
*/
|
||||
patch: operations["setPageRestricted"];
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/pages/{id}/access/users": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
/**
|
||||
* Share the page and its subpages with someone by email (editor)
|
||||
* @description A workspace member gets the role on the page. Someone from the workspace's organization who is not in the workspace joins it as a guest. Anyone else is invited as a guest (workspace members only).
|
||||
*/
|
||||
put: operations["sharePageWithUser"];
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/pages/{id}/access/users/{userId}": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
userId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
post?: never;
|
||||
/** Remove someone's grant on the page (editor, or the person themselves) */
|
||||
delete: operations["unsharePageWithUser"];
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/pages/{id}/access/groups/{groupId}": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
groupId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
/** Share the page and its subpages with a group of the workspace (editor) */
|
||||
put: operations["sharePageWithGroup"];
|
||||
post?: never;
|
||||
/** Remove a group's grant on the page (editor) */
|
||||
delete: operations["unsharePageWithGroup"];
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/pages/{id}/share": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -1549,7 +1635,9 @@ export interface components {
|
||||
description: string;
|
||||
visibility: components["schemas"]["SpaceVisibility"];
|
||||
defaultRole: components["schemas"]["SpaceDefaultRole"];
|
||||
role: components["schemas"]["SpaceRole"];
|
||||
role: components["schemas"]["SpaceCallerRole"];
|
||||
/** @description The caller cannot open the space itself and sees only pages shared with them */
|
||||
limited: boolean;
|
||||
created: string;
|
||||
};
|
||||
SpaceMember: {
|
||||
@@ -1562,12 +1650,14 @@ export interface components {
|
||||
};
|
||||
PageNode: {
|
||||
id: string;
|
||||
/** @description Parent page id; empty at the top level */
|
||||
/** @description Parent page id; empty at the top level. In a page tree, a page whose parent the caller cannot open hangs from its nearest visible ancestor. */
|
||||
parent: string;
|
||||
title: string;
|
||||
icon: string;
|
||||
/** @description Fractional sort key among siblings */
|
||||
position: string;
|
||||
/** @description This page itself is restricted */
|
||||
restricted: boolean;
|
||||
updated: string;
|
||||
};
|
||||
PageRef: {
|
||||
@@ -1588,12 +1678,61 @@ export interface components {
|
||||
deletedAt: string;
|
||||
/** @description The page or one of its ancestors is in the trash */
|
||||
inTrash: boolean;
|
||||
/** @description Root first */
|
||||
/** @description Root first; pages the caller cannot open are left out */
|
||||
ancestors: components["schemas"]["PageRef"][];
|
||||
/** @description The caller's role on this page */
|
||||
role: components["schemas"]["SpaceRole"];
|
||||
/** @description The page or one of its ancestors is restricted */
|
||||
restricted: boolean;
|
||||
/** @description In the caller's favorites */
|
||||
favorite: boolean;
|
||||
};
|
||||
/** @enum {string} */
|
||||
PageGrantRole: "editor" | "commenter" | "viewer";
|
||||
/**
|
||||
* @description The caller's space role; empty when they see only pages shared with them
|
||||
* @enum {string}
|
||||
*/
|
||||
SpaceCallerRole: "admin" | "editor" | "commenter" | "viewer" | "";
|
||||
PageGrant: {
|
||||
/** @enum {string} */
|
||||
type: "user" | "group";
|
||||
id: string;
|
||||
name: string;
|
||||
/** @description Empty for groups */
|
||||
email: string;
|
||||
role: components["schemas"]["PageGrantRole"];
|
||||
/** @description Where the grant was made */
|
||||
page: components["schemas"]["PageRef"];
|
||||
/** @description Granted on an ancestor */
|
||||
inherited: boolean;
|
||||
};
|
||||
PageInvite: {
|
||||
id: string;
|
||||
email: string;
|
||||
role: components["schemas"]["PageGrantRole"];
|
||||
expires: string;
|
||||
};
|
||||
PageAccess: {
|
||||
/** @description The page or an ancestor is restricted; space members then see it only through grants */
|
||||
restricted: boolean;
|
||||
/** @description The restricted ancestor, when the restriction comes from one */
|
||||
inheritedFrom: components["schemas"]["PageRef"] | null;
|
||||
/** @description This page's grants first */
|
||||
grants: components["schemas"]["PageGrant"][];
|
||||
/** @description Pending guest invites for this page (editors only) */
|
||||
invites: components["schemas"]["PageInvite"][];
|
||||
/** @description The caller's role on this page */
|
||||
role: components["schemas"]["SpaceRole"];
|
||||
canManage: boolean;
|
||||
/** @description May share with people outside the workspace */
|
||||
canInvite: boolean;
|
||||
};
|
||||
SharePageResult: {
|
||||
access: components["schemas"]["PageAccess"];
|
||||
/** @description Set when the person was invited as a guest; the grant is made when they accept */
|
||||
invite: components["schemas"]["Invite"] | null;
|
||||
};
|
||||
PageContent: {
|
||||
/** @description Tiptap JSON with type "doc"; null for a page that was never edited */
|
||||
content: {
|
||||
@@ -4045,6 +4184,175 @@ export interface operations {
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
getPageAccess: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["PageAccess"];
|
||||
};
|
||||
};
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
setPageRestricted: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
restricted: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["PageAccess"];
|
||||
};
|
||||
};
|
||||
403: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
sharePageWithUser: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
/** Format: email */
|
||||
email: string;
|
||||
role: components["schemas"]["PageGrantRole"];
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["SharePageResult"];
|
||||
};
|
||||
};
|
||||
400: components["responses"]["Error"];
|
||||
403: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
409: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
unsharePageWithUser: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
userId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description The page's access afterwards */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["PageAccess"];
|
||||
};
|
||||
};
|
||||
403: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
sharePageWithGroup: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
groupId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
role: components["schemas"]["PageGrantRole"];
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["PageAccess"];
|
||||
};
|
||||
};
|
||||
400: components["responses"]["Error"];
|
||||
403: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
unsharePageWithGroup: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
groupId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description The page's access afterwards */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["PageAccess"];
|
||||
};
|
||||
};
|
||||
403: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
getShareLink: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
||||
Reference in new issue
Block a user