feat(core): add doc grant feature to share menu (#9672)

This commit is contained in:
JimmFly
2025-02-07 13:05:58 +00:00
parent 459972fe6c
commit 5ae5fd88f1
57 changed files with 3188 additions and 697 deletions

View File

@@ -8,7 +8,7 @@ export interface UserFriendlyErrorResponse {
type: string;
name: ErrorNames;
message: string;
args?: any;
data?: any;
stacktrace?: string;
}
@@ -21,7 +21,7 @@ export class UserFriendlyError
readonly type = this.response.type;
override readonly name = this.response.name;
override readonly message = this.response.message;
readonly args = this.response.args;
readonly data = this.response.data;
readonly stacktrace = this.response.stacktrace;
static fromAnyError(response: any) {

View File

@@ -1,7 +1,7 @@
query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) {
query getMembersByWorkspaceId($workspaceId: String!, $skip: Int, $take: Int, $query: String) {
workspace(id: $workspaceId) {
memberCount
members(skip: $skip, take: $take) {
members(skip: $skip, take: $take, query: $query) {
id
name
email

View File

@@ -0,0 +1,24 @@
query getPageGrantedUsersList($pagination: PaginationInput!, $docId: String!, $workspaceId: String!) {
workspace(id: $workspaceId) {
doc(docId: $docId) {
grantedUsersList(pagination: $pagination) {
totalCount
pageInfo {
endCursor
hasNextPage
}
edges {
node {
role
user {
id
name
email
avatarUrl
}
}
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
mutation grantDocUserRoles($input: GrantDocUserRolesInput!) {
grantDocUserRoles(input: $input)
}

View File

@@ -525,10 +525,10 @@ export const getMembersByWorkspaceIdQuery = {
definitionName: 'workspace',
containsFile: false,
query: `
query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) {
query getMembersByWorkspaceId($workspaceId: String!, $skip: Int, $take: Int, $query: String) {
workspace(id: $workspaceId) {
memberCount
members(skip: $skip, take: $take) {
members(skip: $skip, take: $take, query: $query) {
id
name
email
@@ -555,6 +555,38 @@ query oauthProviders {
}`,
};
export const getPageGrantedUsersListQuery = {
id: 'getPageGrantedUsersListQuery' as const,
operationName: 'getPageGrantedUsersList',
definitionName: 'workspace',
containsFile: false,
query: `
query getPageGrantedUsersList($pagination: PaginationInput!, $docId: String!, $workspaceId: String!) {
workspace(id: $workspaceId) {
doc(docId: $docId) {
grantedUsersList(pagination: $pagination) {
totalCount
pageInfo {
endCursor
hasNextPage
}
edges {
node {
role
user {
id
name
email
avatarUrl
}
}
}
}
}
}
}`,
};
export const getPromptsQuery = {
id: 'getPromptsQuery' as const,
operationName: 'getPrompts',
@@ -830,6 +862,17 @@ query getWorkspaces {
}`,
};
export const grantDocUserRolesMutation = {
id: 'grantDocUserRolesMutation' as const,
operationName: 'grantDocUserRoles',
definitionName: 'grantDocUserRoles',
containsFile: false,
query: `
mutation grantDocUserRoles($input: GrantDocUserRolesInput!) {
grantDocUserRoles(input: $input)
}`,
};
export const listHistoryQuery = {
id: 'listHistoryQuery' as const,
operationName: 'listHistory',
@@ -1019,6 +1062,17 @@ mutation resumeSubscription($plan: SubscriptionPlan = Pro, $workspaceId: String)
}`,
};
export const revokeDocUserRolesMutation = {
id: 'revokeDocUserRolesMutation' as const,
operationName: 'revokeDocUserRoles',
definitionName: 'revokeDocUserRoles',
containsFile: false,
query: `
mutation revokeDocUserRoles($input: RevokeDocUserRoleInput!) {
revokeDocUserRoles(input: $input)
}`,
};
export const revokeMemberPermissionMutation = {
id: 'revokeMemberPermissionMutation' as const,
operationName: 'revokeMemberPermission',
@@ -1196,6 +1250,17 @@ mutation updateCopilotSession($options: UpdateChatSessionInput!) {
}`,
};
export const updateDocUserRoleMutation = {
id: 'updateDocUserRoleMutation' as const,
operationName: 'updateDocUserRole',
definitionName: 'updateDocUserRole',
containsFile: false,
query: `
mutation updateDocUserRole($input: UpdateDocUserRoleInput!) {
updateDocUserRole(input: $input)
}`,
};
export const updatePromptMutation = {
id: 'updatePromptMutation' as const,
operationName: 'updatePrompt',

View File

@@ -0,0 +1,3 @@
mutation revokeDocUserRoles($input: RevokeDocUserRoleInput!) {
revokeDocUserRoles(input: $input)
}

View File

@@ -0,0 +1,3 @@
mutation updateDocUserRole($input: UpdateDocUserRoleInput!) {
updateDocUserRole(input: $input)
}

View File

@@ -348,6 +348,7 @@ export enum ErrorNames {
CANNOT_DELETE_ALL_ADMIN_ACCOUNT = 'CANNOT_DELETE_ALL_ADMIN_ACCOUNT',
CANNOT_DELETE_OWN_ACCOUNT = 'CANNOT_DELETE_OWN_ACCOUNT',
CANT_UPDATE_ONETIME_PAYMENT_SUBSCRIPTION = 'CANT_UPDATE_ONETIME_PAYMENT_SUBSCRIPTION',
CAN_NOT_BATCH_GRANT_DOC_OWNER_PERMISSIONS = 'CAN_NOT_BATCH_GRANT_DOC_OWNER_PERMISSIONS',
CAPTCHA_VERIFICATION_FAILED = 'CAPTCHA_VERIFICATION_FAILED',
COPILOT_ACTION_TAKEN = 'COPILOT_ACTION_TAKEN',
COPILOT_FAILED_TO_CREATE_MESSAGE = 'COPILOT_FAILED_TO_CREATE_MESSAGE',
@@ -925,7 +926,7 @@ export interface MutationRevokeArgs {
}
export interface MutationRevokeDocUserRolesArgs {
input: RevokeDocUserRolesInput;
input: RevokeDocUserRoleInput;
}
export interface MutationRevokeInviteLinkArgs {
@@ -1202,9 +1203,9 @@ export interface RemoveAvatar {
success: Scalars['Boolean']['output'];
}
export interface RevokeDocUserRolesInput {
export interface RevokeDocUserRoleInput {
docId: Scalars['String']['input'];
userIds: Array<Scalars['String']['input']>;
userId: Scalars['String']['input'];
workspaceId: Scalars['String']['input'];
}
@@ -2160,8 +2161,9 @@ export type GetMemberCountByWorkspaceIdQuery = {
export type GetMembersByWorkspaceIdQueryVariables = Exact<{
workspaceId: Scalars['String']['input'];
skip: Scalars['Int']['input'];
take: Scalars['Int']['input'];
skip?: InputMaybe<Scalars['Int']['input']>;
take?: InputMaybe<Scalars['Int']['input']>;
query?: InputMaybe<Scalars['String']['input']>;
}>;
export type GetMembersByWorkspaceIdQuery = {
@@ -2193,6 +2195,45 @@ export type OauthProvidersQuery = {
};
};
export type GetPageGrantedUsersListQueryVariables = Exact<{
pagination: PaginationInput;
docId: Scalars['String']['input'];
workspaceId: Scalars['String']['input'];
}>;
export type GetPageGrantedUsersListQuery = {
__typename?: 'Query';
workspace: {
__typename?: 'WorkspaceType';
doc: {
__typename?: 'DocType';
grantedUsersList: {
__typename?: 'PaginatedGrantedDocUserType';
totalCount: number;
pageInfo: {
__typename?: 'PageInfo';
endCursor: string | null;
hasNextPage: boolean;
};
edges: Array<{
__typename?: 'GrantedDocUserTypeEdge';
node: {
__typename?: 'GrantedDocUserType';
role: DocRole;
user: {
__typename?: 'PublicUserType';
id: string;
name: string;
email: string;
avatarUrl: string | null;
};
};
}>;
};
};
};
};
export type GetPromptsQueryVariables = Exact<{ [key: string]: never }>;
export type GetPromptsQuery = {
@@ -2442,6 +2483,15 @@ export type GetWorkspacesQuery = {
}>;
};
export type GrantDocUserRolesMutationVariables = Exact<{
input: GrantDocUserRolesInput;
}>;
export type GrantDocUserRolesMutation = {
__typename?: 'Mutation';
grantDocUserRoles: boolean;
};
export type ListHistoryQueryVariables = Exact<{
workspaceId: Scalars['String']['input'];
pageDocId: Scalars['String']['input'];
@@ -2613,6 +2663,15 @@ export type ResumeSubscriptionMutation = {
};
};
export type RevokeDocUserRolesMutationVariables = Exact<{
input: RevokeDocUserRoleInput;
}>;
export type RevokeDocUserRolesMutation = {
__typename?: 'Mutation';
revokeDocUserRoles: boolean;
};
export type RevokeMemberPermissionMutationVariables = Exact<{
workspaceId: Scalars['String']['input'];
userId: Scalars['String']['input'];
@@ -2774,6 +2833,15 @@ export type UpdateCopilotSessionMutation = {
updateCopilotSession: string;
};
export type UpdateDocUserRoleMutationVariables = Exact<{
input: UpdateDocUserRoleInput;
}>;
export type UpdateDocUserRoleMutation = {
__typename?: 'Mutation';
updateDocUserRole: boolean;
};
export type UpdatePromptMutationVariables = Exact<{
name: Scalars['String']['input'];
messages: Array<CopilotPromptMessageInput> | CopilotPromptMessageInput;
@@ -3129,6 +3197,11 @@ export type Queries =
variables: OauthProvidersQueryVariables;
response: OauthProvidersQuery;
}
| {
name: 'getPageGrantedUsersListQuery';
variables: GetPageGrantedUsersListQueryVariables;
response: GetPageGrantedUsersListQuery;
}
| {
name: 'getPromptsQuery';
variables: GetPromptsQueryVariables;
@@ -3371,6 +3444,11 @@ export type Mutations =
variables: GenerateLicenseKeyMutationVariables;
response: GenerateLicenseKeyMutation;
}
| {
name: 'grantDocUserRolesMutation';
variables: GrantDocUserRolesMutationVariables;
response: GrantDocUserRolesMutation;
}
| {
name: 'leaveWorkspaceMutation';
variables: LeaveWorkspaceMutationVariables;
@@ -3396,6 +3474,11 @@ export type Mutations =
variables: ResumeSubscriptionMutationVariables;
response: ResumeSubscriptionMutation;
}
| {
name: 'revokeDocUserRolesMutation';
variables: RevokeDocUserRolesMutationVariables;
response: RevokeDocUserRolesMutation;
}
| {
name: 'revokeMemberPermissionMutation';
variables: RevokeMemberPermissionMutationVariables;
@@ -3451,6 +3534,11 @@ export type Mutations =
variables: UpdateCopilotSessionMutationVariables;
response: UpdateCopilotSessionMutation;
}
| {
name: 'updateDocUserRoleMutation';
variables: UpdateDocUserRoleMutationVariables;
response: UpdateDocUserRoleMutation;
}
| {
name: 'updatePromptMutation';
variables: UpdatePromptMutationVariables;