mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +08:00
feat(server): add all ignored docs endpoint (#11953)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to view a complete list of ignored documents for a workspace without pagination. - Introduced separate options to add or remove ignored documents from workspace embeddings. - Added a new query to fetch all ignored documents for a workspace, including document IDs and creation timestamps. - **Refactor** - Reorganized and clarified GraphQL mutations and queries related to managing ignored documents in workspace embeddings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -31,6 +31,7 @@ import { MAX_EMBEDDABLE_SIZE } from '../types';
|
||||
import { CopilotWorkspaceService } from './service';
|
||||
import {
|
||||
CopilotWorkspaceFileType,
|
||||
CopilotWorkspaceIgnoredDocType,
|
||||
PaginatedCopilotWorkspaceFileType,
|
||||
PaginatedIgnoredDocsType,
|
||||
} from './types';
|
||||
@@ -90,6 +91,18 @@ export class CopilotWorkspaceEmbeddingConfigResolver {
|
||||
return paginate(ignoredDocs, 'createdAt', pagination, totalCount);
|
||||
}
|
||||
|
||||
@ResolveField(() => [CopilotWorkspaceIgnoredDocType], {
|
||||
complexity: 2,
|
||||
})
|
||||
async allIgnoredDocs(
|
||||
@Parent() config: CopilotWorkspaceConfigType
|
||||
): Promise<CopilotWorkspaceIgnoredDocType[]> {
|
||||
const [ignoredDocs] = await this.copilotWorkspace.listIgnoredDocs(
|
||||
config.workspaceId
|
||||
);
|
||||
|
||||
return ignoredDocs;
|
||||
}
|
||||
@Mutation(() => Number, {
|
||||
name: 'updateWorkspaceEmbeddingIgnoredDocs',
|
||||
complexity: 2,
|
||||
|
||||
@@ -273,6 +273,7 @@ type CopilotSessionType {
|
||||
}
|
||||
|
||||
type CopilotWorkspaceConfig {
|
||||
allIgnoredDocs: [CopilotWorkspaceIgnoredDoc!]!
|
||||
files(pagination: PaginationInput!): PaginatedCopilotWorkspaceFileType!
|
||||
ignoredDocs(pagination: PaginationInput!): PaginatedIgnoredDocsType!
|
||||
workspaceId: String!
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
mutation addWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $add: [String!]!) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(workspaceId: $workspaceId, add: $add)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
query getAllWorkspaceEmbeddingIgnoredDocs($workspaceId: String!) {
|
||||
workspace(id: $workspaceId) {
|
||||
embedding {
|
||||
allIgnoredDocs {
|
||||
docId
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
mutation removeWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $remove: [String!]!) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(workspaceId: $workspaceId, remove: $remove)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
mutation updateWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $add: [String!], $remove: [String!]) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(workspaceId: $workspaceId, add: $add, remove: $remove)
|
||||
}
|
||||
@@ -756,14 +756,6 @@ export const addWorkspaceEmbeddingFilesMutation = {
|
||||
file: true,
|
||||
};
|
||||
|
||||
export const removeWorkspaceEmbeddingFilesMutation = {
|
||||
id: 'removeWorkspaceEmbeddingFilesMutation' as const,
|
||||
op: 'removeWorkspaceEmbeddingFiles',
|
||||
query: `mutation removeWorkspaceEmbeddingFiles($workspaceId: String!, $fileId: String!) {
|
||||
removeWorkspaceEmbeddingFiles(workspaceId: $workspaceId, fileId: $fileId)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getWorkspaceEmbeddingFilesQuery = {
|
||||
id: 'getWorkspaceEmbeddingFilesQuery' as const,
|
||||
op: 'getWorkspaceEmbeddingFiles',
|
||||
@@ -791,6 +783,37 @@ export const getWorkspaceEmbeddingFilesQuery = {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const removeWorkspaceEmbeddingFilesMutation = {
|
||||
id: 'removeWorkspaceEmbeddingFilesMutation' as const,
|
||||
op: 'removeWorkspaceEmbeddingFiles',
|
||||
query: `mutation removeWorkspaceEmbeddingFiles($workspaceId: String!, $fileId: String!) {
|
||||
removeWorkspaceEmbeddingFiles(workspaceId: $workspaceId, fileId: $fileId)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const addWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
id: 'addWorkspaceEmbeddingIgnoredDocsMutation' as const,
|
||||
op: 'addWorkspaceEmbeddingIgnoredDocs',
|
||||
query: `mutation addWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $add: [String!]!) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(workspaceId: $workspaceId, add: $add)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getAllWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||
id: 'getAllWorkspaceEmbeddingIgnoredDocsQuery' as const,
|
||||
op: 'getAllWorkspaceEmbeddingIgnoredDocs',
|
||||
query: `query getAllWorkspaceEmbeddingIgnoredDocs($workspaceId: String!) {
|
||||
workspace(id: $workspaceId) {
|
||||
embedding {
|
||||
allIgnoredDocs {
|
||||
docId
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||
id: 'getWorkspaceEmbeddingIgnoredDocsQuery' as const,
|
||||
op: 'getWorkspaceEmbeddingIgnoredDocs',
|
||||
@@ -815,15 +838,11 @@ export const getWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const updateWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
id: 'updateWorkspaceEmbeddingIgnoredDocsMutation' as const,
|
||||
op: 'updateWorkspaceEmbeddingIgnoredDocs',
|
||||
query: `mutation updateWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $add: [String!], $remove: [String!]) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(
|
||||
workspaceId: $workspaceId
|
||||
add: $add
|
||||
remove: $remove
|
||||
)
|
||||
export const removeWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
id: 'removeWorkspaceEmbeddingIgnoredDocsMutation' as const,
|
||||
op: 'removeWorkspaceEmbeddingIgnoredDocs',
|
||||
query: `mutation removeWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $remove: [String!]!) {
|
||||
updateWorkspaceEmbeddingIgnoredDocs(workspaceId: $workspaceId, remove: $remove)
|
||||
}`,
|
||||
};
|
||||
|
||||
|
||||
@@ -366,6 +366,7 @@ export interface CopilotSessionType {
|
||||
|
||||
export interface CopilotWorkspaceConfig {
|
||||
__typename?: 'CopilotWorkspaceConfig';
|
||||
allIgnoredDocs: Array<CopilotWorkspaceIgnoredDoc>;
|
||||
files: PaginatedCopilotWorkspaceFileType;
|
||||
ignoredDocs: PaginatedIgnoredDocsType;
|
||||
workspaceId: Scalars['String']['output'];
|
||||
@@ -3273,16 +3274,6 @@ export type AddWorkspaceEmbeddingFilesMutation = {
|
||||
};
|
||||
};
|
||||
|
||||
export type RemoveWorkspaceEmbeddingFilesMutationVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
fileId: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type RemoveWorkspaceEmbeddingFilesMutation = {
|
||||
__typename?: 'Mutation';
|
||||
removeWorkspaceEmbeddingFiles: boolean;
|
||||
};
|
||||
|
||||
export type GetWorkspaceEmbeddingFilesQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
pagination: PaginationInput;
|
||||
@@ -3318,6 +3309,45 @@ export type GetWorkspaceEmbeddingFilesQuery = {
|
||||
};
|
||||
};
|
||||
|
||||
export type RemoveWorkspaceEmbeddingFilesMutationVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
fileId: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type RemoveWorkspaceEmbeddingFilesMutation = {
|
||||
__typename?: 'Mutation';
|
||||
removeWorkspaceEmbeddingFiles: boolean;
|
||||
};
|
||||
|
||||
export type AddWorkspaceEmbeddingIgnoredDocsMutationVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
add: Array<Scalars['String']['input']> | Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type AddWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
__typename?: 'Mutation';
|
||||
updateWorkspaceEmbeddingIgnoredDocs: number;
|
||||
};
|
||||
|
||||
export type GetAllWorkspaceEmbeddingIgnoredDocsQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type GetAllWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||
__typename?: 'Query';
|
||||
workspace: {
|
||||
__typename?: 'WorkspaceType';
|
||||
embedding: {
|
||||
__typename?: 'CopilotWorkspaceConfig';
|
||||
allIgnoredDocs: Array<{
|
||||
__typename?: 'CopilotWorkspaceIgnoredDoc';
|
||||
docId: string;
|
||||
createdAt: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type GetWorkspaceEmbeddingIgnoredDocsQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
pagination: PaginationInput;
|
||||
@@ -3350,17 +3380,12 @@ export type GetWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||
};
|
||||
};
|
||||
|
||||
export type UpdateWorkspaceEmbeddingIgnoredDocsMutationVariables = Exact<{
|
||||
export type RemoveWorkspaceEmbeddingIgnoredDocsMutationVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
add?: InputMaybe<
|
||||
Array<Scalars['String']['input']> | Scalars['String']['input']
|
||||
>;
|
||||
remove?: InputMaybe<
|
||||
Array<Scalars['String']['input']> | Scalars['String']['input']
|
||||
>;
|
||||
remove: Array<Scalars['String']['input']> | Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type UpdateWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
export type RemoveWorkspaceEmbeddingIgnoredDocsMutation = {
|
||||
__typename?: 'Mutation';
|
||||
updateWorkspaceEmbeddingIgnoredDocs: number;
|
||||
};
|
||||
@@ -4628,6 +4653,11 @@ export type Queries =
|
||||
variables: GetWorkspaceEmbeddingFilesQueryVariables;
|
||||
response: GetWorkspaceEmbeddingFilesQuery;
|
||||
}
|
||||
| {
|
||||
name: 'getAllWorkspaceEmbeddingIgnoredDocsQuery';
|
||||
variables: GetAllWorkspaceEmbeddingIgnoredDocsQueryVariables;
|
||||
response: GetAllWorkspaceEmbeddingIgnoredDocsQuery;
|
||||
}
|
||||
| {
|
||||
name: 'getWorkspaceEmbeddingIgnoredDocsQuery';
|
||||
variables: GetWorkspaceEmbeddingIgnoredDocsQueryVariables;
|
||||
@@ -5001,9 +5031,14 @@ export type Mutations =
|
||||
response: RemoveWorkspaceEmbeddingFilesMutation;
|
||||
}
|
||||
| {
|
||||
name: 'updateWorkspaceEmbeddingIgnoredDocsMutation';
|
||||
variables: UpdateWorkspaceEmbeddingIgnoredDocsMutationVariables;
|
||||
response: UpdateWorkspaceEmbeddingIgnoredDocsMutation;
|
||||
name: 'addWorkspaceEmbeddingIgnoredDocsMutation';
|
||||
variables: AddWorkspaceEmbeddingIgnoredDocsMutationVariables;
|
||||
response: AddWorkspaceEmbeddingIgnoredDocsMutation;
|
||||
}
|
||||
| {
|
||||
name: 'removeWorkspaceEmbeddingIgnoredDocsMutation';
|
||||
variables: RemoveWorkspaceEmbeddingIgnoredDocsMutationVariables;
|
||||
response: RemoveWorkspaceEmbeddingIgnoredDocsMutation;
|
||||
}
|
||||
| {
|
||||
name: 'createCheckoutSessionMutation';
|
||||
|
||||
Reference in New Issue
Block a user