@excali-boards/boards-api-client 1.1.21 → 1.1.22
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BoardRole, CategoryRole, GroupRole } from '../external/vars';
|
|
2
|
-
import {
|
|
2
|
+
import { PermUser, ResourceType } from '../external/types';
|
|
3
3
|
import { BoardsManager } from '../core/manager';
|
|
4
4
|
export declare class APIPermissions {
|
|
5
5
|
private web;
|
|
6
6
|
constructor(web: BoardsManager);
|
|
7
|
-
viewPermissions({ auth, query }: PermissionsFunctionsInput['viewPermissions']): Promise<import("..").WebResponse<
|
|
7
|
+
viewPermissions({ auth, query }: PermissionsFunctionsInput['viewPermissions']): Promise<import("..").WebResponse<PermUser[]>>;
|
|
8
|
+
viewAllPermissions({ auth, userIds }: PermissionsFunctionsInput['viewAllPermissions']): Promise<import("..").WebResponse<Record<string, PermUser[]>>>;
|
|
8
9
|
grantPermissions({ auth, body }: PermissionsFunctionsInput['grantPermissions']): Promise<import("..").WebResponse<string>>;
|
|
9
10
|
revokePermissions({ auth, body }: PermissionsFunctionsInput['revokePermissions']): Promise<import("..").WebResponse<string>>;
|
|
10
11
|
}
|
|
@@ -13,6 +14,10 @@ export type PermissionsFunctionsInput = {
|
|
|
13
14
|
auth: string;
|
|
14
15
|
query: ViewPermissionsQuery;
|
|
15
16
|
};
|
|
17
|
+
'viewAllPermissions': {
|
|
18
|
+
auth: string;
|
|
19
|
+
userIds: string[];
|
|
20
|
+
};
|
|
16
21
|
'grantPermissions': {
|
|
17
22
|
auth: string;
|
|
18
23
|
body: GrantPermissionsInput;
|
|
@@ -26,13 +31,6 @@ export type ViewPermissionsQuery = {
|
|
|
26
31
|
type: ResourceType;
|
|
27
32
|
id: string;
|
|
28
33
|
};
|
|
29
|
-
export type ViewPermissionsOutput = {
|
|
30
|
-
userId: string;
|
|
31
|
-
email: string;
|
|
32
|
-
displayName: string;
|
|
33
|
-
avatarUrl: string | null;
|
|
34
|
-
permissions: GrantedEntry[];
|
|
35
|
-
}[];
|
|
36
34
|
export type GrantPermissionsInput = {
|
|
37
35
|
userId: string;
|
|
38
36
|
groupIds?: string[];
|
|
@@ -14,6 +14,12 @@ class APIPermissions {
|
|
|
14
14
|
endpoint: this.web.qp('/permissions/view', query),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
async viewAllPermissions({ auth, userIds }) {
|
|
18
|
+
return await this.web.request({
|
|
19
|
+
method: 'POST', auth, body: { userIds },
|
|
20
|
+
endpoint: this.web.qp('/permissions/view-all'),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
17
23
|
async grantPermissions({ auth, body }) {
|
|
18
24
|
return await this.web.request({
|
|
19
25
|
method: 'POST', auth, body,
|
package/dist/external/types.d.ts
CHANGED
|
@@ -17,6 +17,34 @@ export declare enum GlobalRole {
|
|
|
17
17
|
export type AccessLevel = 'read' | 'write' | 'manage' | 'admin';
|
|
18
18
|
export type ResourceType = 'group' | 'category' | 'board';
|
|
19
19
|
export type GlobalResourceType = ResourceType | 'global';
|
|
20
|
+
export type ResourceId<A extends GlobalResourceType> = A extends 'board' ? {
|
|
21
|
+
boardId: string;
|
|
22
|
+
categoryId: string;
|
|
23
|
+
groupId: string;
|
|
24
|
+
} : A extends 'category' ? {
|
|
25
|
+
categoryId: string;
|
|
26
|
+
groupId: string;
|
|
27
|
+
} : A extends 'group' ? {
|
|
28
|
+
groupId: string;
|
|
29
|
+
} : A extends 'global' ? null : never;
|
|
30
|
+
export type ResourceReturnEnum<A extends GlobalResourceType> = A extends 'board' ? BoardRole : A extends 'category' ? CategoryRole : A extends 'group' ? GroupRole : A extends 'global' ? GlobalRole : never;
|
|
31
|
+
export type PermissionGrantResult = {
|
|
32
|
+
newPermissions: GrantedRoles;
|
|
33
|
+
updatedPermissions: (GrantedRole & {
|
|
34
|
+
dbId: string;
|
|
35
|
+
})[];
|
|
36
|
+
};
|
|
37
|
+
export type PermissionCheckData<T extends ResourceType> = {
|
|
38
|
+
type: T;
|
|
39
|
+
data: ResourceId<T>;
|
|
40
|
+
};
|
|
41
|
+
export type PermUser = {
|
|
42
|
+
email: string;
|
|
43
|
+
userId: string;
|
|
44
|
+
displayName: string;
|
|
45
|
+
avatarUrl: string | null;
|
|
46
|
+
permissions: GrantedEntry[];
|
|
47
|
+
};
|
|
20
48
|
export type GrantedRoles = GrantedRole[];
|
|
21
49
|
export type GrantedRole = {
|
|
22
50
|
type: ResourceType;
|
package/package.json
CHANGED